Skip to content

Commit

Permalink
Replace index() with strchr().
Browse files Browse the repository at this point in the history
strchr() is more portable than index() and is used everywhere in
git already.

Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Dennis Stosberg authored and Junio C Hamano committed Apr 11, 2006
1 parent 40d88d4 commit ef9e58c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions http-fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ static void process_alternates_response(void *callback_data)
newalt->packs = NULL;
path = strstr(target, "//");
if (path) {
path = index(path+2, '/');
path = strchr(path+2, '/');
if (path)
newalt->path_len = strlen(path);
}
Expand Down Expand Up @@ -678,7 +678,7 @@ static void
xml_start_tag(void *userData, const char *name, const char **atts)
{
struct xml_ctx *ctx = (struct xml_ctx *)userData;
const char *c = index(name, ':');
const char *c = strchr(name, ':');
int new_len;

if (c == NULL)
Expand Down Expand Up @@ -707,7 +707,7 @@ static void
xml_end_tag(void *userData, const char *name)
{
struct xml_ctx *ctx = (struct xml_ctx *)userData;
const char *c = index(name, ':');
const char *c = strchr(name, ':');
char *ep;

ctx->userFunc(ctx, 1);
Expand Down Expand Up @@ -1261,7 +1261,7 @@ int main(int argc, char **argv)
alt->next = NULL;
path = strstr(url, "//");
if (path) {
path = index(path+2, '/');
path = strchr(path+2, '/');
if (path)
alt->path_len = strlen(path);
}
Expand Down
6 changes: 3 additions & 3 deletions http-push.c
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@ static void
xml_start_tag(void *userData, const char *name, const char **atts)
{
struct xml_ctx *ctx = (struct xml_ctx *)userData;
const char *c = index(name, ':');
const char *c = strchr(name, ':');
int new_len;

if (c == NULL)
Expand Down Expand Up @@ -1240,7 +1240,7 @@ static void
xml_end_tag(void *userData, const char *name)
{
struct xml_ctx *ctx = (struct xml_ctx *)userData;
const char *c = index(name, ':');
const char *c = strchr(name, ':');
char *ep;

ctx->userFunc(ctx, 1);
Expand Down Expand Up @@ -2350,7 +2350,7 @@ int main(int argc, char **argv)
char *path = strstr(arg, "//");
remote->url = arg;
if (path) {
path = index(path+2, '/');
path = strchr(path+2, '/');
if (path)
remote->path_len = strlen(path);
}
Expand Down

0 comments on commit ef9e58c

Please sign in to comment.