diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2003-11-25 21:17:02 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2003-11-25 21:17:02 +0000 |
commit | c82182a02918a1da623400d7212c6d062516b506 (patch) | |
tree | fd35eb59d9dd51e387885e17d06c2a4f0eea71f3 /gnu/lib/libiberty | |
parent | 6d6d484d3ced0af129ee74472853795aa1ebe3e5 (diff) |
fix instances of cvs brain-damage. We want the current FSF version of
these files.
Diffstat (limited to 'gnu/lib/libiberty')
-rw-r--r-- | gnu/lib/libiberty/src/argv.c | 11 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/basename.c | 4 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/dyn-string.c | 24 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/fnmatch.c | 10 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/getruntime.c | 14 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/memcmp.c | 4 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/mkstemps.c | 3 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/objalloc.c | 7 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/partition.c | 12 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/pexecute.c | 57 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/rename.c | 6 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/setenv.c | 14 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/sigsetmask.c | 2 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/strerror.c | 19 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/strsignal.c | 19 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/strtoul.c | 21 | ||||
-rw-r--r-- | gnu/lib/libiberty/src/xmemdup.c | 3 |
17 files changed, 152 insertions, 78 deletions
diff --git a/gnu/lib/libiberty/src/argv.c b/gnu/lib/libiberty/src/argv.c index 649b51e6731..4205579a576 100644 --- a/gnu/lib/libiberty/src/argv.c +++ b/gnu/lib/libiberty/src/argv.c @@ -25,10 +25,7 @@ Boston, MA 02111-1307, USA. */ #include "ansidecl.h" #include "libiberty.h" -#ifdef isspace -#undef isspace -#endif -#define isspace(ch) ((ch) == ' ' || (ch) == '\t') +#define ISBLANK(ch) ((ch) == ' ' || (ch) == '\t') /* Routines imported from standard C runtime libraries. */ @@ -198,7 +195,7 @@ char **buildargv (input) do { /* Pick off argv[argc] */ - while (isspace (*input)) + while (ISBLANK (*input)) { input++; } @@ -231,7 +228,7 @@ char **buildargv (input) arg = copybuf; while (*input != EOS) { - if (isspace (*input) && !squote && !dquote && !bsquote) + if (ISBLANK (*input) && !squote && !dquote && !bsquote) { break; } @@ -297,7 +294,7 @@ char **buildargv (input) argc++; argv[argc] = NULL; - while (isspace (*input)) + while (ISBLANK (*input)) { input++; } diff --git a/gnu/lib/libiberty/src/basename.c b/gnu/lib/libiberty/src/basename.c index 704e9c89b08..69a982d7dca 100644 --- a/gnu/lib/libiberty/src/basename.c +++ b/gnu/lib/libiberty/src/basename.c @@ -14,7 +14,7 @@ Behavior is undefined if the pathname ends in a directory separator. #include "ansidecl.h" #include "libiberty.h" -#include <ctype.h> +#include "safe-ctype.h" #ifndef DIR_SEPARATOR #define DIR_SEPARATOR '/' @@ -44,7 +44,7 @@ basename (name) #if defined (HAVE_DOS_BASED_FILE_SYSTEM) /* Skip over the disk name in MSDOS pathnames. */ - if (isalpha (name[0]) && name[1] == ':') + if (ISALPHA (name[0]) && name[1] == ':') name += 2; #endif diff --git a/gnu/lib/libiberty/src/dyn-string.c b/gnu/lib/libiberty/src/dyn-string.c index fd6e6b55b52..1da76c2110d 100644 --- a/gnu/lib/libiberty/src/dyn-string.c +++ b/gnu/lib/libiberty/src/dyn-string.c @@ -314,6 +314,30 @@ dyn_string_insert_cstr (dest, pos, src) return 1; } +/* Inserts character C into DEST starting at position POS. DEST is + expanded as necessary. Returns 1 on success. On failure, + RETURN_ON_ALLOCATION_FAILURE, deletes DEST and returns 0. */ + +int +dyn_string_insert_char (dest, pos, c) + dyn_string_t dest; + int pos; + int c; +{ + int i; + + if (dyn_string_resize (dest, dest->length + 1) == NULL) + return 0; + /* Make room for the insertion. Be sure to copy the NUL. */ + for (i = dest->length; i >= pos; --i) + dest->s[i + 1] = dest->s[i]; + /* Add the new character. */ + dest->s[pos] = c; + /* Compute the new length. */ + ++dest->length; + return 1; +} + /* Append S to DS, resizing DS if necessary. Returns 1 on success. On failure, if RETURN_ON_ALLOCATION_FAILURE, deletes DEST and returns 0. */ diff --git a/gnu/lib/libiberty/src/fnmatch.c b/gnu/lib/libiberty/src/fnmatch.c index 0a9bfe6152b..eb898ee14d8 100644 --- a/gnu/lib/libiberty/src/fnmatch.c +++ b/gnu/lib/libiberty/src/fnmatch.c @@ -1,7 +1,7 @@ /* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. -NOTE: The canonical source of this file is maintained with the GNU C Library. -Bugs can be reported to bug-glibc@prep.ai.mit.edu. +NOTE: This source is derived from an old version taken from the GNU C +Library (glibc). This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -45,8 +45,7 @@ Boston, MA 02111-1307, USA. */ #include <errno.h> #include <fnmatch.h> -#include <ctype.h> - +#include <safe-ctype.h> /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C @@ -74,8 +73,7 @@ fnmatch (pattern, string, flags) register const char *p = pattern, *n = string; register unsigned char c; -/* Note that this evalutes C many times. */ -#define FOLD(c) ((flags & FNM_CASEFOLD) && isupper (c) ? tolower (c) : (c)) +#define FOLD(c) ((flags & FNM_CASEFOLD) ? TOLOWER (c) : (c)) while ((c = *p++) != '\0') { diff --git a/gnu/lib/libiberty/src/getruntime.c b/gnu/lib/libiberty/src/getruntime.c index ff836e9fce4..3f7dc0d117a 100644 --- a/gnu/lib/libiberty/src/getruntime.c +++ b/gnu/lib/libiberty/src/getruntime.c @@ -30,10 +30,20 @@ Boston, MA 02111-1307, USA. */ single way is available for all host systems, nor are there reliable ways to find out which way is correct for a given host. */ -#include <time.h> +#ifdef TIME_WITH_SYS_TIME +# include <sys/time.h> +# include <time.h> +#else +# if HAVE_SYS_TIME_H +# include <sys/time.h> +# else +# ifdef HAVE_TIME_H +# include <time.h> +# endif +# endif +#endif #if defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H) -#include <sys/time.h> #include <sys/resource.h> #endif diff --git a/gnu/lib/libiberty/src/memcmp.c b/gnu/lib/libiberty/src/memcmp.c index 011f36c8619..d8d3997d066 100644 --- a/gnu/lib/libiberty/src/memcmp.c +++ b/gnu/lib/libiberty/src/memcmp.c @@ -26,8 +26,8 @@ int DEFUN(memcmp, (str1, str2, count), const PTR str1 AND const PTR str2 AND size_t count) { - register unsigned char *s1 = (unsigned char*)str1; - register unsigned char *s2 = (unsigned char*)str2; + register const unsigned char *s1 = (const unsigned char*)str1; + register const unsigned char *s2 = (const unsigned char*)str2; while (count-- > 0) { diff --git a/gnu/lib/libiberty/src/mkstemps.c b/gnu/lib/libiberty/src/mkstemps.c index d3cb58058aa..1f6600a15b9 100644 --- a/gnu/lib/libiberty/src/mkstemps.c +++ b/gnu/lib/libiberty/src/mkstemps.c @@ -20,6 +20,7 @@ #include "config.h" #endif +#include <sys/types.h> #ifdef HAVE_STDLIB_H #include <stdlib.h> #endif @@ -39,7 +40,7 @@ /* We need to provide a type for gcc_uint64_t. */ #ifdef __GNUC__ -typedef unsigned long long gcc_uint64_t; +__extension__ typedef unsigned long long gcc_uint64_t; #else typedef unsigned long gcc_uint64_t; #endif diff --git a/gnu/lib/libiberty/src/objalloc.c b/gnu/lib/libiberty/src/objalloc.c index 57754a86105..50995691e33 100644 --- a/gnu/lib/libiberty/src/objalloc.c +++ b/gnu/lib/libiberty/src/objalloc.c @@ -18,6 +18,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "ansidecl.h" +#include "config.h" + #include "objalloc.h" /* Get a definition for NULL. */ @@ -33,11 +35,16 @@ Boston, MA 02111-1307, USA. */ #include <stddef.h> #endif +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#else /* For systems with larger pointers than ints, this must be declared. */ extern PTR malloc PARAMS ((size_t)); extern void free PARAMS ((PTR)); #endif +#endif + /* These routines allocate space for an object. Freeing allocated space may or may not free all more recently allocated space. diff --git a/gnu/lib/libiberty/src/partition.c b/gnu/lib/libiberty/src/partition.c index 0934047dde5..07154722079 100644 --- a/gnu/lib/libiberty/src/partition.c +++ b/gnu/lib/libiberty/src/partition.c @@ -27,9 +27,15 @@ #include <stdlib.h> #endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif + #include "libiberty.h" #include "partition.h" +static int elem_compare PARAMS ((const void *, const void *)); + /* Creates a partition of NUM_ELEMENTS elements. Initially each element is in a class by itself. */ @@ -124,8 +130,8 @@ elem_compare (elem1, elem2) const void *elem1; const void *elem2; { - int e1 = * (int *) elem1; - int e2 = * (int *) elem2; + int e1 = * (const int *) elem1; + int e2 = * (const int *) elem2; if (e1 < e2) return -1; else if (e1 > e2) @@ -171,7 +177,7 @@ partition_print (part, fp) c = elements[c].next - elements; } /* Sort them. */ - qsort ((void *) class_elements, count, sizeof (int), &elem_compare); + qsort ((void *) class_elements, count, sizeof (int), elem_compare); /* Print them. */ fputc ('(', fp); for (i = 0; i < count; ++i) diff --git a/gnu/lib/libiberty/src/pexecute.c b/gnu/lib/libiberty/src/pexecute.c index b3a58171657..347c4db1092 100644 --- a/gnu/lib/libiberty/src/pexecute.c +++ b/gnu/lib/libiberty/src/pexecute.c @@ -29,31 +29,24 @@ Boston, MA 02111-1307, USA. */ #include <stdio.h> #include <errno.h> +#ifdef NEED_DECLARATION_ERRNO +extern int errno; +#endif #ifdef HAVE_STRING_H #include <string.h> #endif #ifdef HAVE_UNISTD_H #include <unistd.h> #endif -#define ISSPACE (x) isspace(x) +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#endif #ifdef HAVE_SYS_WAIT_H #include <sys/wait.h> #endif -#ifdef vfork /* Autoconf may define this to fork for us. */ -# define VFORK_STRING "fork" -#else -# define VFORK_STRING "vfork" -#endif -#ifdef HAVE_VFORK_H -#include <vfork.h> -#endif -#ifdef VMS -#define vfork() (decc$$alloc_vfork_blocks() >= 0 ? \ - lib$get_current_invo_context(decc$$get_vfork_jmpbuf()) : -1) -#endif /* VMS */ - #include "libiberty.h" +#include "safe-ctype.h" /* stdin file number. */ #define STDIN_FILE_NO 0 @@ -164,9 +157,9 @@ pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) if ((flags & PEXECUTE_ONE) != PEXECUTE_ONE) abort (); -#ifdef __GO32__ +#ifdef __DJGPP__ /* ??? What are the possible return values from spawnv? */ - rc = (flags & PEXECUTE_SEARCH ? spawnvp : spawnv) (1, program, argv); + rc = (flags & PEXECUTE_SEARCH ? spawnvp : spawnv) (P_WAIT, program, argv); #else char *scmd, *rf; FILE *argfile; @@ -215,7 +208,7 @@ pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) if (rc == -1) { *errmsg_fmt = install_error_msg; - *errmsg_arg = program; + *errmsg_arg = (char *)program; return -1; } @@ -224,6 +217,13 @@ pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) return last_pid; } +/* Use ECHILD if available, otherwise use EINVAL. */ +#ifdef ECHILD +#define PWAIT_ERROR ECHILD +#else +#define PWAIT_ERROR EINVAL +#endif + int pwait (pid, status, flags) int pid; @@ -235,13 +235,16 @@ pwait (pid, status, flags) /* Called twice for the same child? */ || pid == last_reaped) { - /* ??? ECHILD would be a better choice. Can we use it here? */ - errno = EINVAL; + errno = PWAIT_ERROR; return -1; } /* ??? Here's an opportunity to canonicalize the values in STATUS. Needed? */ +#ifdef __DJGPP__ + *status = (last_status >> 8); +#else *status = last_status; +#endif last_reaped = last_pid; return last_pid; } @@ -669,7 +672,7 @@ pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) const char *program; char * const *argv; const char *this_pname; - const char *temp_base; + const char *temp_base ATTRIBUTE_UNUSED; char **errmsg_fmt, **errmsg_arg; int flags; { @@ -711,9 +714,10 @@ pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) /* Fork a subprocess; wait and retry if it fails. */ sleep_interval = 1; + pid = -1; for (retries = 0; retries < 4; retries++) { - pid = vfork (); + pid = fork (); if (pid >= 0) break; sleep (sleep_interval); @@ -723,11 +727,9 @@ pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) switch (pid) { case -1: - { - *errmsg_fmt = VFORK_STRING; - *errmsg_arg = NULL; - return -1; - } + *errmsg_fmt = "fork"; + *errmsg_arg = NULL; + return -1; case 0: /* child */ /* Move the input and output pipes into place, if necessary. */ @@ -751,7 +753,6 @@ pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) /* Exec the program. */ (*func) (program, argv); - /* Note: Calling fprintf and exit here doesn't seem right for vfork. */ fprintf (stderr, "%s: ", this_pname); fprintf (stderr, install_error_msg, program); fprintf (stderr, ": %s\n", xstrerror (errno)); @@ -776,7 +777,7 @@ int pwait (pid, status, flags) int pid; int *status; - int flags; + int flags ATTRIBUTE_UNUSED; { /* ??? Here's an opportunity to canonicalize the values in STATUS. Needed? */ diff --git a/gnu/lib/libiberty/src/rename.c b/gnu/lib/libiberty/src/rename.c index 9957994410b..05630629c1f 100644 --- a/gnu/lib/libiberty/src/rename.c +++ b/gnu/lib/libiberty/src/rename.c @@ -12,7 +12,13 @@ exists, it is removed. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include <errno.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif int rename (zfrom, zto) diff --git a/gnu/lib/libiberty/src/setenv.c b/gnu/lib/libiberty/src/setenv.c index 0ed7ab6f1c9..8394fafe4e1 100644 --- a/gnu/lib/libiberty/src/setenv.c +++ b/gnu/lib/libiberty/src/setenv.c @@ -85,7 +85,7 @@ setenv (name, value, replace) const char *value; int replace; { - register char **ep; + register char **ep = 0; register size_t size; const size_t namelen = strlen (name); const size_t vallen = strlen (value) + 1; @@ -94,11 +94,13 @@ setenv (name, value, replace) size = 0; if (__environ != NULL) - for (ep = __environ; *ep != NULL; ++ep) - if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=') - break; - else - ++size; + { + for (ep = __environ; *ep != NULL; ++ep) + if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=') + break; + else + ++size; + } if (__environ == NULL || *ep == NULL) { diff --git a/gnu/lib/libiberty/src/sigsetmask.c b/gnu/lib/libiberty/src/sigsetmask.c index 0d6eaf478dd..f705fbb2df2 100644 --- a/gnu/lib/libiberty/src/sigsetmask.c +++ b/gnu/lib/libiberty/src/sigsetmask.c @@ -21,6 +21,8 @@ be the value @code{1}). #include <sys/types.h> #include <signal.h> +extern void abort PARAMS ((void)) ATTRIBUTE_NORETURN; + #ifdef SIG_SETMASK int DEFUN(sigsetmask,(set), diff --git a/gnu/lib/libiberty/src/strerror.c b/gnu/lib/libiberty/src/strerror.c index 7e1be0787bd..a1d165efac9 100644 --- a/gnu/lib/libiberty/src/strerror.c +++ b/gnu/lib/libiberty/src/strerror.c @@ -27,14 +27,17 @@ /* Routines imported from standard C runtime libraries. */ -#ifdef __STDC__ -#include <stddef.h> -extern void *malloc (size_t size); /* 4.10.3.3 */ -extern void *memset (void *s, int c, size_t n); /* 4.11.6.1 */ -#else /* !__STDC__ */ -extern char *malloc (); /* Standard memory allocater */ -extern char *memset (); -#endif /* __STDC__ */ +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#else +extern PTR malloc (); +#endif + +#ifdef HAVE_STRING_H +#include <string.h> +#else +extern PTR memset (); +#endif #ifndef MAX # define MAX(a,b) ((a) > (b) ? (a) : (b)) diff --git a/gnu/lib/libiberty/src/strsignal.c b/gnu/lib/libiberty/src/strsignal.c index 27edb960df0..86c8aca5b49 100644 --- a/gnu/lib/libiberty/src/strsignal.c +++ b/gnu/lib/libiberty/src/strsignal.c @@ -24,14 +24,17 @@ /* Routines imported from standard C runtime libraries. */ -#ifdef __STDC__ -#include <stddef.h> -extern void *malloc (size_t size); /* 4.10.3.3 */ -extern void *memset (void *s, int c, size_t n); /* 4.11.6.1 */ -#else /* !__STDC__ */ -extern char *malloc (); /* Standard memory allocater */ -extern char *memset (); -#endif /* __STDC__ */ +#ifdef HAVE_STDLIB_H +#include <stdlib.h> +#else +extern PTR malloc (); +#endif + +#ifdef HAVE_STRING_H +#include <string.h> +#else +extern PTR memset (); +#endif /* Undefine the macro we used to hide the definition of sys_siglist found in the system header files. */ diff --git a/gnu/lib/libiberty/src/strtoul.c b/gnu/lib/libiberty/src/strtoul.c index 2ec32043e6b..66420f268b2 100644 --- a/gnu/lib/libiberty/src/strtoul.c +++ b/gnu/lib/libiberty/src/strtoul.c @@ -28,13 +28,24 @@ * SUCH DAMAGE. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#ifdef HAVE_LIMITS_H #include <limits.h> -#include <ctype.h> +#endif +#ifdef HAVE_SYS_PARAM_H +#include <sys/param.h> +#endif #include <errno.h> +#ifdef NEED_DECLARATION_ERRNO +extern int errno; +#endif #if 0 #include <stdlib.h> #endif #include "ansidecl.h" +#include "safe-ctype.h" #ifndef ULONG_MAX #define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF */ @@ -63,7 +74,7 @@ strtoul(nptr, endptr, base) */ do { c = *s++; - } while (isspace(c)); + } while (ISSPACE(c)); if (c == '-') { neg = 1; c = *s++; @@ -80,10 +91,10 @@ strtoul(nptr, endptr, base) cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; cutlim = (unsigned long)ULONG_MAX % (unsigned long)base; for (acc = 0, any = 0;; c = *s++) { - if (isdigit(c)) + if (ISDIGIT(c)) c -= '0'; - else if (isalpha(c)) - c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else if (ISALPHA(c)) + c -= ISUPPER(c) ? 'A' - 10 : 'a' - 10; else break; if (c >= base) diff --git a/gnu/lib/libiberty/src/xmemdup.c b/gnu/lib/libiberty/src/xmemdup.c index e19a72f1718..9e9d66b715d 100644 --- a/gnu/lib/libiberty/src/xmemdup.c +++ b/gnu/lib/libiberty/src/xmemdup.c @@ -22,6 +22,9 @@ allocated, the remaining memory is zeroed. #include "libiberty.h" #include <sys/types.h> /* For size_t. */ +#ifdef HAVE_STRING_H +#include <string.h> +#endif PTR xmemdup (input, copy_size, alloc_size) |