summaryrefslogtreecommitdiffstats
path: root/contrib/binutils/libiberty
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/binutils/libiberty')
-rw-r--r--contrib/binutils/libiberty/ChangeLog316
-rw-r--r--contrib/binutils/libiberty/Makefile.in64
-rw-r--r--contrib/binutils/libiberty/aclocal.m41
-rw-r--r--contrib/binutils/libiberty/argv.c59
-rw-r--r--contrib/binutils/libiberty/bcopy.c4
-rw-r--r--contrib/binutils/libiberty/choose-temp.c5
-rwxr-xr-xcontrib/binutils/libiberty/configure351
-rw-r--r--contrib/binutils/libiberty/cp-demangle.c854
-rw-r--r--contrib/binutils/libiberty/cp-demangle.h15
-rw-r--r--contrib/binutils/libiberty/cplus-dem.c2
-rw-r--r--contrib/binutils/libiberty/filename_cmp.c78
-rw-r--r--contrib/binutils/libiberty/floatformat.c111
-rw-r--r--contrib/binutils/libiberty/functions.texi82
-rw-r--r--contrib/binutils/libiberty/hashtab.c23
-rw-r--r--contrib/binutils/libiberty/hex.c2
-rw-r--r--contrib/binutils/libiberty/make-relative-prefix.c46
-rw-r--r--contrib/binutils/libiberty/mkstemps.c6
-rw-r--r--contrib/binutils/libiberty/strsignal.c6
18 files changed, 1533 insertions, 492 deletions
diff --git a/contrib/binutils/libiberty/ChangeLog b/contrib/binutils/libiberty/ChangeLog
index fb328da..f700058 100644
--- a/contrib/binutils/libiberty/ChangeLog
+++ b/contrib/binutils/libiberty/ChangeLog
@@ -1,18 +1,312 @@
+2007-06-14 Paolo Bonzini <bonzini@gnu.org>
+
+ * configure.ac: Use ACX_PROG_CC_ALMOST_PEDANTIC too.
+ * configure: Regenerate.
+
+2007-06-14 Paolo Bonzini <bonzini@gnu.org>
+
+ * aclocal.m4: Include config/warnings.m4.
+ * configure.ac: Use ACX_PROG_CC_WARNING_OPTS.
+ * configure: Regenerate.
+
+2007-06-07 Geoffrey Keating <geoffk@apple.com>
+
+ * configure.ac: Non-default multilibs can be cross compilations.
+ * configure: Regenerate
+
+2007-05-07 Nathan Froyd <froydnj@codesourcery.com>
+
+ * argv.c (writeargv): New function.
+
+2007-05-05 Geoffrey Keating <geoffk@apple.com>
+
+ * cp-demangle.c (d_name): Detect local-source-name.
+ (d_prefix): Likewise.
+ (d_unqualified_name): Implement local-source-name.
+
+2007-05-03 Joel Brobecker <brobecker@adacore.com>
+
+ * filename_cmp.c: Replace include of ctype.h by include of
+ safe-ctype.h.
+ (filename_cmp): Use TOLOWER instead of tolower for conversions
+ that are locale-independent.
+ * Makefile.in (filename_cmp.o): Add dependency on safe-ctype.h.
+
+2007-04-11 Thomas Neumann tneumann@users.sourceforge.net
+
+ * argv.c: Use ANSI C declarations.
+ * make-relative-prefix.c: Likewise.
+
+2007-04-06 Joel Brobecker <brobecker@adacore.com>
+
+ * filename_cmp.c (filename_cmp): Improve documentation.
+
+2007-04-02 Andreas Schwab <schwab@suse.de>
+
+ * filename_cmp.c: Include "config.h".
+
+2007-03-29 Joel Brobecker <brobecker@adacore.com>
+
+ * filename_cmp.c: New file.
+ * Makefile.in (CFILES): Add filename_cmp.c.
+ (REQUIRED_OFILES): Add filename_cmp.o
+ (filename_cmp.o): New rule.
+ * functions.texi: Regenerate.
+
+2007-03-15 Geoffrey Keating <geoffk@apple.com>
+
+ * cp-demangle.c (d_encoding): Exit early on error.
+ (d_pointer_to_member_type): Exit early if cplus_demangle_type
+ returns NULL.
+ (cplus_demangle_type): Likewise.
+ * testsuite/demangle-expected: New testcase.
+
+2007-03-01 Brooks Moses <brooks.moses@codesourcery.com>
+
+ * Makefile.in: Add install-pdf target as copied from
+ automake v1.10 rules.
+ * testsuite/Makefile.in: Add dummy install-pdf target.
+
+2007-03-01 Peter Breitenlohner <peb@mppmu.mpg.de>
+ Eric Botcazou <ebotcazou@libertysurf.fr>
+
+ PR other/16513
+ * Makefile.in: Install library under $(MULTIOSDIR), not $(MULTISUBDIR).
+ Install headers in multilib independent location.
+
+2007-02-26 DJ Delorie <dj@redhat.com>
+
+ * configure.ac: add djgpp-specific results, so we don't have to
+ link during a cross compilation.
+ * configure: Regenerated.
+
+2007-01-31 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+
+ * hex.c: Fix typo.
+ * choose-temp.c: Likewise.
+ * functions.texi: Regenerate.
+
+2007-01-31 Vladimir Prus <vladimir@codesourcery.com>
+
+ * pex-common.h (struct pex_obj): New fields
+ stderr_pipe and read_err.
+ * pex-common.c (pex_init_common): Initialize
+ stderr_pipe.
+ (pex_run_in_environment): Add error checking
+ for PEX_STDERR_TO_PIPE. Create a pipe
+ for stderr if necessary.
+ (pex_read_err): New.
+ (pex_free): Close read_err.
+ * pexecute.txh: Document changes.
+ * functions.texi: Regenerated.
+
+2007-01-31 Ben Elliston <bje@au.ibm.com>
+
+ * strsignal.c (psignal): Change type of signo to int.
+ * functions.texi: Regenerate.
+
+2007-01-29 Simon Baldwin <simonb@google.com>
+
+ * cp-demangle.h (cplus_demangle_operators): External definition
+ suppressed if not building for libstdc++.
+ * cp-demangle.c (__gcclibcxx_demangle_callback): Augmented interface
+ to demangling, provides a malloc-less version of __cxa_demangle.
+ (cplus_demangle_print_callback): Public callback version of
+ cplus_demangle_print.
+ (struct d_growable_string): New growable string structure.
+ (d_growable_string_init): New function, provides support for
+ growable strings separate from print info.
+ (d_growable_string_resize): Likewise.
+ (d_growable_string_append_buffer): Likewise.
+ (d_growable_string_callback_adapter):): Likewise.
+ (d_print_init): New print info initialization function.
+ (d_print_error): Macro replace by inline function.
+ (d_print_saw_error): Likewise.
+ (d_append_char): Likewise.
+ (d_append_buffer): Likewise.
+ (d_append_string): New inline function, replaces the
+ d_append_string_constant macro.
+ (d_flush_buffer): New function, flushes buffer to callback.
+ (d_demangle_callback, is_ctor_or_dtor): Malloc-based fallback
+ for unsupported dynamic arrays replaced by alloca().
+ (d_demangle): Return string length estimating removed.
+ (d_dump): Moved error case handling from call site into function.
+ (d_print_resize): Function removed.
+ (d_print_append_char): Likewise.
+ (d_print_append_buffer): Likewise.
+ (d_print_error): Likewise.
+ (d_print_comp): Added special case handling for Java arrays.
+ (java_demangle_v3): Removed string post-processing for Java arrays,
+ now replaced by special case handling in d_print_comp.
+ (cplus_demangle_v3_callback): Augmented interface to demangling,
+ provides a malloc-less version of cplus_demangle_v3.
+ (java_demangle_v3_callback): Augmented interface to demangling,
+ provides a malloc-less version of java_demangle_v3.
+
+2007-01-12 Ben Elliston <bje@au.ibm.com>
+
+ * pex-unix.c (writeerr): Cast write result to void.
+
+ * choose-temp.c (choose_temp_base): Check the result of the call
+ to mktemp rather than testing the length of the modified string.
+
+2006-12-20 Geoffrey Keating <geoffk@apple.com>
+
+ * cp-demangle.h: Add comment explaining what to do to avoid
+ overrunning string.
+ (d_check_char): New.
+ (d_next_char): Don't advance past trailing '\0'.
+ * cp-demangle.c (cplus_demangle_mangled_name): Use d_check_char.
+ (d_nested_name): Likewise.
+ (d_special_name): Likewise.
+ (d_call_offset): Likewise.
+ (d_function_type): Likewise.
+ (d_array_type): Likewise.
+ (d_pointer_to_member_type): Likewise.
+ (d_template_param): Likewise.
+ (d_template_args): Likewise.
+ (d_template_arg): Likewise.
+ (d_expr_primary): Likewise.
+ (d_local_name): Likewise.
+ (d_substitution): Likewise.
+ (d_ctor_dtor_name): Use d_advance rather than d_next_char.
+ * testsuite/test-demangle.c: Include sys/mman.h.
+ (MAP_ANONYMOUS): Define.
+ (protect_end): New.
+ (main): Use protect_end.
+ * testsuite/demangle-expected: Add testcases for overrunning
+ the end of the string.
+
+2006-11-30 Andrew Stubbs <andrew.stubbs@st.com>
+ J"orn Rennecke <joern.rennecke@st.com>
+
+ PR driver/29931
+ * make-relative-prefix.c (make_relative_prefix_1): New function,
+ broken out of make_relative_prefix. Make link resolution dependent
+ on new parameter.
+ (make_relative_prefix): Use make_relative_prefix_1.
+ (make_relative_prefix_ignore_links): New function.
+
+2006-11-08 Vladimir Prus <vladimir@codesourcery.com>
+
+ * pex-win32.c (no_suffixes): Remove.
+ (std_suffixes): Add "" as first element.
+ (find_executable): Remove detection of already-present
+ extension. Try all suffixes in std_suffixes.
+
+2006-11-07 Julian Brown <julian@codesourcery.com>
+
+ * floatformat.c (get_field): Fix segfault with little-endian word
+ order on 64-bit hosts.
+ (put_field): Likewise.
+ (min): Move definition.
+
+2006-10-26 Danny Smith <dannysmith@users.sourceforge.net>
+
+ pex-win32.c (argv_to_cmdline): Replace xmalloc with XNEWVEC.
+ (find_executable): Likewise.
+ (win32_spawn): Cast alloca return to (char**).
+ Replace malloc with XNEWVEC.
+ bcopy.c (bcopy): Add explict casts in assignments.
+
+2006-10-25 Ben Elliston <bje@au.ibm.com>
+
+ * pexecute.txh: Wrap pexecute's "flag" argument with @var {..}.
+
+2006-10-10 Brooks Moses <bmoses@stanford.edu>
+
+ * Makefile.in: Added "pdf", "libiberty.pdf" target support.
+ * testsuite/Makefile.in: Added empty "pdf" target.
+
+2006-09-22 Ian Lance Taylor <ian@airs.com>
+
+ PR other/29176
+ * cp-demangle.c (d_substitution): Check for overflow when
+ computing substitution index.
+
+2006-08-30 Corinna Vinschen <corinna@vinschen.de>
+
+ * configure.ac: Add case for Mingw as host.
+ * configure: Regenerate.
+
+2006-08-27 Ian Lance Taylor <ian@airs.com>
+
+ PR driver/27622
+ * pex-common.h (struct pex_funcs): Add toclose parameter to
+ exec_child field.
+ * pex-common.c (pex_run_in_environment): Pass toclose to
+ exec_child.
+ * pex-djgpp.c (pex_djgpp_exec_child): Add toclose parameter.
+ * pex-unix.c (pex_unix_exec_child): Likewise.
+ * pex-msdos.c (pex_msdos_exec_child): Likewise.
+ * pex-win32.c (pex_win32_exec_child): Likewise.
+
+ PR other/28797
+ * cp-demangle.c (d_pointer_to_member_type): Do add a substitution
+ for a qualified member which is not a function.
+ * testsuite/demangle-expected: Add test case.
+
+2006-07-27 Jan Hubicka <jh@suse.cz>
+
+ PR rtl-optimization/28071
+ * hashtab.c (htab_empty): Clear out n_deleted/n_elements;
+ downsize the hashtable.
+
+2006-07-04 Peter O'Gorman <peter@pogma.com>
+
+ * Makefile.in: chmod 644 before ranlib during install.
+
+2006-06-02 Mark Shinwell <shinwell@codesourcery.com>
+
+ * pex-unix.c (pex_unix_exec_child): Insert cast when assigning
+ to environ.
+
+2006-06-01 Mark Shinwell <shinwell@codesourcery.com>
+
+ * pex-common.c: New function pex_run_in_environment.
+ * pex-common.h: Add environment parameter to exec_child.
+ * pex-msdos.c: Add environment parameter to pex_msdos_exec_child.
+ * pex-djgpp.c: Add environment parameter to pex_djgpp_exec_child.
+ (pex_djgpp_exec_child): Pass environment to child process.
+ * pex-unix.c: Add environment parameter to pex_unix_exec_child.
+ (pex_unix_exec_child): Pass environment to child process.
+ * pex-win32.c: Add environment parameter to pex_win32_exec_child.
+ New function env_compare for comparing VAR=VALUE pairs.
+ (win32_spawn): Assemble environment block and pass to CreateProcess.
+ (spawn_script): Pass environment through to win32_spawn.
+ (pex_win32_exec_child): Pass environment through to spawn_script and
+ win32_spawn.
+ * functions.texi: Regenerate.
+ * pexecute.txh: Document pex_run_in_environment.
+
+2006-05-28 Mark Shinwell <shinwell@codesourcery.com>
+
+ * mkstemps.c: Open temporary files in binary mode.
+
+2006-05-12 Anton Blanchard <anton@samba.org>
+
+ * cplus-dem.c (demangle_fund_type): Ensure buf is large enough to
+ hold "int%u_t".
+
+2006-04-24 Julian Brown <julian@codesourcery.com>
+
+ * floatformat.c (floatformat_to_double): Fix (biased) exponent=0 case.
+
2006-03-29 Jim Blandy <jimb@codesourcery.com>
- * pex-common.c (pex_input_file, pex_input_pipe): New functions.
+ * pex-common.c (pex_input_file, pex_input_pipe): New functions.
(pex_init_common): Initialize obj->input_file.
(pex_run): Close any file opened by pex_input_file.
- * pexecute.txh (pex_input_file, pex_input_pipe): New docs.
- * pex-common.h (struct pex_obj): New field input_file.
+ * pexecute.txh (pex_input_file, pex_input_pipe): New docs.
+ * pex-common.h (struct pex_obj): New field input_file.
(struct pex_funcs): New function ptr fdopenw.
- * pex-unix.c (pex_unix_fdopenw): New function.
- (funcs): List it as our fdopenw function.
- * pex-win32.c (pex_win32_fdopenw): New function.
- (funcs): List it as our fdopenw function.
- * pex-djgpp.c (funcs): Leave fdopenw null.
- * pex-msdos (funcs): Same.
- * functions.texi: Regenerated.
+ * pex-unix.c (pex_unix_fdopenw): New function.
+ (funcs): List it as our fdopenw function.
+ * pex-win32.c (pex_win32_fdopenw): New function.
+ (funcs): List it as our fdopenw function.
+ * pex-djgpp.c (funcs): Leave fdopenw null.
+ * pex-msdos (funcs): Same.
+ * functions.texi: Regenerated.
2006-04-10 Jim Blandy <jimb@codesourcery.com>
@@ -6735,7 +7029,7 @@ Wed Aug 19 14:40:34 1992 Ian Lance Taylor (ian@cygnus.com)
Mon Aug 10 17:33:40 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
- * Makefile.in: clean up definition of CFILES, more comments
+ * Makefile.in: clean up definition of CFILES, more comments
Sat Aug 8 23:10:59 1992 Fred Fish (fnf@cygnus.com)
diff --git a/contrib/binutils/libiberty/Makefile.in b/contrib/binutils/libiberty/Makefile.in
index 95a8278..735f1e6 100644
--- a/contrib/binutils/libiberty/Makefile.in
+++ b/contrib/binutils/libiberty/Makefile.in
@@ -1,6 +1,6 @@
#
# Makefile
-# Copyright (C) 1990, 91-99, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+# Copyright (C) 1990, 91-99, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
# Free Software Foundation
#
# This file is part of the libiberty library.
@@ -131,8 +131,8 @@ CFILES = alloca.c argv.c asprintf.c atexit.c \
calloc.c choose-temp.c clock.c concat.c cp-demangle.c \
cp-demint.c cplus-dem.c \
dyn-string.c \
- fdmatch.c ffs.c fibheap.c floatformat.c fnmatch.c \
- fopen_unlocked.c \
+ fdmatch.c ffs.c fibheap.c filename_cmp.c floatformat.c \
+ fnmatch.c fopen_unlocked.c \
getcwd.c getopt.c getopt1.c getpagesize.c getpwd.c getruntime.c \
gettimeofday.c \
hashtab.c hex.c \
@@ -165,8 +165,8 @@ REQUIRED_OFILES = ./regex.o ./cplus-dem.o ./cp-demangle.o ./md5.o \
./alloca.o ./argv.o \
./choose-temp.o ./concat.o ./cp-demint.o \
./dyn-string.o \
- ./fdmatch.o ./fibheap.o ./floatformat.o ./fnmatch.o \
- ./fopen_unlocked.o \
+ ./fdmatch.o ./fibheap.o ./filename_cmp.o ./floatformat.o \
+ ./fnmatch.o ./fopen_unlocked.o \
./getopt.o ./getopt1.o ./getpwd.o ./getruntime.o \
./hashtab.o ./hex.o \
./lbasename.o ./lrealpath.o \
@@ -246,6 +246,24 @@ install-info: install-info-subdir
clean-info: clean-info-subdir
dvi: libiberty.dvi dvi-subdir
+LIBIBERTY_PDFFILES = libiberty.pdf
+
+pdf: $(LIBIBERTY_PDFFILES) pdf-subdir
+
+.PHONY: install-pdf
+
+pdf__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+
+install-pdf: $(LIBIBERTY_PDFFILES)
+ @$(NORMAL_INSTALL)
+ test -z "$(pdfdir)" || $(mkinstalldirs) "$(DESTDIR)$(pdfdir)"
+ @list='$(LIBIBERTY_PDFFILES)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(pdf__strip_dir) \
+ echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(pdfdir)/$$f'"; \
+ $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(pdfdir)/$$f"; \
+ done
+
# html, install-html targets
HTMLS = libiberty.html
@@ -319,6 +337,9 @@ libiberty.info : $(srcdir)/libiberty.texi $(TEXISRC)
libiberty.dvi : $(srcdir)/libiberty.texi $(TEXISRC)
texi2dvi $(srcdir)/libiberty.texi
+libiberty.pdf : $(srcdir)/libiberty.texi $(TEXISRC)
+ texi2pdf $(srcdir)/libiberty.texi
+
libiberty.html : $(srcdir)/libiberty.texi $(TEXISRC)
$(MAKEINFO) --no-split --html -I$(srcdir) -o $@ $<
@@ -332,15 +353,20 @@ libiberty.html : $(srcdir)/libiberty.texi $(TEXISRC)
INSTALL_DEST = @INSTALL_DEST@
install: install_to_$(INSTALL_DEST) install-subdir
+# This is tricky. Even though CC in the Makefile contains
+# multilib-specific flags, it's overridden by FLAGS_TO_PASS from the
+# default multilib, so we have to take LIBCFLAGS into account as well,
+# since it will be passed the multilib flags.
+MULTIOSDIR = `$(CC) $(LIBCFLAGS) -print-multi-os-directory`
install_to_libdir: all
- ${mkinstalldirs} $(DESTDIR)$(libdir)$(MULTISUBDIR)
- $(INSTALL_DATA) $(TARGETLIB) $(DESTDIR)$(libdir)$(MULTISUBDIR)/$(TARGETLIB)n
- ( cd $(DESTDIR)$(libdir)$(MULTISUBDIR) ; $(RANLIB) $(TARGETLIB)n )
- mv -f $(DESTDIR)$(libdir)$(MULTISUBDIR)/$(TARGETLIB)n $(DESTDIR)$(libdir)$(MULTISUBDIR)/$(TARGETLIB)
+ ${mkinstalldirs} $(DESTDIR)$(libdir)/$(MULTIOSDIR)
+ $(INSTALL_DATA) $(TARGETLIB) $(DESTDIR)$(libdir)/$(MULTIOSDIR)/$(TARGETLIB)n
+ ( cd $(DESTDIR)$(libdir)/$(MULTIOSDIR) ; chmod 644 $(TARGETLIB)n ;$(RANLIB) $(TARGETLIB)n )
+ mv -f $(DESTDIR)$(libdir)/$(MULTIOSDIR)/$(TARGETLIB)n $(DESTDIR)$(libdir)/$(MULTIOSDIR)/$(TARGETLIB)
if test -n "${target_header_dir}"; then \
case "${target_header_dir}" in \
/*) thd=${target_header_dir};; \
- *) thd=${includedir}${MULTISUBDIR}/${target_header_dir};; \
+ *) thd=${includedir}/${target_header_dir};; \
esac; \
${mkinstalldirs} $(DESTDIR)$${thd}; \
for h in ${INSTALLED_HEADERS}; do \
@@ -349,15 +375,10 @@ install_to_libdir: all
fi
@$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
-# This is tricky. Even though CC in the Makefile contains
-# multilib-specific flags, it's overridden by FLAGS_TO_PASS from the
-# default multilib, so we have to take LIBCFLAGS into account as well,
-# since it will be passed the multilib flags.
-MULTIOSDIR = `$(CC) $(LIBCFLAGS) -print-multi-os-directory`
install_to_tooldir: all
${mkinstalldirs} $(DESTDIR)$(tooldir)/lib/$(MULTIOSDIR)
$(INSTALL_DATA) $(TARGETLIB) $(DESTDIR)$(tooldir)/lib/$(MULTIOSDIR)/$(TARGETLIB)n
- ( cd $(DESTDIR)$(tooldir)/lib/$(MULTIOSDIR) ; $(RANLIB) $(TARGETLIB)n )
+ ( cd $(DESTDIR)$(tooldir)/lib/$(MULTIOSDIR) ; chmod 644 $(TARGETLIB)n; $(RANLIB) $(TARGETLIB)n )
mv -f $(DESTDIR)$(tooldir)/lib/$(MULTIOSDIR)/$(TARGETLIB)n $(DESTDIR)$(tooldir)/lib/$(MULTIOSDIR)/$(TARGETLIB)
@$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
@@ -434,7 +455,7 @@ mostlyclean: mostlyclean-subdir
clean: clean-subdir
$(MAKE) SUBDIRS="" mostlyclean
-rm -f *.a required-list tmpmulti.out
- -rm -f libiberty.dvi libiberty.info* libiberty.html
+ -rm -f libiberty.dvi libiberty.pdf libiberty.info* libiberty.html
@$(MULTICLEAN) multi-clean DO=clean
distclean: distclean-subdir
$(MAKE) SUBDIRS="" clean
@@ -463,7 +484,7 @@ config.status: $(srcdir)/configure
# if needed. This prevents problems with parallel builds, in case
# subdirectories need to run config.status also.
all-subdir check-subdir installcheck-subdir info-subdir \
-install-info-subdir clean-info-subdir dvi-subdir install-subdir \
+install-info-subdir clean-info-subdir dvi-subdir pdf-subdir install-subdir \
etags-subdir mostlyclean-subdir clean-subdir distclean-subdir \
maintainer-clean-subdir: config.h
@subdirs='$(SUBDIRS)'; \
@@ -630,6 +651,13 @@ $(CONFIGURED_OFILES): stamp-picdir
else true; fi
$(COMPILE.c) $(srcdir)/fibheap.c $(OUTPUT_OPTION)
+./filename_cmp.o: $(srcdir)/filename_cmp.c $(INCDIR)/filenames.h \
+ $(INCDIR)/safe-ctype.h
+ if [ x"$(PICFLAG)" != x ]; then \
+ $(COMPILE.c) $(PICFLAG) $(srcdir)/filename_cmp.c -o pic/$@; \
+ else true; fi
+ $(COMPILE.c) $(srcdir)/filename_cmp.c $(OUTPUT_OPTION)
+
./floatformat.o: $(srcdir)/floatformat.c config.h $(INCDIR)/ansidecl.h \
$(INCDIR)/floatformat.h $(INCDIR)/libiberty.h
if [ x"$(PICFLAG)" != x ]; then \
diff --git a/contrib/binutils/libiberty/aclocal.m4 b/contrib/binutils/libiberty/aclocal.m4
index 0b49d03..643939e 100644
--- a/contrib/binutils/libiberty/aclocal.m4
+++ b/contrib/binutils/libiberty/aclocal.m4
@@ -1,5 +1,6 @@
sinclude(../config/acx.m4)
sinclude(../config/no-executables.m4)
+sinclude(../config/warnings.m4)
dnl See whether strncmp reads past the end of its string parameters.
dnl On some versions of SunOS4 at least, strncmp reads a word at a time
diff --git a/contrib/binutils/libiberty/argv.c b/contrib/binutils/libiberty/argv.c
index 11ca549..faeb72d 100644
--- a/contrib/binutils/libiberty/argv.c
+++ b/contrib/binutils/libiberty/argv.c
@@ -290,6 +290,61 @@ char **buildargv (const char *input)
/*
+@deftypefn Extension int writeargv (const char **@var{argv}, FILE *@{file})
+
+Write each member of ARGV, handling all necessary quoting, to the file
+named by FILE, separated by whitespace. Return 0 on success, non-zero
+if an error occurred while writing to FILE.
+
+@end deftypefn
+
+*/
+
+int
+writeargv (char **argv, FILE *f)
+{
+ int status = 0;
+
+ if (f == NULL)
+ return 1;
+
+ while (*argv != NULL)
+ {
+ const char *arg = *argv;
+
+ while (*arg != EOS)
+ {
+ char c = *arg;
+
+ if (ISSPACE(c) || c == '\\' || c == '\'' || c == '"')
+ if (EOF == fputc ('\\', f))
+ {
+ status = 1;
+ goto done;
+ }
+
+ if (EOF == fputc (c, f))
+ {
+ status = 1;
+ goto done;
+ }
+ arg++;
+ }
+
+ if (EOF == fputc ('\n', f))
+ {
+ status = 1;
+ goto done;
+ }
+ argv++;
+ }
+
+ done:
+ return status;
+}
+
+/*
+
@deftypefn Extension void expandargv (int *@var{argcp}, char ***@var{argvp})
The @var{argcp} and @code{argvp} arguments are pointers to the usual
@@ -312,9 +367,7 @@ operating system to free the memory when the program exits.
*/
void
-expandargv (argcp, argvp)
- int *argcp;
- char ***argvp;
+expandargv (int *argcp, char ***argvp)
{
/* The argument we are currently processing. */
int i = 0;
diff --git a/contrib/binutils/libiberty/bcopy.c b/contrib/binutils/libiberty/bcopy.c
index 1e2eca9..f9b7a8a 100644
--- a/contrib/binutils/libiberty/bcopy.c
+++ b/contrib/binutils/libiberty/bcopy.c
@@ -16,8 +16,8 @@ bcopy (const void *src, void *dest, size_t len)
{
if (dest < src)
{
- const char *firsts = src;
- char *firstd = dest;
+ const char *firsts = (const char *) src;
+ char *firstd = (char *) dest;
while (len--)
*firstd++ = *firsts++;
}
diff --git a/contrib/binutils/libiberty/choose-temp.c b/contrib/binutils/libiberty/choose-temp.c
index 0cba990..b1c2e5b 100644
--- a/contrib/binutils/libiberty/choose-temp.c
+++ b/contrib/binutils/libiberty/choose-temp.c
@@ -46,7 +46,7 @@ find one. The current directory is chosen if all else fails so the
program is exited if a temporary directory can't be found (@code{mktemp}
fails). The buffer for the result is obtained with @code{xmalloc}.
-This function is provided for backwards compatability only. Its use is
+This function is provided for backwards compatibility only. Its use is
not recommended.
@end deftypefn
@@ -65,8 +65,7 @@ choose_temp_base (void)
strcpy (temp_filename, base);
strcpy (temp_filename + len, TEMP_FILE);
- mktemp (temp_filename);
- if (strlen (temp_filename) == 0)
+ if (mktemp (temp_filename) == 0)
abort ();
return temp_filename;
}
diff --git a/contrib/binutils/libiberty/configure b/contrib/binutils/libiberty/configure
index ed7423a..0312cc4 100755
--- a/contrib/binutils/libiberty/configure
+++ b/contrib/binutils/libiberty/configure
@@ -847,6 +847,7 @@ Optional Features:
--enable-maintainer-mode
enable make rules and dependencies not useful
(and sometimes confusing) to the casual installer
+ --enable-multilib build many library versions (default)
--enable-install-libiberty Install headers for end users
Optional Packages:
@@ -1727,6 +1728,29 @@ else
fi
+# Add --enable-multilib to configure.
+# Default to --enable-multilib
+# Check whether --enable-multilib or --disable-multilib was given.
+if test "${enable_multilib+set}" = set; then
+ enableval="$enable_multilib"
+ case "$enableval" in
+ yes) multilib=yes ;;
+ no) multilib=no ;;
+ *) { { echo "$as_me:$LINENO: error: bad value $enableval for multilib option" >&5
+echo "$as_me: error: bad value $enableval for multilib option" >&2;}
+ { (exit 1); exit 1; }; } ;;
+ esac
+else
+ multilib=yes
+fi;
+
+# Even if the default multilib is not a cross compilation,
+# it may be that some of the other multilibs are.
+if test $cross_compiling = no && test $multilib = yes \
+ && test "x${with_multisubdir}" != x ; then
+ cross_compiling=maybe
+fi
+
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
@@ -2929,22 +2953,33 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
ac_c_preproc_warn_flag=yes
-# Warn C++ incompatibilities if supported.
-echo "$as_me:$LINENO: checking whether ${CC} accepts -Wc++-compat" >&5
-echo $ECHO_N "checking whether ${CC} accepts -Wc++-compat... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_w_cxx_compat+set}" = set; then
+ac_libiberty_warn_cflags=
+save_CFLAGS="$CFLAGS"
+for option in -W -Wall -Wwrite-strings -Wc++-compat \
+ -Wstrict-prototypes; do
+ as_acx_Woption=`echo "acx_cv_prog_cc_warning_$option" | $as_tr_sh`
+
+ echo "$as_me:$LINENO: checking whether $CC supports $option" >&5
+echo $ECHO_N "checking whether $CC supports $option... $ECHO_C" >&6
+if eval "test \"\${$as_acx_Woption+set}\" = set"; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
- save_CFLAGS="$CFLAGS"
- CFLAGS="-Wc++-compat"
- cat >conftest.$ac_ext <<_ACEOF
+ CFLAGS="$option"
+ cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
+int
+main ()
+{
+
+ ;
+ return 0;
+}
_ACEOF
rm -f conftest.$ac_objext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
@@ -2968,29 +3003,91 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
- ac_cv_prog_cc_w_cxx_compat=yes
+ eval "$as_acx_Woption=yes"
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
-ac_cv_prog_cc_w_cxx_compat=no
+eval "$as_acx_Woption=no"
fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
- CFLAGS="$save_CFLAGS"
fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_cc_w_cxx_compat" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_w_cxx_compat" >&6
+echo "$as_me:$LINENO: result: `eval echo '${'$as_acx_Woption'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_acx_Woption'}'`" >&6
+ if test `eval echo '${'$as_acx_Woption'}'` = yes; then
+ ac_libiberty_warn_cflags="$ac_libiberty_warn_cflags${ac_libiberty_warn_cflags:+ }$option"
+fi
+
+ done
+CFLAGS="$save_CFLAGS"
+
+if test "$GCC" = yes; then
+ echo "$as_me:$LINENO: checking whether $CC supports -pedantic " >&5
+echo $ECHO_N "checking whether $CC supports -pedantic ... $ECHO_C" >&6
+if test "${acx_cv_prog_cc_pedantic_+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ save_CFLAGS="$CFLAGS"
+CFLAGS="-pedantic "
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+int
+main ()
+{
-if test x$GCC = xyes; then
- ac_libiberty_warn_cflags='-W -Wall -pedantic -Wwrite-strings -Wstrict-prototypes'
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ acx_cv_prog_cc_pedantic_=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+acx_cv_prog_cc_pedantic_=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+CFLAGS="$save_CFLAGS"
fi
-if test $ac_cv_prog_cc_w_cxx_compat = yes ; then
- ac_libiberty_warn_cflags="${ac_libiberty_warn_cflags} -Wc++-compat"
+echo "$as_me:$LINENO: result: $acx_cv_prog_cc_pedantic_" >&5
+echo "${ECHO_T}$acx_cv_prog_cc_pedantic_" >&6
+if test $acx_cv_prog_cc_pedantic_ = yes; then
+ ac_libiberty_warn_cflags="$ac_libiberty_warn_cflags${ac_libiberty_warn_cflags:+ }-pedantic "
fi
+fi
+
+
+
if test "x$CC" != xcc; then
echo "$as_me:$LINENO: checking whether $CC and cc understand -c and -o together" >&5
echo $ECHO_N "checking whether $CC and cc understand -c and -o together... $ECHO_C" >&6
@@ -5679,6 +5776,208 @@ _ACEOF
fi
+ # If we are being configured for Mingw, we know which functions
+ # Mingw provides and which ones we will be expected to provide.
+
+ case "${host}" in
+ *-*-mingw*)
+ case $LIBOBJS in
+ "asprintf.$ac_objext" | \
+ *" asprintf.$ac_objext" | \
+ "asprintf.$ac_objext "* | \
+ *" asprintf.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS asprintf.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "basename.$ac_objext" | \
+ *" basename.$ac_objext" | \
+ "basename.$ac_objext "* | \
+ *" basename.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS basename.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "bcmp.$ac_objext" | \
+ *" bcmp.$ac_objext" | \
+ "bcmp.$ac_objext "* | \
+ *" bcmp.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS bcmp.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "bcopy.$ac_objext" | \
+ *" bcopy.$ac_objext" | \
+ "bcopy.$ac_objext "* | \
+ *" bcopy.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS bcopy.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "bzero.$ac_objext" | \
+ *" bzero.$ac_objext" | \
+ "bzero.$ac_objext "* | \
+ *" bzero.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS bzero.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "clock.$ac_objext" | \
+ *" clock.$ac_objext" | \
+ "clock.$ac_objext "* | \
+ *" clock.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS clock.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "ffs.$ac_objext" | \
+ *" ffs.$ac_objext" | \
+ "ffs.$ac_objext "* | \
+ *" ffs.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS ffs.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "getpagesize.$ac_objext" | \
+ *" getpagesize.$ac_objext" | \
+ "getpagesize.$ac_objext "* | \
+ *" getpagesize.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS getpagesize.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "index.$ac_objext" | \
+ *" index.$ac_objext" | \
+ "index.$ac_objext "* | \
+ *" index.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS index.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "insque.$ac_objext" | \
+ *" insque.$ac_objext" | \
+ "insque.$ac_objext "* | \
+ *" insque.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS insque.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "mempcpy.$ac_objext" | \
+ *" mempcpy.$ac_objext" | \
+ "mempcpy.$ac_objext "* | \
+ *" mempcpy.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS mempcpy.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "mkstemps.$ac_objext" | \
+ *" mkstemps.$ac_objext" | \
+ "mkstemps.$ac_objext "* | \
+ *" mkstemps.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS mkstemps.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "random.$ac_objext" | \
+ *" random.$ac_objext" | \
+ "random.$ac_objext "* | \
+ *" random.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS random.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "rindex.$ac_objext" | \
+ *" rindex.$ac_objext" | \
+ "rindex.$ac_objext "* | \
+ *" rindex.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS rindex.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "sigsetmask.$ac_objext" | \
+ *" sigsetmask.$ac_objext" | \
+ "sigsetmask.$ac_objext "* | \
+ *" sigsetmask.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS sigsetmask.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "stpcpy.$ac_objext" | \
+ *" stpcpy.$ac_objext" | \
+ "stpcpy.$ac_objext "* | \
+ *" stpcpy.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS stpcpy.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "stpncpy.$ac_objext" | \
+ *" stpncpy.$ac_objext" | \
+ "stpncpy.$ac_objext "* | \
+ *" stpncpy.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS stpncpy.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "strndup.$ac_objext" | \
+ *" strndup.$ac_objext" | \
+ "strndup.$ac_objext "* | \
+ *" strndup.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS strndup.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "strverscmp.$ac_objext" | \
+ *" strverscmp.$ac_objext" | \
+ "strverscmp.$ac_objext "* | \
+ *" strverscmp.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS strverscmp.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "vasprintf.$ac_objext" | \
+ *" vasprintf.$ac_objext" | \
+ "vasprintf.$ac_objext "* | \
+ *" vasprintf.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS vasprintf.$ac_objext" ;;
+esac
+
+ case $LIBOBJS in
+ "waitpid.$ac_objext" | \
+ *" waitpid.$ac_objext" | \
+ "waitpid.$ac_objext "* | \
+ *" waitpid.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS waitpid.$ac_objext" ;;
+esac
+
+
+ for f in $funcs; do
+ case "$f" in
+ asprintf | basename | bcmp | bcopy | bzero | clock | ffs | getpagesize | index | insque | mempcpy | mkstemps | random | rindex | sigsetmask | stpcpy | stpncpy | strdup | strndup | strverscmp | vasprintf | waitpid)
+ ;;
+ *)
+ n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >>confdefs.h <<_ACEOF
+#define $n 1
+_ACEOF
+
+ ;;
+ esac
+ done
+
+ # Mingw doesnt provide any of the variables in $vars, so we
+ # dont have to check them here.
+
+ # Of the functions in $checkfuncs, Mingw only has strerror.
+ cat >>confdefs.h <<\_ACEOF
+#define HAVE_STRERROR 1
+_ACEOF
+
+
+ setobjs=yes
+ ;;
+
+ esac
+
# We may wish to install the target headers somewhere.
# Check whether --enable-install-libiberty or --disable-install-libiberty was given.
if test "${enable_install_libiberty+set}" = set; then
@@ -5840,6 +6139,26 @@ _ACEOF
setobjs=yes
;;
+ *-*-msdosdjgpp)
+ for f in atexit basename bcmp bcopy bsearch bzero calloc clock ffs \
+ getcwd getpagesize getrusage gettimeofday gettimeofday \
+ index insque memchr memcmp memcpy memmove memset psignal \
+ putenv random rename rindex sbrk setenv stpcpy strcasecmp \
+ strchr strdup strerror strncasecmp strrchr strstr strtod \
+ strtol strtoul sysconf times tmpnam vfprintf vprintf \
+ vsprintf waitpid
+ do
+ n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >>confdefs.h <<_ACEOF
+#define $n 1
+_ACEOF
+
+ done
+
+
+ setobjs=yes
+ ;;
+
esac
fi
diff --git a/contrib/binutils/libiberty/cp-demangle.c b/contrib/binutils/libiberty/cp-demangle.c
index 109d533..992b358 100644
--- a/contrib/binutils/libiberty/cp-demangle.c
+++ b/contrib/binutils/libiberty/cp-demangle.c
@@ -1,5 +1,5 @@
/* Demangler for g++ V3 ABI.
- Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
Written by Ian Lance Taylor <ian@wasabisystems.com>.
This file is part of the libiberty library, which is part of GCC.
@@ -42,6 +42,10 @@
This file will normally define the following functions, q.v.:
char *cplus_demangle_v3(const char *mangled, int options)
char *java_demangle_v3(const char *mangled)
+ int cplus_demangle_v3_callback(const char *mangled, int options,
+ demangle_callbackref callback)
+ int java_demangle_v3_callback(const char *mangled,
+ demangle_callbackref callback)
enum gnu_v3_ctor_kinds is_gnu_v3_mangled_ctor (const char *name)
enum gnu_v3_dtor_kinds is_gnu_v3_mangled_dtor (const char *name)
@@ -50,12 +54,14 @@
defined in demangle.h:
enum demangle_component_type
struct demangle_component
+ demangle_callbackref
and these functions defined in this file:
cplus_demangle_fill_name
cplus_demangle_fill_extended_operator
cplus_demangle_fill_ctor
cplus_demangle_fill_dtor
cplus_demangle_print
+ cplus_demangle_print_callback
and other functions defined in the file cp-demint.c.
This file also defines some other functions and variables which are
@@ -64,14 +70,20 @@
Preprocessor macros you can define while compiling this file:
IN_LIBGCC2
- If defined, this file defines the following function, q.v.:
+ If defined, this file defines the following functions, q.v.:
char *__cxa_demangle (const char *mangled, char *buf, size_t *len,
int *status)
- instead of cplus_demangle_v3() and java_demangle_v3().
+ int __gcclibcxx_demangle_callback (const char *,
+ void (*)
+ (const char *, size_t, void *),
+ void *)
+ instead of cplus_demangle_v3[_callback]() and
+ java_demangle_v3[_callback]().
IN_GLIBCPP_V3
- If defined, this file defines only __cxa_demangle(), and no other
- publically visible functions or variables.
+ If defined, this file defines only __cxa_demangle() and
+ __gcclibcxx_demangle_callback(), and no other publically visible
+ functions or variables.
STANDALONE_DEMANGLER
If defined, this file defines a main() function which demangles
@@ -82,6 +94,10 @@
stdout about the mangled string. This is not generally useful.
*/
+#if defined (_AIX) && !defined (__GNUC__)
+ #pragma alloca
+#endif
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@@ -95,6 +111,18 @@
#include <string.h>
#endif
+#ifdef HAVE_ALLOCA_H
+# include <alloca.h>
+#else
+# ifndef alloca
+# ifdef __GNUC__
+# define alloca __builtin_alloca
+# else
+extern char *alloca ();
+# endif /* __GNUC__ */
+# endif /* alloca */
+#endif /* HAVE_ALLOCA_H */
+
#include "ansidecl.h"
#include "libiberty.h"
#include "demangle.h"
@@ -135,6 +163,10 @@ static struct demangle_component *d_type (struct d_info *);
#define cplus_demangle_print d_print
static char *d_print (int, const struct demangle_component *, int, size_t *);
+#define cplus_demangle_print_callback d_print_callback
+static int d_print_callback (int, const struct demangle_component *,
+ demangle_callbackref, void *);
+
#define cplus_demangle_init_info d_init_info
static void d_init_info (const char *, int, size_t, struct d_info *);
@@ -162,8 +194,8 @@ static void d_init_info (const char *, int, size_t, struct d_info *);
V3 demangler code.
As of this writing this file has the following undefined references
- when compiled with -DIN_GLIBCPP_V3: malloc, realloc, free, memcpy,
- strcpy, strcat, strlen. */
+ when compiled with -DIN_GLIBCPP_V3: realloc, free, memcpy, strcpy,
+ strcat, strlen. */
#define IS_DIGIT(c) ((c) >= '0' && (c) <= '9')
#define IS_UPPER(c) ((c) >= 'A' && (c) <= 'Z')
@@ -228,58 +260,46 @@ struct d_print_mod
struct d_print_template *templates;
};
-/* We use this structure to hold information during printing. */
+/* We use these structures to hold information during printing. */
-struct d_print_info
+struct d_growable_string
{
- /* The options passed to the demangler. */
- int options;
/* Buffer holding the result. */
char *buf;
/* Current length of data in buffer. */
size_t len;
/* Allocated size of buffer. */
size_t alc;
+ /* Set to 1 if we had a memory allocation failure. */
+ int allocation_failure;
+};
+
+enum { D_PRINT_BUFFER_LENGTH = 256 };
+struct d_print_info
+{
+ /* The options passed to the demangler. */
+ int options;
+ /* Fixed-length allocated buffer for demangled data, flushed to the
+ callback with a NUL termination once full. */
+ char buf[D_PRINT_BUFFER_LENGTH];
+ /* Current length of data in buffer. */
+ size_t len;
+ /* The last character printed, saved individually so that it survives
+ any buffer flush. */
+ char last_char;
+ /* Callback function to handle demangled buffer flush. */
+ demangle_callbackref callback;
+ /* Opaque callback argument. */
+ void *opaque;
/* The current list of templates, if any. */
struct d_print_template *templates;
/* The current list of modifiers (e.g., pointer, reference, etc.),
if any. */
struct d_print_mod *modifiers;
- /* Set to 1 if we had a memory allocation failure. */
- int allocation_failure;
+ /* Set to 1 if we saw a demangling error. */
+ int demangle_failure;
};
-#define d_print_saw_error(dpi) ((dpi)->buf == NULL)
-
-#define d_append_char(dpi, c) \
- do \
- { \
- if ((dpi)->buf != NULL && (dpi)->len < (dpi)->alc) \
- (dpi)->buf[(dpi)->len++] = (c); \
- else \
- d_print_append_char ((dpi), (c)); \
- } \
- while (0)
-
-#define d_append_buffer(dpi, s, l) \
- do \
- { \
- if ((dpi)->buf != NULL && (dpi)->len + (l) <= (dpi)->alc) \
- { \
- memcpy ((dpi)->buf + (dpi)->len, (s), (l)); \
- (dpi)->len += l; \
- } \
- else \
- d_print_append_buffer ((dpi), (s), (l)); \
- } \
- while (0)
-
-#define d_append_string_constant(dpi, s) \
- d_append_buffer (dpi, (s), sizeof (s) - 1)
-
-#define d_last_char(dpi) \
- ((dpi)->buf == NULL || (dpi)->len == 0 ? '\0' : (dpi)->buf[(dpi)->len - 1])
-
#ifdef CP_DEMANGLE_DEBUG
static void d_dump (struct demangle_component *, int);
#endif
@@ -389,14 +409,34 @@ d_add_substitution (struct d_info *, struct demangle_component *);
static struct demangle_component *d_substitution (struct d_info *, int);
-static void d_print_resize (struct d_print_info *, size_t);
+static void d_growable_string_init (struct d_growable_string *, size_t);
-static void d_print_append_char (struct d_print_info *, int);
+static inline void
+d_growable_string_resize (struct d_growable_string *, size_t);
+
+static inline void
+d_growable_string_append_buffer (struct d_growable_string *,
+ const char *, size_t);
+static void
+d_growable_string_callback_adapter (const char *, size_t, void *);
static void
-d_print_append_buffer (struct d_print_info *, const char *, size_t);
+d_print_init (struct d_print_info *, int, demangle_callbackref, void *);
-static void d_print_error (struct d_print_info *);
+static inline void d_print_error (struct d_print_info *);
+
+static inline int d_print_saw_error (struct d_print_info *);
+
+static inline void d_print_flush (struct d_print_info *);
+
+static inline void d_append_char (struct d_print_info *, char);
+
+static inline void d_append_buffer (struct d_print_info *,
+ const char *, size_t);
+
+static inline void d_append_string (struct d_print_info *, const char *);
+
+static inline char d_last_char (struct d_print_info *);
static void
d_print_comp (struct d_print_info *, const struct demangle_component *);
@@ -426,6 +466,8 @@ d_print_expr_op (struct d_print_info *, const struct demangle_component *);
static void
d_print_cast (struct d_print_info *, const struct demangle_component *);
+static int d_demangle_callback (const char *, int,
+ demangle_callbackref, void *);
static char *d_demangle (const char *, int, size_t *);
#ifdef CP_DEMANGLE_DEBUG
@@ -436,7 +478,11 @@ d_dump (struct demangle_component *dc, int indent)
int i;
if (dc == NULL)
- return;
+ {
+ if (indent == 0)
+ printf ("failed demangling\n");
+ return;
+ }
for (i = 0; i < indent; ++i)
putchar (' ');
@@ -913,9 +959,9 @@ CP_STATIC_IF_GLIBCPP_V3
struct demangle_component *
cplus_demangle_mangled_name (struct d_info *di, int top_level)
{
- if (d_next_char (di) != '_')
+ if (! d_check_char (di, '_'))
return NULL;
- if (d_next_char (di) != 'Z')
+ if (! d_check_char (di, 'Z'))
return NULL;
return d_encoding (di, top_level);
}
@@ -1021,7 +1067,7 @@ d_encoding (struct d_info *di, int top_level)
}
peek = d_peek_char (di);
- if (peek == '\0' || peek == 'E')
+ if (dc == NULL || peek == '\0' || peek == 'E')
return dc;
return d_make_comp (di, DEMANGLE_COMPONENT_TYPED_NAME, dc,
d_bare_function_type (di, has_return_type (dc)));
@@ -1054,6 +1100,9 @@ d_name (struct d_info *di)
case 'Z':
return d_local_name (di);
+ case 'L':
+ return d_unqualified_name (di);
+
case 'S':
{
int subst;
@@ -1123,7 +1172,7 @@ d_nested_name (struct d_info *di)
struct demangle_component *ret;
struct demangle_component **pret;
- if (d_next_char (di) != 'N')
+ if (! d_check_char (di, 'N'))
return NULL;
pret = d_cv_qualifiers (di, &ret, 1);
@@ -1134,7 +1183,7 @@ d_nested_name (struct d_info *di)
if (*pret == NULL)
return NULL;
- if (d_next_char (di) != 'E')
+ if (! d_check_char (di, 'E'))
return NULL;
return ret;
@@ -1174,7 +1223,8 @@ d_prefix (struct d_info *di)
if (IS_DIGIT (peek)
|| IS_LOWER (peek)
|| peek == 'C'
- || peek == 'D')
+ || peek == 'D'
+ || peek == 'L')
dc = d_unqualified_name (di);
else if (peek == 'S')
dc = d_substitution (di, 1);
@@ -1208,6 +1258,9 @@ d_prefix (struct d_info *di)
/* <unqualified-name> ::= <operator-name>
::= <ctor-dtor-name>
::= <source-name>
+ ::= <local-source-name>
+
+ <local-source-name> ::= L <source-name> <discriminator>
*/
static struct demangle_component *
@@ -1229,6 +1282,19 @@ d_unqualified_name (struct d_info *di)
}
else if (peek == 'C' || peek == 'D')
return d_ctor_dtor_name (di);
+ else if (peek == 'L')
+ {
+ struct demangle_component * ret;
+
+ d_advance (di, 1);
+
+ ret = d_source_name (di);
+ if (ret == NULL)
+ return NULL;
+ if (! d_discriminator (di))
+ return NULL;
+ return ret;
+ }
else
return NULL;
}
@@ -1449,11 +1515,8 @@ d_operator_name (struct d_info *di)
static struct demangle_component *
d_special_name (struct d_info *di)
{
- char c;
-
di->expansion += 20;
- c = d_next_char (di);
- if (c == 'T')
+ if (d_check_char (di, 'T'))
{
switch (d_next_char (di))
{
@@ -1502,7 +1565,7 @@ d_special_name (struct d_info *di)
offset = d_number (di);
if (offset < 0)
return NULL;
- if (d_next_char (di) != '_')
+ if (! d_check_char (di, '_'))
return NULL;
base_type = cplus_demangle_type (di);
/* We don't display the offset. FIXME: We should display
@@ -1523,7 +1586,7 @@ d_special_name (struct d_info *di)
return NULL;
}
}
- else if (c == 'G')
+ else if (d_check_char (di, 'G'))
{
switch (d_next_char (di))
{
@@ -1570,14 +1633,14 @@ d_call_offset (struct d_info *di, int c)
else if (c == 'v')
{
d_number (di);
- if (d_next_char (di) != '_')
+ if (! d_check_char (di, '_'))
return 0;
d_number (di);
}
else
return 0;
- if (d_next_char (di) != '_')
+ if (! d_check_char (di, '_'))
return 0;
return 1;
@@ -1601,13 +1664,13 @@ d_ctor_dtor_name (struct d_info *di)
else if (di->last_name->type == DEMANGLE_COMPONENT_SUB_STD)
di->expansion += di->last_name->u.s_string.len;
}
- switch (d_next_char (di))
+ switch (d_peek_char (di))
{
case 'C':
{
enum gnu_v3_ctor_kinds kind;
- switch (d_next_char (di))
+ switch (d_peek_next_char (di))
{
case '1':
kind = gnu_v3_complete_object_ctor;
@@ -1621,6 +1684,7 @@ d_ctor_dtor_name (struct d_info *di)
default:
return NULL;
}
+ d_advance (di, 2);
return d_make_ctor (di, kind, di->last_name);
}
@@ -1628,7 +1692,7 @@ d_ctor_dtor_name (struct d_info *di)
{
enum gnu_v3_dtor_kinds kind;
- switch (d_next_char (di))
+ switch (d_peek_next_char (di))
{
case '0':
kind = gnu_v3_deleting_dtor;
@@ -1642,6 +1706,7 @@ d_ctor_dtor_name (struct d_info *di)
default:
return NULL;
}
+ d_advance (di, 2);
return d_make_dtor (di, kind, di->last_name);
}
@@ -1735,7 +1800,7 @@ cplus_demangle_type (struct d_info *di)
if (pret == NULL)
return NULL;
*pret = cplus_demangle_type (di);
- if (! d_add_substitution (di, ret))
+ if (! *pret || ! d_add_substitution (di, ret))
return NULL;
return ret;
}
@@ -1925,7 +1990,7 @@ d_function_type (struct d_info *di)
{
struct demangle_component *ret;
- if (d_next_char (di) != 'F')
+ if (! d_check_char (di, 'F'))
return NULL;
if (d_peek_char (di) == 'Y')
{
@@ -1934,7 +1999,7 @@ d_function_type (struct d_info *di)
d_advance (di, 1);
}
ret = d_bare_function_type (di, 1);
- if (d_next_char (di) != 'E')
+ if (! d_check_char (di, 'E'))
return NULL;
return ret;
}
@@ -2021,7 +2086,7 @@ d_array_type (struct d_info *di)
char peek;
struct demangle_component *dim;
- if (d_next_char (di) != 'A')
+ if (! d_check_char (di, 'A'))
return NULL;
peek = d_peek_char (di);
@@ -2049,7 +2114,7 @@ d_array_type (struct d_info *di)
return NULL;
}
- if (d_next_char (di) != '_')
+ if (! d_check_char (di, '_'))
return NULL;
return d_make_comp (di, DEMANGLE_COMPONENT_ARRAY_TYPE, dim,
@@ -2065,7 +2130,7 @@ d_pointer_to_member_type (struct d_info *di)
struct demangle_component *mem;
struct demangle_component **pmem;
- if (d_next_char (di) != 'M')
+ if (! d_check_char (di, 'M'))
return NULL;
cl = cplus_demangle_type (di);
@@ -2081,12 +2146,23 @@ d_pointer_to_member_type (struct d_info *di)
g++ does not work that way. g++ treats only the CV-qualified
member function as a substitution source. FIXME. So to work
with g++, we need to pull off the CV-qualifiers here, in order to
- avoid calling add_substitution() in cplus_demangle_type(). */
+ avoid calling add_substitution() in cplus_demangle_type(). But
+ for a CV-qualified member which is not a function, g++ does
+ follow the ABI, so we need to handle that case here by calling
+ d_add_substitution ourselves. */
pmem = d_cv_qualifiers (di, &mem, 1);
if (pmem == NULL)
return NULL;
*pmem = cplus_demangle_type (di);
+ if (*pmem == NULL)
+ return NULL;
+
+ if (pmem != &mem && (*pmem)->type != DEMANGLE_COMPONENT_FUNCTION_TYPE)
+ {
+ if (! d_add_substitution (di, mem))
+ return NULL;
+ }
return d_make_comp (di, DEMANGLE_COMPONENT_PTRMEM_TYPE, cl, mem);
}
@@ -2100,7 +2176,7 @@ d_template_param (struct d_info *di)
{
long param;
- if (d_next_char (di) != 'T')
+ if (! d_check_char (di, 'T'))
return NULL;
if (d_peek_char (di) == '_')
@@ -2113,7 +2189,7 @@ d_template_param (struct d_info *di)
param += 1;
}
- if (d_next_char (di) != '_')
+ if (! d_check_char (di, '_'))
return NULL;
++di->did_subs;
@@ -2135,7 +2211,7 @@ d_template_args (struct d_info *di)
constructor or destructor. */
hold_last_name = di->last_name;
- if (d_next_char (di) != 'I')
+ if (! d_check_char (di, 'I'))
return NULL;
al = NULL;
@@ -2180,7 +2256,7 @@ d_template_arg (struct d_info *di)
case 'X':
d_advance (di, 1);
ret = d_expression (di);
- if (d_next_char (di) != 'E')
+ if (! d_check_char (di, 'E'))
return NULL;
return ret;
@@ -2307,7 +2383,7 @@ d_expr_primary (struct d_info *di)
{
struct demangle_component *ret;
- if (d_next_char (di) != 'L')
+ if (! d_check_char (di, 'L'))
return NULL;
if (d_peek_char (di) == '_')
ret = cplus_demangle_mangled_name (di, 0);
@@ -2353,7 +2429,7 @@ d_expr_primary (struct d_info *di)
}
ret = d_make_comp (di, t, type, d_make_name (di, s, d_str (di) - s));
}
- if (d_next_char (di) != 'E')
+ if (! d_check_char (di, 'E'))
return NULL;
return ret;
}
@@ -2367,12 +2443,12 @@ d_local_name (struct d_info *di)
{
struct demangle_component *function;
- if (d_next_char (di) != 'Z')
+ if (! d_check_char (di, 'Z'))
return NULL;
function = d_encoding (di, 0);
- if (d_next_char (di) != 'E')
+ if (! d_check_char (di, 'E'))
return NULL;
if (d_peek_char (di) == 's')
@@ -2477,7 +2553,7 @@ d_substitution (struct d_info *di, int prefix)
{
char c;
- if (d_next_char (di) != 'S')
+ if (! d_check_char (di, 'S'))
return NULL;
c = d_next_char (di);
@@ -2496,6 +2572,8 @@ d_substitution (struct d_info *di, int prefix)
id = id * 36 + c - 'A' + 10;
else
return NULL;
+ if (id < 0)
+ return NULL;
c = d_next_char (di);
}
while (c != '_');
@@ -2557,80 +2635,181 @@ d_substitution (struct d_info *di, int prefix)
}
}
-/* Resize the print buffer. */
+/* Initialize a growable string. */
static void
-d_print_resize (struct d_print_info *dpi, size_t add)
+d_growable_string_init (struct d_growable_string *dgs, size_t estimate)
{
- size_t need;
+ dgs->buf = NULL;
+ dgs->len = 0;
+ dgs->alc = 0;
+ dgs->allocation_failure = 0;
- if (dpi->buf == NULL)
+ if (estimate > 0)
+ d_growable_string_resize (dgs, estimate);
+}
+
+/* Grow a growable string to a given size. */
+
+static inline void
+d_growable_string_resize (struct d_growable_string *dgs, size_t need)
+{
+ size_t newalc;
+ char *newbuf;
+
+ if (dgs->allocation_failure)
return;
- need = dpi->len + add;
- while (need > dpi->alc)
- {
- size_t newalc;
- char *newbuf;
- newalc = dpi->alc * 2;
- newbuf = (char *) realloc (dpi->buf, newalc);
- if (newbuf == NULL)
- {
- free (dpi->buf);
- dpi->buf = NULL;
- dpi->allocation_failure = 1;
- return;
- }
- dpi->buf = newbuf;
- dpi->alc = newalc;
+ /* Start allocation at two bytes to avoid any possibility of confusion
+ with the special value of 1 used as a return in *palc to indicate
+ allocation failures. */
+ newalc = dgs->alc > 0 ? dgs->alc : 2;
+ while (newalc < need)
+ newalc <<= 1;
+
+ newbuf = (char *) realloc (dgs->buf, newalc);
+ if (newbuf == NULL)
+ {
+ free (dgs->buf);
+ dgs->buf = NULL;
+ dgs->len = 0;
+ dgs->alc = 0;
+ dgs->allocation_failure = 1;
+ return;
}
+ dgs->buf = newbuf;
+ dgs->alc = newalc;
}
-/* Append a character to the print buffer. */
+/* Append a buffer to a growable string. */
-static void
-d_print_append_char (struct d_print_info *dpi, int c)
+static inline void
+d_growable_string_append_buffer (struct d_growable_string *dgs,
+ const char *s, size_t l)
{
- if (dpi->buf != NULL)
- {
- if (dpi->len >= dpi->alc)
- {
- d_print_resize (dpi, 1);
- if (dpi->buf == NULL)
- return;
- }
+ size_t need;
- dpi->buf[dpi->len] = c;
- ++dpi->len;
- }
+ need = dgs->len + l + 1;
+ if (need > dgs->alc)
+ d_growable_string_resize (dgs, need);
+
+ if (dgs->allocation_failure)
+ return;
+
+ memcpy (dgs->buf + dgs->len, s, l);
+ dgs->buf[dgs->len + l] = '\0';
+ dgs->len += l;
}
-/* Append a buffer to the print buffer. */
+/* Bridge growable strings to the callback mechanism. */
static void
-d_print_append_buffer (struct d_print_info *dpi, const char *s, size_t l)
+d_growable_string_callback_adapter (const char *s, size_t l, void *opaque)
{
- if (dpi->buf != NULL)
- {
- if (dpi->len + l > dpi->alc)
- {
- d_print_resize (dpi, l);
- if (dpi->buf == NULL)
- return;
- }
+ struct d_growable_string *dgs = (struct d_growable_string*) opaque;
- memcpy (dpi->buf + dpi->len, s, l);
- dpi->len += l;
- }
+ d_growable_string_append_buffer (dgs, s, l);
}
-/* Indicate that an error occurred during printing. */
+/* Initialize a print information structure. */
static void
+d_print_init (struct d_print_info *dpi, int options,
+ demangle_callbackref callback, void *opaque)
+{
+ dpi->options = options;
+ dpi->len = 0;
+ dpi->last_char = '\0';
+ dpi->templates = NULL;
+ dpi->modifiers = NULL;
+
+ dpi->callback = callback;
+ dpi->opaque = opaque;
+
+ dpi->demangle_failure = 0;
+}
+
+/* Indicate that an error occurred during printing, and test for error. */
+
+static inline void
d_print_error (struct d_print_info *dpi)
{
- free (dpi->buf);
- dpi->buf = NULL;
+ dpi->demangle_failure = 1;
+}
+
+static inline int
+d_print_saw_error (struct d_print_info *dpi)
+{
+ return dpi->demangle_failure != 0;
+}
+
+/* Flush buffered characters to the callback. */
+
+static inline void
+d_print_flush (struct d_print_info *dpi)
+{
+ dpi->buf[dpi->len] = '\0';
+ dpi->callback (dpi->buf, dpi->len, dpi->opaque);
+ dpi->len = 0;
+}
+
+/* Append characters and buffers for printing. */
+
+static inline void
+d_append_char (struct d_print_info *dpi, char c)
+{
+ if (dpi->len == sizeof (dpi->buf) - 1)
+ d_print_flush (dpi);
+
+ dpi->buf[dpi->len++] = c;
+ dpi->last_char = c;
+}
+
+static inline void
+d_append_buffer (struct d_print_info *dpi, const char *s, size_t l)
+{
+ size_t i;
+
+ for (i = 0; i < l; i++)
+ d_append_char (dpi, s[i]);
+}
+
+static inline void
+d_append_string (struct d_print_info *dpi, const char *s)
+{
+ d_append_buffer (dpi, s, strlen (s));
+}
+
+static inline char
+d_last_char (struct d_print_info *dpi)
+{
+ return dpi->last_char;
+}
+
+/* Turn components into a human readable string. OPTIONS is the
+ options bits passed to the demangler. DC is the tree to print.
+ CALLBACK is a function to call to flush demangled string segments
+ as they fill the intermediate buffer, and OPAQUE is a generalized
+ callback argument. On success, this returns 1. On failure,
+ it returns 0, indicating a bad parse. It does not use heap
+ memory to build an output string, so cannot encounter memory
+ allocation failure. */
+
+CP_STATIC_IF_GLIBCPP_V3
+int
+cplus_demangle_print_callback (int options,
+ const struct demangle_component *dc,
+ demangle_callbackref callback, void *opaque)
+{
+ struct d_print_info dpi;
+
+ d_print_init (&dpi, options, callback, opaque);
+
+ d_print_comp (&dpi, dc);
+
+ d_print_flush (&dpi);
+
+ return ! d_print_saw_error (&dpi);
}
/* Turn components into a human readable string. OPTIONS is the
@@ -2646,34 +2825,21 @@ char *
cplus_demangle_print (int options, const struct demangle_component *dc,
int estimate, size_t *palc)
{
- struct d_print_info dpi;
+ struct d_growable_string dgs;
- dpi.options = options;
+ d_growable_string_init (&dgs, estimate);
- dpi.alc = estimate + 1;
- dpi.buf = (char *) malloc (dpi.alc);
- if (dpi.buf == NULL)
+ if (! cplus_demangle_print_callback (options, dc,
+ d_growable_string_callback_adapter,
+ &dgs))
{
- *palc = 1;
+ free (dgs.buf);
+ *palc = 0;
return NULL;
}
- dpi.len = 0;
- dpi.templates = NULL;
- dpi.modifiers = NULL;
-
- dpi.allocation_failure = 0;
-
- d_print_comp (&dpi, dc);
-
- d_append_char (&dpi, '\0');
-
- if (dpi.buf != NULL)
- *palc = dpi.alc;
- else
- *palc = dpi.allocation_failure;
-
- return dpi.buf;
+ *palc = dgs.allocation_failure ? 1 : dgs.alc;
+ return dgs.buf;
}
/* Subroutine to handle components. */
@@ -2703,7 +2869,7 @@ d_print_comp (struct d_print_info *dpi,
case DEMANGLE_COMPONENT_LOCAL_NAME:
d_print_comp (dpi, d_left (dc));
if ((dpi->options & DMGL_JAVA) == 0)
- d_append_string_constant (dpi, "::");
+ d_append_string (dpi, "::");
else
d_append_char (dpi, '.');
d_print_comp (dpi, d_right (dc));
@@ -2812,6 +2978,7 @@ d_print_comp (struct d_print_info *dpi,
case DEMANGLE_COMPONENT_TEMPLATE:
{
struct d_print_mod *hold_dpm;
+ struct demangle_component *dcl;
/* Don't push modifiers into a template definition. Doing so
could give the wrong definition for a template argument.
@@ -2820,16 +2987,32 @@ d_print_comp (struct d_print_info *dpi,
hold_dpm = dpi->modifiers;
dpi->modifiers = NULL;
- d_print_comp (dpi, d_left (dc));
- if (d_last_char (dpi) == '<')
- d_append_char (dpi, ' ');
- d_append_char (dpi, '<');
- d_print_comp (dpi, d_right (dc));
- /* Avoid generating two consecutive '>' characters, to avoid
- the C++ syntactic ambiguity. */
- if (d_last_char (dpi) == '>')
- d_append_char (dpi, ' ');
- d_append_char (dpi, '>');
+ dcl = d_left (dc);
+
+ if ((dpi->options & DMGL_JAVA) != 0
+ && dcl->type == DEMANGLE_COMPONENT_NAME
+ && dcl->u.s_name.len == 6
+ && strncmp (dcl->u.s_name.s, "JArray", 6) == 0)
+ {
+ /* Special-case Java arrays, so that JArray<TYPE> appears
+ instead as TYPE[]. */
+
+ d_print_comp (dpi, d_right (dc));
+ d_append_string (dpi, "[]");
+ }
+ else
+ {
+ d_print_comp (dpi, dcl);
+ if (d_last_char (dpi) == '<')
+ d_append_char (dpi, ' ');
+ d_append_char (dpi, '<');
+ d_print_comp (dpi, d_right (dc));
+ /* Avoid generating two consecutive '>' characters, to avoid
+ the C++ syntactic ambiguity. */
+ if (d_last_char (dpi) == '>')
+ d_append_char (dpi, ' ');
+ d_append_char (dpi, '>');
+ }
dpi->modifiers = hold_dpm;
@@ -2892,69 +3075,69 @@ d_print_comp (struct d_print_info *dpi,
return;
case DEMANGLE_COMPONENT_VTABLE:
- d_append_string_constant (dpi, "vtable for ");
+ d_append_string (dpi, "vtable for ");
d_print_comp (dpi, d_left (dc));
return;
case DEMANGLE_COMPONENT_VTT:
- d_append_string_constant (dpi, "VTT for ");
+ d_append_string (dpi, "VTT for ");
d_print_comp (dpi, d_left (dc));
return;
case DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE:
- d_append_string_constant (dpi, "construction vtable for ");
+ d_append_string (dpi, "construction vtable for ");
d_print_comp (dpi, d_left (dc));
- d_append_string_constant (dpi, "-in-");
+ d_append_string (dpi, "-in-");
d_print_comp (dpi, d_right (dc));
return;
case DEMANGLE_COMPONENT_TYPEINFO:
- d_append_string_constant (dpi, "typeinfo for ");
+ d_append_string (dpi, "typeinfo for ");
d_print_comp (dpi, d_left (dc));
return;
case DEMANGLE_COMPONENT_TYPEINFO_NAME:
- d_append_string_constant (dpi, "typeinfo name for ");
+ d_append_string (dpi, "typeinfo name for ");
d_print_comp (dpi, d_left (dc));
return;
case DEMANGLE_COMPONENT_TYPEINFO_FN:
- d_append_string_constant (dpi, "typeinfo fn for ");
+ d_append_string (dpi, "typeinfo fn for ");
d_print_comp (dpi, d_left (dc));
return;
case DEMANGLE_COMPONENT_THUNK:
- d_append_string_constant (dpi, "non-virtual thunk to ");
+ d_append_string (dpi, "non-virtual thunk to ");
d_print_comp (dpi, d_left (dc));
return;
case DEMANGLE_COMPONENT_VIRTUAL_THUNK:
- d_append_string_constant (dpi, "virtual thunk to ");
+ d_append_string (dpi, "virtual thunk to ");
d_print_comp (dpi, d_left (dc));
return;
case DEMANGLE_COMPONENT_COVARIANT_THUNK:
- d_append_string_constant (dpi, "covariant return thunk to ");
+ d_append_string (dpi, "covariant return thunk to ");
d_print_comp (dpi, d_left (dc));
return;
case DEMANGLE_COMPONENT_JAVA_CLASS:
- d_append_string_constant (dpi, "java Class for ");
+ d_append_string (dpi, "java Class for ");
d_print_comp (dpi, d_left (dc));
return;
case DEMANGLE_COMPONENT_GUARD:
- d_append_string_constant (dpi, "guard variable for ");
+ d_append_string (dpi, "guard variable for ");
d_print_comp (dpi, d_left (dc));
return;
case DEMANGLE_COMPONENT_REFTEMP:
- d_append_string_constant (dpi, "reference temporary for ");
+ d_append_string (dpi, "reference temporary for ");
d_print_comp (dpi, d_left (dc));
return;
case DEMANGLE_COMPONENT_HIDDEN_ALIAS:
- d_append_string_constant (dpi, "hidden alias for ");
+ d_append_string (dpi, "hidden alias for ");
d_print_comp (dpi, d_left (dc));
return;
@@ -3153,7 +3336,7 @@ d_print_comp (struct d_print_info *dpi,
{
d_append_char (dpi, ' ');
d_print_comp (dpi, d_left (dc));
- d_append_string_constant (dpi, "::*");
+ d_append_string (dpi, "::*");
}
dpi->modifiers = dpm.next;
@@ -3166,7 +3349,7 @@ d_print_comp (struct d_print_info *dpi,
d_print_comp (dpi, d_left (dc));
if (d_right (dc) != NULL)
{
- d_append_string_constant (dpi, ", ");
+ d_append_string (dpi, ", ");
d_print_comp (dpi, d_right (dc));
}
return;
@@ -3175,7 +3358,7 @@ d_print_comp (struct d_print_info *dpi,
{
char c;
- d_append_string_constant (dpi, "operator");
+ d_append_string (dpi, "operator");
c = dc->u.s_operator.op->name[0];
if (IS_LOWER (c))
d_append_char (dpi, ' ');
@@ -3185,12 +3368,12 @@ d_print_comp (struct d_print_info *dpi,
}
case DEMANGLE_COMPONENT_EXTENDED_OPERATOR:
- d_append_string_constant (dpi, "operator ");
+ d_append_string (dpi, "operator ");
d_print_comp (dpi, dc->u.s_extended_operator.name);
return;
case DEMANGLE_COMPONENT_CAST:
- d_append_string_constant (dpi, "operator ");
+ d_append_string (dpi, "operator ");
d_print_cast (dpi, dc);
return;
@@ -3225,9 +3408,9 @@ d_print_comp (struct d_print_info *dpi,
d_append_char (dpi, '(');
d_print_comp (dpi, d_left (d_right (dc)));
- d_append_string_constant (dpi, ") ");
+ d_append_string (dpi, ") ");
d_print_expr_op (dpi, d_left (dc));
- d_append_string_constant (dpi, " (");
+ d_append_string (dpi, " (");
d_print_comp (dpi, d_right (d_right (dc)));
d_append_char (dpi, ')');
@@ -3252,11 +3435,11 @@ d_print_comp (struct d_print_info *dpi,
}
d_append_char (dpi, '(');
d_print_comp (dpi, d_left (d_right (dc)));
- d_append_string_constant (dpi, ") ");
+ d_append_string (dpi, ") ");
d_print_expr_op (dpi, d_left (dc));
- d_append_string_constant (dpi, " (");
+ d_append_string (dpi, " (");
d_print_comp (dpi, d_left (d_right (d_right (dc))));
- d_append_string_constant (dpi, ") : (");
+ d_append_string (dpi, ") : (");
d_print_comp (dpi, d_right (d_right (d_right (dc))));
d_append_char (dpi, ')');
return;
@@ -3301,13 +3484,13 @@ d_print_comp (struct d_print_info *dpi,
d_append_char (dpi, 'l');
break;
case D_PRINT_UNSIGNED_LONG:
- d_append_string_constant (dpi, "ul");
+ d_append_string (dpi, "ul");
break;
case D_PRINT_LONG_LONG:
- d_append_string_constant (dpi, "ll");
+ d_append_string (dpi, "ll");
break;
case D_PRINT_UNSIGNED_LONG_LONG:
- d_append_string_constant (dpi, "ull");
+ d_append_string (dpi, "ull");
break;
}
return;
@@ -3322,10 +3505,10 @@ d_print_comp (struct d_print_info *dpi,
switch (d_right (dc)->u.s_name.s[0])
{
case '0':
- d_append_string_constant (dpi, "false");
+ d_append_string (dpi, "false");
return;
case '1':
- d_append_string_constant (dpi, "true");
+ d_append_string (dpi, "true");
return;
default:
break;
@@ -3464,7 +3647,7 @@ d_print_mod_list (struct d_print_info *dpi,
dpi->modifiers = hold_modifiers;
if ((dpi->options & DMGL_JAVA) == 0)
- d_append_string_constant (dpi, "::");
+ d_append_string (dpi, "::");
else
d_append_char (dpi, '.');
@@ -3497,15 +3680,15 @@ d_print_mod (struct d_print_info *dpi,
{
case DEMANGLE_COMPONENT_RESTRICT:
case DEMANGLE_COMPONENT_RESTRICT_THIS:
- d_append_string_constant (dpi, " restrict");
+ d_append_string (dpi, " restrict");
return;
case DEMANGLE_COMPONENT_VOLATILE:
case DEMANGLE_COMPONENT_VOLATILE_THIS:
- d_append_string_constant (dpi, " volatile");
+ d_append_string (dpi, " volatile");
return;
case DEMANGLE_COMPONENT_CONST:
case DEMANGLE_COMPONENT_CONST_THIS:
- d_append_string_constant (dpi, " const");
+ d_append_string (dpi, " const");
return;
case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL:
d_append_char (dpi, ' ');
@@ -3520,16 +3703,16 @@ d_print_mod (struct d_print_info *dpi,
d_append_char (dpi, '&');
return;
case DEMANGLE_COMPONENT_COMPLEX:
- d_append_string_constant (dpi, "complex ");
+ d_append_string (dpi, "complex ");
return;
case DEMANGLE_COMPONENT_IMAGINARY:
- d_append_string_constant (dpi, "imaginary ");
+ d_append_string (dpi, "imaginary ");
return;
case DEMANGLE_COMPONENT_PTRMEM_TYPE:
if (d_last_char (dpi) != '(')
d_append_char (dpi, ' ');
d_print_comp (dpi, d_left (mod));
- d_append_string_constant (dpi, "::*");
+ d_append_string (dpi, "::*");
return;
case DEMANGLE_COMPONENT_TYPED_NAME:
d_print_comp (dpi, d_left (mod));
@@ -3662,7 +3845,7 @@ d_print_array_type (struct d_print_info *dpi,
}
if (need_paren)
- d_append_string_constant (dpi, " (");
+ d_append_string (dpi, " (");
d_print_mod_list (dpi, mods, 0);
@@ -3768,26 +3951,19 @@ cplus_demangle_init_info (const char *mangled, int options, size_t len,
di->expansion = 0;
}
-/* Entry point for the demangler. If MANGLED is a g++ v3 ABI mangled
- name, return a buffer allocated with malloc holding the demangled
- name. OPTIONS is the usual libiberty demangler options. On
- success, this sets *PALC to the allocated size of the returned
- buffer. On failure, this sets *PALC to 0 for a bad name, or 1 for
- a memory allocation failure. On failure, this returns NULL. */
+/* Internal implementation for the demangler. If MANGLED is a g++ v3 ABI
+ mangled name, return strings in repeated callback giving the demangled
+ name. OPTIONS is the usual libiberty demangler options. On success,
+ this returns 1. On failure, returns 0. */
-static char *
-d_demangle (const char* mangled, int options, size_t *palc)
+static int
+d_demangle_callback (const char *mangled, int options,
+ demangle_callbackref callback, void *opaque)
{
- size_t len;
int type;
struct d_info di;
struct demangle_component *dc;
- int estimate;
- char *ret;
-
- *palc = 0;
-
- len = strlen (mangled);
+ int status;
if (mangled[0] == '_' && mangled[1] == 'Z')
type = 0;
@@ -3796,57 +3972,41 @@ d_demangle (const char* mangled, int options, size_t *palc)
&& (mangled[9] == 'D' || mangled[9] == 'I')
&& mangled[10] == '_')
{
- char *r;
+ const char *intro;
- r = (char *) malloc (40 + len - 11);
- if (r == NULL)
- *palc = 1;
- else
- {
- if (mangled[9] == 'I')
- strcpy (r, "global constructors keyed to ");
- else
- strcpy (r, "global destructors keyed to ");
- strcat (r, mangled + 11);
- }
- return r;
+ intro = (mangled[9] == 'I')
+ ? "global constructors keyed to "
+ : "global destructors keyed to ";
+
+ callback (intro, strlen (intro), opaque);
+ callback (mangled + 11, strlen (mangled + 11), opaque);
+ return 1;
}
else
{
if ((options & DMGL_TYPES) == 0)
- return NULL;
+ return 0;
type = 1;
}
- cplus_demangle_init_info (mangled, options, len, &di);
+ cplus_demangle_init_info (mangled, options, strlen (mangled), &di);
{
#ifdef CP_DYNAMIC_ARRAYS
__extension__ struct demangle_component comps[di.num_comps];
__extension__ struct demangle_component *subs[di.num_subs];
- di.comps = &comps[0];
- di.subs = &subs[0];
+ di.comps = comps;
+ di.subs = subs;
#else
- di.comps = ((struct demangle_component *)
- malloc (di.num_comps * sizeof (struct demangle_component)));
- di.subs = ((struct demangle_component **)
- malloc (di.num_subs * sizeof (struct demangle_component *)));
- if (di.comps == NULL || di.subs == NULL)
- {
- if (di.comps != NULL)
- free (di.comps);
- if (di.subs != NULL)
- free (di.subs);
- *palc = 1;
- return NULL;
- }
+ di.comps = alloca (di.num_comps * sizeof (*di.comps));
+ di.subs = alloca (di.num_subs * sizeof (*di.subs));
#endif
- if (! type)
- dc = cplus_demangle_mangled_name (&di, 1);
- else
+ if (type)
dc = cplus_demangle_type (&di);
+ else
+ dc = cplus_demangle_mangled_name (&di, 1);
/* If DMGL_PARAMS is set, then if we didn't consume the entire
mangled string, then we didn't successfully demangle it. If
@@ -3856,46 +4016,43 @@ d_demangle (const char* mangled, int options, size_t *palc)
dc = NULL;
#ifdef CP_DEMANGLE_DEBUG
- if (dc == NULL)
- printf ("failed demangling\n");
- else
- d_dump (dc, 0);
+ d_dump (dc, 0);
#endif
- /* We try to guess the length of the demangled string, to minimize
- calls to realloc during demangling. */
- estimate = len + di.expansion + 10 * di.did_subs;
- estimate += estimate / 8;
+ status = (dc != NULL)
+ ? cplus_demangle_print_callback (options, dc, callback, opaque)
+ : 0;
+ }
- ret = NULL;
- if (dc != NULL)
- ret = cplus_demangle_print (options, dc, estimate, palc);
+ return status;
+}
-#ifndef CP_DYNAMIC_ARRAYS
- free (di.comps);
- free (di.subs);
-#endif
+/* Entry point for the demangler. If MANGLED is a g++ v3 ABI mangled
+ name, return a buffer allocated with malloc holding the demangled
+ name. OPTIONS is the usual libiberty demangler options. On
+ success, this sets *PALC to the allocated size of the returned
+ buffer. On failure, this sets *PALC to 0 for a bad name, or 1 for
+ a memory allocation failure, and returns NULL. */
-#ifdef CP_DEMANGLE_DEBUG
- if (ret != NULL)
- {
- int rlen;
-
- rlen = strlen (ret);
- if (rlen > 2 * estimate)
- printf ("*** Length %d much greater than estimate %d\n",
- rlen, estimate);
- else if (rlen > estimate)
- printf ("*** Length %d greater than estimate %d\n",
- rlen, estimate);
- else if (rlen < estimate / 2)
- printf ("*** Length %d much less than estimate %d\n",
- rlen, estimate);
- }
-#endif
- }
+static char *
+d_demangle (const char *mangled, int options, size_t *palc)
+{
+ struct d_growable_string dgs;
+ int status;
- return ret;
+ d_growable_string_init (&dgs, 0);
+
+ status = d_demangle_callback (mangled, options,
+ d_growable_string_callback_adapter, &dgs);
+ if (status == 0)
+ {
+ free (dgs.buf);
+ *palc = 0;
+ return NULL;
+ }
+
+ *palc = dgs.allocation_failure ? 1 : 0;
+ return dgs.buf;
}
#if defined(IN_LIBGCC2) || defined(IN_GLIBCPP_V3)
@@ -3912,7 +4069,7 @@ extern char *__cxa_demangle (const char *, char *, size_t *, int *);
OUTPUT_BUFFER may instead be NULL; in that case, the demangled name
is placed in a region of memory allocated with malloc.
- If LENGTH is non-NULL, the length of the buffer conaining the
+ If LENGTH is non-NULL, the length of the buffer containing the
demangled name, is placed in *LENGTH.
The return value is a pointer to the start of the NUL-terminated
@@ -3989,6 +4146,48 @@ __cxa_demangle (const char *mangled_name, char *output_buffer,
return demangled;
}
+extern int __gcclibcxx_demangle_callback (const char *,
+ void (*)
+ (const char *, size_t, void *),
+ void *);
+
+/* Alternative, allocationless entry point in the C++ runtime library
+ for performing demangling. MANGLED_NAME is a NUL-terminated character
+ string containing the name to be demangled.
+
+ CALLBACK is a callback function, called with demangled string
+ segments as demangling progresses; it is called at least once,
+ but may be called more than once. OPAQUE is a generalized pointer
+ used as a callback argument.
+
+ The return code is one of the following values, equivalent to
+ the STATUS values of __cxa_demangle() (excluding -1, since this
+ function performs no memory allocations):
+ 0: The demangling operation succeeded.
+ -2: MANGLED_NAME is not a valid name under the C++ ABI mangling rules.
+ -3: One of the arguments is invalid.
+
+ The demangling is performed using the C++ ABI mangling rules, with
+ GNU extensions. */
+
+int
+__gcclibcxx_demangle_callback (const char *mangled_name,
+ void (*callback) (const char *, size_t, void *),
+ void *opaque)
+{
+ int status;
+
+ if (mangled_name == NULL || callback == NULL)
+ return -3;
+
+ status = d_demangle_callback (mangled_name, DMGL_PARAMS | DMGL_TYPES,
+ callback, opaque);
+ if (status == 0)
+ return -2;
+
+ return 0;
+}
+
#else /* ! (IN_LIBGCC2 || IN_GLIBCPP_V3) */
/* Entry point for libiberty demangler. If MANGLED is a g++ v3 ABI
@@ -3996,61 +4195,41 @@ __cxa_demangle (const char *mangled_name, char *output_buffer,
demangled name. Otherwise, return NULL. */
char *
-cplus_demangle_v3 (const char* mangled, int options)
+cplus_demangle_v3 (const char *mangled, int options)
{
size_t alc;
return d_demangle (mangled, options, &alc);
}
+int
+cplus_demangle_v3_callback (const char *mangled, int options,
+ demangle_callbackref callback, void *opaque)
+{
+ return d_demangle_callback (mangled, options, callback, opaque);
+}
+
/* Demangle a Java symbol. Java uses a subset of the V3 ABI C++ mangling
conventions, but the output formatting is a little different.
- This instructs the C++ demangler not to emit pointer characters ("*"), and
- to use Java's namespace separator symbol ("." instead of "::"). It then
- does an additional pass over the demangled output to replace instances
- of JArray<TYPE> with TYPE[]. */
+ This instructs the C++ demangler not to emit pointer characters ("*"), to
+ use Java's namespace separator symbol ("." instead of "::"), and to output
+ JArray<TYPE> as TYPE[]. */
char *
-java_demangle_v3 (const char* mangled)
+java_demangle_v3 (const char *mangled)
{
size_t alc;
- char *demangled;
- int nesting;
- char *from;
- char *to;
- demangled = d_demangle (mangled, DMGL_JAVA | DMGL_PARAMS | DMGL_RET_POSTFIX,
- &alc);
-
- if (demangled == NULL)
- return NULL;
-
- nesting = 0;
- from = demangled;
- to = from;
- while (*from != '\0')
- {
- if (strncmp (from, "JArray<", 7) == 0)
- {
- from += 7;
- ++nesting;
- }
- else if (nesting > 0 && *from == '>')
- {
- while (to > demangled && to[-1] == ' ')
- --to;
- *to++ = '[';
- *to++ = ']';
- --nesting;
- ++from;
- }
- else
- *to++ = *from++;
- }
-
- *to = '\0';
+ return d_demangle (mangled, DMGL_JAVA | DMGL_PARAMS | DMGL_RET_POSTFIX, &alc);
+}
- return demangled;
+int
+java_demangle_v3_callback (const char *mangled,
+ demangle_callbackref callback, void *opaque)
+{
+ return d_demangle_callback (mangled,
+ DMGL_JAVA | DMGL_PARAMS | DMGL_RET_POSTFIX,
+ callback, opaque);
}
#endif /* IN_LIBGCC2 || IN_GLIBCPP_V3 */
@@ -4080,21 +4259,11 @@ is_ctor_or_dtor (const char *mangled,
__extension__ struct demangle_component comps[di.num_comps];
__extension__ struct demangle_component *subs[di.num_subs];
- di.comps = &comps[0];
- di.subs = &subs[0];
+ di.comps = comps;
+ di.subs = subs;
#else
- di.comps = ((struct demangle_component *)
- malloc (di.num_comps * sizeof (struct demangle_component)));
- di.subs = ((struct demangle_component **)
- malloc (di.num_subs * sizeof (struct demangle_component *)));
- if (di.comps == NULL || di.subs == NULL)
- {
- if (di.comps != NULL)
- free (di.comps);
- if (di.subs != NULL)
- free (di.subs);
- return 0;
- }
+ di.comps = alloca (di.num_comps * sizeof (*di.comps));
+ di.subs = alloca (di.num_subs * sizeof (*di.subs));
#endif
dc = cplus_demangle_mangled_name (&di, 1);
@@ -4133,11 +4302,6 @@ is_ctor_or_dtor (const char *mangled,
break;
}
}
-
-#ifndef CP_DYNAMIC_ARRAYS
- free (di.subs);
- free (di.comps);
-#endif
}
return ret;
diff --git a/contrib/binutils/libiberty/cp-demangle.h b/contrib/binutils/libiberty/cp-demangle.h
index 2517a57..8622f29 100644
--- a/contrib/binutils/libiberty/cp-demangle.h
+++ b/contrib/binutils/libiberty/cp-demangle.h
@@ -1,5 +1,5 @@
/* Internal demangler interface for g++ V3 ABI.
- Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
Written by Ian Lance Taylor <ian@wasabisystems.com>.
This file is part of the libiberty library, which is part of GCC.
@@ -123,10 +123,16 @@ struct d_info
int expansion;
};
+/* To avoid running past the ending '\0', don't:
+ - call d_peek_next_char if d_peek_char returned '\0'
+ - call d_advance with an 'i' that is too large
+ - call d_check_char(di, '\0')
+ Everything else is safe. */
#define d_peek_char(di) (*((di)->n))
#define d_peek_next_char(di) ((di)->n[1])
#define d_advance(di, i) ((di)->n += (i))
-#define d_next_char(di) (*((di)->n++))
+#define d_check_char(di, c) (d_peek_char(di) == c ? ((di)->n++, 1) : 0)
+#define d_next_char(di) (d_peek_char(di) == '\0' ? '\0' : *((di)->n++))
#define d_str(di) ((di)->n)
/* Functions and arrays in cp-demangle.c which are referenced by
@@ -137,8 +143,9 @@ struct d_info
#define CP_STATIC_IF_GLIBCPP_V3 extern
#endif
-CP_STATIC_IF_GLIBCPP_V3
-const struct demangle_operator_info cplus_demangle_operators[];
+#ifndef IN_GLIBCPP_V3
+extern const struct demangle_operator_info cplus_demangle_operators[];
+#endif
#define D_BUILTIN_TYPE_COUNT (26)
diff --git a/contrib/binutils/libiberty/cplus-dem.c b/contrib/binutils/libiberty/cplus-dem.c
index 8b60434..1f8b1fc 100644
--- a/contrib/binutils/libiberty/cplus-dem.c
+++ b/contrib/binutils/libiberty/cplus-dem.c
@@ -3693,7 +3693,7 @@ demangle_fund_type (struct work_stuff *work,
{
int done = 0;
int success = 1;
- char buf[10];
+ char buf[INTBUF_SIZE + 5 /* 'int%u_t' */];
unsigned int dec = 0;
type_kind_t tk = tk_integral;
diff --git a/contrib/binutils/libiberty/filename_cmp.c b/contrib/binutils/libiberty/filename_cmp.c
new file mode 100644
index 0000000..0a4d0d8
--- /dev/null
+++ b/contrib/binutils/libiberty/filename_cmp.c
@@ -0,0 +1,78 @@
+/* File name comparison routine.
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+ 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include "filenames.h"
+#include "safe-ctype.h"
+
+/*
+
+@deftypefn Extension int filename_cmp (const char *@var{s1}, const char *@var{s2})
+
+Return zero if the two file names @var{s1} and @var{s2} are equivalent.
+If not equivalent, the returned value is similar to what @code{strcmp}
+would return. In other words, it returns a negative value if @var{s1}
+is less than @var{s2}, or a positive value if @var{s2} is greater than
+@var{s2}.
+
+This function does not normalize file names. As a result, this function
+will treat filenames that are spelled differently as different even in
+the case when the two filenames point to the same underlying file.
+However, it does handle the fact that on DOS-like file systems, forward
+and backward slashes are equal.
+
+@end deftypefn
+
+*/
+
+int
+filename_cmp (const char *s1, const char *s2)
+{
+#ifndef HAVE_DOS_BASED_FILE_SYSTEM
+ return strcmp(s1, s2);
+#else
+ for (;;)
+ {
+ int c1 = TOLOWER (*s1);
+ int c2 = TOLOWER (*s2);
+
+ /* On DOS-based file systems, the '/' and the '\' are equivalent. */
+ if (c1 == '/')
+ c1 = '\\';
+ if (c2 == '/')
+ c2 = '\\';
+
+ if (c1 != c2)
+ return (c1 - c2);
+
+ if (c1 == '\0')
+ return 0;
+
+ s1++;
+ s2++;
+ }
+#endif
+}
+
diff --git a/contrib/binutils/libiberty/floatformat.c b/contrib/binutils/libiberty/floatformat.c
index bd31efa..c5abbb1 100644
--- a/contrib/binutils/libiberty/floatformat.c
+++ b/contrib/binutils/libiberty/floatformat.c
@@ -249,53 +249,51 @@ const struct floatformat floatformat_ia64_quad_little =
floatformat_always_valid
};
+
+#ifndef min
+#define min(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
/* Extract a field which starts at START and is LEN bits long. DATA and
TOTAL_LEN are the thing we are extracting it from, in byteorder ORDER. */
static unsigned long
get_field (const unsigned char *data, enum floatformat_byteorders order,
unsigned int total_len, unsigned int start, unsigned int len)
{
- unsigned long result;
+ unsigned long result = 0;
unsigned int cur_byte;
- int cur_bitshift;
+ int lo_bit, hi_bit, cur_bitshift = 0;
+ int nextbyte = (order == floatformat_little) ? 1 : -1;
+
+ /* Start is in big-endian bit order! Fix that first. */
+ start = total_len - (start + len);
/* Start at the least significant part of the field. */
- cur_byte = (start + len) / FLOATFORMAT_CHAR_BIT;
if (order == floatformat_little)
- cur_byte = (total_len / FLOATFORMAT_CHAR_BIT) - cur_byte - 1;
- cur_bitshift =
- ((start + len) % FLOATFORMAT_CHAR_BIT) - FLOATFORMAT_CHAR_BIT;
- result = *(data + cur_byte) >> (-cur_bitshift);
- cur_bitshift += FLOATFORMAT_CHAR_BIT;
- if (order == floatformat_little)
- ++cur_byte;
+ cur_byte = start / FLOATFORMAT_CHAR_BIT;
else
- --cur_byte;
+ cur_byte = (total_len - start - 1) / FLOATFORMAT_CHAR_BIT;
- /* Move towards the most significant part of the field. */
- while ((unsigned int) cur_bitshift < len)
+ lo_bit = start % FLOATFORMAT_CHAR_BIT;
+ hi_bit = min (lo_bit + len, FLOATFORMAT_CHAR_BIT);
+
+ do
{
- if (len - cur_bitshift < FLOATFORMAT_CHAR_BIT)
- /* This is the last byte; zero out the bits which are not part of
- this field. */
- result |=
- (*(data + cur_byte) & ((1 << (len - cur_bitshift)) - 1))
- << cur_bitshift;
- else
- result |= *(data + cur_byte) << cur_bitshift;
- cur_bitshift += FLOATFORMAT_CHAR_BIT;
- if (order == floatformat_little)
- ++cur_byte;
- else
- --cur_byte;
+ unsigned int shifted = *(data + cur_byte) >> lo_bit;
+ unsigned int bits = hi_bit - lo_bit;
+ unsigned int mask = (1 << bits) - 1;
+ result |= (shifted & mask) << cur_bitshift;
+ len -= bits;
+ cur_bitshift += bits;
+ cur_byte += nextbyte;
+ lo_bit = 0;
+ hi_bit = min (len, FLOATFORMAT_CHAR_BIT);
}
+ while (len != 0);
+
return result;
}
-#ifndef min
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
/* Convert from FMT to a double.
FROM is the address of the extended float.
Store the double in *TO. */
@@ -394,7 +392,7 @@ floatformat_to_double (const struct floatformat *fmt,
/* Handle denormalized numbers. FIXME: What should we do for
non-IEEE formats? */
- if (exponent == 0 && mant != 0)
+ if (special_exponent && exponent == 0 && mant != 0)
dto += ldexp ((double)mant,
(- fmt->exp_bias
- mant_bits
@@ -428,43 +426,34 @@ put_field (unsigned char *data, enum floatformat_byteorders order,
unsigned long stuff_to_put)
{
unsigned int cur_byte;
- int cur_bitshift;
+ int lo_bit, hi_bit;
+ int nextbyte = (order == floatformat_little) ? 1 : -1;
+
+ /* Start is in big-endian bit order! Fix that first. */
+ start = total_len - (start + len);
/* Start at the least significant part of the field. */
- cur_byte = (start + len) / FLOATFORMAT_CHAR_BIT;
- if (order == floatformat_little)
- cur_byte = (total_len / FLOATFORMAT_CHAR_BIT) - cur_byte - 1;
- cur_bitshift =
- ((start + len) % FLOATFORMAT_CHAR_BIT) - FLOATFORMAT_CHAR_BIT;
- *(data + cur_byte) &=
- ~(((1 << ((start + len) % FLOATFORMAT_CHAR_BIT)) - 1) << (-cur_bitshift));
- *(data + cur_byte) |=
- (stuff_to_put & ((1 << FLOATFORMAT_CHAR_BIT) - 1)) << (-cur_bitshift);
- cur_bitshift += FLOATFORMAT_CHAR_BIT;
if (order == floatformat_little)
- ++cur_byte;
+ cur_byte = start / FLOATFORMAT_CHAR_BIT;
else
- --cur_byte;
+ cur_byte = (total_len - start - 1) / FLOATFORMAT_CHAR_BIT;
- /* Move towards the most significant part of the field. */
- while ((unsigned int) cur_bitshift < len)
+ lo_bit = start % FLOATFORMAT_CHAR_BIT;
+ hi_bit = min (lo_bit + len, FLOATFORMAT_CHAR_BIT);
+
+ do
{
- if (len - cur_bitshift < FLOATFORMAT_CHAR_BIT)
- {
- /* This is the last byte. */
- *(data + cur_byte) &=
- ~((1 << (len - cur_bitshift)) - 1);
- *(data + cur_byte) |= (stuff_to_put >> cur_bitshift);
- }
- else
- *(data + cur_byte) = ((stuff_to_put >> cur_bitshift)
- & ((1 << FLOATFORMAT_CHAR_BIT) - 1));
- cur_bitshift += FLOATFORMAT_CHAR_BIT;
- if (order == floatformat_little)
- ++cur_byte;
- else
- --cur_byte;
+ unsigned char *byte_ptr = data + cur_byte;
+ unsigned int bits = hi_bit - lo_bit;
+ unsigned int mask = ((1 << bits) - 1) << lo_bit;
+ *byte_ptr = (*byte_ptr & ~mask) | ((stuff_to_put << lo_bit) & mask);
+ stuff_to_put >>= bits;
+ len -= bits;
+ cur_byte += nextbyte;
+ lo_bit = 0;
+ hi_bit = min (len, FLOATFORMAT_CHAR_BIT);
}
+ while (len != 0);
}
/* The converse: convert the double *FROM to an extended float
diff --git a/contrib/binutils/libiberty/functions.texi b/contrib/binutils/libiberty/functions.texi
index fa92d70..fd3e8e7 100644
--- a/contrib/binutils/libiberty/functions.texi
+++ b/contrib/binutils/libiberty/functions.texi
@@ -153,7 +153,7 @@ find one. The current directory is chosen if all else fails so the
program is exited if a temporary directory can't be found (@code{mktemp}
fails). The buffer for the result is obtained with @code{xmalloc}.
-This function is provided for backwards compatability only. Its use is
+This function is provided for backwards compatibility only. Its use is
not recommended.
@end deftypefn
@@ -268,6 +268,22 @@ value 1). If @var{valu} is zero, zero is returned.
@end deftypefn
+@c filename_cmp.c:28
+@deftypefn Extension int filename_cmp (const char *@var{s1}, const char *@var{s2})
+
+Return zero if the two paths @var{s1} and @var{s2} are equivalent.
+If not equivalent, the returned value is similar to what strcmp would
+return. In other words, it returns a negative value if @var{s1} is less
+than @var{s2}, or a positive value if @var{s2} is greater than @var{s2}.
+
+This function does not normalize path names. As a result, this function
+will treat filenames that are spelled differently as different even in
+the case when the two filenames point to the same underlying file.
+However, it does handle the fact that on DOS-like file systems, forward
+and backward slashes are equal.
+
+@end deftypefn
+
@c fnmatch.txh:1
@deftypefn Replacement int fnmatch (const char *@var{pattern}, const char *@var{string}, int @var{flags})
@@ -420,7 +436,7 @@ or zero if it is not. Note that the value you pass will be cast to
@deftypefn Extension {unsigned int} hex_value (int @var{c})
Returns the numeric equivalent of the given character when interpreted
-as a hexidecimal digit. The result is undefined if you pass an
+as a hexadecimal digit. The result is undefined if you pass an
invalid hex digit. Note that the value you pass will be cast to
@code{unsigned char} within the macro.
@@ -650,7 +666,7 @@ Sets the first @var{count} bytes of @var{s} to the constant byte
@end deftypefn
-@c mkstemps.c:54
+@c mkstemps.c:58
@deftypefn Replacement int mkstemps (char *@var{pattern}, int @var{suffix_len})
Generate a unique temporary file name from @var{pattern}.
@@ -668,14 +684,14 @@ reading and writing.
@end deftypefn
-@c pexecute.txh:231
+@c pexecute.txh:266
@deftypefn Extension void pex_free (struct pex_obj @var{obj})
Clean up and free all data associated with @var{obj}.
@end deftypefn
-@c pexecute.txh:206
+@c pexecute.txh:241
@deftypefn Extension int pex_get_status (struct pex_obj *@var{obj}, int @var{count}, int *@var{vector})
Returns the exit status of all programs run using @var{obj}.
@@ -685,7 +701,7 @@ to @code{pex_run}. Returns 0 on error, 1 on success.
@end deftypefn
-@c pexecute.txh:215
+@c pexecute.txh:250
@deftypefn Extension int pex_get_times (struct pex_obj *@var{obj}, int @var{count}, struct pex_time *@var{vector})
Returns the process execution times of all programs run using
@@ -734,7 +750,7 @@ temporary files; it may be @code{NULL} to use a randomly chosen name.
@end deftypefn
-@c pexecute.txh:133
+@c pexecute.txh:155
@deftypefn Extension {FILE *} pex_input_file (struct pex_obj *@var{obj}, int @var{flags}, const char *@var{in_name})
Return a stream for a temporary file to pass to the first program in
@@ -752,7 +768,7 @@ binary mode; otherwise, open it in the default mode. Including
@code{PEX_BINARY_OUTPUT} in @var{flags} has no effect on Unix.
@end deftypefn
-@c pexecute.txh:150
+@c pexecute.txh:172
@deftypefn Extension {FILE *} pex_input_pipe (struct pex_obj *@var{obj}, int @var{binary})
Return a stream @var{fp} for a pipe connected to the standard input of
@@ -797,7 +813,7 @@ the output pipe is you, but you are blocked on the input pipe.
@end deftypefn
-@c pexecute.txh:237
+@c pexecute.txh:272
@deftypefn Extension {const char *} pex_one (int @var{flags}, const char *@var{executable}, char * const *@var{argv}, const char *@var{pname}, const char *@var{outname}, const char *@var{errname}, int *@var{status}, int *@var{err})
An interface to permit the easy execution of a
@@ -810,7 +826,20 @@ be set to the exit status of the program.
@end deftypefn
-@c pexecute.txh:194
+@c pexecute.txh:228
+@deftypefn Extension {FILE *} pex_read_err (struct pex_obj *@var{obj}, int @var{binary})
+
+Returns a @code{FILE} pointer which may be used to read the standard
+error of the last program in the pipeline. When this is used,
+@code{PEX_LAST} should not be used in a call to @code{pex_run}. After
+this is called, @code{pex_run} may no longer be called with the same
+@var{obj}. @var{binary} should be non-zero if the file should be
+opened in binary mode. Don't call @code{fclose} on the returned file;
+it will be closed by @code{pex_free}.
+
+@end deftypefn
+
+@c pexecute.txh:216
@deftypefn Extension {FILE *} pex_read_output (struct pex_obj *@var{obj}, int @var{binary})
Returns a @code{FILE} pointer which may be used to read the standard
@@ -861,14 +890,23 @@ Send the program's standard error to standard output, if possible.
@vindex PEX_BINARY_INPUT
@vindex PEX_BINARY_OUTPUT
+@vindex PEX_BINARY_ERROR
@item PEX_BINARY_INPUT
@itemx PEX_BINARY_OUTPUT
-The standard input (output) of the program should be read (written) in
+@itemx PEX_BINARY_ERROR
+The standard input (output or error) of the program should be read (written) in
binary mode rather than text mode. These flags are ignored on systems
which do not distinguish binary mode and text mode, such as Unix. For
proper behavior these flags should match appropriately---a call to
@code{pex_run} using @code{PEX_BINARY_OUTPUT} should be followed by a
call using @code{PEX_BINARY_INPUT}.
+
+@vindex PEX_STDERR_TO_PIPE
+@item PEX_STDERR_TO_PIPE
+Send the program's standard error to a pipe, if possible. This flag
+cannot be specified together with @code{PEX_STDERR_TO_STDOUT}. This
+flag can be specified only on the last program in pipeline.
+
@end table
@var{executable} is the program to execute. @var{argv} is the set of
@@ -924,8 +962,22 @@ value, or to 0 if there is no relevant @code{errno}.
@end deftypefn
-@c pexecute.txh:249
-@deftypefn Extension int pexecute (const char *@var{program}, char * const *@var{argv}, const char *@var{this_pname}, const char *@var{temp_base}, char **@var{errmsg_fmt}, char **@var{errmsg_arg}, int flags)
+@c pexecute.txh:142
+@deftypefn Extension {const char *} pex_run_in_environment (struct pex_obj *@var{obj}, int @var{flags}, const char *@var{executable}, char * const *@var{argv}, char * const *@var{env}, int @var{env_size}, const char *@var{outname}, const char *@var{errname}, int *@var{err})
+
+Execute one program in a pipeline, permitting the environment for the
+program to be specified. Behaviour and parameters not listed below are
+as for @code{pex_run}.
+
+@var{env} is the environment for the child process, specified as an array of
+character pointers. Each element of the array should point to a string of the
+form @code{VAR=VALUE}, with the exception of the last element that must be
+@code{NULL}.
+
+@end deftypefn
+
+@c pexecute.txh:284
+@deftypefn Extension int pexecute (const char *@var{program}, char * const *@var{argv}, const char *@var{this_pname}, const char *@var{temp_base}, char **@var{errmsg_fmt}, char **@var{errmsg_arg}, int @var{flags})
This is the old interface to execute one or more programs. It is
still supported for compatibility purposes, but is no longer
@@ -934,7 +986,7 @@ documented.
@end deftypefn
@c strsignal.c:539
-@deftypefn Supplemental void psignal (unsigned @var{signo}, char *@var{message})
+@deftypefn Supplemental void psignal (int @var{signo}, char *@var{message})
Print @var{message} to the standard error, followed by a colon,
followed by the description of the signal specified by @var{signo},
@@ -952,7 +1004,7 @@ name is unset/removed.
@end deftypefn
-@c pexecute.txh:257
+@c pexecute.txh:292
@deftypefn Extension int pwait (int @var{pid}, int *@var{status}, int @var{flags})
Another part of the old execution interface.
diff --git a/contrib/binutils/libiberty/hashtab.c b/contrib/binutils/libiberty/hashtab.c
index a5671a0..bf34a6d 100644
--- a/contrib/binutils/libiberty/hashtab.c
+++ b/contrib/binutils/libiberty/hashtab.c
@@ -421,7 +421,28 @@ htab_empty (htab_t htab)
if (entries[i] != HTAB_EMPTY_ENTRY && entries[i] != HTAB_DELETED_ENTRY)
(*htab->del_f) (entries[i]);
- memset (entries, 0, size * sizeof (PTR));
+ /* Instead of clearing megabyte, downsize the table. */
+ if (size > 1024*1024 / sizeof (PTR))
+ {
+ int nindex = higher_prime_index (1024 / sizeof (PTR));
+ int nsize = prime_tab[nindex].prime;
+
+ if (htab->free_f != NULL)
+ (*htab->free_f) (htab->entries);
+ else if (htab->free_with_arg_f != NULL)
+ (*htab->free_with_arg_f) (htab->alloc_arg, htab->entries);
+ if (htab->alloc_with_arg_f != NULL)
+ htab->entries = (PTR *) (*htab->alloc_with_arg_f) (htab->alloc_arg, nsize,
+ sizeof (PTR *));
+ else
+ htab->entries = (PTR *) (*htab->alloc_f) (nsize, sizeof (PTR *));
+ htab->size = nsize;
+ htab->size_prime_index = nindex;
+ }
+ else
+ memset (entries, 0, size * sizeof (PTR));
+ htab->n_deleted = 0;
+ htab->n_elements = 0;
}
/* Similar to htab_find_slot, but without several unwanted side effects:
diff --git a/contrib/binutils/libiberty/hex.c b/contrib/binutils/libiberty/hex.c
index 86ba0b5..5eeafdb 100644
--- a/contrib/binutils/libiberty/hex.c
+++ b/contrib/binutils/libiberty/hex.c
@@ -50,7 +50,7 @@ or zero if it is not. Note that the value you pass will be cast to
@deftypefn Extension {unsigned int} hex_value (int @var{c})
Returns the numeric equivalent of the given character when interpreted
-as a hexidecimal digit. The result is undefined if you pass an
+as a hexadecimal digit. The result is undefined if you pass an
invalid hex digit. Note that the value you pass will be cast to
@code{unsigned char} within the macro.
diff --git a/contrib/binutils/libiberty/make-relative-prefix.c b/contrib/binutils/libiberty/make-relative-prefix.c
index 66ddcaa..037809e 100644
--- a/contrib/binutils/libiberty/make-relative-prefix.c
+++ b/contrib/binutils/libiberty/make-relative-prefix.c
@@ -1,6 +1,6 @@
/* Relative (relocatable) prefix support.
Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2006 Free Software Foundation, Inc.
This file is part of libiberty.
@@ -217,9 +217,9 @@ free_split_directories (char **dirs)
If no relative prefix can be found, return NULL. */
-char *
-make_relative_prefix (const char *progname,
- const char *bin_prefix, const char *prefix)
+static char *
+make_relative_prefix_1 (const char *progname, const char *bin_prefix,
+ const char *prefix, const int resolve_links)
{
char **prog_dirs, **bin_dirs, **prefix_dirs;
int prog_num, bin_num, prefix_num;
@@ -289,9 +289,14 @@ make_relative_prefix (const char *progname,
}
}
- full_progname = lrealpath (progname);
- if (full_progname == NULL)
- return NULL;
+ if ( resolve_links )
+ {
+ full_progname = lrealpath (progname);
+ if (full_progname == NULL)
+ return NULL;
+ }
+ else
+ full_progname = strdup(progname);
prog_dirs = split_directories (full_progname, &prog_num);
bin_dirs = split_directories (bin_prefix, &bin_num);
@@ -387,3 +392,30 @@ make_relative_prefix (const char *progname,
return ret;
}
+
+
+/* Do the full job, including symlink resolution.
+ This path will find files installed in the same place as the
+ program even when a soft link has been made to the program
+ from somwhere else. */
+
+char *
+make_relative_prefix (const char *progname, const char *bin_prefix,
+ const char *prefix)
+{
+ return make_relative_prefix_1 (progname, bin_prefix, prefix, 1);
+}
+
+/* Make the relative pathname without attempting to resolve any links.
+ '..' etc may also be left in the pathname.
+ This will find the files the user meant the program to find if the
+ installation is patched together with soft links. */
+
+char *
+make_relative_prefix_ignore_links (const char *progname,
+ const char *bin_prefix,
+ const char *prefix)
+{
+ return make_relative_prefix_1 (progname, bin_prefix, prefix, 0);
+}
+
diff --git a/contrib/binutils/libiberty/mkstemps.c b/contrib/binutils/libiberty/mkstemps.c
index 89b37d9..6c2e472 100644
--- a/contrib/binutils/libiberty/mkstemps.c
+++ b/contrib/binutils/libiberty/mkstemps.c
@@ -49,6 +49,10 @@ typedef unsigned long gcc_uint64_t;
#define TMP_MAX 16384
#endif
+#ifndef O_BINARY
+# define O_BINARY 0
+#endif
+
/*
@deftypefn Replacement int mkstemps (char *@var{pattern}, int @var{suffix_len})
@@ -119,7 +123,7 @@ mkstemps (char *pattern, int suffix_len)
v /= 62;
XXXXXX[5] = letters[v % 62];
- fd = open (pattern, O_RDWR|O_CREAT|O_EXCL, 0600);
+ fd = open (pattern, O_BINARY|O_RDWR|O_CREAT|O_EXCL, 0600);
if (fd >= 0)
/* The file does not exist. */
return fd;
diff --git a/contrib/binutils/libiberty/strsignal.c b/contrib/binutils/libiberty/strsignal.c
index c3a16ab..4ca9e21 100644
--- a/contrib/binutils/libiberty/strsignal.c
+++ b/contrib/binutils/libiberty/strsignal.c
@@ -9,7 +9,7 @@
/* We need to declare sys_siglist, because even if the system provides
it we can't assume that it is declared in <signal.h> (for example,
SunOS provides sys_siglist, but it does not declare it in any
- header file). fHowever, we can't declare sys_siglist portably,
+ header file). However, we can't declare sys_siglist portably,
because on some systems it is declared with const and on some
systems it is declared without const. If we were using autoconf,
we could work out the right declaration. Until, then we just
@@ -536,7 +536,7 @@ strtosigno (const char *name)
/*
-@deftypefn Supplemental void psignal (unsigned @var{signo}, char *@var{message})
+@deftypefn Supplemental void psignal (int @var{signo}, char *@var{message})
Print @var{message} to the standard error, followed by a colon,
followed by the description of the signal specified by @var{signo},
@@ -549,7 +549,7 @@ followed by a newline.
#ifndef HAVE_PSIGNAL
void
-psignal (unsigned signo, char *message)
+psignal (int signo, char *message)
{
if (signal_names == NULL)
{
OpenPOWER on IntegriCloud