diff options
author | Ian Lance Taylor <ian@airs.com> | 2000-02-22 16:18:13 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 2000-02-22 16:18:13 +0000 |
commit | 9e7fba8ade016a355d662ba84005773746a3c7c0 (patch) | |
tree | 66613bc864c3dd53c6ad2571513130fa98da08f2 /libiberty | |
parent | f507d52b48cf10a4a5b82548478505edc89df964 (diff) | |
download | gdb-9e7fba8ade016a355d662ba84005773746a3c7c0.tar.gz |
import libiberty from egcs
Diffstat (limited to 'libiberty')
-rw-r--r-- | libiberty/basename.c | 39 | ||||
-rw-r--r-- | libiberty/calloc.c | 3 | ||||
-rw-r--r-- | libiberty/config.table | 3 | ||||
-rw-r--r-- | libiberty/getcwd.c | 10 | ||||
-rw-r--r-- | libiberty/makefile.vms | 2 | ||||
-rw-r--r-- | libiberty/random.c | 35 | ||||
-rw-r--r-- | libiberty/strtol.c | 5 | ||||
-rw-r--r-- | libiberty/strtoul.c | 7 | ||||
-rw-r--r-- | libiberty/tmpnam.c | 2 | ||||
-rw-r--r-- | libiberty/vmsbuild.com | 2 | ||||
-rw-r--r-- | libiberty/xstrdup.c | 1 |
11 files changed, 80 insertions, 29 deletions
diff --git a/libiberty/basename.c b/libiberty/basename.c index f544c853910..7698f06f8ae 100644 --- a/libiberty/basename.c +++ b/libiberty/basename.c @@ -14,24 +14,53 @@ DESCRIPTION last component of the pathname ("ls.c" in this case). BUGS - Presumes a UNIX style path with UNIX style separators. + Presumes a UNIX or DOS/Windows style path with UNIX or DOS/Windows + style separators. */ #include "ansidecl.h" #include "libiberty.h" +#include <ctype.h> + +#ifndef DIR_SEPARATOR +#define DIR_SEPARATOR '/' +#endif + +#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ + defined (__OS2__) +#define HAVE_DOS_BASED_FILE_SYSTEM +#ifndef DIR_SEPARATOR_2 +#define DIR_SEPARATOR_2 '\\' +#endif +#endif + +/* Define IS_DIR_SEPARATOR. */ +#ifndef DIR_SEPARATOR_2 +# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) +#else /* DIR_SEPARATOR_2 */ +# define IS_DIR_SEPARATOR(ch) \ + (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) +#endif /* DIR_SEPARATOR_2 */ char * basename (name) const char *name; { - const char *base = name; + const char *base; - while (*name) +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + /* Skip over the disk name in MSDOS pathnames. */ + if (isalpha (name[0]) && name[1] == ':') + name += 2; +#endif + + for (base = name; *name; name++) { - if (*name++ == '/') + if (IS_DIR_SEPARATOR (*name)) { - base = name; + base = name + 1; } } return (char *) base; } + diff --git a/libiberty/calloc.c b/libiberty/calloc.c index c8c0a78a7a1..334b18db86a 100644 --- a/libiberty/calloc.c +++ b/libiberty/calloc.c @@ -1,3 +1,6 @@ +/* calloc -- allocate memory which has been initialized to zero. + This function is in the public domain. */ + #include "ansidecl.h" #include "libiberty.h" diff --git a/libiberty/config.table b/libiberty/config.table index 5913b23ad63..4e33746164c 100644 --- a/libiberty/config.table +++ b/libiberty/config.table @@ -4,6 +4,7 @@ case "${host}" in *-*-cxux7*) frag=mh-cxux7 ;; *-*-freebsd2.1.*) frag=mh-fbsd21 ;; *-*-freebsd2.2.[012]) frag=mh-fbsd21 ;; + i370-*-opened*) frag=mh-openedition ;; i[345]86-*-windows*) frag=mh-windows ;; *-*-beos*) frag=mh-beos ;; esac @@ -57,4 +58,4 @@ else fi frag=xhost-mkfrag -${CONFIG_SHELL} ${libiberty_topdir}/move-if-change temp-frag xhost-mkfrag +${CONFIG_SHELL-/bin/sh} ${libiberty_topdir}/move-if-change temp-frag xhost-mkfrag diff --git a/libiberty/getcwd.c b/libiberty/getcwd.c index 06d55c04f58..47b1c1eec31 100644 --- a/libiberty/getcwd.c +++ b/libiberty/getcwd.c @@ -14,6 +14,9 @@ DESCRIPTION current directory's path doesn't fit in LEN characters, the result is NULL and errno is set. + If pathname is a null pointer, getcwd() will obtain size bytes of + space using malloc. + BUGS Emulated via the getwd() call, which is reasonable for most systems that do not have getcwd(). @@ -48,6 +51,13 @@ getcwd (buf, len) errno = ERANGE; return 0; } + if (!buf) { + buf = (char*)malloc(len); + if (!buf) { + errno = ENOMEM; + return 0; + } + } strcpy (buf, ourbuf); } return buf; diff --git a/libiberty/makefile.vms b/libiberty/makefile.vms index b61b51290da..6a7dd45718e 100644 --- a/libiberty/makefile.vms +++ b/libiberty/makefile.vms @@ -10,7 +10,7 @@ OBJS=bcopy.obj,bcmp.obj,getopt.obj,obstack.obj,xexit.obj,xmalloc.obj,hex.obj,\ getopt1.obj,cplus-dem.obj,strncasecmp.obj,strcasecmp.obj,strdup.obj,\ concat.obj,getruntime.obj,getpagesize.obj,alloca.obj,xstrerror.obj,\ - xstrdup.obj,xatexit.obj,choose-temp.obj,fnmatch.obj,objalloc.obj + xmemdup.obj,xstrdup.obj,xatexit.obj,choose-temp.obj,fnmatch.obj,objalloc.obj ifeq ($(CC),gcc) CFLAGS=/include=([],[-.include]) diff --git a/libiberty/random.c b/libiberty/random.c index 0a950709fce..ef00da0a5ae 100644 --- a/libiberty/random.c +++ b/libiberty/random.c @@ -2,17 +2,30 @@ * Copyright (c) 1983 Regents of the University of California. * All rights reserved. * - * Redistribution and use in source and binary forms are permitted - * provided that the above copyright notice and this paragraph are - * duplicated in all such forms and that any documentation, - * advertising materials, and other materials related to such - * distribution and use acknowledge that the software was developed - * by the University of California, Berkeley. The name of the - * University may not be used to endorse or promote products derived - * from this software without specific prior written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. [rescinded 22 July 1999] + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. */ /* diff --git a/libiberty/strtol.c b/libiberty/strtol.c index 37d170660f2..5467cc3e2e9 100644 --- a/libiberty/strtol.c +++ b/libiberty/strtol.c @@ -10,10 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. + * 3. [rescinded 22 July 1999] * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. diff --git a/libiberty/strtoul.c b/libiberty/strtoul.c index ff6f2d6784d..2ec32043e6b 100644 --- a/libiberty/strtoul.c +++ b/libiberty/strtoul.c @@ -10,10 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. + * 3. [rescinded 22 July 1999] * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -91,7 +88,7 @@ strtoul(nptr, endptr, base) break; if (c >= base) break; - if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) any = -1; else { any = 1; diff --git a/libiberty/tmpnam.c b/libiberty/tmpnam.c index c0614677425..8eb77e28c0b 100644 --- a/libiberty/tmpnam.c +++ b/libiberty/tmpnam.c @@ -1,7 +1,7 @@ #include <stdio.h> #ifndef L_tmpnam -#define L_tmpname 100 +#define L_tmpnam 100 #endif #ifndef P_tmpdir #define P_tmpdir "/usr/tmp" diff --git a/libiberty/vmsbuild.com b/libiberty/vmsbuild.com index 4fede380bfd..497ea8974f2 100644 --- a/libiberty/vmsbuild.com +++ b/libiberty/vmsbuild.com @@ -15,7 +15,7 @@ $! manually copied from Makefile.in $ REQUIRED_OFILES = "argv.o basename.o choose-temp.o concat.o cplus-dem.o "- + "fdmatch.o fnmatch.o getopt.o getopt1.o getruntime.o hex.o "- + "floatformat.o objalloc.o obstack.o spaces.o strerror.o strsignal.o "- - + "xatexit.o xexit.o xmalloc.o xstrdup.o xstrerror.o" + + "xatexit.o xexit.o xmalloc.o xmemdup.o xstrdup.o xstrerror.o" $! anything not caught by link+search of dummy.* should be added here $ EXTRA_OFILES = "" $! diff --git a/libiberty/xstrdup.c b/libiberty/xstrdup.c index e16aba08554..6f846cfea15 100644 --- a/libiberty/xstrdup.c +++ b/libiberty/xstrdup.c @@ -2,6 +2,7 @@ This trivial function is in the public domain. Ian Lance Taylor, Cygnus Support, December 1995. */ +#include <sys/types.h> #ifdef HAVE_CONFIG_H #include "config.h" #endif |