diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2010-07-16 12:41:09 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2010-07-16 12:41:09 +0300 |
commit | 8c042f99cc7465c86351d21331a129111b75345d (patch) | |
tree | 9656e653be0e42e5469cec77635c20356de152c2 /missing/strchr.c | |
parent | 8ceb5f934787eb7be5fb452fb39179df66119954 (diff) | |
download | egawk-8c042f99cc7465c86351d21331a129111b75345d.tar.gz egawk-8c042f99cc7465c86351d21331a129111b75345d.tar.bz2 egawk-8c042f99cc7465c86351d21331a129111b75345d.zip |
Move to gawk-3.0.0.
Diffstat (limited to 'missing/strchr.c')
-rw-r--r-- | missing/strchr.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/missing/strchr.c b/missing/strchr.c index 76016d89..7da479fc 100644 --- a/missing/strchr.c +++ b/missing/strchr.c @@ -4,13 +4,25 @@ * We supply this routine for those systems that aren't standard yet. */ +#if 0 +#include <stdio.h> +#endif + char * -strchr (str, c) +strchr(str, c) register const char *str, c; { - for (; *str; str++) - if (*str == c) - return (char *) str; + if (c == '\0') { + /* thanks to Mike Brennan ... */ + do { + if (*str == c) + return (char *) str; + } while (*str++); + } else { + for (; *str; str++) + if (*str == c) + return (char *) str; + } return NULL; } @@ -22,7 +34,7 @@ register const char *str, c; */ char * -strrchr (str, c) +strrchr(str, c) register const char *str, c; { register const char *save = NULL; |