Skip to content

Commit

Permalink
Avoid multi-arch strchr in tzdata-update
Browse files Browse the repository at this point in the history
  • Loading branch information
H.J. Lu authored and Andreas Schwab committed Nov 2, 2009
1 parent 587045f commit 27a4a1d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions fedora/tzdata-update.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,15 @@ update (const char *filename)
INTERNAL_SYSCALL (unlink, err, 1, tempfilename);
}

static char *
simple_strchr (const char *s, int c)
{
for (; *s != (char) c; ++s)
if (*s == '\0')
return NULL;
return (char *) s;
}

int
main (int argc, char **argv)
{
Expand All @@ -508,7 +517,7 @@ main (int argc, char **argv)
while (*p == ' ' || *p == '\t') p++;
if (*p == '"') p++;
char *q = p;
while (strchr (" \t\n\"", *p) == NULL) p++;
while (simple_strchr (" \t\n\"", *p) == NULL) p++;
const char path[] = "/usr/share/zoneinfo/";
if (p - q >= sizeof (zonename) - sizeof (path))
return 0;
Expand All @@ -517,7 +526,7 @@ main (int argc, char **argv)
break;
}
}
p = strchr (p, '\n');
p = simple_strchr (p, '\n');
if (p) p++;
}
if (*zonename == '\0')
Expand Down

0 comments on commit 27a4a1d

Please sign in to comment.