Author: danger (doc committer)
Date: Tue Feb  3 17:58:20 2009
New Revision: 188080
URL: http://svn.freebsd.org/changeset/base/188080

Log:
  - ANSIfy function definitions
  - use nul when we are looking for a terminating character where appropriate
  
  Approved by:  imp

Modified:
  head/lib/libc/string/memccpy.c
  head/lib/libc/string/memchr.c
  head/lib/libc/string/memcmp.c
  head/lib/libc/string/memmem.c
  head/lib/libc/string/strcasecmp.c
  head/lib/libc/string/strcasestr.c
  head/lib/libc/string/strcmp.c
  head/lib/libc/string/strcoll.c
  head/lib/libc/string/strdup.c
  head/lib/libc/string/strmode.c
  head/lib/libc/string/strncmp.c
  head/lib/libc/string/strncpy.c
  head/lib/libc/string/strnstr.c
  head/lib/libc/string/strpbrk.c
  head/lib/libc/string/strsep.c
  head/lib/libc/string/strstr.c
  head/lib/libc/string/wcscat.c
  head/lib/libc/string/wcscmp.c
  head/lib/libc/string/wcscpy.c
  head/lib/libc/string/wcscspn.c
  head/lib/libc/string/wcslcat.c
  head/lib/libc/string/wcslcpy.c
  head/lib/libc/string/wcslen.c
  head/lib/libc/string/wcsncat.c
  head/lib/libc/string/wcsncmp.c
  head/lib/libc/string/wcspbrk.c
  head/lib/libc/string/wcsspn.c
  head/lib/libc/string/wcsstr.c
  head/lib/libc/string/wmemchr.c
  head/lib/libc/string/wmemcmp.c
  head/lib/libc/string/wmemcpy.c
  head/lib/libc/string/wmemmove.c
  head/lib/libc/string/wmemset.c

Modified: head/lib/libc/string/memccpy.c
==============================================================================
--- head/lib/libc/string/memccpy.c      Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/memccpy.c      Tue Feb  3 17:58:20 2009        
(r188080)
@@ -36,11 +36,7 @@ __FBSDID("$FreeBSD$");
 #include <string.h>
 
 void *
