Skip to content

Commit ef9e58c

Browse files
dstosbergJunio C Hamano
authored andcommitted
Replace index() with strchr().
strchr() is more portable than index() and is used everywhere in git already. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 40d88d4 commit ef9e58c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

http-fetch.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ static void process_alternates_response(void *callback_data)
597597
newalt->packs = NULL;
598598
path = strstr(target, "//");
599599
if (path) {
600-
path = index(path+2, '/');
600+
path = strchr(path+2, '/');
601601
if (path)
602602
newalt->path_len = strlen(path);
603603
}
@@ -678,7 +678,7 @@ static void
678678
xml_start_tag(void *userData, const char *name, const char **atts)
679679
{
680680
struct xml_ctx *ctx = (struct xml_ctx *)userData;
681-
const char *c = index(name, ':');
681+
const char *c = strchr(name, ':');
682682
int new_len;
683683

684684
if (c == NULL)
@@ -707,7 +707,7 @@ static void
707707
xml_end_tag(void *userData, const char *name)
708708
{
709709
struct xml_ctx *ctx = (struct xml_ctx *)userData;
710-
const char *c = index(name, ':');
710+
const char *c = strchr(name, ':');
711711
char *ep;
712712

713713
ctx->userFunc(ctx, 1);
@@ -1261,7 +1261,7 @@ int main(int argc, char **argv)
12611261
alt->next = NULL;
12621262
path = strstr(url, "//");
12631263
if (path) {
1264-
path = index(path+2, '/');
1264+
path = strchr(path+2, '/');
12651265
if (path)
12661266
alt->path_len = strlen(path);
12671267
}

http-push.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ static void
12111211
xml_start_tag(void *userData, const char *name, const char **atts)
12121212
{
12131213
struct xml_ctx *ctx = (struct xml_ctx *)userData;
1214-
const char *c = index(name, ':');
1214+
const char *c = strchr(name, ':');
12151215
int new_len;
12161216

12171217
if (c == NULL)
@@ -1240,7 +1240,7 @@ static void
12401240
xml_end_tag(void *userData, const char *name)
12411241
{
12421242
struct xml_ctx *ctx = (struct xml_ctx *)userData;
1243-
const char *c = index(name, ':');
1243+
const char *c = strchr(name, ':');
12441244
char *ep;
12451245

12461246
ctx->userFunc(ctx, 1);
@@ -2350,7 +2350,7 @@ int main(int argc, char **argv)
23502350
char *path = strstr(arg, "//");
23512351
remote->url = arg;
23522352
if (path) {
2353-
path = index(path+2, '/');
2353+
path = strchr(path+2, '/');
23542354
if (path)
23552355
remote->path_len = strlen(path);
23562356
}

0 commit comments

Comments
 (0)