aboutsummaryrefslogtreecommitdiffstats
path: root/missing/strchr.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2010-07-16 12:41:09 +0300
committerArnold D. Robbins <arnold@skeeve.com>2010-07-16 12:41:09 +0300
commit8c042f99cc7465c86351d21331a129111b75345d (patch)
tree9656e653be0e42e5469cec77635c20356de152c2 /missing/strchr.c
parent8ceb5f934787eb7be5fb452fb39179df66119954 (diff)
downloadegawk-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.c22
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;