]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
string: Cosmetic cleanup of string functions
authorWill Newton <will.newton@linaro.org>
Mon, 31 Mar 2014 12:47:56 +0000 (13:47 +0100)
committerWill Newton <will.newton@linaro.org>
Mon, 7 Apr 2014 08:44:02 +0000 (09:44 +0100)
Clean up string functions that do not have a version in gnulib on
the assumption that glibc is the canonical upstream copy of this
code. basename has a copy in gnulib but it is largely written to
handle Windows paths so merging it is not really viable. The changes
mostly consist of switching to ANSI function prototypes and removing
unused includes.

As many of these functions do not get built in a typical build due
to architecture optimized versions being used instead I built these
by hand to verify there were no build warnings and the code was
identical.

2014-04-07  Will Newton  <will.newton@linaro.org>

* string/basename.c [HAVE_CONFIG_H]: Remove #ifdef and
and contents.  [!_LIBC] Remove #ifndef and contents.
(basename): Use ANSI prototype.  [_LIBC] Remove #idef.
* string/memccpy.c (__memccpy): Use ANSI prototype.
* string/memfrob.c (memfrob): Likewise.
* string/strcoll.c (STRCOLL): Likewise.
* string/strlen.c (strlen): Likewise.
* string/strtok.c (STRTOK): Likewise.
* string/strcat.c: Remove unused #include of memcopy.h.
(strcat): Use ANSI prototype.
* string/strchr.c: Remove unused #include of memcopy.h.
(strchr): Use ANSI prototype.
* string/strcmp.c: Remove unused #include of memcopy.h.
(strcmp): Use ANSI prototype.
* string/strcpy.c: Remove unused #include of memcopy.h.
(strcpy): Use ANSI prototype.

ChangeLog
string/basename.c
string/memccpy.c
string/memfrob.c
string/strcat.c
string/strchr.c
string/strcmp.c
string/strcoll.c
string/strcpy.c
string/strlen.c
string/strtok.c

index 221a474da6765d4126bd538b256f0a737627a1e0..6a5c67846eb9c65d5050a0dbfe94423fe88b4a68 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2014-04-07  Will Newton  <will.newton@linaro.org>
+
+       * string/basename.c [HAVE_CONFIG_H]: Remove #ifdef and
+       and contents.  [!_LIBC] Remove #ifndef and contents.
+       (basename): Use ANSI prototype.  [_LIBC] Remove #idef.
+       * string/memccpy.c (__memccpy): Use ANSI prototype.
+       * string/memfrob.c (memfrob): Likewise.
+       * string/strcoll.c (STRCOLL): Likewise.
+       * string/strlen.c (strlen): Likewise.
+       * string/strtok.c (STRTOK): Likewise.
+       * string/strcat.c: Remove unused #include of memcopy.h.
+       (strcat): Use ANSI prototype.
+       * string/strchr.c: Remove unused #include of memcopy.h.
+       (strchr): Use ANSI prototype.
+       * string/strcmp.c: Remove unused #include of memcopy.h.
+       (strcmp): Use ANSI prototype.
+       * string/strcpy.c: Remove unused #include of memcopy.h.
+       (strcpy): Use ANSI prototype.
+
 2014-04-06  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
 
        * Makeconfig (CPPFLAGS): Add config-extra-cppflags to list.
index 29b84eecb4d354992d6168efbbff9ef2bfb690d2..98bf96c3e2cf5dab501d954544c580666f809d27 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
 #include <string.h>
 
-#ifndef _LIBC
-/* We cannot generally use the name `basename' since XPG defines an unusable
-   variant of the function but we cannot use it.  */
-# define basename gnu_basename
-#endif
-
-
 char *
-basename (filename)
-     const char *filename;
+basename (const char *filename)
 {
   char *p = strrchr (filename, '/');
   return p ? p + 1 : (char *) filename;
 }
-#ifdef _LIBC
 libc_hidden_def (basename)
-#endif
index 793f68ee1cf068a1516fc3feaff3b9cf7dde041b..70ee2ae42e6fb84aafd93a2e54fdd573de01103f 100644 (file)
    Return the position in DEST one byte past where C was copied, or
    NULL if C was not found in the first N bytes of SRC.  */
 void *
