diff options
Diffstat (limited to 'string')
-rw-r--r-- | string/argz.h | 6 | ||||
-rw-r--r-- | string/stratcliff.c | 26 | ||||
-rw-r--r-- | string/string.h | 28 | ||||
-rw-r--r-- | string/swab.c | 36 |
4 files changed, 52 insertions, 44 deletions
diff --git a/string/argz.h b/string/argz.h index d7814fd..8d81853 100644 --- a/string/argz.h +++ b/string/argz.h @@ -27,8 +27,6 @@ __BEGIN_DECLS -#ifdef __USE_GNU - /* Make a '\0' separated arg vector from a unix argv vector, returning it in ARGZ, and the total length in LEN. If a memory allocation error occurs, ENOMEM is returned, otherwise 0. The result can be destroyed using free. */ @@ -129,6 +127,4 @@ argz_next (char *__argz, size_t __argz_len, __const char *__entry) } #endif /* optimizing GCC2 */ -#endif /* use GNU */ - -#endif /* __ARGZ_H__ */ +#endif /* argz.h */ diff --git a/string/stratcliff.c b/string/stratcliff.c index 10c1f1f..a994e56 100644 --- a/string/stratcliff.c +++ b/string/stratcliff.c @@ -1,3 +1,23 @@ +/* Test for string function add boundaries of usable memory. + Copyright (C) 1996 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + #define _GNU_SOURCE 1 #include <errno.h> #include <stdio.h> @@ -13,7 +33,7 @@ int main (int argc, char *argv[]) { - size_t size = sysconf (_SC_PAGESIZE); + int size = sysconf (_SC_PAGESIZE); char *adr, *dest; int result = 0; @@ -52,7 +72,7 @@ main (int argc, char *argv[]) { adr[inner] = '\0'; - if (strlen (&adr[outer]) != inner - outer) + if (strlen (&adr[outer]) != (size_t) (inner - outer)) { printf ("strlen flunked for outer = %d, inner = %d\n", outer, inner); @@ -127,7 +147,7 @@ main (int argc, char *argv[]) adr[inner] = '\0'; if (strcpy (dest, &adr[outer]) != dest - || strlen (dest) != inner - outer) + || strlen (dest) != (size_t) (inner - outer)) { printf ("strcpy flunked for outer = %d, inner = %d\n", outer, inner); diff --git a/string/string.h b/string/string.h index 414f2cb..ff6d3df 100644 --- a/string/string.h +++ b/string/string.h @@ -46,7 +46,7 @@ extern __ptr_t memmove __P ((__ptr_t __dest, __const __ptr_t __src, or NULL if C was not found in the first N bytes of SRC. */ extern __ptr_t __memccpy __P ((__ptr_t __dest, __const __ptr_t __src, int __c, size_t __n)); -#if defined (__USE_SVID) || defined (__USE_BSD) +#if defined (__USE_SVID) || defined (__USE_BSD) || defined (__USE_XOPEN) extern __ptr_t memccpy __P ((__ptr_t __dest, __const __ptr_t __src, int __c, size_t __n)); #endif /* SVID. */ @@ -83,7 +83,7 @@ extern int strcoll __P ((__const char *__s1, __const char *__s2)); /* Put a transformation of SRC into no more than N bytes of DEST. */ extern size_t strxfrm __P ((char *__dest, __const char *__src, size_t __n)); -#if defined (__USE_SVID) || defined (__USE_BSD) +#if defined(__USE_SVID) || defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED) /* Duplicate S, returning an identical malloc'd string. */ extern char *__strdup __P ((__const char *__s)); extern char *strdup __P ((__const char *__s)); @@ -177,13 +177,7 @@ extern char *strerror __P ((int __errnum)); extern char *strerror_r __P ((int __errnum, char *__buf, size_t __buflen)); #endif -#ifdef __USE_BSD -/* Find the first occurrence of C in S (same as strchr). */ -extern char *index __P ((__const char *__s, int __c)); - -/* Find the last occurrence of C in S (same as strrchr). */ -extern char *rindex __P ((__const char *__s, int __c)); - +#if defined(__USE_BSD) || defined(__USE_XOPEN_EXTENDED) /* Copy N bytes of SRC to DEST (like memmove, but args reversed). */ extern void bcopy __P ((__const __ptr_t __src, __ptr_t __dest, size_t __n)); @@ -193,6 +187,12 @@ extern void bzero __P ((__ptr_t __s, size_t __n)); /* Compare N bytes of S1 and S2 (same as memcmp). */ extern int bcmp __P ((__const __ptr_t __s1, __const __ptr_t __s2, size_t __n)); +/* Find the first occurrence of C in S (same as strchr). */ +extern char *index __P ((__const char *__s, int __c)); + +/* Find the last occurrence of C in S (same as strrchr). */ +extern char *rindex __P ((__const char *__s, int __c)); + /* Return the position of the first bit set in I, or 0 if none are set. The least-significant bit is position 1, the most-significant 32. */ extern int ffs __P ((int __i)); @@ -206,7 +206,9 @@ extern int __strncasecmp __P ((__const char *__s1, __const char *__s2, size_t __n)); extern int strncasecmp __P ((__const char *__s1, __const char *__s2, size_t __n)); +#endif /* Use BSD or X/Open Unix. */ +#ifdef __USE_BSD /* Return the next DELIM-delimited token from *STRINGP, terminating it with a '\0', and update *STRINGP to point past it. */ extern char *__strsep __P ((char **__stringp, __const char *__delim)); @@ -238,14 +240,6 @@ extern __ptr_t memfrob __P ((__ptr_t __s, size_t __n)); extern char *basename __P ((__const char *__filename)); #endif -#ifdef __USE_SVID -/* Swab pairs bytes in the first N bytes of the area pointed to by - FROM and copy the result to TO. The value of TO must not be in the - range [FROM - N + 1, FROM - 1]. If N is odd the first byte in FROM - is without partner. */ -extern void swab __P ((__const char *__from, __const char *__to, size_t __n)); -#endif - __END_DECLS #endif /* string.h */ diff --git a/string/swab.c b/string/swab.c index 350d9a3..9d7858c 100644 --- a/string/swab.c +++ b/string/swab.c @@ -1,31 +1,29 @@ -/* Copyright (C) 1992 Free Software Foundation, Inc. -This file is part of the GNU C Library. +/* Copyright (C) 1992, 1996 Free Software Foundation, Inc. + This file is part of the GNU C Library. -The GNU C Library is free software; you can redistribute it and/or -modify it under the terms of the GNU Library General Public License as -published by the Free Software Foundation; either version 2 of the -License, or (at your option) any later version. + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. -The GNU C Library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Library General Public License for more details. + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. -You should have received a copy of the GNU Library General Public -License along with the GNU C Library; see the file COPYING.LIB. If -not, write to the Free Software Foundation, Inc., 675 Mass Ave, -Cambridge, MA 02139, USA. */ + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ -#include <ansidecl.h> -#include <stddef.h> +#include <unistd.h> void -DEFUN(swab, (from, to, n), - CONST char *from AND char *to AND size_t n) +swab (const char *from, char *to, ssize_t n) { while (n > 1) { - CONST char b0 = from[--n], b1 = from[--n]; + const char b0 = from[--n], b1 = from[--n]; to[n] = b0; to[n + 1] = b1; } |