OSDN Git Service

drop __BCC__ cruft from string code
authorMike Frysinger <vapier@gentoo.org>
Sat, 10 Oct 2009 16:44:02 +0000 (12:44 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sat, 10 Oct 2009 16:44:02 +0000 (12:44 -0400)
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
14 files changed:
libc/string/bcopy.c
libc/string/bzero.c
libc/string/memchr.c
libc/string/memcpy.c
libc/string/memmove.c
libc/string/mempcpy.c
libc/string/memrchr.c
libc/string/memset.c
libc/string/stpcpy.c
libc/string/stpncpy.c
libc/string/strcpy.c
libc/string/strncat.c
libc/string/strncpy.c
libc/string/strnlen.c

index 4b718f9..6234fd8 100644 (file)
@@ -15,24 +15,6 @@ void bcopy(const void *s2, void *s1, size_t n)
 #if 1
        memmove(s1, s2, n);
 #else
-#ifdef __BCC__
-       register char *s;
-       register const char *p;
-
-       s = s1;
-       p = s2;
-       if (p >= s) {
-               while (n--) {
-                       *s++ = *p++;
-               }
-       } else {
-               s += n;
-               p += n;
-               while (n--) {
-                       *--s = *--p;
-               }
-       }
-#else
        register char *s;
        register const char *p;
 
@@ -50,6 +32,5 @@ void bcopy(const void *s2, void *s1, size_t n)
                }
        }
 #endif
-#endif
 }
 #endif
index 364456f..a541f36 100644 (file)
@@ -8,26 +8,17 @@
 #include "_string.h"
 
 #ifdef __UCLIBC_SUSV3_LEGACY__
-
-
 void bzero(void *s, size_t n)
 {
 #if 1
        (void)memset(s, 0, n);
 #else
        register unsigned char *p = s;
-#ifdef __BCC__
-       /* bcc can optimize the counter if it thinks it is a pointer... */
-       register const char *np = (const char *) n;
-#else
-#define np n
-#endif
 
-       while (np) {
+       while (n) {
                *p++ = 0;
-               --np;
+               --n;
        }
 #endif
 }
-#undef np
 #endif
index 438f4fa..99e13a2 100644 (file)
 Wvoid *Wmemchr(const Wvoid *s, Wint c, size_t n)
 {
        register const Wuchar *r = (const Wuchar *) s;
-#ifdef __BCC__
-       /* bcc can optimize the counter if it thinks it is a pointer... */
-       register const char *np = (const char *) n;
-#else
-# define np n
-#endif
 
-       while (np) {
+       while (n) {
                if (*r == ((Wuchar)c)) {
                        return (Wvoid *) r;     /* silence the warning */
                }
                ++r;
-               --np;
+               --n;
        }
 
        return NULL;
 }
-#undef np
 
 libc_hidden_def(Wmemchr)
index cbb6e63..42436e0 100644 (file)
@@ -19,16 +19,10 @@ Wvoid *Wmemcpy(Wvoid * __restrict s1, const Wvoid * __restrict s2, size_t n)
        register Wchar *r1 = s1;
        register const Wchar *r2 = s2;
 
-#ifdef __BCC__
-       while (n--) {
-               *r1++ = *r2++;
-       }
-#else
        while (n) {
                *r1++ = *r2++;
                --n;
        }
-#endif
 
        return s1;
 }
index 8dcc6e4..9fb0efe 100644 (file)
 
 Wvoid *Wmemmove(Wvoid *s1, const Wvoid *s2, size_t n)
 {
-#ifdef __BCC__
-       register Wchar *s = (Wchar *) s1;
-       register const Wchar *p = (const Wchar *) s2;
-
-       if (p >= s) {
-               while (n--) {
-                       *s++ = *p++;
-               }
-       } else {
-               s += n;
-               p += n;
-               while (n--) {
-                       *--s = *--p;
-               }
-       }
-
-       return s1;
-#else
        register Wchar *s = (Wchar *) s1;
        register const Wchar *p = (const Wchar *) s2;
 
@@ -49,7 +31,6 @@ Wvoid *Wmemmove(Wvoid *s1, const Wvoid *s2, size_t n)
        }
 
        return s1;
-#endif
 }
 
 #ifndef WANT_WIDE
index d79bd19..d1d752b 100644 (file)
@@ -21,16 +21,10 @@ Wvoid *Wmempcpy(Wvoid * __restrict s1, const Wvoid * __restrict s2, size_t n)
        register Wchar *r1 = s1;
        register const Wchar *r2 = s2;
 
-#ifdef __BCC__
-       while (n--) {
-               *r1++ = *r2++;
-       }
-#else
        while (n) {
                *r1++ = *r2++;
                --n;
        }
