diff options
author | jdp <jdp@FreeBSD.org> | 1998-09-06 22:57:45 +0000 |
---|---|---|
committer | jdp <jdp@FreeBSD.org> | 1998-09-06 22:57:45 +0000 |
commit | effee09f856ecc81feb91290459a2cda49d20287 (patch) | |
tree | 5c46ac1ee102130859f788aeb927e8086985cfe7 /contrib/binutils/libiberty | |
parent | 31cb88078db5bdc51eb451c5a61e31a426fb8ae6 (diff) | |
download | FreeBSD-src-effee09f856ecc81feb91290459a2cda49d20287.zip FreeBSD-src-effee09f856ecc81feb91290459a2cda49d20287.tar.gz |
Import GNU binutils-2.9.1. This will break things for a few minutes
until I've made the commits to resolve the conflicts.
Submitted by: Doug Rabson <dfr>
Diffstat (limited to 'contrib/binutils/libiberty')
21 files changed, 1397 insertions, 259 deletions
diff --git a/contrib/binutils/libiberty/ChangeLog b/contrib/binutils/libiberty/ChangeLog index a4aaa91..e3f0773 100644 --- a/contrib/binutils/libiberty/ChangeLog +++ b/contrib/binutils/libiberty/ChangeLog @@ -1,12 +1,246 @@ +Mon Feb 23 14:33:15 1998 Ian Lance Taylor <ian@cygnus.com> + + * choose-temp.c: Fix handling of sys/file.h to work in libiberty. + +Sun Feb 22 18:03:23 1998 Jeffrey A Law (law@cygnus.com) + + * choose-temp.c: Sync with copy in gcc. + +Thu Feb 12 16:29:49 1998 Ian Lance Taylor <ian@cygnus.com> + + * getopt.c: Update to latest FSF version. + * getopt1.c: Likewise. + +Tue Feb 10 16:58:33 1998 Stan Shebs <shebs@andros.cygnus.com> + + * cplus-dem.c (gnu_special): Don't get confused by .<digits> + strings that are not actually lengths. + +Thu Feb 5 18:48:56 1998 Geoffrey Noer <noer@cygnus.com> + + * config/mh-cygwin32: remove vasprintf.o from EXTRA_OFILES + since it gets built automatically + +Sun Feb 1 02:52:32 1998 Mike Stump <mrs@wrs.com> + + * config.table (vxworks configs): Default to VxWorks 5.x, as that is + the currently shipping OS. + +Tue Jan 27 16:08:20 1998 Pat Rankin <rankin@eql.caltech.edu> + + * vmsbuild.com [REQUIRE_OFILES]: Synchronized with Makefile.in: + Add fnmatch.o and objalloc.o; remove vasprintf.o. + [config.h]: Define NEED_strsignal. + +Mon Jan 19 12:20:01 1998 Ian Lance Taylor <ian@cygnus.com> + + * functions.def: Correct argument types for strerror and + strsignal. Reported by Alex Gutman <agutman@emc.com>. + +Sun Jan 18 15:57:28 1998 Michael Snyder <msnyder@cleaver.cygnus.com> + + * vasprintf.c (int_vasprintf): Increase buffer size for float/double + values. + +Sat Jan 17 22:28:38 1997 Mumit Khan <khan@xraylith.wisc.edu> + J.J. VanderHeijden <J.J.vanderHeijden@student.utwente.nl> + + Add mingw32 support. + * pexecute.c (pexecute): New function for mingw32. Supports pipes. + (pwait): New function for mingw32. + + * config.table (i[3456]86-*-mingw32*): Support for i386-mingw32. + * config/mt-mingw32: New file. + * xmalloc.c (first_break): Not used for mingw32. + (xmalloc_set_program_name): Don't use sbrk on mingw32. + (xmalloc): Likewise. + (xrealloc): Likewise. + +Sat Jan 17 22:28:05 1998 Jeffrey A Law (law@cygnus.com) + + * choose-temp.c: Sync with gcc version. + +Tue Jan 13 18:34:39 1998 Jim Wilson <wilson@cygnus.com> + + * Makefile.in (install_to_libdir, install_to_tooldir): Add MULTISUBDIR + to all filenames in libdir and tooldir. + (distclean): Do MULTICLEAN before deleting Makefile. + (stamp-needed, stamp-config): Add MULTISRCTOP to + pathname for move-if-change. + +Thu Dec 4 17:25:19 1997 Jeffrey A Law (law@cygnus.com) + + * strsignal.c (sys_nsig): Try NSIG and _NSIG. + +Wed Nov 19 13:37:06 1997 Michael Meissner <meissner@cygnus.com> + + * alloca-norm.h (alloca, GCC case): Don't redefine alloca if it + was already defined previously. + +Mon Nov 10 12:48:03 1997 Philippe De Muyter <phdm@macqel.be> + + * Makefile.in (INSTALL): Use ../install-sh, not install. + +Tue Oct 28 23:41:15 1997 Judy Goldberg <jodyg@idt.net> + + * Makefile.in (CFILES): Add pexecute.c. + +Wed Oct 15 19:13:48 1997 Ian Lance Taylor <ian@cygnus.com> + + * asprintf.c: Consistently use either stdarg or varargs. + +Tue Oct 14 12:01:00 1997 Mark Mitchell <mmitchell@usa.net> + + * cplus-dem.c (demangle_signature): Don't look for return types on + constructors. Handle member template constructors. + +Fri Oct 3 17:53:30 1997 Ian Lance Taylor <ian@cygnus.com> + + * README: Fix configuration instructions. + +Mon Sep 29 12:28:41 1997 Ian Lance Taylor <ian@cygnus.com> + + * pexecute.c: Update to current version from /gd/gnu/lib: + + Mon Sep 29 12:27:59 1997 Ian Lance Taylor <ian@cygnus.com> + + * pexecute.c: Use spawn if __CYGWIN32__. + + 1997-08-08 Paul Eggert <eggert@twinsun.com> + + * pexecute.c: Include "config.h" first, as per autoconf manual. + + Fri Jun 27 15:20:29 1997 Scott Christley <scottc@net-community.com> + + * pexecute.c (fix_argv): New function. + (pexecute): Win32 but not Cygwin32 needs its arguments fixed. + Add underscore to cwait function call. + +Sun Sep 28 12:00:52 1997 Mark Mitchell <mmitchell@usa.net> + + * cplus-dem.c (demangle_template): Add new parameter. Handle new + template-function mangling. + (consume_count_with_underscores): New function. + (demangle_signature): Handle new name-mangling scheme. + +Wed Sep 24 00:31:59 1997 Felix Lee <flee@yin.cygnus.com> + + * asprintf.c: stdarg.h when ALMOST_STDC + * config/mh-windows (EXTRA_OFILES): add asprintf.o and + strncasecmp.o. + +Thu Aug 28 14:27:15 1997 Andrew Cagney <cagney@b1.cygnus.com> + + * vasprintf.c (vasprintf): Allow for _BSD_VA_LIST_. + + * config.table: Add case for FreeBSD 2.1 and 2.2, needs mh-fbsd21. + + * config/mh-fbsd21 (EXTRA_OFILES): Force vasprintf.o + +Wed Sep 10 12:43:10 1997 Jason Merrill <jason@yorick.cygnus.com> + + * cplus-dem.c (demangle_fund_type): Change "complex" to "__complex". + +Fri Sep 5 16:34:42 1997 Andrew Cagney <cagney@b1.cygnus.com> + + * asprintf.c (asprintf): New file. + * Makefile.in (CFILES): Add asprintf.c + * functions.def: Ditto. + +Thu Aug 28 18:53:34 1997 Andrew Cagney <cagney@b1.cygnus.com> + + * argv.c (dupargv): New function, duplicate an argument vector. + +Tue Aug 19 20:28:45 1997 Geoffrey Noer <noer@cygnus.com> + + * config/mh-cygwin32: also build random.o + +Tue Aug 19 17:10:56 1997 Jason Merrill <jason@yorick.cygnus.com> + + * cplus-dem.c: Add 'extern' to prepends_underscore. + +Wed Jul 30 11:42:19 1997 Per Bothner <bothner@cygnus.com> + + * cplus-dem.c: Various changes to produce Java output when passed + DMGL_JAVA. Thus "::" becomes "." and "JArray<Foo>" becomes "Foo[]". + (main): Support --java and -j flags to set DMGL_JAVA. + +Tue Jul 22 19:05:23 1997 Robert Hoehne <robert.hoehne@Mathematik.TU-Chemnitz.DE> + + * config/mh-go32 (CC, AR, RANLIB): Don't define. + +Tue Jul 22 17:49:54 1997 Ian Lance Taylor <ian@cygnus.com> + + * Makefile.in (REQUIRED_OFILES): Add pexecute.o. + (pexecute.o): New target. + + * Makefile.in (stamp-needed): New target, replacing needed-list. + (needed-list): Just depend upon stamp-needed. + (stamp-config): New target, replacing config.h. + (config.h): Just depend upon stamp-config. + (mostlyclean): Remove stamp-*. + +Thu Jun 12 11:00:18 1997 Angela Marie Thomas (angela@cygnus.com) + + * Makefile.in (FLAGS_TO_PASS): pass INSTALL, INSTALL_PROGRAM and + INSTALL_DATA for multilibbed installs + +Tue Jun 3 13:21:05 1997 Doug Evans <dje@canuck.cygnus.com> + + Tue Dec 10 09:44:57 1996 Paul Eggert <eggert@twinsun.com> + + * choose-temp.c (choose_temp_base): Don't dump core if TMPDIR is empty. + + * choose-temp.c (try): Insist that temp dir be searchable. + + Wed Oct 23 17:36:39 1996 Doug Rupp (rupp@gnat.com) + + * choose-temp.c (choose_temp_base): On VMS, use proper syntax + for current directory. + + Sat Feb 15 19:03:48 1997 Geoffrey Noer (noer@cygnus.com) + + * pexecute.c: Remove special cases for cygwin32. + (pwait): Remove local definition of `pid'. + + Tue Nov 12 18:26:15 1996 Doug Rupp (rupp@gnat.com) + + * pexecute.c (vfork): Supply new definition for VMS. + (pwait): Use waitpid instead of wait for VMS. + +Tue May 20 14:02:20 1997 Brendan Kehoe <brendan@lisa.cygnus.com> + + * cplus-dem.c (do_type): Handle `J'. + (demangle_fund_type): Print "complex" for it. + +Wed Apr 30 12:15:45 1997 Jason Merrill <jason@yorick.cygnus.com> + + * configure.in: Don't turn on multilib here. + +Mon Apr 28 19:04:31 1997 Michael Snyder <msnyder@cleaver.cygnus.com> + + * obstack.c: move _obstack_memory_used outside of ifdef. Cannot be + elided; needed by gdb and not present in libc. + Thu Apr 24 19:33:47 1997 Ian Lance Taylor <ian@cygnus.com> * Makefile.in (clean): Remove tmpmulti.out. +Tue Apr 22 10:25:15 1997 Fred Fish <fnf@cygnus.com> + + * floatformat.c (floatformat_ieee_double_littlebyte_bigword): + Add new floatformat, mainly for ARM doubles. + Mon Apr 14 12:11:16 1997 Ian Lance Taylor <ian@cygnus.com> * config.table: Use ${config_shell} with ${moveifchange}. From Thomas Graichen <graichen@rzpd.de>. +Fri Apr 4 03:09:24 1997 Ulrich Drepper <drepper@cygnus.com> + + * configure.in: Enable multilibing by default. + Update multilib template to read config-ml.in. + Tue Apr 1 16:26:39 1997 Klaus Kaempf <kkaempf@progis.de> * makefile.vms: Add objalloc. diff --git a/contrib/binutils/libiberty/Makefile.in b/contrib/binutils/libiberty/Makefile.in index b7f6392..58fabd5 100644 --- a/contrib/binutils/libiberty/Makefile.in +++ b/contrib/binutils/libiberty/Makefile.in @@ -59,7 +59,7 @@ MULTISUBDIR = MULTIDO = true MULTICLEAN = true -INSTALL = install -c +INSTALL = $(SHELL) $(srcdir)/../install-sh -c INSTALL_PROGRAM = $(INSTALL) INSTALL_DATA = $(INSTALL) @@ -106,6 +106,9 @@ FLAGS_TO_PASS = \ "LIBCFLAGS=$(LIBCFLAGS)" \ "EXTRA_OFILES=$(EXTRA_OFILES)" \ "HDEFINES=$(HDEFINES)" \ + "INSTALL=$(INSTALL)" \ + "INSTALL_DATA=$(INSTALL_DATA)" \ + "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \ "LDFLAGS=$(LDFLAGS)" \ "LOADLIBES=$(LOADLIBES)" \ "PICFLAG=$(PICFLAG)" \ @@ -143,12 +146,12 @@ HFILES = # NOTE: If you add new files to the library, add them to this list # (alphabetical), and add them to REQUIRED_OFILES or 'functions.def'. -CFILES = alloca.c argv.c atexit.c basename.c bcmp.c bcopy.c bzero.c \ +CFILES = asprintf.c alloca.c argv.c atexit.c basename.c bcmp.c bcopy.c bzero.c \ choose-temp.c clock.c concat.c cplus-dem.c fdmatch.c fnmatch.c \ getcwd.c getopt.c getopt1.c getpagesize.c getruntime.c \ floatformat.c hex.c index.c insque.c \ memchr.c memcmp.c memcpy.c memmove.c memset.c objalloc.c \ - obstack.c random.c rename.c rindex.c sigsetmask.c spaces.c \ + obstack.c pexecute.c random.c rename.c rindex.c sigsetmask.c spaces.c \ strcasecmp.c strncasecmp.c \ strchr.c strdup.c strerror.c strrchr.c strsignal.c \ strstr.c strtod.c strtol.c strtoul.c tmpnam.c \ @@ -157,8 +160,8 @@ CFILES = alloca.c argv.c atexit.c basename.c bcmp.c bcopy.c bzero.c \ # These are always included in the library. 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 + floatformat.o objalloc.o obstack.o pexecute.o spaces.o strerror.o \ + strsignal.o xatexit.o xexit.o xmalloc.o xstrdup.o xstrerror.o # Do we want/need any config overrides? # @@ -169,15 +172,15 @@ INSTALL_DEST = libdir install: install_to_$(INSTALL_DEST) install_to_libdir: all - $(INSTALL_DATA) $(TARGETLIB) $(libdir)/$(TARGETLIB).n - ( cd $(libdir) ; $(RANLIB) $(libdir)/$(TARGETLIB).n ) - mv -f $(libdir)/$(TARGETLIB).n $(libdir)$(MULTISUBDIR)/$(TARGETLIB) + $(INSTALL_DATA) $(TARGETLIB) $(libdir)$(MULTISUBDIR)/$(TARGETLIB).n + ( cd $(libdir)$(MULTISUBDIR) ; $(RANLIB) $(TARGETLIB).n ) + mv -f $(libdir)$(MULTISUBDIR)/$(TARGETLIB).n $(libdir)$(MULTISUBDIR)/$(TARGETLIB) @$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install install_to_tooldir: all - $(INSTALL_DATA) $(TARGETLIB) $(tooldir)/lib/$(TARGETLIB).n - ( cd $(tooldir) ; $(RANLIB) $(tooldir)/lib/$(TARGETLIB).n ) - mv -f $(tooldir)/lib/$(TARGETLIB).n $(tooldir)/lib$(MULTISUBDIR)/$(TARGETLIB) + $(INSTALL_DATA) $(TARGETLIB) $(tooldir)/lib$(MULTISUBDIR)/$(TARGETLIB).n + ( cd $(tooldir)/lib$(MULTISUBDIR) ; $(RANLIB) $(TARGETLIB).n ) + mv -f $(tooldir)/lib$(MULTISUBDIR)/$(TARGETLIB).n $(tooldir)/lib$(MULTISUBDIR)/$(TARGETLIB) @$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install # The default configuration adds to libiberty all those functions that are @@ -185,8 +188,12 @@ install_to_tooldir: all # Then a sed+awk combination translates the ld error messages into # a list of .o files. -needed-list: stamp-picdir $(NEEDED_LIST) - cp $(NEEDED_LIST) needed-list +stamp-needed: stamp-picdir $(NEEDED_LIST) + cp $(NEEDED_LIST) needed-tmp + $(SHELL) $(srcdir)/$(MULTISRCTOP)../move-if-change needed-tmp needed-list + touch stamp-needed + +needed-list: stamp-needed ; @true lneeded-list: $(EXTRA_OFILES) needed.awk errors rm -f lneeded-list @@ -211,8 +218,12 @@ needed.awk: $(srcdir)/functions.def Makefile | sed -e '/DEF/s|DEF.\([^,]*\).*|/\1/ { printf "\1.o " }|' \ >>needed.awk -config.h: $(CONFIG_H) - cp $(CONFIG_H) config.h +stamp-config: $(CONFIG_H) + cp $(CONFIG_H) config.tmp + $(SHELL) $(srcdir)/$(MULTISRCTOP)../move-if-change config.tmp config.h + touch stamp-config + +config.h: stamp-config ; @true lconfig.h: needed2.awk errors echo "/* !Automatically generated from $(srcdir)/functions.def"\ @@ -285,15 +296,15 @@ ls: mostlyclean: rm -rf *.o pic core errs \#* *.E a.out - rm -f needed.awk needed2.awk errors dummy needed-list config.h + rm -f needed.awk needed2.awk errors dummy needed-list config.h stamp-* rm -f $(CONFIG_H) $(NEEDED_LIST) stamp-picdir @$(MULTICLEAN) multi-clean DO=mostlyclean clean: mostlyclean rm -f *.a required-list tmpmulti.out @$(MULTICLEAN) multi-clean DO=clean distclean: clean - rm -f *~ Makefile config.status alloca-conf.h xhost-mkfrag TAGS multilib.out @$(MULTICLEAN) multi-clean DO=distclean + rm -f *~ Makefile config.status alloca-conf.h xhost-mkfrag TAGS multilib.out maintainer-clean realclean: distclean force: @@ -314,6 +325,7 @@ hex.o: $(INCDIR)/libiberty.h floatformat.o: $(INCDIR)/floatformat.h objalloc.o: $(INCDIR)/objalloc.h obstack.o: $(INCDIR)/obstack.h +pexecute.o: $(INCDIR)/libiberty.h spaces.o: $(INCDIR)/libiberty.h strerror.o: $(INCDIR)/libiberty.h strsignal.o: $(INCDIR)/libiberty.h diff --git a/contrib/binutils/libiberty/README b/contrib/binutils/libiberty/README index 5081bba..92dc202 100644 --- a/contrib/binutils/libiberty/README +++ b/contrib/binutils/libiberty/README @@ -11,10 +11,9 @@ Current members include: We expect many of the GNU subroutines that are floating around to eventually arrive here. -To build the library, do: - - ./configure HOSTTYPE - make +The library must be configured from the top source directory. Don't +try to run configure in this directory. Follow the configuration +instructions in ../README. Please report bugs and fixes to "bug-gnu-utils@prep.ai.mit.edu". Thank you. diff --git a/contrib/binutils/libiberty/alloca-norm.h b/contrib/binutils/libiberty/alloca-norm.h index 394a653..bda4fc0 100644 --- a/contrib/binutils/libiberty/alloca-norm.h +++ b/contrib/binutils/libiberty/alloca-norm.h @@ -1,7 +1,9 @@ /* "Normal" configuration for alloca. */ #ifdef __GNUC__ +#ifndef alloca #define alloca __builtin_alloca +#endif #else /* ! defined (__GNUC__) */ #if defined (sparc) && defined (sun) #include <alloca.h> diff --git a/contrib/binutils/libiberty/argv.c b/contrib/binutils/libiberty/argv.c index 60694f9..824a029 100644 --- a/contrib/binutils/libiberty/argv.c +++ b/contrib/binutils/libiberty/argv.c @@ -72,6 +72,63 @@ extern char *strdup (); /* Duplicate a string */ NAME + dupargv -- duplicate an argument vector + +SYNOPSIS + + char **dupargv (vector) + char **vector; + +DESCRIPTION + + Duplicate an argument vector. Simply scans through the + vector, duplicating each argument argument until the + terminating NULL is found. + +RETURNS + + Returns a pointer to the argument vector if + successful. Returns NULL if there is insufficient memory to + complete building the argument vector. + +*/ + +char ** +dupargv (argv) + char **argv; +{ + int argc; + char **copy; + + if (argv == NULL) + return NULL; + + /* the vector */ + for (argc = 0; argv[argc] != NULL; argc++); + copy = (char **) malloc ((argc + 1) * sizeof (char *)); + if (copy == NULL) + return NULL; + + /* the strings */ + for (argc = 0; argv[argc] != NULL; argc++) + { + int len = strlen (argv[argc]); + copy[argc] = malloc (sizeof (char *) * (len + 1)); + if (copy[argc] == NULL) + { + freeargv (copy); + return NULL; + } + strcpy (copy[argc], argv[argc]); + } + copy[argc] = NULL; + return copy; +} + +/* + +NAME + freeargv -- free an argument vector SYNOPSIS diff --git a/contrib/binutils/libiberty/asprintf.c b/contrib/binutils/libiberty/asprintf.c new file mode 100644 index 0000000..5aaf320 --- /dev/null +++ b/contrib/binutils/libiberty/asprintf.c @@ -0,0 +1,57 @@ +/* Like sprintf but provides a pointer to malloc'd storage, which must + be freed by the caller. + Copyright (C) 1997 Free Software Foundation, Inc. + Contributed by Cygnus Solutions. + +This file is part of the libiberty library. +Libiberty 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. + +Libiberty 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 libiberty; 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 "libiberty.h" + +#if defined (ANSI_PROTOTYPES) || defined (ALMOST_STDC) +#define USE_STDARG +#endif + +#ifdef USE_STDARG +#include <stdarg.h> +#else +#include <varargs.h> +#endif + +/* VARARGS */ +#ifdef USE_STDARG +int +asprintf (char **buf, const char *fmt, ...) +#else +int +asprintf (buf, fmt, va_alist) + char **buf; + const char *fmt; + va_dcl +#endif +{ + int status; + va_list ap; +#ifdef USE_STDARG + va_start (ap, fmt); +#else + va_start (ap); +#endif + status = vasprintf (buf, fmt, ap); + va_end (ap); + return status; +} diff --git a/contrib/binutils/libiberty/choose-temp.c b/contrib/binutils/libiberty/choose-temp.c index 0383832..5668f74 100644 --- a/contrib/binutils/libiberty/choose-temp.c +++ b/contrib/binutils/libiberty/choose-temp.c @@ -1,5 +1,5 @@ /* Utility to pick a temporary filename prefix. - Copyright (C) 1996 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. This file is part of the libiberty library. Libiberty is free software; you can redistribute it and/or @@ -22,7 +22,16 @@ Boston, MA 02111-1307, USA. */ /* This file lives in at least two places: libiberty and gcc. Don't change one without the other. */ -#ifndef NO_SYS_FILE_H +#if defined (IN_GCC) || defined (HAVE_CONFIG_H) +#include "config.h" +#endif + +/* If we are in gcc, or we have a config.h, we assume that + HAVE_SYS_FILE_H tells us whether to include sys/file.h. However, + libiberty does not have a config.h, and instead arranges to define + NO_SYS_FILE_H on the command line when there is no sys/file.h. */ + +#if (defined (IN_GCC) || defined (HAVE_CONFIG_H)) ? defined (HAVE_SYS_FILE_H) : ! defined (NO_SYS_FILE_H) #include <sys/types.h> #include <sys/file.h> /* May get R_OK, etc. on some systems. */ #endif @@ -36,7 +45,6 @@ Boston, MA 02111-1307, USA. */ #include <stdio.h> /* May get P_tmpdir. */ #ifdef IN_GCC -#include "config.h" #include "gansidecl.h" extern char *xmalloc (); #else @@ -54,7 +62,7 @@ extern char *xmalloc (); /* On MSDOS, write temp files in current dir because there's no place else we can expect to use. */ /* ??? Although the current directory is tried as a last resort, - this is left in so that on MSDOS it is prefered to /tmp on the + this is left in so that on MSDOS it is preferred to /tmp on the off chance that someone requires this, since that was the previous behaviour. */ #ifdef __MSDOS__ @@ -68,7 +76,7 @@ extern char *xmalloc (); #define TEMP_FILE "ccXXXXXX" /* Subroutine of choose_temp_base. - If BASE is non-NULL, returh it. + If BASE is non-NULL, return it. Otherwise it checks if DIR is a usable directory. If success, DIR is returned. Otherwise NULL is returned. */ @@ -80,7 +88,7 @@ try (dir, base) if (base != 0) return base; if (dir != 0 - && access (dir, R_OK | W_OK) == 0) + && access (dir, R_OK | W_OK | X_OK) == 0) return dir; return 0; } @@ -121,14 +129,13 @@ choose_temp_base () #endif len = strlen (base); - if (len == 0) - abort (); temp_filename = xmalloc (len + 1 /*DIR_SEPARATOR*/ + strlen (TEMP_FILE) + 1); strcpy (temp_filename, base); #ifndef MPW - if (temp_filename[len-1] != '/' + if (len != 0 + && temp_filename[len-1] != '/' && temp_filename[len-1] != DIR_SEPARATOR) temp_filename[len++] = DIR_SEPARATOR; #else /* MPW */ diff --git a/contrib/binutils/libiberty/config.table b/contrib/binutils/libiberty/config.table index dba783b..e367e1b 100644 --- a/contrib/binutils/libiberty/config.table +++ b/contrib/binutils/libiberty/config.table @@ -10,6 +10,8 @@ case "${host}" in *-*-cxux7*) frag=mh-cxux7 ;; *-*-cygwin32) frag=mh-cygwin32 ;; *-*-dgux*) frag=mh-sysv ;; + *-*-freebsd2.1.*) frag=mh-fbsd21 ;; + *-*-freebsd2.2.*) frag=mh-fbsd21 ;; hppa*-hp-bsd*) frag=mh-hpbsd ;; *-*-hpux*) frag=mh-hpux ;; *-*-hiux*) frag=mh-hpux ;; @@ -22,11 +24,18 @@ case "${host}" in *-*-go32) frag=mh-go32 ;; i[345]86-*-windows*) frag=mh-windows ;; - *-*-vxworks5*) + *-*-vxworks5* | *-*-vxworks) # VxWorks 5 needs special action, because the usual # autoconfiguration scheme does not work. frag=mt-vxworks5 ;; + + i[3456]86-*-mingw32*) + # Mingw32 does not require strerror.o from REQUIRED_OFILES. + # Worse: it will not compile it because of an incompatible sys_errlist + # definition. + frag=mt-mingw32 + ;; esac # Try to handle funky case of solaris 2 -> sun 4. diff --git a/contrib/binutils/libiberty/config/mh-fbsd21 b/contrib/binutils/libiberty/config/mh-fbsd21 new file mode 100644 index 0000000..1375a78 --- /dev/null +++ b/contrib/binutils/libiberty/config/mh-fbsd21 @@ -0,0 +1 @@ +EXTRA_OFILES=vasprintf.o diff --git a/contrib/binutils/libiberty/config/mt-mingw32 b/contrib/binutils/libiberty/config/mt-mingw32 new file mode 100644 index 0000000..2fb17d7 --- /dev/null +++ b/contrib/binutils/libiberty/config/mt-mingw32 @@ -0,0 +1,27 @@ +# Mingw32 target Makefile fragment. +# The autoconfiguration fails for a Mingw32 target, because of an +# incompatible definition of sys_errlist, which is imported from a DLL. +# Therefore, we compute the dependencies by hand. + +HDEFINES = -DNO_SYS_PARAM_H -DNO_SYS_FILE_H +CONFIG_H = mgconfig.h +NEEDED_LIST = mgneeded-list + +mgconfig.h: Makefile + if [ -f ../newlib/Makefile ]; then \ + $(MAKE) $(FLAGS_TO_PASS) xconfig.h; \ + cp xconfig.h mgconfig.h; \ + else \ + echo "#define NEED_sys_siglist 1" >>mgconfig.h; \ + echo "#define NEED_strsignal 1" >>mgconfig.h; \ + echo "#define NEED_psignal 1" >>mgconfig.h; \ + echo "#define NEED_basename 1" >>mgconfig.h; \ + fi + +mgneeded-list: Makefile + if [ -f ../newlib/Makefile ]; then \ + $(MAKE) $(FLAGS_TO_PASS) xneeded-list; \ + cp xneeded-list mgneeded-list; \ + else \ + echo getopt.o vasprintf.o >mgneeded-list; \ + fi diff --git a/contrib/binutils/libiberty/configure.in b/contrib/binutils/libiberty/configure.in index b8fe5fe..b0020d8 100644 --- a/contrib/binutils/libiberty/configure.in +++ b/contrib/binutils/libiberty/configure.in @@ -54,25 +54,13 @@ fi # We need multilib support, but only if configuring for the target. if [ -n "${with_target_subdir}" ] ; then - case ${srcdir} in - .) + if [ "${srcdir}" = "." ] ; then if [ "${with_target_subdir}" != "." ] ; then - - # Set MULTISRCTOP to the value we need if we are not doing - # multilib. This will be overridden if --enable-multilib was - # used. - sed -e "s:^MULTISRCTOP[ ]*=.*$:MULTISRCTOP = ../:" \ - ${Makefile} > Makefile.tem - rm -f ${Makefile} - mv Makefile.tem ${Makefile} - - . ${srcdir}/${with_multisrctop}../../config-ml.in + . ${with_multisrctop}../../config-ml.in else - . ${srcdir}/${with_multisrctop}../config-ml.in + . ${with_multisrctop}../config-ml.in fi - ;; - *) + else . ${srcdir}/../config-ml.in - ;; - esac + fi fi diff --git a/contrib/binutils/libiberty/cplus-dem.c b/contrib/binutils/libiberty/cplus-dem.c index 9579021..f4d7123 100644 --- a/contrib/binutils/libiberty/cplus-dem.c +++ b/contrib/binutils/libiberty/cplus-dem.c @@ -102,6 +102,8 @@ struct work_stuff int destructor; int static_type; /* A static member function */ int const_type; /* A const member function */ + char **tmpl_argvec; /* Template function arguments. */ + int ntmpl_args; /* The number of template function arguments. */ }; #define PRINT_ANSI_QUALIFIERS (work -> options & DMGL_ANSI) @@ -222,7 +224,7 @@ demangle_method_args PARAMS ((struct work_stuff *work, const char **, string *)) static int demangle_template PARAMS ((struct work_stuff *work, const char **, string *, - string *)); + string *, int)); static int arm_pt PARAMS ((struct work_stuff *, const char *, int, const char **, @@ -294,6 +296,9 @@ get_count PARAMS ((const char **, int *)); static int consume_count PARAMS ((const char **)); +static int +consume_count_with_underscores PARAMS ((const char**)); + static int demangle_args PARAMS ((struct work_stuff *, const char **, string *)); @@ -336,6 +341,42 @@ consume_count (type) return (count); } + +/* Like consume_count, but for counts that are preceeded and followed + by '_' if they are greater than 10. Also, -1 is returned for + failure, since 0 can be a valid value. */ + +static int +consume_count_with_underscores (mangled) + const char **mangled; +{ + int idx; + + if (**mangled == '_') + { + (*mangled)++; + if (!isdigit (**mangled)) + return -1; + + idx = consume_count (mangled); + if (**mangled != '_') + /* The trailing underscore was missing. */ + return -1; + + (*mangled)++; + } + else + { + if (**mangled < '0' || **mangled > '9') + return -1; + + idx = **mangled - '0'; + (*mangled)++; + } + + return idx; +} + int cplus_demangle_opname (opname, result, options) const char *opname; @@ -580,7 +621,17 @@ mop_up (work, declp, success) { free ((char *) work -> typevec); } - + if (work->tmpl_argvec) + { + int i; + + for (i = 0; i < work->ntmpl_args; i++) + if (work->tmpl_argvec[i]) + free ((char*) work->tmpl_argvec[i]); + + free ((char*) work->tmpl_argvec); + } + /* If demangling was successful, ensure that the demangled string is null terminated and return it. Otherwise, free the demangling decl. */ @@ -635,6 +686,7 @@ demangle_signature (work, mangled, declp) int success = 1; int func_done = 0; int expect_func = 0; + int expect_return_type = 0; const char *oldmangled = NULL; string trawname; string tname; @@ -726,12 +778,12 @@ demangle_signature (work, mangled, declp) { oldmangled = *mangled; } - success = demangle_template (work, mangled, &tname, &trawname); + success = demangle_template (work, mangled, &tname, &trawname, 1); if (success) { remember_type (work, oldmangled, *mangled - oldmangled); } - string_append(&tname, "::"); + string_append(&tname, (work -> options & DMGL_JAVA) ? "." : "::"); string_prepends(declp, &tname); if (work -> destructor & 1) { @@ -751,14 +803,43 @@ demangle_signature (work, mangled, declp) break; case '_': - /* At the outermost level, we cannot have a return type specified, - so if we run into another '_' at this point we are dealing with - a mangled name that is either bogus, or has been mangled by - some algorithm we don't know how to deal with. So just - reject the entire demangling. */ - success = 0; + if (GNU_DEMANGLING && expect_return_type) + { + /* Read the return type. */ + string return_type; + string_init (&return_type); + + (*mangled)++; + success = do_type (work, mangled, &return_type); + APPEND_BLANK (&return_type); + + string_prepends (declp, &return_type); + string_delete (&return_type); + break; + } + else + /* At the outermost level, we cannot have a return type specified, + so if we run into another '_' at this point we are dealing with + a mangled name that is either bogus, or has been mangled by + some algorithm we don't know how to deal with. So just + reject the entire demangling. */ + success = 0; break; + case 'H': + if (GNU_DEMANGLING) + { + /* A G++ template function. Read the template arguments. */ + success = demangle_template (work, mangled, declp, 0, 0); + if (!(work->constructor & 1)) + expect_return_type = 1; + (*mangled)++; + break; + } + else + /* fall through */ + ; + default: if (AUTO_DEMANGLING || GNU_DEMANGLING) { @@ -785,6 +866,10 @@ demangle_signature (work, mangled, declp) { func_done = 1; success = demangle_args (work, mangled, declp); + /* Since template include the mangling of their return types, + we must set expect_func to 0 so that we don't try do + demangle more arguments the next time we get here. */ + expect_func = 0; } } } @@ -838,11 +923,12 @@ demangle_method_args (work, mangled, declp) #endif static int -demangle_template (work, mangled, tname, trawname) +demangle_template (work, mangled, tname, trawname, is_type) struct work_stuff *work; const char **mangled; string *tname; string *trawname; + int is_type; { int i; int is_pointer; @@ -857,25 +943,43 @@ demangle_template (work, mangled, tname, trawname) const char *old_p; const char *start; int symbol_len; + int is_java_array = 0; string temp; (*mangled)++; - start = *mangled; - /* get template name */ - if ((r = consume_count (mangled)) == 0 || strlen (*mangled) < r) + if (is_type) { - return (0); + start = *mangled; + /* get template name */ + if ((r = consume_count (mangled)) == 0 || strlen (*mangled) < r) + { + return (0); + } + if (trawname) + string_appendn (trawname, *mangled, r); + is_java_array = (work -> options & DMGL_JAVA) + && strncmp (*mangled, "JArray1Z", 8) == 0; + if (! is_java_array) + { + string_appendn (tname, *mangled, r); + } + *mangled += r; } - if (trawname) - string_appendn (trawname, *mangled, r); - string_appendn (tname, *mangled, r); - *mangled += r; - string_append (tname, "<"); + if (!is_java_array) + string_append (tname, "<"); /* get size of template parameter list */ if (!get_count (mangled, &r)) { return (0); } + if (!is_type) + { + /* Create an array for saving the template argument values. */ + work->tmpl_argvec = (char**) xmalloc (r * sizeof (char *)); + work->ntmpl_args = r; + for (i = 0; i < r; i++) + work->tmpl_argvec[i] = 0; + } for (i = 0; i < r; i++) { if (need_comma) @@ -891,6 +995,15 @@ demangle_template (work, mangled, tname, trawname) if (success) { string_appends (tname, &temp); + + if (!is_type) + { + /* Save the template argument. */ + int len = temp.p - temp.b; + work->tmpl_argvec[i] = xmalloc (len + 1); + memcpy (work->tmpl_argvec[i], temp.b, len); + work->tmpl_argvec[i][len] = '\0'; + } } string_delete(&temp); if (!success) @@ -900,6 +1013,9 @@ demangle_template (work, mangled, tname, trawname) } else { + string param; + string* s; + /* otherwise, value parameter */ old_p = *mangled; is_pointer = 0; @@ -913,7 +1029,7 @@ demangle_template (work, mangled, tname, trawname) /* if (success) { - string_appends (tname, &temp); + string_appends (s, &temp); } */ string_delete(&temp); @@ -922,8 +1038,17 @@ demangle_template (work, mangled, tname, trawname) break; } /* - string_append (tname, "="); + string_append (s, "="); */ + + if (!is_type) + { + s = ¶m; + string_init (s); + } + else + s = tname; + while (*old_p && !done) { switch (*old_p) @@ -940,6 +1065,7 @@ demangle_template (work, mangled, tname, trawname) case 'F': /* function */ case 'M': /* member function */ case 'O': /* ??? */ + case 'J': /* complex */ old_p++; continue; case 'Q': /* qualified name */ @@ -976,16 +1102,41 @@ demangle_template (work, mangled, tname, trawname) done = is_integral = 1; } } - if (is_integral) + if (**mangled == 'Y') + { + /* The next argument is a template parameter. */ + int idx; + + (*mangled)++; + idx = consume_count_with_underscores (mangled); + if (idx == -1 + || (work->tmpl_argvec && idx >= work->ntmpl_args) + || consume_count_with_underscores (mangled) == -1) + { + success = 0; + if (!is_type) + string_delete (s); + break; + } + if (work->tmpl_argvec) + string_append (s, work->tmpl_argvec[idx]); + else + { + char buf[10]; + sprintf(buf, "T%d", idx); + string_append (s, buf); + } + } + else if (is_integral) { if (**mangled == 'm') { - string_appendn (tname, "-", 1); + string_appendn (s, "-", 1); (*mangled)++; } while (isdigit (**mangled)) { - string_appendn (tname, *mangled, 1); + string_appendn (s, *mangled, 1); (*mangled)++; } } @@ -995,28 +1146,30 @@ demangle_template (work, mangled, tname, trawname) int val; if (**mangled == 'm') { - string_appendn (tname, "-", 1); + string_appendn (s, "-", 1); (*mangled)++; } - string_appendn (tname, "'", 1); + string_appendn (s, "'", 1); val = consume_count(mangled); if (val == 0) { success = 0; + if (!is_type) + string_delete (s); break; } tmp[0] = (char)val; tmp[1] = '\0'; - string_appendn (tname, &tmp[0], 1); - string_appendn (tname, "'", 1); + string_appendn (s, &tmp[0], 1); + string_appendn (s, "'", 1); } else if (is_bool) { int val = consume_count (mangled); if (val == 0) - string_appendn (tname, "false", 5); + string_appendn (s, "false", 5); else if (val == 1) - string_appendn (tname, "true", 4); + string_appendn (s, "true", 4); else success = 0; } @@ -1024,31 +1177,31 @@ demangle_template (work, mangled, tname, trawname) { if (**mangled == 'm') { - string_appendn (tname, "-", 1); + string_appendn (s, "-", 1); (*mangled)++; } while (isdigit (**mangled)) { - string_appendn (tname, *mangled, 1); + string_appendn (s, *mangled, 1); (*mangled)++; } if (**mangled == '.') /* fraction */ { - string_appendn (tname, ".", 1); + string_appendn (s, ".", 1); (*mangled)++; while (isdigit (**mangled)) { - string_appendn (tname, *mangled, 1); + string_appendn (s, *mangled, 1); (*mangled)++; } } if (**mangled == 'e') /* exponent */ { - string_appendn (tname, "e", 1); + string_appendn (s, "e", 1); (*mangled)++; while (isdigit (**mangled)) { - string_appendn (tname, *mangled, 1); + string_appendn (s, *mangled, 1); (*mangled)++; } } @@ -1059,34 +1212,53 @@ demangle_template (work, mangled, tname, trawname) if (symbol_len == 0) { success = 0; + if (!is_type) + string_delete (s); break; } if (symbol_len == 0) - string_appendn (tname, "0", 1); + string_appendn (s, "0", 1); else { char *p = xmalloc (symbol_len + 1), *q; strncpy (p, *mangled, symbol_len); p [symbol_len] = '\0'; q = cplus_demangle (p, work->options); - string_appendn (tname, "&", 1); + string_appendn (s, "&", 1); if (q) { - string_append (tname, q); + string_append (s, q); free (q); } else - string_append (tname, p); + string_append (s, p); free (p); } *mangled += symbol_len; } + if (!is_type) + { + int len = s->p - s->b; + work->tmpl_argvec[i] = xmalloc (len + 1); + memcpy (work->tmpl_argvec[i], s->b, len); + work->tmpl_argvec[i][len] = '\0'; + + string_appends (tname, s); + string_delete (s); + } } need_comma = 1; } - if (tname->p[-1] == '>') - string_append (tname, " "); - string_append (tname, ">"); + if (is_java_array) + { + string_append (tname, "[]"); + } + else + { + if (tname->p[-1] == '>') + string_append (tname, " "); + string_append (tname, ">"); + } /* if (work -> static_type) @@ -1241,7 +1413,7 @@ demangle_class (work, mangled, declp) work -> constructor -= 1; } } - string_prepend (declp, "::"); + string_prepend (declp, (work -> options & DMGL_JAVA) ? "." : "::"); string_prepends (declp, &class_name); success = 1; } @@ -1362,8 +1534,9 @@ demangle_prefix (work, mangled, declp) success = 0; } } - else if ((scan == *mangled) && - (isdigit (scan[2]) || (scan[2] == 'Q') || (scan[2] == 't'))) + else if ((scan == *mangled) + && (isdigit (scan[2]) || (scan[2] == 'Q') || (scan[2] == 't') + || (scan[2] == 'H'))) { /* The ARM says nothing about the mangling of local variables. But cfront mangles local variables by prepending __<nesting_level> @@ -1380,7 +1553,8 @@ demangle_prefix (work, mangled, declp) { /* A GNU style constructor starts with __[0-9Qt]. But cfront uses names like __Q2_3foo3bar for nested type names. So don't accept - this style of constructor for cfront demangling. */ + this style of constructor for cfront demangling. A GNU + style member-template constructor starts with 'H'. */ if (!(LUCID_DEMANGLING || ARM_DEMANGLING)) work -> constructor += 1; *mangled = scan + 2; @@ -1512,12 +1686,21 @@ gnu_special (work, mangled, declp) success = demangle_qualified (work, mangled, declp, 0, 1); break; case 't': - success = demangle_template (work, mangled, declp, 0); + success = demangle_template (work, mangled, declp, 0, 1); break; default: if (isdigit(*mangled[0])) { n = consume_count(mangled); + /* We may be seeing a too-large size, or else a + ".<digits>" indicating a static local symbol. In + any case, declare victory and move on; *don't* try + to use n to allocate. */ + if (n >= strlen (*mangled)) + { + success = 1; + break; + } } else { @@ -1531,7 +1714,8 @@ gnu_special (work, mangled, declp) { if (p != NULL) { - string_append (declp, "::"); + string_append (declp, + (work -> options & DMGL_JAVA) ? "." : "::"); (*mangled)++; } } @@ -1556,7 +1740,7 @@ gnu_special (work, mangled, declp) success = demangle_qualified (work, mangled, declp, 0, 1); break; case 't': - success = demangle_template (work, mangled, declp, 0); + success = demangle_template (work, mangled, declp, 0, 1); break; default: n = consume_count (mangled); @@ -1568,7 +1752,7 @@ gnu_special (work, mangled, declp) /* Consumed everything up to the cplus_marker, append the variable name. */ (*mangled)++; - string_append (declp, "::"); + string_append (declp, (work -> options & DMGL_JAVA) ? "." : "::"); n = strlen (*mangled); string_appendn (declp, *mangled, n); (*mangled) += n; @@ -1608,7 +1792,7 @@ gnu_special (work, mangled, declp) success = demangle_qualified (work, mangled, declp, 0, 1); break; case 't': - success = demangle_template (work, mangled, declp, 0); + success = demangle_template (work, mangled, declp, 0, 1); break; default: success = demangle_fund_type (work, mangled, declp); @@ -1810,7 +1994,12 @@ demangle_qualified (work, mangled, result, isfuncname, append) *mangled = *mangled + 1; if (*mangled[0] == 't') { - success = demangle_template(work, mangled, &temp, 0); + success = demangle_template(work, mangled, &temp, 0, 1); + if (!success) break; + } + else if (*mangled[0] == 'X') + { + success = do_type (work, mangled, &temp); if (!success) break; } else @@ -1827,7 +2016,7 @@ demangle_qualified (work, mangled, result, isfuncname, append) } if (qualifiers > 0) { - string_appendn (&temp, "::", 2); + string_append (&temp, (work -> options & DMGL_JAVA) ? "." : "::"); } } @@ -1838,7 +2027,7 @@ demangle_qualified (work, mangled, result, isfuncname, append) if (isfuncname && (work->constructor & 1 || work->destructor & 1)) { - string_appendn (&temp, "::", 2); + string_append (&temp, (work -> options & DMGL_JAVA) ? "." : "::"); if (work -> destructor & 1) { string_append (&temp, "~"); @@ -1857,7 +2046,7 @@ demangle_qualified (work, mangled, result, isfuncname, append) { if (!STRING_EMPTY (result)) { - string_appendn (&temp, "::", 2); + string_append (&temp, (work -> options & DMGL_JAVA) ? "." : "::"); } string_prepends (result, &temp); } @@ -1950,7 +2139,8 @@ do_type (work, mangled, result) case 'P': case 'p': (*mangled)++; - string_prepend (&decl, "*"); + if (! (work -> options & DMGL_JAVA)) + string_prepend (&decl, "*"); break; /* A reference type */ @@ -2032,7 +2222,7 @@ do_type (work, mangled, result) } string_append (&decl, ")"); - string_prepend (&decl, "::"); + string_prepend (&decl, (work -> options & DMGL_JAVA) ? "." : "::"); if (isdigit (**mangled)) { n = consume_count (mangled); @@ -2048,7 +2238,7 @@ do_type (work, mangled, result) { string temp; string_init (&temp); - success = demangle_template (work, mangled, &temp, NULL); + success = demangle_template (work, mangled, &temp, NULL, 1); if (success) { string_prependn (&decl, temp.b, temp.p - temp.b); @@ -2136,6 +2326,37 @@ do_type (work, mangled, result) success = demangle_qualified (work, mangled, result, 0, 1); break; + case 'X': + case 'Y': + /* A template parm. We substitute the corresponding argument. */ + { + int idx; + int lvl; + + (*mangled)++; + idx = consume_count_with_underscores (mangled); + + if (idx == -1 + || (work->tmpl_argvec && idx >= work->ntmpl_args) + || consume_count_with_underscores (mangled) == -1) + { + success = 0; + break; + } + + if (work->tmpl_argvec) + string_append (result, work->tmpl_argvec[idx]); + else + { + char buf[10]; + sprintf(buf, "T%d", idx); + string_append (result, buf); + } + + success = 1; + } + break; + default: success = demangle_fund_type (work, mangled, result); break; @@ -2211,6 +2432,11 @@ demangle_fund_type (work, mangled, result) string_append (result, "volatile"); } break; + case 'J': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "__complex"); + break; default: done = 1; break; @@ -2305,7 +2531,7 @@ demangle_fund_type (work, mangled, result) } break; case 't': - success = demangle_template(work,mangled, result, 0); + success = demangle_template(work,mangled, result, 0, 1); break; default: success = 0; @@ -2349,15 +2575,15 @@ remember_type (work, start, len) if (work -> typevec_size == 0) { work -> typevec_size = 3; - work -> typevec = - (char **) xmalloc (sizeof (char *) * work -> typevec_size); + work -> typevec + = (char **) xmalloc (sizeof (char *) * work -> typevec_size); } else { work -> typevec_size *= 2; - work -> typevec = - (char **) xrealloc ((char *)work -> typevec, - sizeof (char *) * work -> typevec_size); + work -> typevec + = (char **) xrealloc ((char *)work -> typevec, + sizeof (char *) * work -> typevec_size); } } tem = xmalloc (len + 1); @@ -2860,6 +3086,12 @@ string_prependn (p, s, n) #ifdef MAIN +#include "getopt.h" + +static char *program_name; +static char *program_version = VERSION; +static int flags = DMGL_PARAMS | DMGL_ANSI; + static void demangle_it PARAMS ((char *)); static void usage PARAMS ((FILE *, int)); static void fatal PARAMS ((char *)); @@ -2870,7 +3102,7 @@ demangle_it (mangled_name) { char *result; - result = cplus_demangle (mangled_name, DMGL_PARAMS | DMGL_ANSI); + result = cplus_demangle (mangled_name, flags); if (result == NULL) { printf ("%s\n", mangled_name); @@ -2882,11 +3114,6 @@ demangle_it (mangled_name) } } -#include "getopt.h" - -static char *program_name; -static char *program_version = VERSION; - static void usage (stream, status) FILE *stream; @@ -2894,8 +3121,8 @@ usage (stream, status) { fprintf (stream, "\ Usage: %s [-_] [-n] [-s {gnu,lucid,arm}] [--strip-underscores]\n\ -[--no-strip-underscores] [--format={gnu,lucid,arm}]\n\ -[--help] [--version] [arg...]\n", + [--no-strip-underscores] [--format={gnu,lucid,arm}]\n\ + [--help] [--version] [arg...]\n", program_name); exit (status); } @@ -2912,6 +3139,7 @@ static struct option long_options[] = { {"strip-underscores", no_argument, 0, '_'}, {"format", required_argument, 0, 's'}, {"help", no_argument, 0, 'h'}, + {"java", no_argument, 0, 'j'}, {"no-strip-underscores", no_argument, 0, 'n'}, {"version", no_argument, 0, 'v'}, {0, no_argument, 0, 0} @@ -2929,7 +3157,7 @@ main (argc, argv) strip_underscore = prepends_underscore; - while ((c = getopt_long (argc, argv, "_ns:", long_options, (int *) 0)) != EOF) + while ((c = getopt_long (argc, argv, "_ns:j", long_options, (int *) 0)) != EOF) { switch (c) { @@ -2947,6 +3175,9 @@ main (argc, argv) case '_': strip_underscore = 1; break; + case 'j': + flags |= DMGL_JAVA; + break; case 's': if (strcmp (optarg, "gnu") == 0) { @@ -3005,8 +3236,7 @@ main (argc, argv) mbuffer[i] = 0; - result = cplus_demangle (mbuffer + skip_first, - DMGL_PARAMS | DMGL_ANSI); + result = cplus_demangle (mbuffer + skip_first, flags); if (result) { if (mbuffer[0] == '.') diff --git a/contrib/binutils/libiberty/floatformat.c b/contrib/binutils/libiberty/floatformat.c index a012064..7f6086f 100644 --- a/contrib/binutils/libiberty/floatformat.c +++ b/contrib/binutils/libiberty/floatformat.c @@ -51,6 +51,14 @@ const struct floatformat floatformat_ieee_double_little = floatformat_little, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no }; +/* floatformat for IEEE double, little endian byte order, with big endian word + ordering, as on the ARM. */ + +const struct floatformat floatformat_ieee_double_littlebyte_bigword = +{ + floatformat_littlebyte_bigword, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no +}; + const struct floatformat floatformat_i387_ext = { floatformat_little, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64, diff --git a/contrib/binutils/libiberty/functions.def b/contrib/binutils/libiberty/functions.def index aeed4c6..0f13f10 100644 --- a/contrib/binutils/libiberty/functions.def +++ b/contrib/binutils/libiberty/functions.def @@ -9,6 +9,7 @@ * the corresponding function in libc. */ +DEF(asprintf, int, (), NOTHING) DEF(atexit, int, (f), void (*f)()) DEF(bcmp, int, (s1, s2, length), char *s1 AND char *s2 AND int length ) DEF(bcopy, void, (s1, s2, length), char *s1 AND char *s2 AND int length ) @@ -62,8 +63,8 @@ DEFVAR(sys_siglist, char *sys_siglist[], sys_siglist[0] = 0) environment, and to generate an entry NEED_<funcname> in config.h if they are not found. */ -DEFFUNC(strerror, char*, (), NOTHING) +DEFFUNC(strerror, char*, (errnoval), int errnoval) DEFFUNC(psignal, void, (signo, message), unsigned signo AND char *message) DEFFUNC(basename, char *, (name), CONST char *name) DEFFUNC(on_exit, void, (f, arg), void (*f)() AND char *arg) -DEFFUNC(strsignal, char *, (), NOTHING) +DEFFUNC(strsignal, const char *, (signo), int signo) diff --git a/contrib/binutils/libiberty/getopt.c b/contrib/binutils/libiberty/getopt.c index 79080aa..fc87ce6 100644 --- a/contrib/binutils/libiberty/getopt.c +++ b/contrib/binutils/libiberty/getopt.c @@ -3,29 +3,26 @@ "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu before changing it! - Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95 + Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97 Free Software Foundation, Inc. -This file is part of the libiberty library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. */ + 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. + + 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 + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + USA. */ /* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>. Ditto for AIX 3.2 and <stdlib.h>. */ @@ -34,17 +31,10 @@ the executable file might be covered by the GNU General Public License. */ #endif #ifdef HAVE_CONFIG_H -#if defined (emacs) || defined (CONFIG_BROKETS) -/* We use <config.h> instead of "config.h" so that a compilation - using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h - (which it would do because it found this file in $srcdir). */ #include <config.h> -#else -#include "config.h" -#endif #endif -#ifndef __STDC__ +#if !defined (__STDC__) || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const @@ -61,11 +51,16 @@ the executable file might be covered by the GNU General Public License. */ (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ -/* Many versions of the Linux C library include older, broken versions - of these routines, which will break the linker's command-line - parsing. */ -#if defined (_LIBC) || !defined (__GNU_LIBRARY__) || defined (__linux__) +#define GETOPT_INTERFACE_VERSION 2 +#if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2 +#include <gnu-versions.h> +#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION +#define ELIDE_CODE +#endif +#endif + +#ifndef ELIDE_CODE /* This needs to come after some library #include @@ -74,8 +69,27 @@ the executable file might be covered by the GNU General Public License. */ /* Don't include stdlib.h for non-GNU C libraries because some of them contain conflicting prototypes for getopt. */ #include <stdlib.h> +#include <unistd.h> #endif /* GNU C library. */ +#ifdef VMS +#include <unixlib.h> +#if HAVE_STRING_H - 0 +#include <string.h> +#endif +#endif + +#ifndef _ +/* This is for other GNU distributions with internationalized messages. + When compiling libc, the _ macro is predefined. */ +#ifdef HAVE_LIBINTL_H +# include <libintl.h> +# define _(msgid) gettext (msgid) +#else +# define _(msgid) (msgid) +#endif +#endif + /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. @@ -106,14 +120,20 @@ char *optarg = NULL; On entry to `getopt', zero means this is the first call; initialize. - When `getopt' returns EOF, this is the index of the first of the + When `getopt' returns -1, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ -/* XXX 1003.2 says this must be 1 before any call. */ -int optind = 0; +/* 1003.2 says this must be 1 before any call. */ +int optind = 1; + +/* Formerly, initialization of getopt depended on optind==0, which + causes problems with re-calling getopt as programs generally don't + know that. */ + +int __getopt_initialized = 0; /* The next char to be scanned in the option-element in which the last option character we returned was found. @@ -162,12 +182,15 @@ int optopt = '?'; The special argument `--' forces an end of option-scanning regardless of the value of `ordering'. In the case of RETURN_IN_ORDER, only - `--' can cause `getopt' to return EOF with `optind' != ARGC. */ + `--' can cause `getopt' to return -1 with `optind' != ARGC. */ static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; + +/* Value of POSIXLY_CORRECT environment variable. */ +static char *posixly_correct; #ifdef __GNU_LIBRARY__ /* We want to avoid inclusion of string.h with non-GNU libraries @@ -202,7 +225,7 @@ my_index (str, chr) #ifdef __GNUC__ /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. That was relevant to code that was here before. */ -#ifndef __STDC__ +#if !defined (__STDC__) || !__STDC__ /* gcc with -traditional declares the built-in strlen to return int, and has done so at least since version 2.4.5. -- rms. */ extern int strlen (const char *); @@ -220,6 +243,46 @@ extern int strlen (const char *); static int first_nonopt; static int last_nonopt; +#ifdef _LIBC +/* Bash 2.0 gives us an environment variable containing flags + indicating ARGV elements that should not be considered arguments. */ + +/* Defined in getopt_init.c */ +extern char *__getopt_nonoption_flags; + +static int nonoption_flags_max_len; +static int nonoption_flags_len; + +static int original_argc; +static char *const *original_argv; + +/* Make sure the environment variable bash 2.0 puts in the environment + is valid for the getopt call we must make sure that the ARGV passed + to getopt is that one passed to the process. */ +static void +__attribute__ ((unused)) +store_args_and_env (int argc, char *const *argv) +{ + /* XXX This is no good solution. We should rather copy the args so + that we can compare them later. But we must not use malloc(3). */ + original_argc = argc; + original_argv = argv; +} +# ifdef text_set_element +text_set_element (__libc_subinit, store_args_and_env); +# endif /* text_set_element */ + +# define SWAP_FLAGS(ch1, ch2) \ + if (nonoption_flags_len > 0) \ + { \ + char __tmp = __getopt_nonoption_flags[ch1]; \ + __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ + __getopt_nonoption_flags[ch2] = __tmp; \ + } +#else /* !_LIBC */ +# define SWAP_FLAGS(ch1, ch2) +#endif /* _LIBC */ + /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) which contains all the non-options that have been skipped so far. @@ -229,6 +292,10 @@ static int last_nonopt; `first_nonopt' and `last_nonopt' are relocated so that they describe the new indices of the non-options in ARGV after they are moved. */ +#if defined (__STDC__) && __STDC__ +static void exchange (char **); +#endif + static void exchange (argv) char **argv; @@ -243,6 +310,28 @@ exchange (argv) It leaves the longer segment in the right place overall, but it consists of two parts that need to be swapped next. */ +#ifdef _LIBC + /* First make sure the handling of the `__getopt_nonoption_flags' + string can work normally. Our top argument must be in the range + of the string. */ + if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) + { + /* We must extend the array. The user plays games with us and + presents new arguments. */ + char *new_str = malloc (top + 1); + if (new_str == NULL) + nonoption_flags_len = nonoption_flags_max_len = 0; + else + { + memset (__mempcpy (new_str, __getopt_nonoption_flags, + nonoption_flags_max_len), + '\0', top + 1 - nonoption_flags_max_len); + nonoption_flags_max_len = top + 1; + __getopt_nonoption_flags = new_str; + } + } +#endif + while (top > middle && middle > bottom) { if (top - middle > middle - bottom) @@ -257,6 +346,7 @@ exchange (argv) tem = argv[bottom + i]; argv[bottom + i] = argv[top - (middle - bottom) + i]; argv[top - (middle - bottom) + i] = tem; + SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); } /* Exclude the moved bottom segment from further swapping. */ top -= len; @@ -273,6 +363,7 @@ exchange (argv) tem = argv[bottom + i]; argv[bottom + i] = argv[middle + i]; argv[middle + i] = tem; + SWAP_FLAGS (bottom + i, middle + i); } /* Exclude the moved top segment from further swapping. */ bottom += len; @@ -287,18 +378,25 @@ exchange (argv) /* Initialize the internal data when the first call is made. */ +#if defined (__STDC__) && __STDC__ +static const char *_getopt_initialize (int, char *const *, const char *); +#endif static const char * -_getopt_initialize (optstring) +_getopt_initialize (argc, argv, optstring) + int argc; + char *const *argv; const char *optstring; { /* Start processing options with ARGV-element 1 (since ARGV-element 0 is the program name); the sequence of previously skipped non-option ARGV-elements is empty. */ - first_nonopt = last_nonopt = optind = 1; + first_nonopt = last_nonopt = optind; nextchar = NULL; + posixly_correct = getenv ("POSIXLY_CORRECT"); + /* Determine how to handle the ordering of options and nonoptions. */ if (optstring[0] == '-') @@ -311,11 +409,41 @@ _getopt_initialize (optstring) ordering = REQUIRE_ORDER; ++optstring; } - else if (getenv ("POSIXLY_CORRECT") != NULL) + else if (posixly_correct != NULL) ordering = REQUIRE_ORDER; else ordering = PERMUTE; +#ifdef _LIBC + if (posixly_correct == NULL + && argc == original_argc && argv == original_argv) + { + if (nonoption_flags_max_len == 0) + { + if (__getopt_nonoption_flags == NULL + || __getopt_nonoption_flags[0] == '\0') + nonoption_flags_max_len = -1; + else + { + const char *orig_str = __getopt_nonoption_flags; + int len = nonoption_flags_max_len = strlen (orig_str); + if (nonoption_flags_max_len < argc) + nonoption_flags_max_len = argc; + __getopt_nonoption_flags = + (char *) malloc (nonoption_flags_max_len); + if (__getopt_nonoption_flags == NULL) + nonoption_flags_max_len = -1; + else + memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), + '\0', nonoption_flags_max_len - len); + } + } + nonoption_flags_len = nonoption_flags_max_len; + } + else + nonoption_flags_len = 0; +#endif + return optstring; } @@ -332,7 +460,7 @@ _getopt_initialize (optstring) updating `optind' and `nextchar' so that the next call to `getopt' can resume the scan with the following option character or ARGV-element. - If there are no more option characters, `getopt' returns `EOF'. + If there are no more option characters, `getopt' returns -1. Then `optind' is the index in ARGV of the first ARGV-element that is not an option. (The ARGV-elements have been permuted so that those that are not options now come last.) @@ -386,16 +514,37 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) { optarg = NULL; - if (optind == 0) - optstring = _getopt_initialize (optstring); + if (optind == 0 || !__getopt_initialized) + { + if (optind == 0) + optind = 1; /* Don't scan ARGV[0], the program name. */ + optstring = _getopt_initialize (argc, argv, optstring); + __getopt_initialized = 1; + } - if (argc == 0) - return EOF; + /* Test whether ARGV[optind] points to a non-option argument. + Either it does not have option syntax, or there is an environment flag + from the shell indicating it is not an option. The later information + is only used when the used in the GNU libc. */ +#ifdef _LIBC +#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ + || (optind < nonoption_flags_len \ + && __getopt_nonoption_flags[optind] == '1')) +#else +#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') +#endif if (nextchar == NULL || *nextchar == '\0') { /* Advance to the next ARGV-element. */ + /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been + moved back by the user (who may also have changed the arguments). */ + if (last_nonopt > optind) + last_nonopt = optind; + if (first_nonopt > optind) + first_nonopt = optind; + if (ordering == PERMUTE) { /* If we have just processed some options following some non-options, @@ -409,8 +558,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) /* Skip any additional non-options and extend the range of non-options previously skipped. */ - while (optind < argc - && (argv[optind][0] != '-' || argv[optind][1] == '\0')) + while (optind < argc && NONOPTION_P) optind++; last_nonopt = optind; } @@ -442,16 +590,16 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) that we previously skipped, so the caller will digest them. */ if (first_nonopt != last_nonopt) optind = first_nonopt; - return EOF; + return -1; } /* If we have come to a non-option and did not permute it, either stop the scan or describe it to the caller and pass it by. */ - if ((argv[optind][0] != '-' || argv[optind][1] == '\0')) + if (NONOPTION_P) { if (ordering == REQUIRE_ORDER) - return EOF; + return -1; optarg = argv[optind++]; return 1; } @@ -487,7 +635,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) const struct option *pfound = NULL; int exact = 0; int ambig = 0; - int indfound; + int indfound = -1; int option_index; for (nameend = nextchar; *nameend && *nameend != '='; nameend++) @@ -498,7 +646,8 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { - if (nameend - nextchar == strlen (p->name)) + if ((unsigned int) (nameend - nextchar) + == (unsigned int) strlen (p->name)) { /* Exact match found. */ pfound = p; @@ -520,10 +669,11 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) if (ambig && !exact) { if (opterr) - fprintf (stderr, "%s: option `%s' is ambiguous\n", + fprintf (stderr, _("%s: option `%s' is ambiguous\n"), argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; + optopt = 0; return '?'; } @@ -540,19 +690,20 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) else { if (opterr) - { - if (argv[optind - 1][1] == '-') - /* --option */ - fprintf (stderr, - "%s: option `--%s' doesn't allow an argument\n", - argv[0], pfound->name); - else - /* +option or -option */ - fprintf (stderr, - "%s: option `%c%s' doesn't allow an argument\n", - argv[0], argv[optind - 1][0], pfound->name); - } + if (argv[optind - 1][1] == '-') + /* --option */ + fprintf (stderr, + _("%s: option `--%s' doesn't allow an argument\n"), + argv[0], pfound->name); + else + /* +option or -option */ + fprintf (stderr, + _("%s: option `%c%s' doesn't allow an argument\n"), + argv[0], argv[optind - 1][0], pfound->name); + nextchar += strlen (nextchar); + + optopt = pfound->val; return '?'; } } @@ -563,9 +714,11 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) else { if (opterr) - fprintf (stderr, "%s: option `%s' requires an argument\n", - argv[0], argv[optind - 1]); + fprintf (stderr, + _("%s: option `%s' requires an argument\n"), + argv[0], argv[optind - 1]); nextchar += strlen (nextchar); + optopt = pfound->val; return optstring[0] == ':' ? ':' : '?'; } } @@ -591,15 +744,16 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) { if (argv[optind][1] == '-') /* --option */ - fprintf (stderr, "%s: unrecognized option `--%s'\n", + fprintf (stderr, _("%s: unrecognized option `--%s'\n"), argv[0], nextchar); else /* +option or -option */ - fprintf (stderr, "%s: unrecognized option `%c%s'\n", + fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), argv[0], argv[optind][0], nextchar); } nextchar = (char *) ""; optind++; + optopt = 0; return '?'; } } @@ -618,12 +772,141 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) { if (opterr) { - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, "%s: illegal option -- %c\n", argv[0], c); + if (posixly_correct) + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, _("%s: illegal option -- %c\n"), + argv[0], c); + else + fprintf (stderr, _("%s: invalid option -- %c\n"), + argv[0], c); } optopt = c; return '?'; } + /* Convenience. Treat POSIX -W foo same as long option --foo */ + if (temp[0] == 'W' && temp[1] == ';') + { + char *nameend; + const struct option *p; + const struct option *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = 0; + int option_index; + + /* This is an option that requires an argument. */ + if (*nextchar != '\0') + { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } + else if (optind == argc) + { + if (opterr) + { + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, _("%s: option requires an argument -- %c\n"), + argv[0], c); + } + optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + return c; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; + + /* optarg is now the argument, see if it's in the + table of longopts. */ + + for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; + + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, nextchar, nameend - nextchar)) + { + if ((unsigned int) (nameend - nextchar) == strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else + /* Second or later nonexact match found. */ + ambig = 1; + } + if (ambig && !exact) + { + if (opterr) + fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), + argv[0], argv[optind]); + nextchar += strlen (nextchar); + optind++; + return '?'; + } + if (pfound != NULL) + { + option_index = indfound; + if (*nameend) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + optarg = nameend + 1; + else + { + if (opterr) + fprintf (stderr, _("\ +%s: option `-W %s' doesn't allow an argument\n"), + argv[0], pfound->name); + + nextchar += strlen (nextchar); + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + if (opterr) + fprintf (stderr, + _("%s: option `%s' requires an argument\n"), + argv[0], argv[optind - 1]); + nextchar += strlen (nextchar); + return optstring[0] == ':' ? ':' : '?'; + } + } + nextchar += strlen (nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + nextchar = NULL; + return 'W'; /* Let the application handle it. */ + } if (temp[1] == ':') { if (temp[2] == ':') @@ -653,8 +936,9 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) if (opterr) { /* 1003.2 specifies the format of this message. */ - fprintf (stderr, "%s: option requires an argument -- %c\n", - argv[0], c); + fprintf (stderr, + _("%s: option requires an argument -- %c\n"), + argv[0], c); } optopt = c; if (optstring[0] == ':') @@ -685,7 +969,7 @@ getopt (argc, argv, optstring) 0); } -#endif /* _LIBC or not __GNU_LIBRARY__. */ +#endif /* Not ELIDE_CODE. */ #ifdef TEST @@ -705,7 +989,7 @@ main (argc, argv) int this_option_optind = optind ? optind : 1; c = getopt (argc, argv, "abc:d:0123456789"); - if (c == EOF) + if (c == -1) break; switch (c) diff --git a/contrib/binutils/libiberty/getopt1.c b/contrib/binutils/libiberty/getopt1.c index c3400e5..af8e681 100644 --- a/contrib/binutils/libiberty/getopt1.c +++ b/contrib/binutils/libiberty/getopt1.c @@ -1,35 +1,31 @@ /* getopt_long and getopt_long_only entry points for GNU getopt. - Copyright (C) 1987, 88, 89, 90, 91, 92, 1993 - Free Software Foundation, Inc. + Copyright (C) 1987,88,89,90,91,92,93,94,96,97 Free Software Foundation, Inc. - This program 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, or - (at your option) any later version. + 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. + + 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 + Free Software Foundation; either version 2, or (at your option) any + later version. This program 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. + GNU General Public License for more details. - You should have received a copy of the GNU Library General Public License + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + USA. */ #ifdef HAVE_CONFIG_H -#if defined (emacs) || defined (CONFIG_BROKETS) -/* We use <config.h> instead of "config.h" so that a compilation - using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h - (which it would do because it found this file in $srcdir). */ #include <config.h> -#else -#include "config.h" -#endif #endif #include "getopt.h" -#ifndef __STDC__ +#if !defined (__STDC__) || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ #ifndef const @@ -46,19 +42,22 @@ (especially if it is a shared library). Rather than having every GNU program understand `configure --with-gnu-libc' and omit the object files, it is simpler to just do this in the source for each such file. */ -/* Many versions of the Linux C library include older, broken versions - of these routines, which will break the linker's command-line - parsing. */ -#if defined (_LIBC) || !defined (__GNU_LIBRARY__) || defined (__linux__) +#define GETOPT_INTERFACE_VERSION 2 +#if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2 +#include <gnu-versions.h> +#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION +#define ELIDE_CODE +#endif +#endif + +#ifndef ELIDE_CODE /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ #include <stdlib.h> -#else -char *getenv (); #endif #ifndef NULL @@ -93,7 +92,7 @@ getopt_long_only (argc, argv, options, long_options, opt_index) } -#endif /* _LIBC or not __GNU_LIBRARY__. */ +#endif /* Not ELIDE_CODE. */ #ifdef TEST @@ -124,7 +123,7 @@ main (argc, argv) c = getopt_long (argc, argv, "abc:d:0123456789", long_options, &option_index); - if (c == EOF) + if (c == -1) break; switch (c) diff --git a/contrib/binutils/libiberty/obstack.c b/contrib/binutils/libiberty/obstack.c index 2ccf590..a6880ca 100644 --- a/contrib/binutils/libiberty/obstack.c +++ b/contrib/binutils/libiberty/obstack.c @@ -39,6 +39,23 @@ Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #endif #endif +/* CYGNUS LOCAL (not to be elided!) */ + +int +_obstack_memory_used (h) + struct obstack *h; +{ + register struct _obstack_chunk* lp; + register int nbytes = 0; + + for (lp = h->chunk; lp != 0; lp = lp->prev) + { + nbytes += lp->limit - (char *) lp; + } + return nbytes; +} + +/* END CYGNUS LOCAL */ #ifndef ELIDE_CODE @@ -379,24 +396,6 @@ obstack_free (h, obj) abort (); } -/* CYGNUS LOCAL */ - -int -_obstack_memory_used (h) - struct obstack *h; -{ - register struct _obstack_chunk* lp; - register int nbytes = 0; - - for (lp = h->chunk; lp != 0; lp = lp->prev) - { - nbytes += lp->limit - (char *) lp; - } - return nbytes; -} - -/* END CYGNUS LOCAL */ - #if 0 /* These are now turned off because the applications do not use it and it uses bcopy via obstack_grow, which causes trouble on sysV. */ diff --git a/contrib/binutils/libiberty/pexecute.c b/contrib/binutils/libiberty/pexecute.c index 7ffe9ca..fbbea40 100644 --- a/contrib/binutils/libiberty/pexecute.c +++ b/contrib/binutils/libiberty/pexecute.c @@ -1,6 +1,6 @@ /* Utilities to execute a program in a subprocess (possibly linked by pipes with other subprocesses), and wait for it. - Copyright (C) 1996 Free Software Foundation, Inc. + Copyright (C) 1996, 1997 Free Software Foundation, Inc. This file is part of the libiberty library. Libiberty is free software; you can redistribute it and/or @@ -23,11 +23,14 @@ Boston, MA 02111-1307, USA. */ /* This file lives in at least two places: libiberty and gcc. Don't change one without the other. */ +#ifdef IN_GCC +#include "config.h" +#endif + #include <stdio.h> #include <errno.h> #ifdef IN_GCC -#include "config.h" #include "gansidecl.h" /* ??? Need to find a suitable header file. */ #define PEXECUTE_FIRST 1 @@ -217,12 +220,16 @@ pwait (pid, status, flags) #endif /* MSDOS */ -#if defined (_WIN32) && !defined (__CYGWIN32__) +#if defined (_WIN32) #include <process.h> -/* ??? Why are these __spawnv{,p} and not _spawnv{,p}? */ -extern int __spawnv (); -extern int __spawnvp (); + +#ifdef __CYGWIN32__ + +#define fix_argv(argvec) (argvec) + +extern int _spawnv (); +extern int _spawnvp (); int pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) @@ -237,29 +244,204 @@ pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) if ((flags & PEXECUTE_ONE) != PEXECUTE_ONE) abort (); - pid = (flags & PEXECUTE_SEARCH ? __spawnvp : __spawnv) (_P_NOWAIT, program, argv); + pid = (flags & PEXECUTE_SEARCH ? _spawnvp : _spawnv) + (_P_NOWAIT, program, fix_argv(argv)); + if (pid == -1) + { + *errmsg_fmt = install_error_msg; + *errmsg_arg = program; + return -1; + } + return pid; +} + +int +pwait (pid, status, flags) + int pid; + int *status; + int flags; +{ + /* ??? Here's an opportunity to canonicalize the values in STATUS. + Needed? */ + return cwait (status, pid, WAIT_CHILD); +} + +#else /* ! __CYGWIN32__ */ + +/* This is a kludge to get around the Microsoft C spawn functions' propensity + to remove the outermost set of double quotes from all arguments. */ + +const char * const * +fix_argv (argvec) + char **argvec; +{ + int i; + + for (i = 1; argvec[i] != 0; i++) + { + int len, j; + char *temp, *newtemp; + + temp = argvec[i]; + len = strlen (temp); + for (j = 0; j < len; j++) + { + if (temp[j] == '"') + { + newtemp = xmalloc (len + 2); + strncpy (newtemp, temp, j); + newtemp [j] = '\\'; + strncpy (&newtemp [j+1], &temp [j], len-j); + newtemp [len+1] = 0; + temp = newtemp; + len++; + j++; + } + } + + argvec[i] = temp; + } + + return (const char * const *) argvec; +} + +#include <io.h> +#include <fcntl.h> +#include <signal.h> + +/* mingw32 headers may not define the following. */ + +#ifndef _P_WAIT +# define _P_WAIT 0 +# define _P_NOWAIT 1 +# define _P_OVERLAY 2 +# define _P_NOWAITO 3 +# define _P_DETACH 4 + +# define WAIT_CHILD 0 +# define WAIT_GRANDCHILD 1 +#endif + +/* Win32 supports pipes */ +int +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; + char **errmsg_fmt, **errmsg_arg; + int flags; +{ + int pid; + int pdes[2], org_stdin, org_stdout; + int input_desc, output_desc; + int retries, sleep_interval; + + /* Pipe waiting from last process, to be used as input for the next one. + Value is STDIN_FILE_NO if no pipe is waiting + (i.e. the next command is the first of a group). */ + static int last_pipe_input; + + /* If this is the first process, initialize. */ + if (flags & PEXECUTE_FIRST) + last_pipe_input = STDIN_FILE_NO; + + input_desc = last_pipe_input; + + /* If this isn't the last process, make a pipe for its output, + and record it as waiting to be the input to the next process. */ + if (! (flags & PEXECUTE_LAST)) + { + if (_pipe (pdes, 256, O_BINARY) < 0) + { + *errmsg_fmt = "pipe"; + *errmsg_arg = NULL; + return -1; + } + output_desc = pdes[WRITE_PORT]; + last_pipe_input = pdes[READ_PORT]; + } + else + { + /* Last process. */ + output_desc = STDOUT_FILE_NO; + last_pipe_input = STDIN_FILE_NO; + } + + if (input_desc != STDIN_FILE_NO) + { + org_stdin = dup (STDIN_FILE_NO); + dup2 (input_desc, STDIN_FILE_NO); + close (input_desc); + } + + if (output_desc != STDOUT_FILE_NO) + { + org_stdout = dup (STDOUT_FILE_NO); + dup2 (output_desc, STDOUT_FILE_NO); + close (output_desc); + } + + pid = (flags & PEXECUTE_SEARCH ? _spawnvp : _spawnv) + (_P_NOWAIT, program, fix_argv(argv)); + + if (input_desc != STDIN_FILE_NO) + { + dup2 (org_stdin, STDIN_FILE_NO); + close (org_stdin); + } + + if (output_desc != STDOUT_FILE_NO) + { + dup2 (org_stdout, STDOUT_FILE_NO); + close (org_stdout); + } + if (pid == -1) { *errmsg_fmt = install_error_msg; *errmsg_arg = program; return -1; } + return pid; } +/* MS CRTDLL doesn't return enough information in status to decide if the + child exited due to a signal or not, rather it simply returns an + integer with the exit code of the child; eg., if the child exited with + an abort() call and didn't have a handler for SIGABRT, it simply returns + with status = 3. We fix the status code to conform to the usual WIF* + macros. Note that WIFSIGNALED will never be true under CRTDLL. */ + int pwait (pid, status, flags) int pid; int *status; int flags; { + int termstat; + + pid = _cwait (&termstat, pid, WAIT_CHILD); + /* ??? Here's an opportunity to canonicalize the values in STATUS. Needed? */ - int pid = cwait (status, pid, WAIT_CHILD); + + /* cwait returns the child process exit code in termstat. + A value of 3 indicates that the child caught a signal, but not + which one. Since only SIGABRT, SIGFPE and SIGINT do anything, we + report SIGABRT. */ + if (termstat == 3) + *status = SIGABRT; + else + *status = (((termstat) & 0xff) << 8); + return pid; } -#endif /* WIN32 */ +#endif /* ! defined (__CYGWIN32__) */ + +#endif /* _WIN32 */ #ifdef OS2 @@ -433,11 +615,16 @@ pfinish () /* include for Unix-like environments but not for Dos-like environments */ #if ! defined (__MSDOS__) && ! defined (OS2) && ! defined (MPW) \ - && (defined (__CYGWIN32__) || ! defined (_WIN32)) + && ! defined (_WIN32) +#ifdef VMS +#define vfork() (decc$$alloc_vfork_blocks() >= 0 ? \ + lib$get_current_invo_context(decc$$get_vfork_jmpbuf()) : -1) +#else #ifdef USG #define vfork fork #endif +#endif extern int execv (); extern int execvp (); @@ -566,8 +753,12 @@ pwait (pid, status, flags) { /* ??? Here's an opportunity to canonicalize the values in STATUS. Needed? */ +#ifdef VMS + pid = waitpid (-1, status, 0); +#else pid = wait (status); +#endif return pid; } -#endif /* ! __MSDOS__ && ! OS2 && ! MPW && (__CYGWIN32___ || ! _WIN32) */ +#endif /* ! __MSDOS__ && ! OS2 && ! MPW && ! _WIN32 */ diff --git a/contrib/binutils/libiberty/strsignal.c b/contrib/binutils/libiberty/strsignal.c index 7d40b4c..d517eed 100644 --- a/contrib/binutils/libiberty/strsignal.c +++ b/contrib/binutils/libiberty/strsignal.c @@ -243,7 +243,13 @@ static const char **sys_siglist; #else +#ifdef NSIG static int sys_nsig = NSIG; +#else +#ifdef _NSIG +static int sys_nsig = _NSIG; +#endif +#endif extern const char * const sys_siglist[]; #endif diff --git a/contrib/binutils/libiberty/vasprintf.c b/contrib/binutils/libiberty/vasprintf.c index 3794cbd..da83db2 100644 --- a/contrib/binutils/libiberty/vasprintf.c +++ b/contrib/binutils/libiberty/vasprintf.c @@ -74,7 +74,7 @@ int_vasprintf (result, format, args) } while (strchr ("hlL", *p)) ++p; - /* Should be big enough for any format specifier except %s. */ + /* Should be big enough for any format specifier except %s and floats. */ total_width += 30; switch (*p) { @@ -93,6 +93,9 @@ int_vasprintf (result, format, args) case 'g': case 'G': (void) va_arg (ap, double); + /* Since an ieee double can have an exponent of 307, we'll + make the buffer wide enough to cover the gross case. */ + total_width += 307; break; case 's': total_width += strlen (va_arg (ap, char *)); @@ -118,7 +121,11 @@ int vasprintf (result, format, args) char **result; const char *format; +#if defined (_BSD_VA_LIST_) && defined (__FreeBSD__) + _BSD_VA_LIST_ args; +#else va_list args; +#endif { return int_vasprintf (result, format, &args); } diff --git a/contrib/binutils/libiberty/xmalloc.c b/contrib/binutils/libiberty/xmalloc.c index c479b1f..b88105a 100644 --- a/contrib/binutils/libiberty/xmalloc.c +++ b/contrib/binutils/libiberty/xmalloc.c @@ -42,16 +42,22 @@ PTR sbrk PARAMS ((ptrdiff_t)); /* The program name if set. */ static const char *name = ""; -/* The initial sbrk, set when the program name is set. */ +#if ! defined (_WIN32) || defined (__CYGWIN32__) +/* The initial sbrk, set when the program name is set. Not used for win32 + ports other than cygwin32. */ static char *first_break = NULL; +#endif void xmalloc_set_program_name (s) const char *s; { name = s; +#if ! defined (_WIN32) || defined (__CYGWIN32__) + /* Win32 ports other than cygwin32 don't have brk() */ if (first_break == NULL) first_break = (char *) sbrk (0); +#endif /* ! _WIN32 || __CYGWIN32 __ */ } PTR @@ -65,6 +71,7 @@ xmalloc (size) newmem = malloc (size); if (!newmem) { +#if ! defined (_WIN32) || defined (__CYGWIN32__) extern char **environ; size_t allocated; @@ -76,6 +83,12 @@ xmalloc (size) "\n%s%sCan not allocate %lu bytes after allocating %lu bytes\n", name, *name ? ": " : "", (unsigned long) size, (unsigned long) allocated); +#else + fprintf (stderr, + "\n%s%sCan not allocate %lu bytes\n", + name, *name ? ": " : "", + (unsigned long) size); +#endif /* ! _WIN32 || __CYGWIN32 __ */ xexit (1); } return (newmem); @@ -96,6 +109,7 @@ xrealloc (oldmem, size) newmem = realloc (oldmem, size); if (!newmem) { +#ifndef __MINGW32__ extern char **environ; size_t allocated; @@ -107,6 +121,12 @@ xrealloc (oldmem, size) "\n%s%sCan not reallocate %lu bytes after allocating %lu bytes\n", name, *name ? ": " : "", (unsigned long) size, (unsigned long) allocated); +#else + fprintf (stderr, + "\n%s%sCan not reallocate %lu bytes\n", + name, *name ? ": " : "", + (unsigned long) size); +#endif /* __MINGW32__ */ xexit (1); } return (newmem); |