-memccpy(t, f, c, n)
-       void *t;
-       const void *f;
-       int c;
-       size_t n;
+memccpy(void *t, const void *f, int c, size_t n)
 {
 
        if (n) {

Modified: head/lib/libc/string/memchr.c
==============================================================================
--- head/lib/libc/string/memchr.c       Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/memchr.c       Tue Feb  3 17:58:20 2009        
(r188080)
@@ -39,10 +39,7 @@ __FBSDID("$FreeBSD$");
 #include <string.h>
 
 void *
-memchr(s, c, n)
-       const void *s;
-       unsigned char c;
-       size_t n;
+memchr(const void *s, unsigned char c, size_t n)
 {
        if (n != 0) {
                const unsigned char *p = s;

Modified: head/lib/libc/string/memcmp.c
==============================================================================
--- head/lib/libc/string/memcmp.c       Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/memcmp.c       Tue Feb  3 17:58:20 2009        
(r188080)
@@ -42,9 +42,7 @@ __FBSDID("$FreeBSD$");
  * Compare memory regions.
  */
 int
-memcmp(s1, s2, n)
-       const void *s1, *s2;
-       size_t n;
+memcmp(const void *s1, const void *s2, size_t n)
 {
        if (n != 0) {
                const unsigned char *p1 = s1, *p2 = s2;

Modified: head/lib/libc/string/memmem.c
==============================================================================
--- head/lib/libc/string/memmem.c       Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/memmem.c       Tue Feb  3 17:58:20 2009        
(r188080)
@@ -36,9 +36,7 @@ __FBSDID("$FreeBSD$");
  */
 
 void *
-memmem(l, l_len, s, s_len)
-       const void *l; size_t l_len;
-       const void *s; size_t s_len;
+memmem(const void *l, size_t l_len, const void *s, size_t s_len)
 {
        register char *cur, *last;
        const char *cl = (const char *)l;

Modified: head/lib/libc/string/strcasecmp.c
==============================================================================
--- head/lib/libc/string/strcasecmp.c   Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/strcasecmp.c   Tue Feb  3 17:58:20 2009        
(r188080)
@@ -39,8 +39,7 @@ __FBSDID("$FreeBSD$");
 typedef unsigned char u_char;
 
 int
-strcasecmp(s1, s2)
-       const char *s1, *s2;
+strcasecmp(const char *s1, const char *s2)
 {
        const u_char
                        *us1 = (const u_char *)s1,
@@ -53,9 +52,7 @@ strcasecmp(s1, s2)
 }
 
 int
-strncasecmp(s1, s2, n)
-       const char *s1, *s2;
-       size_t n;
+strncasecmp(const char *s1, const char *s2, size_t n)
 {
        if (n != 0) {
                const u_char

Modified: head/lib/libc/string/strcasestr.c
==============================================================================
--- head/lib/libc/string/strcasestr.c   Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/strcasestr.c   Tue Feb  3 17:58:20 2009        
(r188080)
@@ -40,8 +40,7 @@ __FBSDID("$FreeBSD$");
  * Find the first occurrence of find in s, ignore case.
  */
 char *
-strcasestr(s, find)
-       const char *s, *find;
+strcasestr(const char *s, const char *find)
 {
        char c, sc;
        size_t len;

Modified: head/lib/libc/string/strcmp.c
==============================================================================
--- head/lib/libc/string/strcmp.c       Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/strcmp.c       Tue Feb  3 17:58:20 2009        
(r188080)
@@ -42,11 +42,10 @@ __FBSDID("$FreeBSD$");
  * Compare strings.
  */
 int
-strcmp(s1, s2)
-       const char *s1, *s2;
+strcmp(const char *s1, const char *s2)
 {
        while (*s1 == *s2++)
-               if (*s1++ == 0)
+               if (*s1++ == '\0')
                        return (0);
        return (*(const unsigned char *)s1 - *(const unsigned char *)(s2 - 1));
 }

Modified: head/lib/libc/string/strcoll.c
==============================================================================
--- head/lib/libc/string/strcoll.c      Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/strcoll.c      Tue Feb  3 17:58:20 2009        
(r188080)
@@ -33,8 +33,7 @@ __FBSDID("$FreeBSD$");
 #include "collate.h"
 
 int
-strcoll(s, s2)
-       const char *s, *s2;
+strcoll(const char *s, const char *s2)
 {
        int len, len2, prim, prim2, sec, sec2, ret, ret2;
        const char *t, *t2;

Modified: head/lib/libc/string/strdup.c
==============================================================================
--- head/lib/libc/string/strdup.c       Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/strdup.c       Tue Feb  3 17:58:20 2009        
(r188080)
@@ -38,8 +38,7 @@ __FBSDID("$FreeBSD$");
 #include <string.h>
 
 char *
-strdup(str)
-       const char *str;
+strdup(const char *str)
 {
        size_t len;
        char *copy;

Modified: head/lib/libc/string/strmode.c
==============================================================================
--- head/lib/libc/string/strmode.c      Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/strmode.c      Tue Feb  3 17:58:20 2009        
(r188080)
@@ -38,9 +38,7 @@ __FBSDID("$FreeBSD$");
 #include <string.h>
 
 void
-strmode(mode, p)
-       mode_t mode;
-       char *p;
+strmode(mode_t mode, char *p)
 {
         /* print type */
        switch (mode & S_IFMT) {

Modified: head/lib/libc/string/strncmp.c
==============================================================================
--- head/lib/libc/string/strncmp.c      Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/strncmp.c      Tue Feb  3 17:58:20 2009        
(r188080)
@@ -36,9 +36,7 @@ __FBSDID("$FreeBSD$");
 #include <string.h>
 
 int
-strncmp(s1, s2, n)
-       const char *s1, *s2;
-       size_t n;
+strncmp(const char *s1, const char *s2, size_t n)
 {
 
        if (n == 0)
@@ -47,7 +45,7 @@ strncmp(s1, s2, n)
                if (*s1 != *s2++)
                        return (*(const unsigned char *)s1 -
                                *(const unsigned char *)(s2 - 1));
-               if (*s1++ == 0)
+               if (*s1++ == '\0')
                        break;
        } while (--n != 0);
        return (0);

Modified: head/lib/libc/string/strncpy.c
==============================================================================
--- head/lib/libc/string/strncpy.c      Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/strncpy.c      Tue Feb  3 17:58:20 2009        
(r188080)
@@ -50,10 +50,10 @@ strncpy(char * __restrict dst, const cha
                const char *s = src;
 
                do {
-                       if ((*d++ = *s++) == 0) {
+                       if ((*d++ = *s++) == '\0') {
                                /* NUL pad the remaining n-1 bytes */
                                while (--n != 0)
-                                       *d++ = 0;
+                                       *d++ = '\0';
                                break;
                        }
                } while (--n != 0);

Modified: head/lib/libc/string/strnstr.c
==============================================================================
--- head/lib/libc/string/strnstr.c      Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/strnstr.c      Tue Feb  3 17:58:20 2009        
(r188080)
@@ -44,10 +44,7 @@ __FBSDID("$FreeBSD$");
  * first slen characters of s.
  */
 char *
-strnstr(s, find, slen)
-       const char *s;
-       const char *find;
-       size_t slen;
+strnstr(const char *s, const char *find, size_t slen)
 {
        char c, sc;
        size_t len;

Modified: head/lib/libc/string/strpbrk.c
==============================================================================
--- head/lib/libc/string/strpbrk.c      Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/strpbrk.c      Tue Feb  3 17:58:20 2009        
(r188080)
@@ -39,14 +39,13 @@ __FBSDID("$FreeBSD$");
  * Find the first occurrence in s1 of a character in s2 (excluding NUL).
  */
 char *
-strpbrk(s1, s2)
-       const char *s1, *s2;
+strpbrk(const char *s1, const char *s2)
 {
        const char *scanp;
        int c, sc;
 
        while ((c = *s1++) != 0) {
-               for (scanp = s2; (sc = *scanp++) != 0;)
+               for (scanp = s2; (sc = *scanp++) != '\0';)
                        if (sc == c)
                                return ((char *)(s1 - 1));
        }

Modified: head/lib/libc/string/strsep.c
==============================================================================
--- head/lib/libc/string/strsep.c       Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/strsep.c       Tue Feb  3 17:58:20 2009        
(r188080)
@@ -48,9 +48,7 @@ __FBSDID("$FreeBSD$");
  * If *stringp is NULL, strsep returns NULL.
  */
 char *
-strsep(stringp, delim)
-       char **stringp;
-       const char *delim;
+strsep(char **stringp, const char *delim)
 {
        char *s;
        const char *spanp;

Modified: head/lib/libc/string/strstr.c
==============================================================================
--- head/lib/libc/string/strstr.c       Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/strstr.c       Tue Feb  3 17:58:20 2009        
(r188080)
@@ -42,17 +42,16 @@ __FBSDID("$FreeBSD$");
  * Find the first occurrence of find in s.
  */
 char *
-strstr(s, find)
-       const char *s, *find;
+strstr(const char *s, const char *find)
 {
        char c, sc;
        size_t len;
 
-       if ((c = *find++) != 0) {
+       if ((c = *find++) != '\0') {
                len = strlen(find);
                do {
                        do {
-                               if ((sc = *s++) == 0)
+                               if ((sc = *s++) == '\0')
                                        return (NULL);
                        } while (sc != c);
                } while (strncmp(s, find, len) != 0);

Modified: head/lib/libc/string/wcscat.c
==============================================================================
--- head/lib/libc/string/wcscat.c       Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/wcscat.c       Tue Feb  3 17:58:20 2009        
(r188080)
@@ -37,9 +37,7 @@ __FBSDID("$FreeBSD$");
 #include <wchar.h>
 
 wchar_t *
-wcscat(s1, s2)
-       wchar_t * __restrict s1;
-       const wchar_t * __restrict s2;
+wcscat(wchar_t * __restrict s1, const wchar_t * __restrict s2)
 {
        wchar_t *cp;
 

Modified: head/lib/libc/string/wcscmp.c
==============================================================================
--- head/lib/libc/string/wcscmp.c       Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/wcscmp.c       Tue Feb  3 17:58:20 2009        
(r188080)
@@ -45,12 +45,11 @@ __FBSDID("$FreeBSD$");
  * Compare strings.
  */
 int
-wcscmp(s1, s2)
-       const wchar_t *s1, *s2;
+wcscmp(const wchar_t *s1, const wchar_t *s2)
 {
 
        while (*s1 == *s2++)
-               if (*s1++ == 0)
+               if (*s1++ == '\0')
                        return (0);
        /* XXX assumes wchar_t = int */
        return (*(const unsigned int *)s1 - *(const unsigned int *)--s2);

Modified: head/lib/libc/string/wcscpy.c
==============================================================================
--- head/lib/libc/string/wcscpy.c       Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/wcscpy.c       Tue Feb  3 17:58:20 2009        
(r188080)
@@ -37,9 +37,7 @@ __FBSDID("$FreeBSD$");
 #include <wchar.h>
 
 wchar_t *
-wcscpy(s1, s2)
-       wchar_t * __restrict s1;
-       const wchar_t * __restrict s2;
+wcscpy(wchar_t * __restrict s1, const wchar_t * __restrict s2)
 {
        wchar_t *cp;
 

Modified: head/lib/libc/string/wcscspn.c
==============================================================================
--- head/lib/libc/string/wcscspn.c      Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/wcscspn.c      Tue Feb  3 17:58:20 2009        
(r188080)
@@ -37,9 +37,7 @@ __FBSDID("$FreeBSD$");
 #include <wchar.h>
 
 size_t
-wcscspn(s, set)
-       const wchar_t *s;
-       const wchar_t *set;
+wcscspn(const wchar_t *s, const wchar_t *set)
 {
        const wchar_t *p;
        const wchar_t *q;

Modified: head/lib/libc/string/wcslcat.c
==============================================================================
--- head/lib/libc/string/wcslcat.c      Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/wcslcat.c      Tue Feb  3 17:58:20 2009        
(r188080)
@@ -46,10 +46,7 @@ __FBSDID("$FreeBSD$");
  * truncation occurred.
  */
 size_t
-wcslcat(dst, src, siz)
-       wchar_t *dst;
-       const wchar_t *src;
-       size_t siz;
+wcslcat(wchar_t *dst, const wchar_t *src, size_t siz)
 {
        wchar_t *d = dst;
        const wchar_t *s = src;

Modified: head/lib/libc/string/wcslcpy.c
==============================================================================
--- head/lib/libc/string/wcslcpy.c      Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/wcslcpy.c      Tue Feb  3 17:58:20 2009        
(r188080)
@@ -44,10 +44,7 @@ __FBSDID("$FreeBSD$");
  * Returns wcslen(src); if retval >= siz, truncation occurred.
  */
 size_t
-wcslcpy(dst, src, siz)
-       wchar_t *dst;
-       const wchar_t *src;
-       size_t siz;
+wcslcpy(wchar_t *dst, const wchar_t *src, size_t siz)
 {
        wchar_t *d = dst;
        const wchar_t *s = src;

Modified: head/lib/libc/string/wcslen.c
==============================================================================
--- head/lib/libc/string/wcslen.c       Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/wcslen.c       Tue Feb  3 17:58:20 2009        
(r188080)
@@ -37,8 +37,7 @@ __FBSDID("$FreeBSD$");
 #include <wchar.h>
 
 size_t
-wcslen(s)
-       const wchar_t *s;
+wcslen(const wchar_t *s)
 {
        const wchar_t *p;
 

Modified: head/lib/libc/string/wcsncat.c
==============================================================================
--- head/lib/libc/string/wcsncat.c      Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/wcsncat.c      Tue Feb  3 17:58:20 2009        
(r188080)
@@ -37,10 +37,7 @@ __FBSDID("$FreeBSD$");
 #include <wchar.h>
 
 wchar_t *
-wcsncat(s1, s2, n)
-       wchar_t * __restrict s1;
-       const wchar_t * __restrict s2;
-       size_t n;
+wcsncat(wchar_t * __restrict s1, const wchar_t * __restrict s2, size_t n)
 {
        wchar_t *p;
        wchar_t *q;

Modified: head/lib/libc/string/wcsncmp.c
==============================================================================
--- head/lib/libc/string/wcsncmp.c      Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/wcsncmp.c      Tue Feb  3 17:58:20 2009        
(r188080)
@@ -39,9 +39,7 @@ __FBSDID("$FreeBSD$");
 #include <wchar.h>
 
 int
-wcsncmp(s1, s2, n)
-       const wchar_t *s1, *s2;
-       size_t n;
+wcsncmp(const wchar_t *s1, const wchar_t *s2, size_t n)
 {
 
        if (n == 0)

Modified: head/lib/libc/string/wcspbrk.c
==============================================================================
--- head/lib/libc/string/wcspbrk.c      Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/wcspbrk.c      Tue Feb  3 17:58:20 2009        
(r188080)
@@ -37,9 +37,7 @@ __FBSDID("$FreeBSD$");
 #include <wchar.h>
 
 wchar_t *
-wcspbrk(s, set)
-       const wchar_t *s;
-       const wchar_t *set;
+wcspbrk(const wchar_t *s, const wchar_t *set)
 {
        const wchar_t *p;
        const wchar_t *q;

Modified: head/lib/libc/string/wcsspn.c
==============================================================================
--- head/lib/libc/string/wcsspn.c       Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/wcsspn.c       Tue Feb  3 17:58:20 2009        
(r188080)
@@ -37,9 +37,7 @@ __FBSDID("$FreeBSD$");
 #include <wchar.h>
 
 size_t
-wcsspn(s, set)
-       const wchar_t *s;
-       const wchar_t *set;
+wcsspn(const wchar_t *s, const wchar_t *set)
 {
        const wchar_t *p;
        const wchar_t *q;

Modified: head/lib/libc/string/wcsstr.c
==============================================================================
--- head/lib/libc/string/wcsstr.c       Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/wcsstr.c       Tue Feb  3 17:58:20 2009        
(r188080)
@@ -49,7 +49,7 @@ wcsstr(const wchar_t * __restrict s, con
        wchar_t c, sc;
        size_t len;
 
-       if ((c = *find++) != 0) {
+       if ((c = *find++) != L'\0') {
                len = wcslen(find);
                do {
                        do {

Modified: head/lib/libc/string/wmemchr.c
==============================================================================
--- head/lib/libc/string/wmemchr.c      Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/wmemchr.c      Tue Feb  3 17:58:20 2009        
(r188080)
@@ -37,10 +37,7 @@ __FBSDID("$FreeBSD$");
 #include <wchar.h>
 
 wchar_t        *
-wmemchr(s, c, n)
-       const wchar_t *s;
-       wchar_t c;
-       size_t n;
+wmemchr(const wchar_t *s, wchar_t c, size_t n)
 {
        size_t i;
 

Modified: head/lib/libc/string/wmemcmp.c
==============================================================================
--- head/lib/libc/string/wmemcmp.c      Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/wmemcmp.c      Tue Feb  3 17:58:20 2009        
(r188080)
@@ -37,10 +37,7 @@ __FBSDID("$FreeBSD$");
 #include <wchar.h>
 
 int
-wmemcmp(s1, s2, n)
-       const wchar_t *s1;
-       const wchar_t *s2;
-       size_t n;
+wmemcmp(const wchar_t *s1, const wchar_t *s2, size_t n)
 {
        size_t i;
 

Modified: head/lib/libc/string/wmemcpy.c
==============================================================================
--- head/lib/libc/string/wmemcpy.c      Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/wmemcpy.c      Tue Feb  3 17:58:20 2009        
(r188080)
@@ -38,11 +38,7 @@ __FBSDID("$FreeBSD$");
 #include <wchar.h>
 
 wchar_t *
-wmemcpy(d, s, n)
-       wchar_t * __restrict d;
-       const wchar_t * __restrict s;
-       size_t n;
+wmemcpy(wchar_t * __restrict d, const wchar_t * __restrict s, size_t n)
 {
-
        return (wchar_t *)memcpy(d, s, n * sizeof(wchar_t));
 }

Modified: head/lib/libc/string/wmemmove.c
==============================================================================
--- head/lib/libc/string/wmemmove.c     Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/wmemmove.c     Tue Feb  3 17:58:20 2009        
(r188080)
@@ -38,11 +38,7 @@ __FBSDID("$FreeBSD$");
 #include <wchar.h>
 
 wchar_t *
-wmemmove(d, s, n)
-       wchar_t *d;
-       const wchar_t *s;
-       size_t n;
+wmemmove(wchar_t *d, const wchar_t *s, size_t n)
 {
-
        return (wchar_t *)memmove(d, s, n * sizeof(wchar_t));
 }

Modified: head/lib/libc/string/wmemset.c
==============================================================================
--- head/lib/libc/string/wmemset.c      Tue Feb  3 17:13:37 2009        
(r188079)
+++ head/lib/libc/string/wmemset.c      Tue Feb  3 17:58:20 2009        
(r188080)
@@ -37,10 +37,7 @@ __FBSDID("$FreeBSD$");
 #include <wchar.h>
 
 wchar_t        *
-wmemset(s, c, n)
-       wchar_t *s;
-       wchar_t c;
-       size_t n;
+wmemset(wchar_t *s, wchar_t *c, size_t n)
 {
        size_t i;
        wchar_t *p;
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to