-#endif
 
        return r1;
 }
index 3a7e22f..60211f8 100644 (file)
@@ -8,30 +8,21 @@
 #include "_string.h"
 
 #ifdef __USE_GNU
-
-
 void *memrchr(const void *s, int c, size_t n)
 {
        register const unsigned char *r;
-#ifdef __BCC__
-       /* bcc can optimize the counter if it thinks it is a pointer... */
-       register const char *np = (const char *) n;
-#else
-#define np n
-#endif
 
-       r = ((unsigned char *)s) + ((size_t) np);
+       r = ((unsigned char *)s) + ((size_t) n);
 
-       while (np) {
+       while (n) {
                if (*--r == ((unsigned char)c)) {
                        return (void *) r;      /* silence the warning */
                }
-               --np;
+               --n;
        }
 
        return NULL;
 }
-#undef np
 
 libc_hidden_def(memrchr)
 #endif
index 9daf59f..2a7c19d 100644 (file)
 Wvoid *Wmemset(Wvoid *s, Wint c, size_t n)
 {
        register Wuchar *p = (Wuchar *) s;
-#ifdef __BCC__
-       /* bcc can optimize the counter if it thinks it is a pointer... */
-       register const char *np = (const char *) n;
-#else
-# define np n
-#endif
 
-       while (np) {
+       while (n) {
                *p++ = (Wuchar) c;
-               --np;
+               --n;
        }
 
        return s;
 }
-#undef np
 
 #ifndef WANT_WIDE
 libc_hidden_def(memset)
index 58ace8f..2fd2c06 100644 (file)
 
 Wchar *Wstpcpy(register Wchar * __restrict s1, const Wchar * __restrict s2)
 {
-#ifdef __BCC__
-       do {
-               *s1 = *s2++;
-       } while (*s1++ != 0);
-#else
        while ( (*s1++ = *s2++) != 0 );
-#endif
 
        return s1 - 1;
 }
index 0524ee9..088145d 100644 (file)
@@ -20,20 +20,12 @@ Wchar *Wstpncpy(register Wchar * __restrict s1,
        Wchar *s = s1;
        const Wchar *p = s2;
 
-#ifdef __BCC__
-       while (n--) {
-               if ((*s = *s2) != 0) s2++; /* Need to fill tail with 0s. */
-               ++s;
-       }
-       return s1 + (s2 - p);
-#else
        while (n) {
                if ((*s = *s2) != 0) s2++; /* Need to fill tail with 0s. */
                ++s;
                --n;
        }
        return s1 + (s2 - p);
-#endif
 }
 
 #ifndef WANT_WIDE
index 568efbf..bb5a168 100644 (file)
@@ -17,13 +17,7 @@ Wchar *Wstrcpy(Wchar * __restrict s1, const Wchar * __restrict s2)
 {
        register Wchar *s = s1;
 
-#ifdef __BCC__
-       do {
-               *s = *s2++;
-       } while (*s++ != 0);
-#else
        while ( (*s++ = *s2++) != 0 );
-#endif
 
        return s1;
 }
index cbbb0c5..0fa9b4a 100644 (file)
@@ -20,14 +20,10 @@ Wchar *Wstrncat(Wchar * __restrict s1, register const Wchar * __restrict s2,
 
        while (*s++);
        --s;
-#ifdef __BCC__
-       while (n-- && ((*s = *s2++) != 0)) ++s;
-#else
        while (n && ((*s = *s2++) != 0)) {
                --n;
                ++s;
        }
-#endif
        *s = 0;
 
        return s1;
index ccf031b..4a44e1f 100644 (file)
@@ -18,18 +18,11 @@ Wchar *Wstrncpy(Wchar * __restrict s1, register const Wchar * __restrict s2,
 {
        register Wchar *s = s1;
 
-#ifdef __BCC__
-       while (n--) {
-               if ((*s = *s2) != 0) s2++; /* Need to fill tail with 0s. */
-               ++s;
-       }
-#else
        while (n) {
                if ((*s = *s2) != 0) s2++; /* Need to fill tail with 0s. */
                ++s;
                --n;
        }
-#endif
 
        return s1;
 }
index 98267e5..08de088 100644 (file)
 size_t Wstrnlen(const Wchar *s, size_t max)
 {
        register const Wchar *p = s;
-#ifdef __BCC__
-       /* bcc can optimize the counter if it thinks it is a pointer... */
-       register const char *maxp = (const char *) max;
-#else
-# define maxp max
-#endif
 
-       while (maxp && *p) {
+       while (max && *p) {
                ++p;
-               --maxp;
+               --max;
        }
 
        return p - s;
 }
-#undef maxp
 
 libc_hidden_def(Wstrnlen)
 #endif