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>
This commit is contained in:
Dennis Stosberg 2006-04-11 18:37:58 +02:00 committed by Junio C Hamano
parent 40d88d4fa3
commit ef9e58c826
2 changed files with 7 additions and 7 deletions

View File

@ -597,7 +597,7 @@ static void process_alternates_response(void *callback_data)
newalt->packs = NULL; newalt->packs = NULL;
path = strstr(target, "//"); path = strstr(target, "//");
if (path) { if (path) {
path = index(path+2, '/'); path = strchr(path+2, '/');
if (path) if (path)
newalt->path_len = strlen(path); newalt->path_len = strlen(path);
} }
@ -678,7 +678,7 @@ static void
xml_start_tag(void *userData, const char *name, const char **atts) xml_start_tag(void *userData, const char *name, const char **atts)
{ {
struct xml_ctx *ctx = (struct xml_ctx *)userData; struct xml_ctx *ctx = (struct xml_ctx *)userData;
const char *c = index(name, ':'); const char *c = strchr(name, ':');
int new_len; int new_len;
if (c == NULL) if (c == NULL)
@ -707,7 +707,7 @@ static void
xml_end_tag(void *userData, const char *name) xml_end_tag(void *userData, const char *name)
{ {
struct xml_ctx *ctx = (struct xml_ctx *)userData; struct xml_ctx *ctx = (struct xml_ctx *)userData;
const char *c = index(name, ':'); const char *c = strchr(name, ':');
char *ep; char *ep;
ctx->userFunc(ctx, 1); ctx->userFunc(ctx, 1);
@ -1261,7 +1261,7 @@ int main(int argc, char **argv)
alt->next = NULL; alt->next = NULL;
path = strstr(url, "//"); path = strstr(url, "//");
if (path) { if (path) {
path = index(path+2, '/'); path = strchr(path+2, '/');
if (path) if (path)
alt->path_len = strlen(path); alt->path_len = strlen(path);
} }

View File

@ -1211,7 +1211,7 @@ static void
xml_start_tag(void *userData, const char *name, const char **atts) xml_start_tag(void *userData, const char *name, const char **atts)
{ {
struct xml_ctx *ctx = (struct xml_ctx *)userData; struct xml_ctx *ctx = (struct xml_ctx *)userData;
const char *c = index(name, ':'); const char *c = strchr(name, ':');
int new_len; int new_len;
if (c == NULL) if (c == NULL)
@ -1240,7 +1240,7 @@ static void
xml_end_tag(void *userData, const char *name) xml_end_tag(void *userData, const char *name)
{ {
struct xml_ctx *ctx = (struct xml_ctx *)userData; struct xml_ctx *ctx = (struct xml_ctx *)userData;
const char *c = index(name, ':'); const char *c = strchr(name, ':');
char *ep; char *ep;
ctx->userFunc(ctx, 1); ctx->userFunc(ctx, 1);
@ -2350,7 +2350,7 @@ int main(int argc, char **argv)
char *path = strstr(arg, "//"); char *path = strstr(arg, "//");
remote->url = arg; remote->url = arg;
if (path) { if (path) {
path = index(path+2, '/'); path = strchr(path+2, '/');
if (path) if (path)
remote->path_len = strlen(path); remote->path_len = strlen(path);
} }