diff options
| author | Robert Drehmel <robert@FreeBSD.org> | 2002-08-30 19:42:07 +0000 | 
|---|---|---|
| committer | Robert Drehmel <robert@FreeBSD.org> | 2002-08-30 19:42:07 +0000 | 
| commit | 425289a9db71798c280b36e39f1a29d79dfd8ed3 (patch) | |
| tree | 73cc35c843328d5541c417f0803442e2f6f05d29 /lib | |
| parent | 554331bbb9fe7d143663402be8c0a7bd3e7a35cc (diff) | |
Notes
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/libc/string/index.3 | 9 | ||||
| -rw-r--r-- | lib/libc/string/index.c | 20 | ||||
| -rw-r--r-- | lib/libc/string/rindex.3 | 9 | ||||
| -rw-r--r-- | lib/libc/string/rindex.c | 17 | 
4 files changed, 38 insertions, 17 deletions
| diff --git a/lib/libc/string/index.3 b/lib/libc/string/index.3 index 902b19ca8df5..0102fa6ffaf5 100644 --- a/lib/libc/string/index.3 +++ b/lib/libc/string/index.3 @@ -43,7 +43,7 @@  .Sh LIBRARY  .Lb libc  .Sh SYNOPSIS -.In string.h +.In strings.h  .Ft char *  .Fn index "const char *s" "int c"  .Sh DESCRIPTION @@ -81,3 +81,10 @@ A  .Fn index  function appeared in  .At v6 . +Its prototype existed previously in +.Aq Pa string.h +before it was moved to +.Aq Pa strings.h +for +.St -p1003.1-2001 +compliance. diff --git a/lib/libc/string/index.c b/lib/libc/string/index.c index 7eaf3d71de86..c81f95b0989b 100644 --- a/lib/libc/string/index.c +++ b/lib/libc/string/index.c @@ -37,22 +37,26 @@ static char sccsid[] = "@(#)index.c	8.1 (Berkeley) 6/4/93";  #include <sys/cdefs.h>  __FBSDID("$FreeBSD$"); -#include <string.h>  #include <stddef.h> -char *  #ifdef STRCHR -strchr(p, ch) +#include <string.h> + +char * +strchr  #else -index(p, ch) +#include <strings.h> + +char * +index  #endif -	const char *p, ch; +(const char *p, int ch)  {  	for (;; ++p) {  		if (*p == ch) -			return((char *)p); -		if (!*p) -			return((char *)NULL); +			return ((char *)p); +		if (*p == '\0') +			return (NULL);  	}  	/* NOTREACHED */  } diff --git a/lib/libc/string/rindex.3 b/lib/libc/string/rindex.3 index b5ffd1c9708b..954f1261bcf9 100644 --- a/lib/libc/string/rindex.3 +++ b/lib/libc/string/rindex.3 @@ -43,7 +43,7 @@  .Sh LIBRARY  .Lb libc  .Sh SYNOPSIS -.In string.h +.In strings.h  .Ft char *  .Fn rindex "const char *s" "int c"  .Sh DESCRIPTION @@ -83,3 +83,10 @@ A  .Fn rindex  function appeared in  .At v6 . +Its prototype existed previously in +.Aq Pa string.h +before it was moved to +.Aq Pa strings.h +for +.St -p1003.1-2001 +compliance. diff --git a/lib/libc/string/rindex.c b/lib/libc/string/rindex.c index 1b08dd1a134e..d0be32e4549b 100644 --- a/lib/libc/string/rindex.c +++ b/lib/libc/string/rindex.c @@ -38,24 +38,27 @@ static char sccsid[] = "@(#)rindex.c	8.1 (Berkeley) 6/4/93";  __FBSDID("$FreeBSD$");  #include <stddef.h> + +#ifdef STRRCHR  #include <string.h>  char * -#ifdef STRRCHR -strrchr(p, ch) +strrchr  #else -rindex(p, ch) +#include <strings.h> + +char * +rindex  #endif -	const char *p; -	int ch; +(const char *p, int ch)  {  	char *save;  	for (save = NULL;; ++p) {  		if (*p == ch)  			save = (char *)p; -		if (!*p) -			return(save); +		if (*p == '\0') +			return (save);  	}  	/* NOTREACHED */  } | 