-__memccpy (dest, src, c, n)
-      void *dest;
-      const void *src;
-      int c;
-      size_t n;
+__memccpy (void *dest, const void *src, int c, size_t n)
 {
   const char *s = src;
   char *d = dest;
index 4841309874cda918ae3510e1bbb5aadd2be98f82..68339f730091ee99d0328754c45d3df8e678e8db 100644 (file)
@@ -18,9 +18,7 @@
 #include <string.h>
 
 void *
-memfrob (s, n)
-     void *s;
-     size_t n;
+memfrob (void *s, size_t n)
 {
   char *p = (char *) s;
 
index bb7c0a990971d76be3b6ed989dfee56ed3f248dc..2cbe8b32dacb5ed5b7173cfc7816e404391be6fb 100644 (file)
    <http://www.gnu.org/licenses/>.  */
 
 #include <string.h>
-#include <memcopy.h>
 
 #undef strcat
 
 /* Append SRC on the end of DEST.  */
 char *
-strcat (dest, src)
-     char *dest;
-     const char *src;
+strcat (char *dest, const char *src)
 {
   char *s1 = dest;
   const char *s2 = src;
index da69ed23539cf341b43331597b988d8c1b3ec787..6bea03eec98a7b82a66146dd4810585e13e7dc33 100644 (file)
    <http://www.gnu.org/licenses/>.  */
 
 #include <string.h>
-#include <memcopy.h>
 #include <stdlib.h>
 
 #undef strchr
 
 /* Find the first occurrence of C in S.  */
 char *
-strchr (s, c_in)
-     const char *s;
-     int c_in;
+strchr (const char *s, int c_in)
 {
   const unsigned char *char_ptr;
   const unsigned long int *longword_ptr;
index 212f20cc1c670b0bd51186c9f8490be4e6ba478f..85b0170277392ae37f69db6a1d87e56d85047808 100644 (file)
@@ -16,7 +16,6 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <string.h>
-#include <memcopy.h>
 
 #undef strcmp
 
@@ -24,9 +23,7 @@
    greater than zero if S1 is lexicographically less than,
    equal to or greater than S2.  */
 int
-strcmp (p1, p2)
-     const char *p1;
-     const char *p2;
+strcmp (const char *p1, const char *p2)
 {
   const unsigned char *s1 = (const unsigned char *) p1;
   const unsigned char *s2 = (const unsigned char *) p2;
index 779ba1309c8e43bdc52035a67b540b1876566a1c..367ab2e782b2e1360cc3f53bd1a487cb50fffc99 100644 (file)
@@ -29,9 +29,7 @@
 
 
 int
-STRCOLL (s1, s2)
-     const STRING_TYPE *s1;
-     const STRING_TYPE *s2;
+STRCOLL (const STRING_TYPE *s1, const STRING_TYPE *s2)
 {
   return STRCOLL_L (s1, s2, _NL_CURRENT_LOCALE);
 }
index f13691643711e32d3da2831dc7898cbda497ca4e..caa234a691cc64457e78e08db263b6568e494e2b 100644 (file)
 
 #include <stddef.h>
 #include <string.h>
-#include <memcopy.h>
 
 #undef strcpy
 
 /* Copy SRC to DEST.  */
 char *
-strcpy (dest, src)
-     char *dest;
-     const char *src;
+strcpy (char *dest, const char *src)
 {
   char c;
   char *s = (char *) src;
index 342c4a2b70b2755171803df92d4e42cfd3c16422..19d2b2bb8296444a9815cc4dbb39a06dc4fee5af 100644 (file)
@@ -26,8 +26,7 @@
 /* Return the length of the null-terminated string STR.  Scan for
    the null terminator quickly by testing four bytes at a time.  */
 size_t
-strlen (str)
-     const char *str;
+strlen (const char *str)
 {
   const char *char_ptr;
   const unsigned long int *longword_ptr;
index 225344003e29574f47003e88078ab6ee43b93c08..924313e8782467a1d9711de8f6dca0f43ad433c8 100644 (file)
@@ -36,9 +36,7 @@ static char *olds;
                // s = "abc\0=-def\0"
 */
 char *
-STRTOK (s, delim)
-     char *s;
-     const char *delim;
+STRTOK (char *s, const char *delim)
 {
   char *token;