summaryrefslogtreecommitdiffstats
path: root/contrib/binutils/libiberty
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2002-01-27 12:00:11 +0000
committerobrien <obrien@FreeBSD.org>2002-01-27 12:00:11 +0000
commit2c76fd68f4fb39c1af5cde1a8eac2bdd7b3f9909 (patch)
treed0fb877bb74b99ef3fc1c560a6340040f60f0392 /contrib/binutils/libiberty
parentea6b809e7d17f67670458d8b26735098ed0ec32a (diff)
parentfc89183cdc6be5afa8deb7250fd15a20832ab528 (diff)
downloadFreeBSD-src-2c76fd68f4fb39c1af5cde1a8eac2bdd7b3f9909.zip
FreeBSD-src-2c76fd68f4fb39c1af5cde1a8eac2bdd7b3f9909.tar.gz
This commit was generated by cvs2svn to compensate for changes in r89857,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'contrib/binutils/libiberty')
-rw-r--r--contrib/binutils/libiberty/ChangeLog656
-rw-r--r--contrib/binutils/libiberty/Makefile.in306
-rw-r--r--contrib/binutils/libiberty/_doprnt.c303
-rw-r--r--contrib/binutils/libiberty/aclocal.m455
-rw-r--r--contrib/binutils/libiberty/alloca.c101
-rw-r--r--contrib/binutils/libiberty/argv.c120
-rw-r--r--contrib/binutils/libiberty/asprintf.c44
-rw-r--r--contrib/binutils/libiberty/atexit.c10
-rw-r--r--contrib/binutils/libiberty/basename.c16
-rw-r--r--contrib/binutils/libiberty/bcmp.c27
-rw-r--r--contrib/binutils/libiberty/bcopy.c16
-rw-r--r--contrib/binutils/libiberty/bsearch.c17
-rw-r--r--contrib/binutils/libiberty/bzero.c14
-rw-r--r--contrib/binutils/libiberty/calloc.c11
-rw-r--r--contrib/binutils/libiberty/choose-temp.c163
-rw-r--r--contrib/binutils/libiberty/clock.c12
-rw-r--r--contrib/binutils/libiberty/concat.c239
-rw-r--r--contrib/binutils/libiberty/config.in48
-rw-r--r--contrib/binutils/libiberty/config.table1
-rwxr-xr-xcontrib/binutils/libiberty/configure878
-rw-r--r--contrib/binutils/libiberty/configure.in115
-rw-r--r--contrib/binutils/libiberty/copying-lib.texi565
-rw-r--r--contrib/binutils/libiberty/copysign.c12
-rw-r--r--contrib/binutils/libiberty/cp-demangle.c348
-rw-r--r--contrib/binutils/libiberty/cplus-dem.c88
-rw-r--r--contrib/binutils/libiberty/fdmatch.c32
-rw-r--r--contrib/binutils/libiberty/ffs.c27
-rw-r--r--contrib/binutils/libiberty/fibheap.c523
-rw-r--r--contrib/binutils/libiberty/floatformat.c54
-rw-r--r--contrib/binutils/libiberty/fnmatch.txh48
-rw-r--r--contrib/binutils/libiberty/functions.texi937
-rw-r--r--contrib/binutils/libiberty/gather-docs128
-rw-r--r--contrib/binutils/libiberty/getcwd.c24
-rw-r--r--contrib/binutils/libiberty/getopt.c2
-rw-r--r--contrib/binutils/libiberty/getpagesize.c18
-rw-r--r--contrib/binutils/libiberty/getpwd.c12
-rw-r--r--contrib/binutils/libiberty/getruntime.c12
-rw-r--r--contrib/binutils/libiberty/hashtab.c112
-rw-r--r--contrib/binutils/libiberty/hex.c100
-rw-r--r--contrib/binutils/libiberty/index.c12
-rw-r--r--contrib/binutils/libiberty/insque.c31
-rw-r--r--contrib/binutils/libiberty/lbasename.c37
-rw-r--r--contrib/binutils/libiberty/libiberty.texi324
-rw-r--r--contrib/binutils/libiberty/maint-tool278
-rw-r--r--contrib/binutils/libiberty/make-temp-file.c179
-rw-r--r--contrib/binutils/libiberty/md5.c136
-rw-r--r--contrib/binutils/libiberty/memchr.c41
-rw-r--r--contrib/binutils/libiberty/memcmp.c17
-rw-r--r--contrib/binutils/libiberty/memcpy.c13
-rw-r--r--contrib/binutils/libiberty/memmove.c12
-rw-r--r--contrib/binutils/libiberty/memset.c11
-rw-r--r--contrib/binutils/libiberty/mkstemps.c27
-rw-r--r--contrib/binutils/libiberty/obstack.c2
-rw-r--r--contrib/binutils/libiberty/obstacks.texi758
-rw-r--r--contrib/binutils/libiberty/partition.c4
-rw-r--r--contrib/binutils/libiberty/pexecute.c81
-rw-r--r--contrib/binutils/libiberty/putenv.c19
-rw-r--r--contrib/binutils/libiberty/random.c18
-rw-r--r--contrib/binutils/libiberty/regex.c8373
-rw-r--r--contrib/binutils/libiberty/rename.c11
-rw-r--r--contrib/binutils/libiberty/rindex.c12
-rw-r--r--contrib/binutils/libiberty/setenv.c24
-rw-r--r--contrib/binutils/libiberty/sigsetmask.c13
-rw-r--r--contrib/binutils/libiberty/spaces.c18
-rw-r--r--contrib/binutils/libiberty/splay-tree.c36
-rw-r--r--contrib/binutils/libiberty/strcasecmp.c12
-rw-r--r--contrib/binutils/libiberty/strchr.c18
-rw-r--r--contrib/binutils/libiberty/strdup.c11
-rw-r--r--contrib/binutils/libiberty/strerror.c125
-rw-r--r--contrib/binutils/libiberty/strncasecmp.c12
-rw-r--r--contrib/binutils/libiberty/strncmp.c11
-rw-r--r--contrib/binutils/libiberty/strrchr.c22
-rw-r--r--contrib/binutils/libiberty/strsignal.c135
-rw-r--r--contrib/binutils/libiberty/strstr.c22
-rw-r--r--contrib/binutils/libiberty/strtod.c15
-rw-r--r--contrib/binutils/libiberty/strtol.c19
-rw-r--r--contrib/binutils/libiberty/ternary.c166
-rw-r--r--contrib/binutils/libiberty/tmpnam.c14
-rw-r--r--contrib/binutils/libiberty/vasprintf.c40
-rw-r--r--contrib/binutils/libiberty/vfork.c10
-rw-r--r--contrib/binutils/libiberty/vprintf.c17
-rw-r--r--contrib/binutils/libiberty/vsprintf.c6
-rw-r--r--contrib/binutils/libiberty/waitpid.c12
-rw-r--r--contrib/binutils/libiberty/xatexit.c14
-rw-r--r--contrib/binutils/libiberty/xexit.c12
-rw-r--r--contrib/binutils/libiberty/xmalloc.c43
-rw-r--r--contrib/binutils/libiberty/xmemdup.c13
-rw-r--r--contrib/binutils/libiberty/xstrdup.c11
-rw-r--r--contrib/binutils/libiberty/xstrerror.c11
89 files changed, 15869 insertions, 1583 deletions
diff --git a/contrib/binutils/libiberty/ChangeLog b/contrib/binutils/libiberty/ChangeLog
index 4b59976..59f48d45 100644
--- a/contrib/binutils/libiberty/ChangeLog
+++ b/contrib/binutils/libiberty/ChangeLog
@@ -1,6 +1,556 @@
-2001-07-19 David O'Brien <obrien@FreeBSD.org>
+2002-01-22 Momchil Velikov <velco@fadata.bg>
+
+ * configure.in (variable detection): Use arrays of unspecified
+ size instead of plain integers.
+
+2002-01-18 DJ Delorie <dj@redhat.com>
+
+ * Makefile.in (TESTLIB): New. This library is for future
+ testsuites.
+ (CFILES, REQUIRED_OFILES, CONFIGURED_OFILES): Re-alphabetize,
+ break down by letter.
+ (REQUIRED_OFILES): List long-to-compile files first.
+ (maint-deps): New, target for updating dependencies.
+ (dependencies): Update.
+ * maint-tool: Add dependency-generating option.
+ * configure.in: Check for _doprnt even if we're not providing it.
+ * configure: Regenerate.
+
+ * _doprnt.c: Modifications to allow compiling on any platform.
+ * copysign.c: Likewise.
+ * putenv.c: Likewise.
+ * setenv.c: Likewise.
+ * vsprintf.c: Likewise.
+
+2002-01-15 Douglas B Rupp <rupp@gnat.com>
+
+ * mkstemps.c (mkstemps): On VMS, open temp file with option
+ that causes it to be deleted when closed.
+
+2002-01-02 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * cp-demangle.c (long_options): Const-ify.
+ * cplus-dem.c (long_options): Likewise.
+
+ * cplus-dem.c (mystrstr): Delete. All callers changed to use
+ strstr instead.
+
+2001-12-31 Ira Ruben <ira@apple.com>
+
+ * aclocal.m4 (libiberty_AC_FUNC_STRNCMP): Use anon mmap as 2nd try.
+ * configure: Regenerated.
+
+2001-12-24 Douglas B. Rupp <rupp@gnat.com>
+
+ * configure.in (uintptr_t): Use AC_CHECK_TYPE.
+ * configure: Regenerated.
+
+2001-12-12 Craig Rodrigues <rodrigc@gcc.gnu.org>
+
+ PR other/2719
+ * cplus-dem.c (consume_count): Treat negative count as an error.
+ * testsuite/demangle-expected: Added testcase.
+
+Tue Dec 11 07:08:57 2001 Douglas B. Rupp <rupp@gnat.com>
+
+ * configure.in: Hardcode that vfork works on VMS host.
+ * configure: Regenerated.
+
+2001-12-06 Richard Henderson <rth@redhat.com>
+
+ * cplus-dem.c (libiberty_demanglers): Add no_demangling case.
+ (cplus_demangle): Support no_demangling.
+
+2001-11-27 Zack Weinberg <zack@codesourcery.com>
+
+ * _doprnt.c: Moved here from gcc/doprint.c. Adjust to build
+ in libiberty context. Fix typo in leading comment.
+ * configure.in: Fix various AC_DEFINEs so autoheader works.
+ If any of vprintf, vsprintf, vfprintf is missing from libc,
+ then AC_REPLACE_FUNCS(_doprnt).
+
+2001-11-26 DJ Delorie <dj@redhat.com>
+ Daniel Jacobowitz <drow@mvista.com>
+
+ * Makefile.in (stamp-h): Depend on Makefile for proper
+ serialization.
+ (*-subdir): Depend on config.h for proper serialization.
+
+2001-11-26 DJ Delorie <dj@redhat.com>
+
+ * configure.in: Check for alloca.h (for regex.c and putenv.c).
+ * configure: Regenerate.
+ * config.h: Add HAVE_ALLOCA_H.
+
+2001-11-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * regex.c: Check defined(__STDC__) || defined(ALMOST_STDC) ||
+ defined(HAVE_STRINGIZE) to determine whether ISO CPP token pasting
+ is available.
+
+Thu Nov 15 11:06:25 2001 Jeffrey A Law (law@cygnus.com)
+
+ * config.in (HAVE_UINTPTR_T): Provide autoconf stub.
+ * configure.in (HAVE_UINTPTR_T): Test for system defining
+ uintptr_t and define HAVE_UINTPTR_T appropriately.
+ * regex.c (uintptr_t): Do not provide a definition if the
+ system provided one.
+
+ * regex.c (PREFIX): Provide an alternate definition for
+ non-ANSI/ISO compilers.
+ (ARG_PREFIX): Likewise.
+
+2001-11-12 Jim Meyering <meyering@lucent.com>
+
+ * obstack.c (_): Honor the setting of ENABLE_NLS. Otherwise,
+ this code would end up calling gettext even in packages built
+ with --disable-nls.
+ * getopt.c (_): Likewise.
+ * regex.c (_): Likewise.
+
+2001-11-03 Alan Modra <amodra@bigpond.net.au>
+
+ * configure.in: Cope with missing makeinfo.
+ * configure: Regenerate.
+
+2001-10-22 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * hex.c (hex_init): Provide empty stub.
+
+ * hex.c (hex_init): Delete.
+ (_hex_value): Const-ify and initialize at compile-time.
+
+2001-10-19 H.J. Lu <hjl@gnu.org>
+
+ * Makefile.in ($(TARGETLIB)): Also generate pic/$(TARGETLIB) if
+ necessary.
+
+2001-10-17 DJ Delorie <dj@redhat.com>
+
+ * argv.c, asprintf.c, choose-temp.c, concat.c, cplus-dem.c,
+ ffs.c, fnmatch.txh, getruntime.c, make-temp-file.c,
+ mkstemps.c, pexecute.c, random.c, strsignal.c, vasprintf.c:
+ Improve manual formatting.
+ * functions.texi: Regenerate.
+
+2001-10-15 DJ Delorie <dj@redhat.com>
+
+ * Makefile.in (TEXIFILES): Add fnmatch.txh.
+ (maint-undoc): New.
+ maint-tool: Add "undoc" tool.
+ * alloca.c, argv.c, asprintf.c, choose-temp.c, concat.c,
+ fdmatch.c, ffs.c, getruntime.c, insque.c, lbasename.c,
+ make-temp-file.c, mkstemps.c, pexecute.c, random.c, spaces.c,
+ strerror.s, strsignal.c, strtol.c, vasprintf.c: Add or update
+ documentation.
+ * fnmatch.txh: New.
+ * functions.texi: Regenerate.
+
+2001-10-10 Joseph S. Myers <jsm28@cam.ac.uk>
+
+ * bcmp.c, setenv.c: Use "nonzero" instead of "non-zero".
+ * strtod.c: Use "ISO C" instead of "ANSI C".
+ * functions.texi: Regenerate.
+
+2001-10-07 Joseph S. Myers <jsm28@cam.ac.uk>
+
+ * alloca.c, clock.c, getcwd.c, getpagesize.c, getpwd.c, index.c,
+ libiberty.texi, memchr.c, putenv.c, rindex.c, strchr.c, strdup.c,
+ strerror.c, strrchr.c, strstr.c, strtod.c, tmpnam.c, vfork.c,
+ xatexit.c, xmalloc.c, xstrerror.c: Improve manual formatting. Fix
+ spelling. Give names to function arguments in documentation. Use
+ (void) prototypes in documentation.
+ * functions.texi: Regenerate.
+
+2001-10-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * argv.c (buildargv, tests, main): Const-ify.
+ * cp-demangle.c (operator_code): Likewise.
+ * cplus-dem.c (optable, libiberty_demanglers,
+ cplus_demangle_set_style, cplus_demangle_name_to_style,
+ print_demangler_list): Likewise.
+ * hashtab.c (higher_prime_number): Likewise.
+ * strcasecmp.c (charmap): Likewise.
+ * strerror.c (error_info, strerror, main): Likewise.
+ * strncasecmp.c (charmap): Likewise.
+ * strsignal.c (signal_info): Likewise.
+
+2001-09-29 DJ Delorie <dj@redhat.com>
+
+ * configure: Regenerate.
+
+2001-09-28 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * concat.c: Include stdlib.h.
+
+2001-09-27 Eli Zaretskii <eliz@is.elta.co.il>
+
+ * libiberty.texi: (Top level): Add syncodeindex pg. Add
+ @dircategory and @direntry directives. Add @finalout.
+ (many nodes): Lose the next,prev,up pointers on the @nide line.
+ (Using, Supplemental Functions, Replacement Functions): Fix
+ markup.
+ (Functions): Move around, to allow makeinfo to build the manual
+ without next,prev,up pointers in thye node lines.
+ (Licenses): Fix typos.
+
+ * index.c, rindex.c, strchr.c, strerror.c, strrchr.c, strstr.c,
+ strtol.c, xatexit.c, xexit.c, xmalloc.c: Fix spelling and markup.
+ * functions.texi: Regenerate.
+
+ * copying-lib.texi: Lose the next,prev,up pointers on the @node
+ line.
+
+2001-09-27 DJ Delorie <dj@redhat.com>
+
+ * configure.in: Don't use in-tree texinfo, because libiberty must
+ be built before it. Check for makeinfo version 4 or higher.
+ * functions.texi: Regenerate.
+
+2001-09-20 DJ Delorie <dj@redhat.com>
+ Phil Edwards <pedwards@disaster.jaj.com>
+
+ * configure.in (MAKEINFO, PERL): Detect these.
+ (--enable-maintainer-mode): Add.
+ * configure: Regenerate.
+ * Makefile.in (MAKEINFO, PERL): Define.
+ (libiberty.info, libiberty.dvi, libiberty.html): New.
+ (CFILES): Add bsearch.c.
+ (CONFIGURED_OFILES): New, list of objects configure might add.
+ (maint-missing, maint-buildall): New, for maintainers only.
+ (clean, mostlyclean): Add info/dvi/html files.
+ * libiberty.texi, copying-lib.texi, obstacks.texi, functions.texi: New.
+ * gather-docs: New, for maintainers.
+ * maint-tool: New, for maintainers.
+ * alloca.c, atexit.c, basename.c, bcmp.c, bcopy.c, bsearch.c,
+ bzero.c, calloc.c, clock.c, configure.in, configure, getcwd.c,
+ getpagesize.c, getpwd.c, index.c, memchr.c, memcmp.c, memcpy.c,
+ memmove.c, memset.c, putenv.c, rename.c, rindex.c, setenv.c,
+ sigsetmask.c, strcasecmp.c, strchr.c, strdup.c, strerror.c,
+ strncasecmp.c, strncmp.c, strrchr.c, strstr.c, strtod.c, strtol.c,
+ tmpnam.c, vfork.c, vprintf.c, waitpid.c, xatexit.c, xexit.c,
+ xmalloc.c, xmemdup.c, xstrdup.c, xstrerror.c: Add or update
+ documentation.
+
+2001-09-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * concat.c (reconcat): Fix for traditional C.
+
+2001-09-24 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * concat.c (reconcat): New function.
+
+2001-09-17 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * concat.c (vconcat_length, vconcat_copy, concat_length,
+ concat_copy, concat_copy2): New functions.
+ (concat): Use vconcat_length/vconcat_copy.
+
+ * alloca.c (libiberty_optr, libiberty_nptr, libiberty_len):
+ Define.
+
+2001-09-04 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * asprintf.c: Don't define USE_STDARG. Use VPARAMS, VA_OPEN,
+ VA_FIXEDARG & VA_CLOSE.
+
+ * vasprintf.c: Check HAVE_STRING_H when including string.h.
+ (checkit): Delete redundant prototype. Add ATTRIBUTE_PRINTF_1.
+ Use VA_OPEN, VA_FIXEDARG & VA_CLOSE. Free allocated string.
+
+2001-08-27 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * concat.c (concat): Use VPARAMS, VA_OPEN, VA_FIXEDARG & VA_CLOSE.
+
+2001-08-23 Ulrich Drepper <drepper@redhat.com>
+
+ * regex.c (truncate_wchar): Use wcrtomb not wctomb.
+
+2001-08-23 Ulrich Drepper <drepper@redhat.com>
+
+ * posix/regex.c [_LIBC] (convert_mbs_to_wcs): Use __mbrtowc
+ instead of mbrtowc.
+ [_LIBC]: Use __iswctype instead of iswctype, __wcslen instead of
+ wcslen, and __wcscoll instead of wcscoll.
+
+2001-08-22 Matt Kraai <kraai@alumni.carnegiemellon.edu>
+
+ * fibheap.c (fibheap_init, fibnode_init): Remove.
+ (fibheap_new, fibnode_new): Use xcalloc to allocate and
+ initialize memory.
+ (fibheap_insert): Remove check for node allocation failure.
+
+2001-08-21 Richard Henderson <rth@redhat.com>
+
+ * Makefile.in (fibheap.o): Depend on config.h.
+ * fibheap.c: Tidy formatting. Use config.h.` Rearrange some
+ functions for inlining.
+
+Tue Aug 21 12:35:04 2001 Christopher Faylor <cgf@cygnus.com>
+
+ * configure.in: Need to set HAVE_SYS_ERRLIST and HAVE_SYS_NERR whenever
+ hosting on cygwin.
+ * configure: Regenerate.
+
+2001-08-20 Andrew Cagney <ac131313@redhat.com>
+
+ * floatformat.c (floatformat_m88110_ext): Remove #ifdef
+ HARRIS_FLOAT_FORMAT.
+ (floatformat_ia64_spill_little, floatformat_ia64_quad_little)
+ (floatformat_ia64_spill_big, floatformat_ia64_quad_big)
+ (floatformat_arm_ext_big, floatformat_arm_ext_littlebyte_bigword)
+ (floatformat_m88110_harris_ext): New float formats.
+
+2001-08-20 Daniel Berlin <dan@cgsoftware.com>
+
+ * fibheap.c: New file. Fibonacci heap.
+
+ * Makefile.in (CFILES): Add fibheap.c.
+ (REQUIRED_OFILES): Add fibheap.o.
+ (fibheap.o): Add dependencies for fibheap.o.
+
+2001-08-17 Christopher Faylor <cgf@cygnus.com>
+
+ * configure.in: Always set HAVE_SYS_ERRLIST when targetting cygwin.
+ * configure: Regenerate.
+
+2001-08-16 Richard Henderson <rth@redhat.com>
+
+ * hashtab.c (htab_hash_string): New.
+
+2001-08-13 Andrew Cagney <ac131313@redhat.com>
+
+ * floatformat.c (floatformat_ieee_double_littlebyte_bigword): Fix
+ name.
+
+2001-08-12 Isamu Hasegawa <isamu@yamato.ibm.com>
+
+ * regex.c (wcs_regex_compile): Use appropriate string
+ to compare with collating element.
+ Fix the padding for the alignment.
+
+2001-08-10 Andrew Cagney <ac131313@redhat.com>
+
+ * lbasename.c (lbasename): Change function definition to return a
+ const char pointer.
+
+2001-08-07 Jason Merrill <jason_merrill@redhat.com>
+
+ * cp-demangle.c (demangle_special_name): "GR" -> "reference temporary
+ for".
+
+2001-08-03 Richard Henderson <rth@redhat.com>
+
+ * Makefile.in (concat.o): Depend on config.h.
+
+2001-07-30 Andreas Jaeger <aj@suse.de>
+
+ * concat.c: Include "config.h".
+
+2001-07-30 Andreas Jaeger <aj@suse.de>
+
+ * regex.c: Declare wcs functions only if compiling with
+ MBS_SUPPORT.
+ Don't use #elif for traditional C.
+
+2001-07-23 Ulrich Drepper <drepper@redhat.com>
+
+ * regex.c: Revamp memory allocation for WCHAR functions to
+ not use too much stack.
+
+2001-07-30 Andreas Jaeger <aj@suse.de>
+
+ * regex.c: Declare wcs functions only if compiling with
+ MBS_SUPPORT.
+ Don't use #elif for traditional C.
+
+2001-07-25 Daniel Jacobowitz <drow@mvista.com>
+
+ * Makefile.in (regex.o): Add dependency on config.h.
+
+2001-07-18 Andreas Schwab <schwab@suse.de>
+
+ * regex.c (WORDCHAR_P) [WCHAR]: Also return true for the
+ underscore character.
+
+2001-07-18 Ulrich Drepper <drepper@redhat.com>
+
+ * regex.c: Limit string length printed in debug messages to 100
+ chars.
+
+2001-07-18 Andreas Jaeger <aj@suse.de>
+
+ * regex.c: Place under LGPL version 2.1.
+
+2001-07-10 Jeff Johnston <jjohnstn@redhat.com>
+
+ * Makefile.in: Add support for regex code.
+ * regex.c: New file.
+
+2001-07-05 Mark Klein <mklein@dis.com>
+
+ * Makefile.in: Add ffs.c dependency.
+ * configure.in: Add ffs.c.
+ * ffs.c: New file.
+
+2001-06-18 Richard Henderson <rth@redhat.com>
+
+ * concat.c: Include <sys/types.h>.
- * lbasename.c: New file.
+2001-06-11 Loren J. Rittle <ljrittle@acm.org>
+
+ bootstrap/3106
+ * strerror.c (sys_nerr): Hide the OS header version.
+ * strsignal.c (sys_nsig): Likewise.
+
+2001-06-10 Richard Henderson <rth@redhat.com>
+
+ * concat.c: Include string.h. Fix int vs size_t usage.
+ Simplify the iteration loops. Use memcpy.
+
+2001-05-16 Matt Kraai <kraai@alumni.carnegiemellon.edu>
+
+ * partition.c: Fix misspelling of `implementation'.
+
+2001-05-09 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
+
+ * md5.c (md5_init_ctx): Declare constants as unsigned.
+ (md5_process_block): Likewise.
+
+2001-05-07 Zack Weinberg <zackw@stanford.edu>
+
+ * cp-demangle.c (demangle_v3_with_details,
+ is_gnu_v3_mangled_ctor, is_gnu_v3_mangled_dtor): Use K+R style
+ function definition.
+ * ternary.c: Use K+R style function definitions. Use PTR, not
+ void *. Make arguments constant where possible.
+
+2001-05-07 Mark Mitchell <mark@codesourcery.com>
+
+ * splay-tree.h (splay_tree_max): New function.
+ (splay_tree_min): Likewise.
+
+2001-04-15 Daniel Berlin <dan@cgsoftware.com>
+
+ * ternary.c: New file - Ternary search tree implementation.
+
+ * Makefile.in: Add ternary.o, and ternary.c dependencies.
+
+2001-04-03 Zack Weinberg <zackw@stanford.edu>
+
+ * make-temp-file.c (try): Inline.
+
+2001-02-28 Richard Henderson <rth@redhat.com>
+
+ * Makefile.in (make-temp-file.o): Depend on config.h.
+
+2001-03-27 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * memchr.c (memchr): Adjust condition to avoid infinite loop.
+
+2001-03-23 Jakub Jelinek <jakub@redhat.com>
+
+ * cp-demangle.c (demangle_discriminator): `_0' is discriminator #1,
+ `_' not followed by a digit is invalid.
+
+2001-03-22 Jim Blandy <jimb@redhat.com>
+
+ * cp-demangle.c (string_list_delete): Use dyn_string_delete
+ instead of free, to free the contents as well as the string
+ structure.
+
+2001-03-21 Zack Weinberg <zackw@stanford.edu>
+
+ * make-temp-file.c: Always default DIR_SEPARATOR to '/'.
+ Don't default P_tmpdir to anything. Try /var/tmp before
+ /usr/tmp.
+
+2001-03-20 Zack Weinberg <zackw@stanford.edu>
+
+ * choose-temp.c: Split off make_temp_file, and the code
+ duplicated between it and choose_temp_base, into...
+ * make-temp-file.c: ... here; new file.
+
+ * Makefile.in (CFILES): Add make-temp-file.c.
+ (REQUIRED_OFILES): Add make-temp-file.o.
+
+2001-03-20 Jim Blandy <jimb@redhat.com>
+
+ * cp-demangle.c (struct demangling_def): New fields:
+ is_constructor and is_destructor.
+ (demangling_new): Initialize them.
+ (demangle_ctor_dtor_name): Set them, if we detect a constructor
+ or destructor.
+ (demangle_v3_with_details, is_gnu_v3_mangled_ctor,
+ is_gnu_v3_mangled_dtor): New functions.
+
+2001-03-20 Jason Merrill <jason@redhat.com>
+
+ * cplus-dem.c (main): Skip initial $.
+
+2001-03-15 Michael Meissner <meissner@redhat.com>
+
+ * hashtab.c (higher_prime_number): Silence warning that 4294967291
+ might be a signed integer under pre-ISO C systems.
+
+2001-03-10 Neil Booth <neil@daikokuya.demon.co.uk>
+ John David Anglin <dave@hiauly1.hia.nrc.ca>
+
+ * libiberty/lbasename.c: New file.
+ * libiberty/Makefile.in: Update for lbasename.
+
+2001-03-06 Zack Weinberg <zackw@stanford.edu>
+
+ * aclocal.m4 (libiberty_AC_FUNC_C_ALLOCA): New.
+ * configure.in: Replace all alloca logic with a simple use of
+ the above new macro.
+ * config.table: Kill *-*-beos* entry.
+ * config/mh-beos: Delete.
+ * configure, config.in: Regenerate.
+
+ * Makefile.in (ALLOCA, HFILES): Kill.
+ (REQUIRED_OFILES): Add alloca.o.
+ (alloca.o): Depend on libiberty.h.
+ (argv.o): Don't depend on alloca-conf.h.
+ * alloca-conf.h: Delete.
+ * alloca.c: Include libiberty.h. Kill all #ifdef emacs
+ blocks. Provide the C alloca unconditionally. Use PTR where
+ appropriate. Make i00afunc static.
+ * argv.c: Don't include alloca-conf.h.
+
+2001-03-04 John David Anglin <dave@hiauly1.hia.nrc.ca>
+
+ * cplus-dem.c (main): Cast enum style to int.
+
+2001-02-16 Loren J. Rittle <ljrittle@acm.org>
+
+ * cplus-dem.c (main): Initialize style.
+
+2001-02-02 Phil Edwards <pme@sources.redhat.com>
+
+ * COPYING.LIB: Update to LGPL 2.1 from the FSF.
+
+2001-01-31 Bryce McKinlay <bryce@albatross.co.nz>
+
+ Add support for Java demangling under the v3 ABI:
+ * cp-demangle.c (NAMESPACE_SEPARATOR): New define.
+ (struct demangling_def): Add `style' field.
+ (demangling_new): New parameter `style'. Set it in demangling_t.
+ (demangle_prefix): Use NAMESPACE_SEPARATOR.
+ (demangle_type_ptr): Don't emit pointer symbol if doing Java output.
+ (cp_demangle): New parameter `style'. Pass it to demangling_new().
+ (main): Call cp_demangle with extra parameter.
+ (java_demangle_v3): New function.
+ (java_builtin_type_names): New. Table of primitive type names used
+ for Java demangling.
+ (demangle_builtin_type): Look up in java_builtin_type_names if doing
+ Java output.
+ * cplus-dem.c (cplus_demangle): Use java_demangle_v3 to do Java
+ demangling.
+ (long_options): Remove obsolete `java' option.
+ (main): Remove explicit handling of `java' option. Instead, pass style
+ parameter in cplus_demangle flags as gdb does.
+ * testsuite/demangle.expected: Add some Java test cases.
2000-12-29 DJ Delorie <dj@redhat.com>
@@ -10,7 +560,7 @@
* getopt1.c: Ditto.
* md5.c: Ditto.
* obstack.c: Ditto.
-
+
2000-12-26 Michael Sokolov <msokolov@ivan.Harhan.ORG>
* bsearch.c: New file.
@@ -115,12 +665,12 @@
2000-11-04 Hans-Peter Nilsson <hp@bitrange.com>
* hashtab.c (htab_expand): Change to return int. Use calloc or
- xcalloc depending on htab->return_allocation_failure. Return zero
- if calloc fails.
+ xcalloc depending on htab->return_allocation_failure. Return zero
+ if calloc fails.
(htab_create): Update comment to cover memory allocation.
(htab_try_create): New.
(htab_find_slot_with_hash): Return NULL if htab_expand fails.
- Update comment to cover this.
+ Update comment to cover this.
2000-11-03 Hans-Peter Nilsson <hp@bitrange.com>
@@ -623,7 +1173,7 @@ Tue May 30 15:07:52 2000 Jeffrey A Law (law@cygnus.com)
2000-05-23 Mike Stump <mrs@wrs.com>
* Makefile.in (xmalloc.o): Add dependency for config.h, fixes make
- -j3.
+ -j3.
2000-05-18 J. David Anglin <dave@hiauly1.hia.nrc.ca>
@@ -1256,9 +1806,9 @@ Tue Dec 22 09:43:35 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* choose-temp.c: Include stdlib.h.
* cplus-dem.c (demangle_arm_pt): Remove unused prototype.
- (snarf_numeric_literal): Constify first parameter.
- (code_for_qualifier): Avoid a gcc extension, make the parameter an
- int, not a char.
+ (snarf_numeric_literal): Constify first parameter.
+ (code_for_qualifier): Avoid a gcc extension, make the parameter an
+ int, not a char.
(demangle_qualifier): Likewise.
(demangle_signature): Cast the argument of a ctype function to
unsigned char.
@@ -1271,11 +1821,11 @@ Tue Dec 22 09:43:35 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
Cast the argument of a ctype function to unsigned char.
* floatformat.c (floatformat_to_double): Add explicit braces to
- avoid ambiguous `else'.
+ avoid ambiguous `else'.
* fnmatch.c (fnmatch): Change type of variables `c', `c1',
- `cstart' and `cend' to unsigned char. Cast the argument of macro
- `FOLD', which uses ctype functions, to unsigned char.
+ `cstart' and `cend' to unsigned char. Cast the argument of macro
+ `FOLD', which uses ctype functions, to unsigned char.
* objalloc.c (free): Add prototype.
@@ -1286,7 +1836,7 @@ Sun Dec 20 16:03:46 1998 Hans-Peter Nilsson <hp@axis.se>
Fri Dec 18 17:50:18 1998 David Taylor <taylor@texas.cygnus.com>
* cplus-dem.c (demangle_arm_pt): remove declaration -- function
- doesn't exist.
+ doesn't exist.
(do_hpacc_template_literal): remove unused variable `i'.
Fri Dec 18 16:11:43 EST 1998 Andrew MacLeod <amacleod@cygnus.com>
@@ -1330,48 +1880,48 @@ Fri Dec 4 13:51:04 1998 David Taylor <taylor@texas.cygnus.com>
* HP aCC demangling support.
* cplus-dem.c
(main): Remove default to HP style demangling, set to EDG
- demangling correctly when -edg specified; set the demangling style
- when user specifies 'edg'. Set strip_underscore to
- prepends_underscore, if not HPUXHPPA. Set
- current_demangling_style to hp_demangling if HPUXHPPA. Set
- current demangling style correctly if the switch is hp. Read
- label correctly also in the HP style case.
+ demangling correctly when -edg specified; set the demangling style
+ when user specifies 'edg'. Set strip_underscore to
+ prepends_underscore, if not HPUXHPPA. Set
+ current_demangling_style to hp_demangling if HPUXHPPA. Set
+ current demangling style correctly if the switch is hp. Read
+ label correctly also in the HP style case.
(work_stuff): add temp_start field; add field for volatile member
- function.
+ function.
(arm_pt): handle ARM_DEMANGLING and EDG_DEMANGLING styles; HP
- style for this case is the same as ARM.
+ style for this case is the same as ARM.
(demangle_args): handle EDG_DEMANGLING style; support HP style.
(demangle_arm_hp_template): new function. (It was
- demangle_arm_pt.); check and set value of temp_start field in
- multiple places. Also, when ceching for end of template args,
- check to see if at end of static member of template class.
+ demangle_arm_pt.); check and set value of temp_start field in
+ multiple places. Also, when ceching for end of template args,
+ check to see if at end of static member of template class.
(demangle_class): new local variable : save_class_name_end Don't
- include template args in string defining class.
+ include template args in string defining class.
(demangle_class_name): use demangel_arm_hp_template.
(demangle_function_name): handle case where demangling style is
- HP_DEMANGLING and currently point at an 'X' in the mangled name.
- Handle EDG_DEMANGLING style. Handle constructor and destructor
- ops for HP style.
+ HP_DEMANGLING and currently point at an 'X' in the mangled name.
+ Handle EDG_DEMANGLING style. Handle constructor and destructor
+ ops for HP style.
(demangle_prefix): handle EDG_DEMANGLING and ARM_DEMANGLING
- styles. global destructor and constructor for HP style are same
- as for ARM style. Same for local variables.
+ styles. global destructor and constructor for HP style are same
+ as for ARM style. Same for local variables.
(demangle_qualified): handle EDG_DEMANGLING style.
(demangle_signature): add case for volatile member function. For
- cases '1' - '9' : initialize the temp_start field to -1 and handle
- the EDG_DEMANGLING style. for case 'F' : handle EDG_DEMANGLING
- and AUTO_DEMANGLING styles. If expecting a function and managed
- to demangle the funct args, then handle the LUCID_DEMANGLING,
- ARM_DEMANGLING, and EDG_DEMANGLING styles. Add case for local
- class name after "Lnnn_ in HP style case. HP style too needs to
- forget types. _nnn is OK for HP style, so don't report failure.
+ cases '1' - '9' : initialize the temp_start field to -1 and handle
+ the EDG_DEMANGLING style. for case 'F' : handle EDG_DEMANGLING
+ and AUTO_DEMANGLING styles. If expecting a function and managed
+ to demangle the funct args, then handle the LUCID_DEMANGLING,
+ ARM_DEMANGLING, and EDG_DEMANGLING styles. Add case for local
+ class name after "Lnnn_ in HP style case. HP style too needs to
+ forget types. _nnn is OK for HP style, so don't report failure.
(do_hpacc_template_const_value): new function. Handle template's
- value param for HP/aCC.
+ value param for HP/aCC.
(do_hpacc_template_literal): new function. Handle a template's
- literal parameter for HP aCC.
+ literal parameter for HP aCC.
(recursively_demangle): new function
(snarf_numeric_literal): new function.
(usage): add 'edg' to the list of demangling styles; add hp switch
- to message.
+ to message.
Sat Nov 28 17:25:22 1998 Christopher Faylor <cgf@cygnus.com>
@@ -1453,13 +2003,13 @@ Mon Nov 2 15:05:33 1998 Geoffrey Noer <noer@cygnus.com>
Mon Nov 2 10:22:01 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* pexecute.c: Check HAVE_CONFIG_H, not IN_GCC, when determining
- whether to include config.h. Possibly include unistd.h in the
- !IN_GCC case. Define VFORK_STRING as a printable function call
- for error messages (either "vfork" or "fork".) If HAVE_VFORK_H is
- defined, include vfork.h. If VMS is defined, define vfork()
- appropriately. Remove vfork check on USG, we're using autoconf.
- (pexecute): Set `errmsg_fmt' to VFORK_STRING instead of checking
- locally what string to use.
+ whether to include config.h. Possibly include unistd.h in the
+ !IN_GCC case. Define VFORK_STRING as a printable function call
+ for error messages (either "vfork" or "fork".) If HAVE_VFORK_H is
+ defined, include vfork.h. If VMS is defined, define vfork()
+ appropriately. Remove vfork check on USG, we're using autoconf.
+ (pexecute): Set `errmsg_fmt' to VFORK_STRING instead of checking
+ locally what string to use.
1998-10-26 Mark Mitchell <mark@markmitchell.com>
@@ -1565,8 +2115,8 @@ Thu Oct 8 23:42:08 1998 Jeffrey A Law (law@cygnus.com)
Mon Sep 7 23:29:01 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* mkstemp.c: Include config.h even when not IN_GCC. Wrap header
- inclusions inside HAVE_*_H macros. Include ansidecl.h when not
- IN_GCC.
+ inclusions inside HAVE_*_H macros. Include ansidecl.h when not
+ IN_GCC.
* vasprintf.c: Include stdarg.h/varargs.h first.
@@ -1880,7 +2430,7 @@ Mon May 4 13:00:28 1998 Ian Lance Taylor <ian@cygnus.com>
* config/mh-sysv4 (RANLIB, INSTALL): Don't define.
* config.table: Change config_shell to CONFIG_SHELL, and use
libiberty_topdir to find move-if-change.
- (m68k-apollo-bsd*, m68k-apollo-sysv*): Remove.
+ (m68k-apollo-bsd*, m68k-apollo-sysv*): Remove.
(i[3456]86-ncr-sysv4*, *-*-dgux*, hppa*-hp-bsd*): Remove.
(*-*-irix*, *-*-m88kbcs*, *-*-sysv*): Remove.
* Makefile.in (srcdir): Set to @srcdir@.
@@ -2097,7 +2647,7 @@ Wed Sep 24 00:31:59 1997 Felix Lee <flee@yin.cygnus.com>
* asprintf.c: stdarg.h when ALMOST_STDC
* config/mh-windows (EXTRA_OFILES): add asprintf.o and
- strncasecmp.o.
+ strncasecmp.o.
Thu Aug 28 14:27:15 1997 Andrew Cagney <cagney@b1.cygnus.com>
@@ -4139,7 +4689,7 @@ Thu Jan 30 22:48:41 1992 Stu Grossman (grossman at cygnus.com)
Mon Jan 20 18:53:23 1992 Stu Grossman (grossman at cygnus.com)
- * getopt.c, getopt1.c, ../include/getopt.h: Get latest versions.
+ * getopt.c, getopt1.c, ../include/getopt.h: Get latest versions.
Sat Jan 18 16:53:01 1992 Fred Fish (fnf at cygnus.com)
diff --git a/contrib/binutils/libiberty/Makefile.in b/contrib/binutils/libiberty/Makefile.in
index 16a040c..5fa9630 100644
--- a/contrib/binutils/libiberty/Makefile.in
+++ b/contrib/binutils/libiberty/Makefile.in
@@ -1,6 +1,6 @@
#
# Makefile
-# Copyright (C) 1990, 91-99, 2000
+# Copyright (C) 1990, 91-99, 2000, 2001
# Free Software Foundation
#
# This file is part of the libiberty library.
@@ -56,15 +56,17 @@ CC = @CC@
CFLAGS = @CFLAGS@
LIBCFLAGS = $(CFLAGS)
RANLIB = @RANLIB@
+MAKEINFO = @MAKEINFO@
+PERL = @PERL@
PICFLAG =
MAKEOVERRIDES =
TARGETLIB = libiberty.a
+TESTLIB = testlib.a
LIBOBJS = @LIBOBJS@
-ALLOCA = @ALLOCA@
# A configuration can specify extra .o files that should be included,
# even if they are in libc. (Perhaps the libc version is buggy.)
@@ -95,6 +97,7 @@ FLAGS_TO_PASS = \
# Subdirectories to recurse into. We need to override this during cleaning
SUBDIRS = testsuite
+# FIXME: add @BUILD_INFO@ once we're sure it works for everyone.
all: stamp-picdir $(TARGETLIB) needed-list required-list all-subdir
@$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=all
@@ -113,45 +116,122 @@ COMPILE.c = $(CC) -c @DEFS@ $(LIBCFLAGS) -I. -I$(INCDIR) $(HDEFINES) @ac_libiber
else true; fi
$(COMPILE.c) $<
-info: info-subdir
+# NOTE: If you add new files to the library, add them to this list
+# (alphabetical), and add them to REQUIRED_OFILES, or
+# CONFIGURED_OFILES and funcs in configure.in.
+CFILES = alloca.c argv.c asprintf.c atexit.c \
+ basename.c bcmp.c bcopy.c bsearch.c bzero.c \
+ calloc.c choose-temp.c clock.c concat.c cp-demangle.c \
+ cplus-dem.c \
+ dyn-string.c \
+ fdmatch.c ffs.c fibheap.c floatformat.c fnmatch.c \
+ getcwd.c getopt.c getopt1.c getpagesize.c getpwd.c getruntime.c \
+ hashtab.c hex.c \
+ index.c insque.c \
+ lbasename.c \
+ make-temp-file.c md5.c memchr.c memcmp.c memcpy.c memmove.c \
+ memset.c mkstemps.c \
+ objalloc.c obstack.c \
+ partition.c pexecute.c putenv.c \
+ random.c regex.c rename.c rindex.c \
+ safe-ctype.c setenv.c sigsetmask.c sort.c spaces.c \
+ splay-tree.c strcasecmp.c strchr.c strdup.c strerror.c \
+ strncasecmp.c strncmp.c strrchr.c strsignal.c strstr.c \
+ strtod.c strtol.c strtoul.c \
+ ternary.c tmpnam.c \
+ vasprintf.c vfork.c vfprintf.c vprintf.c vsprintf.c \
+ waitpid.c \
+ xatexit.c xexit.c xmalloc.c xmemdup.c xstrdup.c xstrerror.c
+
+# These are always included in the library. The first four are listed
+# first and by compile time to optimize parallel builds.
+REQUIRED_OFILES = regex.o cplus-dem.o cp-demangle.o md5.o \
+ alloca.o argv.o \
+ choose-temp.o concat.o \
+ dyn-string.o \
+ fdmatch.o fibheap.o floatformat.o fnmatch.o \
+ getopt.o getopt1.o getpwd.o getruntime.o \
+ hashtab.o hex.o \
+ lbasename.o \
+ make-temp-file.o \
+ objalloc.o obstack.o \
+ partition.o pexecute.o \
+ safe-ctype.o sort.o spaces.o splay-tree.o strerror.o \
+ strsignal.o \
+ ternary.o \
+ xatexit.o xexit.o xmalloc.o xmemdup.o xstrdup.o xstrerror.o
+
+# These are all the objects that configure may add to the library via
+# $funcs or EXTRA_OFILES. This list exists here only for "make
+# maint-missing" and "make check".
+CONFIGURED_OFILES = asprintf.o atexit.o \
+ basename.o bcmp.o bcopy.o bsearch.o bzero.o \
+ calloc.o clock.o copysign.o \
+ _doprnt.o \
+ ffs.o \
+ getcwd.o getpagesize.o \
+ index.o insque.o \
+ memchr.o memcmp.o memcpy.o memmove.o memset.o mkstemps.o \
+ putenv.o \
+ random.o rename.o rindex.o \
+ setenv.o sigsetmask.o strcasecmp.o strchr.o strdup.o \
+ strncasecmp.o strncmp.o strrchr.o strstr.o strtod.o strtol.o \
+ strtoul.o \
+ tmpnam.o \
+ vasprintf.o vfork.o vfprintf.o vprintf.o vsprintf.o \
+ waitpid.o
+
+$(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS)
+ -rm -f $(TARGETLIB) pic/$(TARGETLIB)
+ $(AR) $(AR_FLAGS) $(TARGETLIB) \
+ $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS)
+ $(RANLIB) $(TARGETLIB)
+ if [ x"$(PICFLAG)" != x ]; then \
+ cd pic; \
+ $(AR) $(AR_FLAGS) $(TARGETLIB) \
+ $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS); \
+ $(RANLIB) $(TARGETLIB); \
+ cd ..; \
+ else true; fi
+
+$(TESTLIB): $(REQUIRED_OFILES) $(CONFIGURED_OFILES)
+ -rm -f $(TESTLIB)
+ $(AR) $(AR_FLAGS) $(TESTLIB) \
+ $(REQUIRED_OFILES) $(CONFIGURED_OFILES)
+ $(RANLIB) $(TESTLIB)
+
+info: libiberty.info info-subdir
install-info: install-info-subdir
clean-info: clean-info-subdir
-dvi: dvi-subdir
+dvi: libiberty.dvi dvi-subdir
+html: libiberty.html
-# Include files that are in this directory.
-HFILES = alloca-conf.h
+TEXISRC = \
+ $(srcdir)/libiberty.texi \
+ $(srcdir)/copying-lib.texi \
+ $(srcdir)/obstacks.texi \
+ $(srcdir)/functions.texi
-# NOTE: If you add new files to the library, add them to this list
-# (alphabetical), and add them to REQUIRED_OFILES or funcs in
-# configure.in.
-CFILES = asprintf.c alloca.c argv.c atexit.c basename.c bcmp.c bcopy.c \
- bzero.c calloc.c choose-temp.c clock.c concat.c cplus-dem.c \
- cp-demangle.c dyn-string.c fdmatch.c fnmatch.c getcwd.c \
- getpwd.c getopt.c getopt1.c getpagesize.c getruntime.c \
- floatformat.c hashtab.c hex.c index.c insque.c lbasename.c \
- md5.c memchr.c \
- memcmp.c memcpy.c memmove.c memset.c mkstemps.c objalloc.c obstack.c \
- partition.c pexecute.c putenv.c random.c rename.c rindex.c setenv.c \
- sigsetmask.c safe-ctype.c sort.c spaces.c splay-tree.c strcasecmp.c \
- strncasecmp.c strchr.c strdup.c strerror.c strncmp.c strrchr.c \
- strsignal.c strstr.c strtod.c strtol.c strtoul.c tmpnam.c vasprintf.c \
- vfork.c vfprintf.c vprintf.c vsprintf.c waitpid.c xatexit.c xexit.c \
- xmalloc.c xmemdup.c xstrdup.c xstrerror.c
-
-# These are always included in the library.
-REQUIRED_OFILES = argv.o choose-temp.o concat.o cplus-dem.o cp-demangle.o \
- dyn-string.o fdmatch.o fnmatch.o getopt.o getopt1.o getpwd.o \
- getruntime.o hashtab.o hex.o floatformat.o lbasename.o md5.o \
- objalloc.o obstack.o \
- partition.o pexecute.o safe-ctype.o sort.o spaces.o splay-tree.o \
- strerror.o strsignal.o xatexit.o xexit.o xmalloc.o xmemdup.o \
- xstrdup.o xstrerror.o
-
-$(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS) $(ALLOCA)
- -rm -f $(TARGETLIB)
- $(AR) $(AR_FLAGS) $(TARGETLIB) \
- $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS) $(ALLOCA)
- $(RANLIB) $(TARGETLIB)
+# Additional files that have texi snippets that need to be collected
+# and sorted. Some are here because the sources are imported from
+# elsewhere. Others represent headers in ../include.
+TEXIFILES = fnmatch.txh
+
+libiberty.info : $(srcdir)/libiberty.texi $(TEXISRC)
+ $(MAKEINFO) -I$(srcdir) $(srcdir)/libiberty.texi
+
+libiberty.dvi : $(srcdir)/libiberty.texi $(TEXISRC)
+ texi2dvi $(srcdir)/libiberty.texi
+
+libiberty.html : $(srcdir)/libiberty.texi $(TEXISRC)
+ $(MAKEINFO) --html -I$(srcdir) $(srcdir)/libiberty.texi
+
+@MAINT@$(srcdir)/functions.texi : stamp-functions
+@MAINT@ @true
+
+@MAINT@stamp-functions : $(CFILES) $(TEXIFILES) $(srcdir)/gather-docs Makefile
+@MAINT@@HAVE_PERL@ $(PERL) $(srcdir)/gather-docs $(srcdir) $(srcdir)/functions.texi $(CFILES) $(TEXIFILES)
+@MAINT@ echo stamp > stamp-functions
INSTALL_DEST = @INSTALL_DEST@
install: install_to_$(INSTALL_DEST) install-subdir
@@ -199,8 +279,8 @@ stamp-picdir:
etags tags: TAGS etags-subdir
-TAGS: $(CFILES) $(HFILES)
- etags `for i in $(HFILES) $(CFILES); do echo $(srcdir)/$$i ; done`
+TAGS: $(CFILES)
+ etags `for i in $(CFILES); do echo $(srcdir)/$$i ; done`
# The standalone demangler (c++filt) has been moved to binutils.
demangle:
@@ -209,7 +289,21 @@ demangle:
@false
ls:
- @echo Makefile $(HFILES) $(CFILES)
+ @echo Makefile $(CFILES)
+
+# Various targets for maintainers.
+
+maint-missing :
+ @$(PERL) $(srcdir)/maint-tool -s $(srcdir) missing $(CFILES) $(REQUIRED_OFILES) $(CONFIGURED_OFILES)
+
+maint-buildall : $(REQUIRED_OFILES) $(CONFIGURED_OFILES)
+ @true
+
+maint-undoc : $(srcdir)/functions.texi
+ @$(PERL) $(srcdir)/maint-tool -s $(srcdir) undoc
+
+maint-deps :
+ @$(PERL) $(srcdir)/maint-tool -s $(srcdir) deps $(INCDIR)
# Need to deal with profiled libraries, too.
@@ -219,10 +313,15 @@ mostlyclean: mostlyclean-subdir
-rm -rf *.o pic core errs \#* *.E a.out
-rm -f needed.awk needed2.awk errors dummy needed-list config.h stamp-*
-rm -f $(CONFIG_H) $(NEEDED_LIST) stamp-picdir
+ -rm -f libiberty.aux libiberty.cp libiberty.cps libiberty.fn libiberty.ky
+ -rm -f libiberty.log libiberty.tmp libiberty.tps libiberty.pg
+ -rm -f libiberty.pgs libiberty.toc libiberty.tp libiberty.tpl libiberty.vr
+ -rm -f libtexi.stamp
@$(MULTICLEAN) multi-clean DO=mostlyclean
clean: clean-subdir
$(MAKE) SUBDIRS="" mostlyclean
-rm -f *.a required-list tmpmulti.out
+ -rm -f libiberty.dvi libiberty.info* libiberty.html
@$(MULTICLEAN) multi-clean DO=clean
distclean: distclean-subdir
$(MAKE) SUBDIRS="" clean
@@ -238,68 +337,115 @@ force:
Makefile: $(srcdir)/Makefile.in config.status
CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status
+# Depending on Makefile makes sure that config.status has been re-run
+# if needed. This prevents problems with parallel builds.
config.h: stamp-h ; @true
-stamp-h: config.in config.status
+stamp-h: config.in config.status Makefile
CONFIG_FILES= CONFIG_HEADERS=config.h:config.in $(SHELL) ./config.status
config.status: $(srcdir)/configure $(srcdir)/config.table
$(SHELL) ./config.status --recheck
-
+# Depending on config.h makes sure that config.status has been re-run
+# 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 \
etags-subdir mostlyclean-subdir clean-subdir distclean-subdir \
-maintainer-clean-subdir:
+maintainer-clean-subdir: config.h
@subdirs='$(SUBDIRS)'; \
target=`echo $@ | sed -e 's/-subdir//'`; \
for dir in $$subdirs ; do \
cd $$dir && $(MAKE) $$target; \
done
-$(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS) $(ALLOCA): stamp-picdir
+$(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS): stamp-picdir
+$(CONFIGURED_OFILES): stamp-picdir
+
+# The dependencies in the remainder of this file are automatically
+# generated by "make maint-deps". Manual edits will be lost.
-alloca.o: config.h
+_doprnt.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/safe-ctype.h
+alloca.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
+argv.o: $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
+asprintf.o: $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
atexit.o: config.h
-argv.o: config.h alloca-conf.h $(INCDIR)/libiberty.h
-basename.o: $(INCDIR)/libiberty.h
-choose-temp.o: config.h
+basename.o: $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \
+ $(INCDIR)/safe-ctype.h
+bsearch.o: config.h $(INCDIR)/ansidecl.h
+calloc.o: $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
+choose-temp.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
clock.o: config.h
-concat.o: $(INCDIR)/libiberty.h
-cplus-dem.o: config.h $(INCDIR)/demangle.h
-cp-demangle.o: config.h $(INCDIR)/dyn-string.h $(INCDIR)/demangle.h
-dyn-string.o: config.h $(INCDIR)/dyn-string.h
-fdmatch.o: $(INCDIR)/libiberty.h
-fnmatch.o: config.h $(INCDIR)/fnmatch.h
+concat.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
+copysign.o: $(INCDIR)/ansidecl.h
+cp-demangle.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/demangle.h \
+ $(INCDIR)/dyn-string.h $(INCDIR)/getopt.h $(INCDIR)/libiberty.h
+cplus-dem.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/demangle.h \
+ $(INCDIR)/getopt.h $(INCDIR)/libiberty.h $(INCDIR)/safe-ctype.h
+dyn-string.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/dyn-string.h \
+ $(INCDIR)/libiberty.h
+fdmatch.o: $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
+fibheap.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/fibheap.h \
+ $(INCDIR)/libiberty.h
+floatformat.o: $(INCDIR)/ansidecl.h $(INCDIR)/floatformat.h
+fnmatch.o: config.h $(INCDIR)/fnmatch.h $(INCDIR)/safe-ctype.h
getcwd.o: config.h
getopt.o: config.h $(INCDIR)/getopt.h
getopt1.o: config.h $(INCDIR)/getopt.h
getpagesize.o: config.h
-getpwd.o: config.h $(INCDIR)/libiberty.h
-getruntime.o: config.h $(INCDIR)/libiberty.h
-hex.o: $(INCDIR)/libiberty.h
-floatformat.o: $(INCDIR)/floatformat.h
-lbasename.o: $(INCDIR)/libiberty.h
-mkstemps.o: config.h
-md5.o: config.h
-objalloc.o: config.h $(INCDIR)/objalloc.h
+getpwd.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
+getruntime.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
+hashtab.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/hashtab.h \
+ $(INCDIR)/libiberty.h
+hex.o: $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
+lbasename.o: $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \
+ $(INCDIR)/safe-ctype.h
+make-temp-file.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
+md5.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/md5.h
+memchr.o: $(INCDIR)/ansidecl.h
+memcmp.o: $(INCDIR)/ansidecl.h
+memcpy.o: $(INCDIR)/ansidecl.h
+memmove.o: $(INCDIR)/ansidecl.h
+memset.o: $(INCDIR)/ansidecl.h
+mkstemps.o: config.h $(INCDIR)/ansidecl.h
+objalloc.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/objalloc.h
obstack.o: config.h $(INCDIR)/obstack.h
-partition.o: config.h $(INCDIR)/partition.h
-pexecute.o: config.h $(INCDIR)/libiberty.h
+partition.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \
+ $(INCDIR)/partition.h
+pexecute.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \
+ $(INCDIR)/safe-ctype.h
+putenv.o: config.h $(INCDIR)/ansidecl.h
+random.o: $(INCDIR)/ansidecl.h
+regex.o: config.h $(INCDIR)/xregex.h $(INCDIR)/xregex2.h
rename.o: config.h
-setenv.o: config.h
-sort.o: config.h $(INCDIR)/sort.h $(INCDIR)/ansidecl.h
-spaces.o: $(INCDIR)/libiberty.h
-splay-tree.o: config.h $(INCDIR)/libiberty.h $(INCDIR)/splay-tree.h $(INCDIR)/ansidecl.h
-strerror.o: config.h $(INCDIR)/libiberty.h
-strsignal.o: config.h $(INCDIR)/libiberty.h
-strtol.o: config.h
-strtoul.o: config.h
-vasprintf.o: config.h
-xatexit.o: $(INCDIR)/libiberty.h
-xexit.o: config.h $(INCDIR)/libiberty.h
-xmalloc.o: config.h $(INCDIR)/libiberty.h
-xmemdup.o: config.h $(INCDIR)/libiberty.h
-xstrdup.o: config.h $(INCDIR)/libiberty.h
-xstrerror.o: config.h $(INCDIR)/libiberty.h
+safe-ctype.o: $(INCDIR)/ansidecl.h $(INCDIR)/safe-ctype.h
+setenv.o: config.h $(INCDIR)/ansidecl.h
+sigsetmask.o: $(INCDIR)/ansidecl.h
+sort.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \
+ $(INCDIR)/sort.h
+spaces.o: $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
+splay-tree.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \
+ $(INCDIR)/splay-tree.h
+strcasecmp.o: $(INCDIR)/ansidecl.h
+strchr.o: $(INCDIR)/ansidecl.h
+strerror.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
+strncasecmp.o: $(INCDIR)/ansidecl.h
+strncmp.o: $(INCDIR)/ansidecl.h
+strrchr.o: $(INCDIR)/ansidecl.h
+strsignal.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
+strtod.o: $(INCDIR)/ansidecl.h $(INCDIR)/safe-ctype.h
+strtol.o: config.h $(INCDIR)/safe-ctype.h
+strtoul.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/safe-ctype.h
+ternary.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h \
+ $(INCDIR)/ternary.h
+vasprintf.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
+vfork.o: $(INCDIR)/ansidecl.h
+vprintf.o: $(INCDIR)/ansidecl.h
+vsprintf.o: $(INCDIR)/ansidecl.h
waitpid.o: config.h
-hashtab.o: config.h $(INCDIR)/libiberty.h $(INCDIR)/hashtab.h $(INCDIR)/ansidecl.h
+xatexit.o: $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
+xexit.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
+xmalloc.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
+xmemdup.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
+xstrdup.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
+xstrerror.o: config.h $(INCDIR)/ansidecl.h $(INCDIR)/libiberty.h
diff --git a/contrib/binutils/libiberty/_doprnt.c b/contrib/binutils/libiberty/_doprnt.c
new file mode 100644
index 0000000..8ce1415
--- /dev/null
+++ b/contrib/binutils/libiberty/_doprnt.c
@@ -0,0 +1,303 @@
+/* Provide a version of _doprnt in terms of fprintf.
+ Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ Contributed by Kaveh Ghazi (ghazi@caip.rutgers.edu) 3/29/98
+
+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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#include "config.h"
+#include "ansidecl.h"
+#include "safe-ctype.h"
+
+#include <stdio.h>
+#ifdef ANSI_PROTOTYPES
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#undef _doprnt
+
+#ifdef HAVE__DOPRNT
+#define TEST
+#endif
+
+#ifdef TEST /* Make sure to use the internal one. */
+#define _doprnt my_doprnt
+#endif
+
+#define COPY_VA_INT \
+ do { \
+ const int value = abs (va_arg (ap, int)); \
+ char buf[32]; \
+ ptr++; /* Go past the asterisk. */ \
+ *sptr = '\0'; /* NULL terminate sptr. */ \
+ sprintf(buf, "%d", value); \
+ strcat(sptr, buf); \
+ while (*sptr) sptr++; \
+ } while (0)
+
+#define PRINT_CHAR(CHAR) \
+ do { \
+ putc(CHAR, stream); \
+ ptr++; \
+ total_printed++; \
+ continue; \
+ } while (0)
+
+#define PRINT_TYPE(TYPE) \
+ do { \
+ int result; \
+ TYPE value = va_arg (ap, TYPE); \
+ *sptr++ = *ptr++; /* Copy the type specifier. */ \
+ *sptr = '\0'; /* NULL terminate sptr. */ \
+ result = fprintf(stream, specifier, value); \
+ if (result == -1) \
+ return -1; \
+ else \
+ { \
+ total_printed += result; \
+ continue; \
+ } \
+ } while (0)
+
+int
+_doprnt (format, ap, stream)
+ const char * format;
+ va_list ap;
+ FILE * stream;
+{
+ const char * ptr = format;
+ char specifier[128];
+ int total_printed = 0;
+
+ while (*ptr != '\0')
+ {
+ if (*ptr != '%') /* While we have regular characters, print them. */
+ PRINT_CHAR(*ptr);
+ else /* We got a format specifier! */
+ {
+ char * sptr = specifier;
+ int wide_width = 0, short_width = 0;
+
+ *sptr++ = *ptr++; /* Copy the % and move forward. */
+
+ while (strchr ("-+ #0", *ptr)) /* Move past flags. */
+ *sptr++ = *ptr++;
+
+ if (*ptr == '*')
+ COPY_VA_INT;
+ else
+ while (ISDIGIT(*ptr)) /* Handle explicit numeric value. */
+ *sptr++ = *ptr++;
+
+ if (*ptr == '.')
+ {
+ *sptr++ = *ptr++; /* Copy and go past the period. */
+ if (*ptr == '*')
+ COPY_VA_INT;
+ else
+ while (ISDIGIT(*ptr)) /* Handle explicit numeric value. */
+ *sptr++ = *ptr++;
+ }
+ while (strchr ("hlL", *ptr))
+ {
+ switch (*ptr)
+ {
+ case 'h':
+ short_width = 1;
+ break;
+ case 'l':
+ wide_width++;
+ break;
+ case 'L':
+ wide_width = 2;
+ break;
+ default:
+ abort();
+ }
+ *sptr++ = *ptr++;
+ }
+
+ switch (*ptr)
+ {
+ case 'd':
+ case 'i':
+ case 'o':
+ case 'u':
+ case 'x':
+ case 'X':
+ case 'c':
+ {
+ /* Short values are promoted to int, so just copy it
+ as an int and trust the C library printf to cast it
+ to the right width. */
+ if (short_width)
+ PRINT_TYPE(int);
+ else
+ {
+ switch (wide_width)
+ {
+ case 0:
+ PRINT_TYPE(int);
+ break;
+ case 1:
+ PRINT_TYPE(long);
+ break;
+ case 2:
+ default:
+#if defined(__GNUC__) || defined(HAVE_LONG_LONG)
+ PRINT_TYPE(long long);
+#else
+ PRINT_TYPE(long); /* Fake it and hope for the best. */
+#endif
+ break;
+ } /* End of switch (wide_width) */
+ } /* End of else statement */
+ } /* End of integer case */
+ break;
+ case 'f':
+ case 'e':
+ case 'E':
+ case 'g':
+ case 'G':
+ {
+ if (wide_width == 0)
+ PRINT_TYPE(double);
+ else
+ {
+#if defined(__GNUC__) || defined(HAVE_LONG_DOUBLE)
+ PRINT_TYPE(long double);
+#else
+ PRINT_TYPE(double); /* Fake it and hope for the best. */
+#endif
+ }
+ }
+ break;
+ case 's':
+ PRINT_TYPE(char *);
+ break;
+ case 'p':
+ PRINT_TYPE(void *);
+ break;
+ case '%':
+ PRINT_CHAR('%');
+ break;
+ default:
+ abort();
+ } /* End of switch (*ptr) */
+ } /* End of else statement */
+ }
+
+ return total_printed;
+}
+
+#ifdef TEST
+
+#include <math.h>
+#ifndef M_PI
+#define M_PI (3.1415926535897932385)
+#endif
+
+#define RESULT(x) do \
+{ \
+ int i = (x); \
+ printf ("printed %d characters\n", i); \
+ fflush(stdin); \
+} while (0)
+
+static int checkit PARAMS ((const char * format, ...)) ATTRIBUTE_PRINTF_1;
+
+static int
+checkit VPARAMS ((const char* format, ...))
+{
+ int result;
+ VA_OPEN (args, format);
+ VA_FIXEDARG (args, char *, format);
+
+ result = _doprnt (format, args, stdout);
+ VA_CLOSE (args);
+
+ return result;
+}
+
+int
+main ()
+{
+ RESULT(checkit ("<%d>\n", 0x12345678));
+ RESULT(printf ("<%d>\n", 0x12345678));
+
+ RESULT(checkit ("<%200d>\n", 5));
+ RESULT(printf ("<%200d>\n", 5));
+
+ RESULT(checkit ("<%.300d>\n", 6));
+ RESULT(printf ("<%.300d>\n", 6));
+
+ RESULT(checkit ("<%100.150d>\n", 7));
+ RESULT(printf ("<%100.150d>\n", 7));
+
+ RESULT(checkit ("<%s>\n",
+ "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\
+777777777777777777333333333333366666666666622222222222777777777777733333"));
+ RESULT(printf ("<%s>\n",
+ "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\
+777777777777777777333333333333366666666666622222222222777777777777733333"));
+
+ RESULT(checkit ("<%f><%0+#f>%s%d%s>\n",
+ 1.0, 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx"));
+ RESULT(printf ("<%f><%0+#f>%s%d%s>\n",
+ 1.0, 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx"));
+
+ RESULT(checkit ("<%4f><%.4f><%%><%4.4f>\n", M_PI, M_PI, M_PI));
+ RESULT(printf ("<%4f><%.4f><%%><%4.4f>\n", M_PI, M_PI, M_PI));
+
+ RESULT(checkit ("<%*f><%.*f><%%><%*.*f>\n", 3, M_PI, 3, M_PI, 3, 3, M_PI));
+ RESULT(printf ("<%*f><%.*f><%%><%*.*f>\n", 3, M_PI, 3, M_PI, 3, 3, M_PI));
+
+ RESULT(checkit ("<%d><%i><%o><%u><%x><%X><%c>\n",
+ 75, 75, 75, 75, 75, 75, 75));
+ RESULT(printf ("<%d><%i><%o><%u><%x><%X><%c>\n",
+ 75, 75, 75, 75, 75, 75, 75));
+
+ RESULT(checkit ("<%d><%i><%o><%u><%x><%X><%c>\n",
+ 75, 75, 75, 75, 75, 75, 75));
+ RESULT(printf ("<%d><%i><%o><%u><%x><%X><%c>\n",
+ 75, 75, 75, 75, 75, 75, 75));
+
+ RESULT(checkit ("Testing (hd) short: <%d><%ld><%hd><%hd><%d>\n", 123, (long)234, 345, 123456789, 456));
+ RESULT(printf ("Testing (hd) short: <%d><%ld><%hd><%hd><%d>\n", 123, (long)234, 345, 123456789, 456));
+
+#if defined(__GNUC__) || defined (HAVE_LONG_LONG)
+ RESULT(checkit ("Testing (lld) long long: <%d><%lld><%d>\n", 123, 234234234234234234LL, 345));
+ RESULT(printf ("Testing (lld) long long: <%d><%lld><%d>\n", 123, 234234234234234234LL, 345));
+ RESULT(checkit ("Testing (Ld) long long: <%d><%Ld><%d>\n", 123, 234234234234234234LL, 345));
+ RESULT(printf ("Testing (Ld) long long: <%d><%Ld><%d>\n", 123, 234234234234234234LL, 345));
+#endif
+
+#if defined(__GNUC__) || defined (HAVE_LONG_DOUBLE)
+ RESULT(checkit ("Testing (Lf) long double: <%.20f><%.20Lf><%0+#.20f>\n",
+ 1.23456, 1.234567890123456789L, 1.23456));
+ RESULT(printf ("Testing (Lf) long double: <%.20f><%.20Lf><%0+#.20f>\n",
+ 1.23456, 1.234567890123456789L, 1.23456));
+#endif
+
+ return 0;
+}
+#endif /* TEST */
diff --git a/contrib/binutils/libiberty/aclocal.m4 b/contrib/binutils/libiberty/aclocal.m4
index c562835..103e246 100644
--- a/contrib/binutils/libiberty/aclocal.m4
+++ b/contrib/binutils/libiberty/aclocal.m4
@@ -48,6 +48,9 @@ main ()
p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, dev_zero, 0);
if (p == (char *)-1)
+ p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE,
+ MAP_ANON|MAP_PRIVATE, -1, 0);
+ if (p == (char *)-1)
exit (2);
else
{
@@ -134,3 +137,55 @@ define(AC_DEFINE_NOAUTOHEADER,
[#define] $1 ifelse($#, 2, [$2], $#, 3, [$2], 1)
EOF
])
+
+# We always want a C version of alloca() compiled into libiberty,
+# because native-compiler support for the real alloca is so !@#$%
+# unreliable that GCC has decided to use it only when being compiled
+# by GCC. This is the part of AC_FUNC_ALLOCA that calculates the
+# information alloca.c needs.
+AC_DEFUN(libiberty_AC_FUNC_C_ALLOCA,
+[AC_CACHE_CHECK(whether alloca needs Cray hooks, ac_cv_os_cray,
+[AC_EGREP_CPP(webecray,
+[#if defined(CRAY) && ! defined(CRAY2)
+webecray
+#else
+wenotbecray
+#endif
+], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
+if test $ac_cv_os_cray = yes; then
+ for ac_func in _getb67 GETB67 getb67; do
+ AC_CHECK_FUNC($ac_func,
+ [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
+ [Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP
+ systems. This function is required for alloca.c support on those
+ systems.]) break])
+ done
+fi
+
+AC_CACHE_CHECK(stack direction for C alloca, ac_cv_c_stack_direction,
+[AC_TRY_RUN([find_stack_direction ()
+{
+ static char *addr = 0;
+ auto char dummy;
+ if (addr == 0)
+ {
+ addr = &dummy;
+ return find_stack_direction ();
+ }
+ else
+ return (&dummy > addr) ? 1 : -1;
+}
+main ()
+{
+ exit (find_stack_direction() < 0);
+}],
+ ac_cv_c_stack_direction=1,
+ ac_cv_c_stack_direction=-1,
+ ac_cv_c_stack_direction=0)])
+AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction,
+ [Define if you know the direction of stack growth for your system;
+ otherwise it will be automatically deduced at run-time.
+ STACK_DIRECTION > 0 => grows toward higher addresses
+ STACK_DIRECTION < 0 => grows toward lower addresses
+ STACK_DIRECTION = 0 => direction of growth unknown])
+])
diff --git a/contrib/binutils/libiberty/alloca.c b/contrib/binutils/libiberty/alloca.c
index 0f8a215..918235d 100644
--- a/contrib/binutils/libiberty/alloca.c
+++ b/contrib/binutils/libiberty/alloca.c
@@ -21,10 +21,33 @@
allocating any. It is a good idea to use alloca(0) in
your main control loop, etc. to force garbage collection. */
+/*
+
+@deftypefn Replacement void* alloca (size_t @var{size})
+
+This function allocates memory which will be automatically reclaimed
+after the procedure exits. The @libib{} implementation does not free
+the memory immediately but will do so eventually during subsequent
+calls to this function. Memory is allocated using @code{xmalloc} under
+normal circumstances.
+
+The header file @file{alloca-conf.h} can be used in conjunction with the
+GNU Autoconf test @code{AC_FUNC_ALLOCA} to test for and properly make
+available this function. The @code{AC_FUNC_ALLOCA} test requires that
+client code use a block of preprocessor code to be safe (see the Autoconf
+manual for more); this header incorporates that logic and more, including
+the possibility of a GCC built-in function.
+
+@end deftypefn
+
+*/
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
+#include <libiberty.h>
+
#ifdef HAVE_STRING_H
#include <string.h>
#endif
@@ -32,67 +55,26 @@
#include <stdlib.h>
#endif
-#ifdef emacs
-#include "blockinput.h"
-#endif
-
-/* If compiling with GCC 2, this file's not needed. Except of course if
- the C alloca is explicitly requested. */
-#if defined (USE_C_ALLOCA) || !defined (__GNUC__) || __GNUC__ < 2
-
-/* If someone has defined alloca as a macro,
- there must be some other way alloca is supposed to work. */
-#ifndef alloca
-
-#ifdef emacs
-#ifdef static
-/* actually, only want this if static is defined as ""
- -- this is for usg, in which emacs must undefine static
- in order to make unexec workable
- */
-#ifndef STACK_DIRECTION
-you
-lose
--- must know STACK_DIRECTION at compile-time
-#endif /* STACK_DIRECTION undefined */
-#endif /* static */
-#endif /* emacs */
+/* These variables are used by the ASTRDUP implementation that relies
+ on C_alloca. */
+const char *libiberty_optr;
+char *libiberty_nptr;
+unsigned long libiberty_len;
/* If your stack is a linked list of frames, you have to
provide an "address metric" ADDRESS_FUNCTION macro. */
#if defined (CRAY) && defined (CRAY_STACKSEG_END)
-long i00afunc ();
+static long i00afunc ();
#define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg))
#else
#define ADDRESS_FUNCTION(arg) &(arg)
#endif
-#if __STDC__
-typedef void *pointer;
-#else
-typedef char *pointer;
-#endif
-
#ifndef NULL
#define NULL 0
#endif
-/* Different portions of Emacs need to call different versions of
- malloc. The Emacs executable needs alloca to call xmalloc, because
- ordinary malloc isn't protected from input signals. On the other
- hand, the utilities in lib-src need alloca to call malloc; some of
- them are very simple, and don't have an xmalloc routine.
-
- Non-Emacs programs expect this to call use xmalloc.
-
- Callers below should use malloc. */
-
-#ifndef emacs
-#define malloc xmalloc
-#endif
-extern pointer malloc ();
-
/* Define STACK_DIRECTION if you know the direction of stack
growth for your system; otherwise it will be automatically
deduced at run-time.
@@ -168,9 +150,11 @@ static header *last_alloca_header = NULL; /* -> last alloca header. */
caller, but that method cannot be made to work for some
implementations of C, for example under Gould's UTX/32. */
-pointer
-alloca (size)
- unsigned size;
+/* @undocumented C_alloca */
+
+PTR
+C_alloca (size)
+ size_t size;
{
auto char probe; /* Probes stack depth: */
register char *depth = ADDRESS_FUNCTION (probe);
@@ -186,17 +170,13 @@ alloca (size)
{
register header *hp; /* Traverses linked list. */
-#ifdef emacs
- BLOCK_INPUT;
-#endif
-
for (hp = last_alloca_header; hp != NULL;)
if ((STACK_DIR > 0 && hp->h.deep > depth)
|| (STACK_DIR < 0 && hp->h.deep < depth))
{
register header *np = hp->h.next;
- free ((pointer) hp); /* Collect garbage. */
+ free ((PTR) hp); /* Collect garbage. */
hp = np; /* -> next header. */
}
@@ -204,10 +184,6 @@ alloca (size)
break; /* Rest are not deeper. */
last_alloca_header = hp; /* -> last valid storage. */
-
-#ifdef emacs
- UNBLOCK_INPUT;
-#endif
}
if (size == 0)
@@ -216,7 +192,7 @@ alloca (size)
/* Allocate combined header + user data storage. */
{
- register pointer new = malloc (sizeof (header) + size);
+ register PTR new = xmalloc (sizeof (header) + size);
/* Address of header. */
if (new == 0)
@@ -229,7 +205,7 @@ alloca (size)
/* User storage begins just after header. */
- return (pointer) ((char *) new + sizeof (header));
+ return (PTR) ((char *) new + sizeof (header));
}
}
@@ -500,6 +476,3 @@ i00afunc (long address)
#endif /* not CRAY2 */
#endif /* CRAY */
-
-#endif /* no alloca */
-#endif /* not GCC version 2 */
diff --git a/contrib/binutils/libiberty/argv.c b/contrib/binutils/libiberty/argv.c
index 7aec9c0..4205579 100644
--- a/contrib/binutils/libiberty/argv.c
+++ b/contrib/binutils/libiberty/argv.c
@@ -1,5 +1,5 @@
/* Create and destroy argument vectors (argv's)
- Copyright (C) 1992 Free Software Foundation, Inc.
+ Copyright (C) 1992, 2001 Free Software Foundation, Inc.
Written by Fred Fish @ Cygnus Support
This file is part of the libiberty library.
@@ -48,7 +48,6 @@ extern char *strdup (); /* Duplicate a string */
#endif /* __STDC__ */
-#include "alloca-conf.h"
#ifndef NULL
#define NULL 0
@@ -63,26 +62,15 @@ extern char *strdup (); /* Duplicate a string */
/*
-NAME
+@deftypefn Extension char** dupargv (char **@var{vector})
- dupargv -- duplicate an argument vector
+Duplicate an argument vector. Simply scans through @var{vector},
+duplicating each argument until the terminating @code{NULL} is found.
+Returns a pointer to the argument vector if successful. Returns
+@code{NULL} if there is insufficient memory to complete building the
+argument vector.
-SYNOPSIS
-
- char **dupargv (vector)
- char **vector;
-
-DESCRIPTION
-
- Duplicate an argument vector. Simply scans through the
- vector, duplicating each argument until the
- terminating NULL is found.
-
-RETURNS
-
- Returns a pointer to the argument vector if
- successful. Returns NULL if there is insufficient memory to
- complete building the argument vector.
+@end deftypefn
*/
@@ -120,24 +108,14 @@ dupargv (argv)
/*
-NAME
-
- freeargv -- free an argument vector
-
-SYNOPSIS
+@deftypefn Extension void freeargv (char **@var{vector})
- void freeargv (vector)
- char **vector;
+Free an argument vector that was built using @code{buildargv}. Simply
+scans through @var{vector}, freeing the memory for each argument until
+the terminating @code{NULL} is found, and then frees @var{vector}
+itself.
-DESCRIPTION
-
- Free an argument vector that was built using buildargv. Simply scans
- through the vector, freeing the memory for each argument until the
- terminating NULL is found, and then frees the vector itself.
-
-RETURNS
-
- No value.
+@end deftypefn
*/
@@ -158,53 +136,46 @@ char **vector;
/*
-NAME
-
- buildargv -- build an argument vector from a string
-
-SYNOPSIS
-
- char **buildargv (sp)
- char *sp;
-
-DESCRIPTION
+@deftypefn Extension char** buildargv (char *@var{sp})
- Given a pointer to a string, parse the string extracting fields
- separated by whitespace and optionally enclosed within either single
- or double quotes (which are stripped off), and build a vector of
- pointers to copies of the string for each field. The input string
- remains unchanged.
+Given a pointer to a string, parse the string extracting fields
+separated by whitespace and optionally enclosed within either single
+or double quotes (which are stripped off), and build a vector of
+pointers to copies of the string for each field. The input string
+remains unchanged. The last element of the vector is followed by a
+@code{NULL} element.
- All of the memory for the pointer array and copies of the string
- is obtained from malloc. All of the memory can be returned to the
- system with the single function call freeargv, which takes the
- returned result of buildargv, as it's argument.
+All of the memory for the pointer array and copies of the string
+is obtained from @code{malloc}. All of the memory can be returned to the
+system with the single function call @code{freeargv}, which takes the
+returned result of @code{buildargv}, as it's argument.
- The memory for the argv array is dynamically expanded as necessary.
+Returns a pointer to the argument vector if successful. Returns
+@code{NULL} if @var{sp} is @code{NULL} or if there is insufficient
+memory to complete building the argument vector.
-RETURNS
+If the input is a null string (as opposed to a @code{NULL} pointer),
+then buildarg returns an argument vector that has one arg, a null
+string.
- Returns a pointer to the argument vector if successful. Returns NULL
- if the input string pointer is NULL or if there is insufficient
- memory to complete building the argument vector.
+@end deftypefn
-NOTES
+The memory for the argv array is dynamically expanded as necessary.
- In order to provide a working buffer for extracting arguments into,
- with appropriate stripping of quotes and translation of backslash
- sequences, we allocate a working buffer at least as long as the input
- string. This ensures that we always have enough space in which to
- work, since the extracted arg is never larger than the input string.
+In order to provide a working buffer for extracting arguments into,
+with appropriate stripping of quotes and translation of backslash
+sequences, we allocate a working buffer at least as long as the input
+string. This ensures that we always have enough space in which to
+work, since the extracted arg is never larger than the input string.
- If the input is a null string (as opposed to a NULL pointer), then
- buildarg returns an argv that has one arg, a null string.
+The argument vector is always kept terminated with a @code{NULL} arg
+pointer, so it can be passed to @code{freeargv} at any time, or
+returned, as appropriate.
- Argv is always kept terminated with a NULL arg pointer, so it can
- be passed to freeargv at any time, or returned, as appropriate.
*/
char **buildargv (input)
-char *input;
+ const char *input;
{
char *arg;
char *copybuf;
@@ -337,7 +308,7 @@ char *input;
/* Simple little test driver. */
-static char *tests[] =
+static const char *const tests[] =
{
"a simple command line",
"arg 'foo' is single quoted",
@@ -354,10 +325,10 @@ static char *tests[] =
NULL
};
-main ()
+int main ()
{
char **argv;
- char **test;
+ const char *const *test;
char **targs;
for (test = tests; *test != NULL; test++)
@@ -378,6 +349,7 @@ main ()
freeargv (argv);
}
+ return 0;
}
#endif /* MAIN */
diff --git a/contrib/binutils/libiberty/asprintf.c b/contrib/binutils/libiberty/asprintf.c
index 5aaf320..5de7756 100644
--- a/contrib/binutils/libiberty/asprintf.c
+++ b/contrib/binutils/libiberty/asprintf.c
@@ -22,36 +22,36 @@ Boston, MA 02111-1307, USA. */
#include "ansidecl.h"
#include "libiberty.h"
-#if defined (ANSI_PROTOTYPES) || defined (ALMOST_STDC)
-#define USE_STDARG
-#endif
-
-#ifdef USE_STDARG
+#ifdef ANSI_PROTOTYPES
#include <stdarg.h>
#else
#include <varargs.h>
#endif
-/* VARARGS */
-#ifdef USE_STDARG
-int
-asprintf (char **buf, const char *fmt, ...)
-#else
+/*
+
+@deftypefn Extension int asprintf (char **@var{resptr}, const char *@var{format}, ...)
+
+Like @code{sprintf}, but instead of passing a pointer to a buffer, you
+pass a pointer to a pointer. This function will compute the size of
+the buffer needed, allocate memory with @code{malloc}, and store a
+pointer to the allocated memory in @code{*@var{resptr}}. The value
+returned is the same as @code{sprintf} would return. If memory could
+not be allocated, zero is returned and @code{NULL} is stored in
+@code{*@var{resptr}}.
+
+@end deftypefn
+
+*/
+
int
-asprintf (buf, fmt, va_alist)
- char **buf;
- const char *fmt;
- va_dcl
-#endif
+asprintf VPARAMS ((char **buf, const char *fmt, ...))
{
int status;
- va_list ap;
-#ifdef USE_STDARG
- va_start (ap, fmt);
-#else
- va_start (ap);
-#endif
+ VA_OPEN (ap, fmt);
+ VA_FIXEDARG (ap, char **, buf);
+ VA_FIXEDARG (ap, const char *, fmt);
status = vasprintf (buf, fmt, ap);
- va_end (ap);
+ VA_CLOSE (ap);
return status;
}
diff --git a/contrib/binutils/libiberty/atexit.c b/contrib/binutils/libiberty/atexit.c
index 137d985..e14de29 100644
--- a/contrib/binutils/libiberty/atexit.c
+++ b/contrib/binutils/libiberty/atexit.c
@@ -1,6 +1,16 @@
/* Wrapper to implement ANSI C's atexit using SunOS's on_exit. */
/* This function is in the public domain. --Mike Stump. */
+/*
+
+@deftypefn Supplemental int atexit (void (*@var{f})())
+
+Causes function @var{f} to be called at exit. Returns 0.
+
+@end deftypefn
+
+*/
+
#include "config.h"
#ifdef HAVE_ON_EXIT
diff --git a/contrib/binutils/libiberty/basename.c b/contrib/binutils/libiberty/basename.c
index ca089eb..69a982d 100644
--- a/contrib/binutils/libiberty/basename.c
+++ b/contrib/binutils/libiberty/basename.c
@@ -2,20 +2,14 @@
This file is in the public domain. */
/*
-NAME
- basename -- return pointer to last component of a pathname
-SYNOPSIS
- char *basename (const char *name)
+@deftypefn Supplemental char* basename (const char *@var{name})
-DESCRIPTION
- Given a pointer to a string containing a typical pathname
- (/usr/src/cmd/ls/ls.c for example), returns a pointer to the
- last component of the pathname ("ls.c" in this case).
+Returns a pointer to the last component of pathname @var{name}.
+Behavior is undefined if the pathname ends in a directory separator.
+
+@end deftypefn
-BUGS
- Presumes a UNIX or DOS/Windows style path with UNIX or DOS/Windows
- style separators.
*/
#include "ansidecl.h"
diff --git a/contrib/binutils/libiberty/bcmp.c b/contrib/binutils/libiberty/bcmp.c
index 11e4417..1895773 100644
--- a/contrib/binutils/libiberty/bcmp.c
+++ b/contrib/binutils/libiberty/bcmp.c
@@ -3,28 +3,15 @@
/*
-NAME
+@deftypefn Supplemental int bcmp (char *@var{x}, char *@var{y}, int @var{count})
- bcmp -- compare two memory regions
+Compares the first @var{count} bytes of two areas of memory. Returns
+zero if they are the same, nonzero otherwise. Returns zero if
+@var{count} is zero. A nonzero result only indicates a difference,
+it does not indicate any sorting order (say, by having a positive
+result mean @var{x} sorts before @var{y}).
-SYNOPSIS
-
- int bcmp (char *from, char *to, int count)
-
-DESCRIPTION
-
- Compare two memory regions and return zero if they are identical,
- non-zero otherwise. If count is zero, return zero.
-
-NOTES
-
- No guarantee is made about the non-zero returned value. In
- particular, the results may be signficantly different than
- strcmp(), where the return value is guaranteed to be less than,
- equal to, or greater than zero, according to lexicographical
- sorting of the compared regions.
-
-BUGS
+@end deftypefn
*/
diff --git a/contrib/binutils/libiberty/bcopy.c b/contrib/binutils/libiberty/bcopy.c
index b655363..70fa7e3 100644
--- a/contrib/binutils/libiberty/bcopy.c
+++ b/contrib/binutils/libiberty/bcopy.c
@@ -1,19 +1,11 @@
/* bcopy -- copy memory regions of arbitary length
-NAME
- bcopy -- copy memory regions of arbitrary length
+@deftypefn Supplemental void bcopy (char *@var{in}, char *@var{out}, int @var{length})
-SYNOPSIS
- void bcopy (char *in, char *out, int length)
+Copies @var{length} bytes from memory region @var{in} to region
+@var{out}. The use of @code{bcopy} is deprecated in new programs.
-DESCRIPTION
- Copy LENGTH bytes from memory region pointed to by IN to memory
- region pointed to by OUT.
-
-BUGS
- Significant speed improvements can be made in some cases by
- implementing copies of multiple bytes simultaneously, or unrolling
- the copy loop.
+@end deftypefn
*/
diff --git a/contrib/binutils/libiberty/bsearch.c b/contrib/binutils/libiberty/bsearch.c
index 6a8ee33..b3283f9 100644
--- a/contrib/binutils/libiberty/bsearch.c
+++ b/contrib/binutils/libiberty/bsearch.c
@@ -28,6 +28,23 @@
* SUCH DAMAGE.
*/
+/*
+
+@deftypefn Supplemental void* bsearch (const void *@var{key}, const void *@var{base}, size_t @var{nmemb}, size_t @var{size}, int (*@var{compar})(const void *, const void *))
+
+Performs a search over an array of @var{nmemb} elements pointed to by
+@var{base} for a member that matches the object pointed to by @var{key}.
+The size of each member is specified by @var{size}. The array contents
+should be sorted in ascending order according to the @var{compar}
+comparison function. This routine should take two arguments pointing to
+the @var{key} and to an array member, in that order, and should return an
+integer less than, equal to, or greater than zero if the @var{key} object
+is respectively less than, matching, or greater than the array member.
+
+@end deftypefn
+
+*/
+
#include "config.h"
#include "ansidecl.h"
#include <sys/types.h> /* size_t */
diff --git a/contrib/binutils/libiberty/bzero.c b/contrib/binutils/libiberty/bzero.c
index d01644b7..8874118 100644
--- a/contrib/binutils/libiberty/bzero.c
+++ b/contrib/binutils/libiberty/bzero.c
@@ -2,19 +2,13 @@
This function is in the public domain. */
/*
-NAME
- bzero -- zero the contents of a specified memory region
-SYNOPSIS
- void bzero (char *to, int count)
+@deftypefn Supplemental void bzero (char *@var{mem}, int @var{count})
-DESCRIPTION
- Zero COUNT bytes of memory pointed to by TO.
+Zeros @var{count} bytes starting at @var{mem}. Use of this function
+is deprecated in favor of @code{memset}.
-BUGS
- Significant speed enhancements may be made in some environments
- by zeroing more than a single byte at a time, or by unrolling the
- loop.
+@end deftypefn
*/
diff --git a/contrib/binutils/libiberty/calloc.c b/contrib/binutils/libiberty/calloc.c
index 334b18d..b342f6c 100644
--- a/contrib/binutils/libiberty/calloc.c
+++ b/contrib/binutils/libiberty/calloc.c
@@ -1,5 +1,16 @@
/* calloc -- allocate memory which has been initialized to zero.
This function is in the public domain. */
+
+/*
+
+@deftypefn Supplemental void* calloc (size_t @var{nelem}, size_t @var{elsize})
+
+Uses @code{malloc} to allocate storage for @var{nelem} objects of
+@var{elsize} bytes each, then zeros the memory.
+
+@end deftypefn
+
+*/
#include "ansidecl.h"
#include "libiberty.h"
diff --git a/contrib/binutils/libiberty/choose-temp.c b/contrib/binutils/libiberty/choose-temp.c
index 1a475dd..5c2c614 100644
--- a/contrib/binutils/libiberty/choose-temp.c
+++ b/contrib/binutils/libiberty/choose-temp.c
@@ -17,124 +17,52 @@ License along with libiberty; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-/* This file exports two functions: choose_temp_base and make_temp_file. */
-
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h> /* May get P_tmpdir. */
-#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
-#ifdef HAVE_SYS_FILE_H
-#include <sys/file.h> /* May get R_OK, etc. on some systems. */
-#endif
-
-#ifndef R_OK
-#define R_OK 4
-#define W_OK 2
-#define X_OK 1
-#endif
#include "libiberty.h"
-extern int mkstemps ();
-
-#ifndef IN_GCC
-#if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN__) && ! defined (_UWIN))
-#define DIR_SEPARATOR '\\'
-#endif
-#endif
-
-#ifndef DIR_SEPARATOR
-#define DIR_SEPARATOR '/'
-#endif
-
-/* On MSDOS, write temp files in current dir
- because there's no place else we can expect to use. */
-/* ??? Although the current directory is tried as a last resort,
- this is left in so that on MSDOS it is preferred to /tmp on the
- off chance that someone requires this, since that was the previous
- behaviour. */
-#ifdef __MSDOS__
-#ifndef P_tmpdir
-#define P_tmpdir "."
-#endif
-#endif
+extern char *choose_tmpdir PARAMS ((void));
/* Name of temporary file.
mktemp requires 6 trailing X's. */
#define TEMP_FILE "ccXXXXXX"
+#define TEMP_FILE_LEN (sizeof(TEMP_FILE) - 1)
-/* Subroutine of choose_temp_base.
- If BASE is non-NULL, return it.
- Otherwise it checks if DIR is a usable directory.
- If success, DIR is returned.
- Otherwise NULL is returned. */
+/*
-static const char *try PARAMS ((const char *, const char *));
+@deftypefn Extension char* choose_temp_base (void)
-static const char *
-try (dir, base)
- const char *dir, *base;
-{
- if (base != 0)
- return base;
- if (dir != 0
- && access (dir, R_OK | W_OK | X_OK) == 0)
- return dir;
- return 0;
-}
+Return a prefix for temporary file names or @code{NULL} if unable to
+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}.
-/* Return a prefix for temporary file names or NULL if unable to find one.
- The current directory is chosen if all else fails so the program is
- exited if a temporary directory can't be found (mktemp fails).
- The buffer for the result is obtained with xmalloc.
+This function is provided for backwards compatability only. Its use is
+not recommended.
- This function is provided for backwards compatability only. It use
- is not recommended. */
+@end deftypefn
+
+*/
char *
choose_temp_base ()
{
- const char *base = 0;
+ const char *base = choose_tmpdir ();
char *temp_filename;
int len;
- static char tmp[] = { DIR_SEPARATOR, 't', 'm', 'p', 0 };
- static char usrtmp[] = { DIR_SEPARATOR, 'u', 's', 'r', DIR_SEPARATOR, 't', 'm', 'p', 0 };
-
- base = try (getenv ("TMPDIR"), base);
- base = try (getenv ("TMP"), base);
- base = try (getenv ("TEMP"), base);
-
-#ifdef P_tmpdir
- base = try (P_tmpdir, base);
-#endif
-
- /* Try /usr/tmp, then /tmp. */
- base = try (usrtmp, base);
- base = try (tmp, base);
-
- /* If all else fails, use the current directory! */
- if (base == 0)
- base = ".";
len = strlen (base);
- temp_filename = xmalloc (len + 1 /*DIR_SEPARATOR*/
- + strlen (TEMP_FILE) + 1);
+ temp_filename = xmalloc (len + TEMP_FILE_LEN + 1);
strcpy (temp_filename, base);
-
- if (len != 0
- && temp_filename[len-1] != '/'
- && temp_filename[len-1] != DIR_SEPARATOR)
- temp_filename[len++] = DIR_SEPARATOR;
strcpy (temp_filename + len, TEMP_FILE);
mktemp (temp_filename);
@@ -142,64 +70,3 @@ choose_temp_base ()
abort ();
return temp_filename;
}
-/* Return a temporary file name (as a string) or NULL if unable to create
- one. */
-
-char *
-make_temp_file (suffix)
- const char *suffix;
-{
- const char *base = 0;
- char *temp_filename;
- int base_len, suffix_len;
- int fd;
- static char tmp[] = { DIR_SEPARATOR, 't', 'm', 'p', 0 };
- static char usrtmp[] = { DIR_SEPARATOR, 'u', 's', 'r', DIR_SEPARATOR, 't', 'm', 'p', 0 };
-
- base = try (getenv ("TMPDIR"), base);
- base = try (getenv ("TMP"), base);
- base = try (getenv ("TEMP"), base);
-
-#ifdef P_tmpdir
- base = try (P_tmpdir, base);
-#endif
-
- /* Try /usr/tmp, then /tmp. */
- base = try (usrtmp, base);
- base = try (tmp, base);
-
- /* If all else fails, use the current directory! */
- if (base == 0)
- base = ".";
-
- base_len = strlen (base);
-
- if (suffix)
- suffix_len = strlen (suffix);
- else
- suffix_len = 0;
-
- temp_filename = xmalloc (base_len + 1 /*DIR_SEPARATOR*/
- + strlen (TEMP_FILE)
- + suffix_len + 1);
- strcpy (temp_filename, base);
-
- if (base_len != 0
- && temp_filename[base_len-1] != '/'
- && temp_filename[base_len-1] != DIR_SEPARATOR)
- temp_filename[base_len++] = DIR_SEPARATOR;
- strcpy (temp_filename + base_len, TEMP_FILE);
-
- if (suffix)
- strcat (temp_filename, suffix);
-
- fd = mkstemps (temp_filename, suffix_len);
- /* If mkstemps failed, then something bad is happening. Maybe we should
- issue a message about a possible security attack in progress? */
- if (fd == -1)
- abort ();
- /* Similarly if we can not close the file. */
- if (close (fd))
- abort ();
- return temp_filename;
-}
diff --git a/contrib/binutils/libiberty/clock.c b/contrib/binutils/libiberty/clock.c
index db2509c..3ea70c3 100644
--- a/contrib/binutils/libiberty/clock.c
+++ b/contrib/binutils/libiberty/clock.c
@@ -22,6 +22,18 @@ the resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why
the executable file might be covered by the GNU General Public License. */
+/*
+
+@deftypefn Supplemental long clock (void)
+
+Returns an approximation of the CPU time used by the process as a
+@code{clock_t}; divide this number by @samp{CLOCKS_PER_SEC} to get the
+number of seconds used.
+
+@end deftypefn
+
+*/
+
#include "config.h"
#ifdef HAVE_GETRUSAGE
diff --git a/contrib/binutils/libiberty/concat.c b/contrib/binutils/libiberty/concat.c
index 5b132c8..98b20e1 100644
--- a/contrib/binutils/libiberty/concat.c
+++ b/contrib/binutils/libiberty/concat.c
@@ -1,5 +1,5 @@
/* Concatenate variable number of strings.
- Copyright (C) 1991, 1994 Free Software Foundation, Inc.
+ Copyright (C) 1991, 1994, 2001 Free Software Foundation, Inc.
Written by Fred Fish @ Cygnus Support
This file is part of the libiberty library.
@@ -21,24 +21,14 @@ Boston, MA 02111-1307, USA. */
/*
-NAME
+@deftypefn Extension char* concat (const char *@var{s1}, const char *@var{s2}, @dots{}, @code{NULL})
- concat -- concatenate a variable number of strings
+Concatenate zero or more of strings and return the result in freshly
+@code{xmalloc}ed memory. Returns @code{NULL} if insufficient memory is
+available. The argument list is terminated by the first @code{NULL}
+pointer encountered. Pointers to empty strings are ignored.
-SYNOPSIS
-
- #include <varargs.h>
-
- char *concat (s1, s2, s3, ..., NULL)
-
-DESCRIPTION
-
- Concatenate a variable number of strings and return the result
- in freshly malloc'd memory.
-
- Returns NULL if insufficient memory is available. The argument
- list is terminated by the first NULL pointer encountered. Pointers
- to empty strings are ignored.
+@end deftypefn
NOTES
@@ -50,11 +40,16 @@ NOTES
deal with low memory situations itself, it should supply an xmalloc
that just directly invokes malloc and blindly returns whatever
malloc returns.
+
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include "ansidecl.h"
#include "libiberty.h"
+#include <sys/types.h> /* size_t */
#ifdef ANSI_PROTOTYPES
#include <stdarg.h>
@@ -62,90 +57,164 @@ NOTES
#include <varargs.h>
#endif
-#ifdef __STDC__
-#include <stddef.h>
-extern size_t strlen (const char *s);
-#else
-extern int strlen ();
+# if HAVE_STRING_H
+# include <string.h>
+# else
+# if HAVE_STRINGS_H
+# include <strings.h>
+# endif
+# endif
+
+#if HAVE_STDLIB_H
+#include <stdlib.h>
#endif
-#define NULLP (char *)0
+static inline unsigned long vconcat_length PARAMS ((const char *, va_list));
+static inline unsigned long
+vconcat_length (first, args)
+ const char *first;
+ va_list args;
+{
+ unsigned long length = 0;
+ const char *arg;
+
+ for (arg = first; arg ; arg = va_arg (args, const char *))
+ length += strlen (arg);
+
+ return length;
+}
+
+static inline char *vconcat_copy PARAMS ((char *, const char *, va_list));
+static inline char *
+vconcat_copy (dst, first, args)
+ char *dst;
+ const char *first;
+ va_list args;
+{
+ char *end = dst;
+ const char *arg;
+
+ for (arg = first; arg ; arg = va_arg (args, const char *))
+ {
+ unsigned long length = strlen (arg);
+ memcpy (end, arg, length);
+ end += length;
+ }
+ *end = '\000';
+
+ return dst;
+}
+
+/* @undocumented concat_length */
+
+unsigned long
+concat_length VPARAMS ((const char *first, ...))
+{
+ unsigned long length;
+
+ VA_OPEN (args, first);
+ VA_FIXEDARG (args, const char *, first);
+ length = vconcat_length (first, args);
+ VA_CLOSE (args);
+
+ return length;
+}
+
+/* @undocumented concat_copy */
-/* VARARGS */
-#ifdef ANSI_PROTOTYPES
char *
-concat (const char *first, ...)
-#else
+concat_copy VPARAMS ((char *dst, const char *first, ...))
+{
+ char *save_dst;
+
+ VA_OPEN (args, first);
+ VA_FIXEDARG (args, char *, dst);
+ VA_FIXEDARG (args, const char *, first);
+ vconcat_copy (dst, first, args);
+ save_dst = dst; /* With K&R C, dst goes out of scope here. */
+ VA_CLOSE (args);
+
+ return save_dst;
+}
+
+char *libiberty_concat_ptr;
+
+/* @undocumented concat_copy2 */
+
char *
-concat (va_alist)
- va_dcl
-#endif
+concat_copy2 VPARAMS ((const char *first, ...))
{
- register int length;
- register char *newstr;
- register char *end;
- register const char *arg;
- va_list args;
-#ifndef ANSI_PROTOTYPES
- const char *first;
-#endif
+ VA_OPEN (args, first);
+ VA_FIXEDARG (args, const char *, first);
+ vconcat_copy (libiberty_concat_ptr, first, args);
+ VA_CLOSE (args);
- /* First compute the size of the result and get sufficient memory. */
+ return libiberty_concat_ptr;
+}
-#ifdef ANSI_PROTOTYPES
- va_start (args, first);
-#else
- va_start (args);
- first = va_arg (args, const char *);
-#endif
+char *
+concat VPARAMS ((const char *first, ...))
+{
+ char *newstr;
- if (first == NULLP)
- length = 0;
- else
- {
- length = strlen (first);
- while ((arg = va_arg (args, const char *)) != NULLP)
- {
- length += strlen (arg);
- }
- }
- newstr = (char *) xmalloc (length + 1);
- va_end (args);
+ /* First compute the size of the result and get sufficient memory. */
+ VA_OPEN (args, first);
+ VA_FIXEDARG (args, const char *, first);
+ newstr = (char *) xmalloc (vconcat_length (first, args) + 1);
+ VA_CLOSE (args);
/* Now copy the individual pieces to the result string. */
+ VA_OPEN (args, first);
+ VA_FIXEDARG (args, const char *, first);
+ vconcat_copy (newstr, first, args);
+ VA_CLOSE (args);
- if (newstr != NULLP)
- {
-#ifdef ANSI_PROTOTYPES
- va_start (args, first);
-#else
- va_start (args);
- first = va_arg (args, const char *);
-#endif
- end = newstr;
- if (first != NULLP)
- {
- arg = first;
- while (*arg)
- {
- *end++ = *arg++;
- }
- while ((arg = va_arg (args, const char *)) != NULLP)
- {
- while (*arg)
- {
- *end++ = *arg++;
- }
- }
- }
- *end = '\000';
- va_end (args);
- }
+ return newstr;
+}
+
+/*
+
+@deftypefn Extension char* reconcat (char *@var{optr}, const char *@var{s1}, @dots{}, @code{NULL})
+
+Same as @code{concat}, except that if @var{optr} is not @code{NULL} it
+is freed after the string is created. This is intended to be useful
+when you're extending an existing string or building up a string in a
+loop:
+
+@example
+ str = reconcat (str, "pre-", str, NULL);
+@end example
+
+@end deftypefn
- return (newstr);
+*/
+
+char *
+reconcat VPARAMS ((char *optr, const char *first, ...))
+{
+ char *newstr;
+
+ /* First compute the size of the result and get sufficient memory. */
+ VA_OPEN (args, first);
+ VA_FIXEDARG (args, char *, optr);
+ VA_FIXEDARG (args, const char *, first);
+ newstr = (char *) xmalloc (vconcat_length (first, args) + 1);
+ VA_CLOSE (args);
+
+ /* Now copy the individual pieces to the result string. */
+ VA_OPEN (args, first);
+ VA_FIXEDARG (args, char *, optr);
+ VA_FIXEDARG (args, const char *, first);
+ vconcat_copy (newstr, first, args);
+ if (optr) /* Done before VA_CLOSE so optr stays in scope for K&R C. */
+ free (optr);
+ VA_CLOSE (args);
+
+ return newstr;
}
#ifdef MAIN
+#define NULLP (char *)0
/* Simple little test driver. */
diff --git a/contrib/binutils/libiberty/config.in b/contrib/binutils/libiberty/config.in
index 1fb946a..e06bbce 100644
--- a/contrib/binutils/libiberty/config.in
+++ b/contrib/binutils/libiberty/config.in
@@ -1,21 +1,8 @@
-/* config.in. Generated automatically from configure.in by autoheader. */
-
-/* Define if using alloca.c. */
-#undef C_ALLOCA
+/* config.in. Generated automatically from configure.in by autoheader 2.13. */
/* Define to empty if the keyword does not work. */
#undef const
-/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
- This function is required for alloca.c support on those systems. */
-#undef CRAY_STACKSEG_END
-
-/* Define if you have alloca, as a function or macro. */
-#undef HAVE_ALLOCA
-
-/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
-#undef HAVE_ALLOCA_H
-
/* Define if you have a working `mmap' system call. */
#undef HAVE_MMAP
@@ -34,15 +21,6 @@
/* Define if you need to in order for stat and other things to work. */
#undef _POSIX_SOURCE
-/* If using the C implementation of alloca, define if you know the
- direction of stack growth for your system; otherwise it will be
- automatically deduced at run-time.
- STACK_DIRECTION > 0 => grows toward higher addresses
- STACK_DIRECTION < 0 => grows toward lower addresses
- STACK_DIRECTION = 0 => direction of growth unknown
- */
-#undef STACK_DIRECTION
-
/* Define if you have the ANSI C header files. */
#undef STDC_HEADERS
@@ -52,6 +30,9 @@
/* Define vfork as fork if vfork does not work. */
#undef vfork
+/* Define if you have the _doprnt function. */
+#undef HAVE__DOPRNT
+
/* Define if you have the asprintf function. */
#undef HAVE_ASPRINTF
@@ -79,6 +60,9 @@
/* Define if you have the clock function. */
#undef HAVE_CLOCK
+/* Define if you have the ffs function. */
+#undef HAVE_FFS
+
/* Define if you have the getcwd function. */
#undef HAVE_GETCWD
@@ -199,6 +183,9 @@
/* Define if you have the waitpid function. */
#undef HAVE_WAITPID
+/* Define if you have the <alloca.h> header file. */
+#undef HAVE_ALLOCA_H
+
/* Define if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
@@ -241,6 +228,9 @@
/* Define if errno must be declared even when <errno.h> is included. */
#undef NEED_DECLARATION_ERRNO
+/* Define if you have the `uintptr_t' type. */
+#undef HAVE_UINTPTR_T
+
/* Define if you have the sys_errlist variable. */
#undef HAVE_SYS_ERRLIST
@@ -250,3 +240,15 @@
/* Define if you have the sys_siglist variable. */
#undef HAVE_SYS_SIGLIST
+/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP
+ systems. This function is required for alloca.c support on those
+ systems. */
+#undef CRAY_STACKSEG_END
+
+/* Define if you know the direction of stack growth for your system;
+ otherwise it will be automatically deduced at run-time.
+ STACK_DIRECTION > 0 => grows toward higher addresses
+ STACK_DIRECTION < 0 => grows toward lower addresses
+ STACK_DIRECTION = 0 => direction of growth unknown */
+#undef STACK_DIRECTION
+
diff --git a/contrib/binutils/libiberty/config.table b/contrib/binutils/libiberty/config.table
index ea3312b..fa892c0 100644
--- a/contrib/binutils/libiberty/config.table
+++ b/contrib/binutils/libiberty/config.table
@@ -6,7 +6,6 @@ case "${host}" in
*-*-freebsd2.2.[012]) frag=mh-fbsd21 ;;
i370-*-opened*) frag=mh-openedition ;;
i[345]86-*-windows*) frag=mh-windows ;;
- *-*-beos*) frag=mh-beos ;;
esac
frags=$frag
diff --git a/contrib/binutils/libiberty/configure b/contrib/binutils/libiberty/configure
index ca24ef9..a406d28 100755
--- a/contrib/binutils/libiberty/configure
+++ b/contrib/binutils/libiberty/configure
@@ -17,6 +17,10 @@ ac_help="$ac_help
--with-cross-host=HOST Configuring with a cross compiler"
ac_help="$ac_help
--with-newlib Configuring with newlib"
+ac_help="$ac_help
+ --enable-maintainer-mode
+ enable make rules and dependencies not useful
+ (and sometimes confusing) to the casual installer"
# Initialize some variables set by options.
# The variables have the same names as the options, with
@@ -581,13 +585,119 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6
+echo "configure:590: checking whether to enable maintainer-specific portions of Makefiles" >&5
+ # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given.
+if test "${enable_maintainer_mode+set}" = set; then
+ enableval="$enable_maintainer_mode"
+ maintainer_mode=$enableval
+else
+ maintainer_mode=no
+fi
+
+
+echo "$ac_t""$maintainer_mode" 1>&6
+
+if test "$maintainer_mode" = "yes"; then
+ MAINT=''
+ NOTMAINT='#'
+else
+ MAINT='#'
+ NOTMAINT=''
+fi
+
+# Do we have a single-tree copy of texinfo? Even if we do, we can't
+# rely on it - libiberty is built before texinfo.
+# Extract the first word of "makeinfo", so it can be a program name with args.
+set dummy makeinfo; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:615: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_MAKEINFO'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$MAKEINFO"; then
+ ac_cv_prog_MAKEINFO="$MAKEINFO" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_MAKEINFO="makeinfo"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+MAKEINFO="$ac_cv_prog_MAKEINFO"
+if test -n "$MAKEINFO"; then
+ echo "$ac_t""$MAKEINFO" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+if test "x$MAKEINFO" = "x"; then
+ MAKEINFO="@echo makeinfo missing; true"
+ BUILD_INFO=
+else
+ BUILD_INFO=info
+ case x"`$MAKEINFO --version | grep 'GNU texinfo'`" in
+ x*\ [1-3].* )
+ MAKEINFO="@echo $MAKEINFO is too old, 4.0 or newer required; true"
+ BUILD_INFO=
+ echo "configure: warning:
+*** Makeinfo is too old. Info documentation will not be built." 1>&2
+ ;;
+ esac
+fi
+
+
+
+# Extract the first word of "perl", so it can be a program name with args.
+set dummy perl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:661: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_PERL'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$PERL"; then
+ ac_cv_prog_PERL="$PERL" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_PERL="perl"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+PERL="$ac_cv_prog_PERL"
+if test -n "$PERL"; then
+ echo "$ac_t""$PERL" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+if test x"$PERL" = x""; then
+ HAVE_PERL='#'
+else
+ HAVE_PERL=''
+fi
+
+
+
# Make sure we can run config.sub.
if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
fi
echo $ac_n "checking host system type""... $ac_c" 1>&6
-echo "configure:591: checking host system type" >&5
+echo "configure:701: checking host system type" >&5
host_alias=$host
case "$host_alias" in
@@ -610,7 +720,7 @@ echo "$ac_t""$host" 1>&6
echo $ac_n "checking build system type""... $ac_c" 1>&6
-echo "configure:614: checking build system type" >&5
+echo "configure:724: checking build system type" >&5
build_alias=$build
case "$build_alias" in
@@ -636,7 +746,7 @@ fi
# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
set dummy ${ac_tool_prefix}ar; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:640: checking for $ac_word" >&5
+echo "configure:750: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -668,7 +778,7 @@ fi
# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
set dummy ${ac_tool_prefix}ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:672: checking for $ac_word" >&5
+echo "configure:782: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -700,7 +810,7 @@ if test -n "$ac_tool_prefix"; then
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:704: checking for $ac_word" >&5
+echo "configure:814: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -737,7 +847,7 @@ fi
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:741: checking for $ac_word" >&5
+echo "configure:851: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -767,7 +877,7 @@ if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:771: checking for $ac_word" >&5
+echo "configure:881: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -816,7 +926,7 @@ fi
fi
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:820: checking whether we are using GNU C" >&5
+echo "configure:930: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -825,7 +935,7 @@ else
yes;
#endif
EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:829: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:939: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
@@ -841,7 +951,7 @@ if test $ac_cv_prog_gcc = yes; then
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:845: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:955: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -872,7 +982,7 @@ fi
echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6
-echo "configure:876: checking for POSIXized ISC" >&5
+echo "configure:986: checking for POSIXized ISC" >&5
if test -d /etc/conf/kconfig.d &&
grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
then
@@ -893,12 +1003,12 @@ else
fi
echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:897: checking for working const" >&5
+echo "configure:1007: checking for working const" >&5
if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 902 "configure"
+#line 1012 "configure"
#include "confdefs.h"
int main() {
@@ -947,7 +1057,7 @@ ccp = (char const *const *) p;
; return 0; }
EOF
-if { (eval echo configure:951: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1061: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_const=yes
else
@@ -968,21 +1078,21 @@ EOF
fi
echo $ac_n "checking for inline""... $ac_c" 1>&6
-echo "configure:972: checking for inline" >&5
+echo "configure:1082: checking for inline" >&5
if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_cv_c_inline=no
for ac_kw in inline __inline__ __inline; do
cat > conftest.$ac_ext <<EOF
-#line 979 "configure"
+#line 1089 "configure"
#include "confdefs.h"
int main() {
} $ac_kw foo() {
; return 0; }
EOF
-if { (eval echo configure:986: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1096: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_c_inline=$ac_kw; break
else
@@ -1025,7 +1135,7 @@ esac
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:1029: checking for a BSD compatible install" >&5
+echo "configure:1139: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -1086,7 +1196,7 @@ host_makefile_frag=${frag}
# able to link anything, it had better be able to at least compile
# something.
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1090: checking how to run the C preprocessor" >&5
+echo "configure:1200: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@@ -1101,13 +1211,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 1105 "configure"
+#line 1215 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1111: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1221: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1118,13 +1228,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 1122 "configure"
+#line 1232 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1128: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1238: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1135,13 +1245,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
-#line 1139 "configure"
+#line 1249 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1145: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1255: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@@ -1165,21 +1275,21 @@ else
fi
echo "$ac_t""$CPP" 1>&6
-for ac_hdr in sys/file.h sys/param.h limits.h stdlib.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h
+for ac_hdr in sys/file.h sys/param.h limits.h stdlib.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1173: checking for $ac_hdr" >&5
+echo "configure:1283: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1178 "configure"
+#line 1288 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1183: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1293: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1206,12 +1316,12 @@ fi
done
echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:1210: checking for sys/wait.h that is POSIX.1 compatible" >&5
+echo "configure:1320: checking for sys/wait.h that is POSIX.1 compatible" >&5
if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1215 "configure"
+#line 1325 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/wait.h>
@@ -1227,7 +1337,7 @@ wait (&s);
s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
; return 0; }
EOF
-if { (eval echo configure:1231: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1341: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_sys_wait_h=yes
else
@@ -1248,12 +1358,12 @@ EOF
fi
echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:1252: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:1362: checking whether time.h and sys/time.h may both be included" >&5
if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1257 "configure"
+#line 1367 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/time.h>
@@ -1262,7 +1372,7 @@ int main() {
struct tm *tp;
; return 0; }
EOF
-if { (eval echo configure:1266: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1376: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_header_time=yes
else
@@ -1284,19 +1394,19 @@ fi
echo $ac_n "checking whether errno must be declared""... $ac_c" 1>&6
-echo "configure:1288: checking whether errno must be declared" >&5
+echo "configure:1398: checking whether errno must be declared" >&5
if eval "test \"`echo '$''{'libiberty_cv_declare_errno'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1293 "configure"
+#line 1403 "configure"
#include "confdefs.h"
#include <errno.h>
int main() {
int x = errno;
; return 0; }
EOF
-if { (eval echo configure:1300: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1410: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
libiberty_cv_declare_errno=no
else
@@ -1317,6 +1427,152 @@ EOF
fi
+echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+echo "configure:1432: checking for ANSI C header files" >&5
+if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1437 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1445: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ ac_cv_header_stdc=yes
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 1462 "configure"
+#include "confdefs.h"
+#include <string.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "memchr" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 1480 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "free" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+if test "$cross_compiling" = yes; then
+ :
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1501 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int main () { int i; for (i = 0; i < 256; i++)
+if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
+exit (0); }
+
+EOF
+if { (eval echo configure:1512: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ :
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_header_stdc=no
+fi
+rm -fr conftest*
+fi
+
+fi
+fi
+
+echo "$ac_t""$ac_cv_header_stdc" 1>&6
+if test $ac_cv_header_stdc = yes; then
+ cat >> confdefs.h <<\EOF
+#define STDC_HEADERS 1
+EOF
+
+fi
+
+echo $ac_n "checking for uintptr_t""... $ac_c" 1>&6
+echo "configure:1536: checking for uintptr_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_uintptr_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1541 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "(^|[^a-zA-Z_0-9])uintptr_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_uintptr_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_uintptr_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_uintptr_t" 1>&6
+if test $ac_cv_type_uintptr_t = no; then
+ cat >> confdefs.h <<\EOF
+#define uintptr_t unsigned long
+EOF
+
+fi
+
+
+if test $ac_cv_type_uintptr_t = yes
+then
+ cat >> confdefs.h <<\EOF
+#define HAVE_UINTPTR_T 1
+EOF
+
+fi
+
# This is the list of functions which libiberty will provide if they
# are not available on the host.
@@ -1329,6 +1585,7 @@ funcs="$funcs bsearch"
funcs="$funcs bzero"
funcs="$funcs calloc"
funcs="$funcs clock"
+funcs="$funcs ffs"
funcs="$funcs getcwd"
funcs="$funcs getpagesize"
funcs="$funcs index"
@@ -1373,12 +1630,12 @@ if test "x" = "y"; then
for ac_func in asprintf atexit basename bcmp bcopy bsearch bzero calloc clock
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1377: checking for $ac_func" >&5
+echo "configure:1634: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1382 "configure"
+#line 1639 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1401,7 +1658,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1405: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1662: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1428,12 +1685,12 @@ done
for ac_func in getcwd getpagesize index insque mkstemps memchr memcmp memcpy
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1432: checking for $ac_func" >&5
+echo "configure:1689: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1437 "configure"
+#line 1694 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1456,7 +1713,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1460: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1717: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1483,12 +1740,12 @@ done
for ac_func in memmove memset putenv random rename rindex sigsetmask
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1487: checking for $ac_func" >&5
+echo "configure:1744: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1492 "configure"
+#line 1749 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1511,7 +1768,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1515: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1772: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1538,12 +1795,12 @@ done
for ac_func in strcasecmp setenv strchr strdup strncasecmp strrchr strstr
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1542: checking for $ac_func" >&5
+echo "configure:1799: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1547 "configure"
+#line 1804 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1566,7 +1823,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1570: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1827: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1593,12 +1850,12 @@ done
for ac_func in strtod strtol strtoul tmpnam vasprintf vfprintf vprintf
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1597: checking for $ac_func" >&5
+echo "configure:1854: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1602 "configure"
+#line 1859 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1621,7 +1878,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1625: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1882: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1648,12 +1905,12 @@ done
for ac_func in vsprintf waitpid getrusage on_exit psignal strerror strsignal
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1652: checking for $ac_func" >&5
+echo "configure:1909: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1657 "configure"
+#line 1914 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1676,7 +1933,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1680: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1937: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1700,15 +1957,15 @@ else
fi
done
- for ac_func in sysconf times sbrk gettimeofday
+ for ac_func in sysconf times sbrk gettimeofday ffs
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1707: checking for $ac_func" >&5
+echo "configure:1964: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1712 "configure"
+#line 1969 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1731,7 +1988,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1735: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1992: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1771,8 +2028,7 @@ fi
# For each of these functions, if the host does not provide the
# function we want to put FN.o in LIBOBJS, and if the host does
-# provide the function, we want to define HAVE_FN in config.h. Also,
-# if the host does not provide alloca, we set ALLOCA to alloca.o
+# provide the function, we want to define HAVE_FN in config.h.
setobjs=
CHECK=
@@ -1787,7 +2043,6 @@ if test -n "${with_target_subdir}"; then
# newlib provide and which ones we will be expected to provide.
if test "x${with_newlib}" = "xyes"; then
- ALLOCA="alloca.o"
LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o"
for f in $funcs; do
@@ -1826,6 +2081,19 @@ fi
+case "${host}" in
+ *-*-cygwin*)
+ cat >> confdefs.h <<\EOF
+#define HAVE_SYS_ERRLIST 1
+EOF
+
+ cat >> confdefs.h <<\EOF
+#define HAVE_SYS_NERR 1
+EOF
+
+ ;;
+esac
+
if test -z "${setobjs}"; then
case "${host}" in
@@ -1912,12 +2180,19 @@ if test -z "${setobjs}"; then
libiberty_cv_var_sys_errlist=yes
;;
+ *-*-*vms*)
+ # Under VMS, vfork works very different than on Unix. The standard test
+ # won't work, and it isn't easily adaptable. It makes more sense to
+ # just force it.
+ ac_cv_func_vfork_works=yes
+ ;;
+
esac
# We haven't set the list of objects yet. Use the standard autoconf
# tests. This will only work if the compiler works.
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:1921: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:2196: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@@ -1928,12 +2203,12 @@ cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext << EOF
-#line 1932 "configure"
+#line 2207 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
-if { (eval echo configure:1937: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2212: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
@@ -1959,19 +2234,19 @@ if test $ac_cv_prog_cc_works = no; then
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:1963: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:2238: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
for ac_func in $funcs
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1970: checking for $ac_func" >&5
+echo "configure:2245: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 1975 "configure"
+#line 2250 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -1994,7 +2269,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:1998: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2273: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2020,131 +2295,13 @@ fi
done
-
- case "${host}" in
- *-*-interix)
- # On Interix, it wrongly concludes that the MSVC compiler supports alloca.
- # (MSVC does on Win32, not on Interix.)
- # This should be temporary.
-
- ac_cv_header_alloca_h=no
- ac_cv_func_alloca_works=no
- ALLOCA=alloca.o
- cat >> confdefs.h <<\EOF
-#define C_ALLOCA 1
-EOF
- cat >> confdefs.h <<EOF
-#define STACK_DIRECTION -1
-EOF
- ;;
- *)
- # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
-# for constant arguments. Useless!
-echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6
-echo "configure:2045: checking for working alloca.h" >&5
-if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2050 "configure"
-#include "confdefs.h"
-#include <alloca.h>
-int main() {
-char *p = alloca(2 * sizeof(int));
-; return 0; }
-EOF
-if { (eval echo configure:2057: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- ac_cv_header_alloca_h=yes
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- ac_cv_header_alloca_h=no
-fi
-rm -f conftest*
-fi
-
-echo "$ac_t""$ac_cv_header_alloca_h" 1>&6
-if test $ac_cv_header_alloca_h = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_ALLOCA_H 1
-EOF
-
-fi
-
-echo $ac_n "checking for alloca""... $ac_c" 1>&6
-echo "configure:2078: checking for alloca" >&5
-if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2083 "configure"
-#include "confdefs.h"
-
-#ifdef __GNUC__
-# define alloca __builtin_alloca
-#else
-# ifdef _MSC_VER
-# include <malloc.h>
-# define alloca _alloca
-# else
-# if HAVE_ALLOCA_H
-# include <alloca.h>
-# else
-# ifdef _AIX
- #pragma alloca
-# else
-# ifndef alloca /* predefined by HP cc +Olibcalls */
-char *alloca ();
-# endif
-# endif
-# endif
-# endif
-#endif
-
-int main() {
-char *p = (char *) alloca(1);
-; return 0; }
-EOF
-if { (eval echo configure:2111: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
- rm -rf conftest*
- ac_cv_func_alloca_works=yes
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- ac_cv_func_alloca_works=no
-fi
-rm -f conftest*
-fi
-
-echo "$ac_t""$ac_cv_func_alloca_works" 1>&6
-if test $ac_cv_func_alloca_works = yes; then
- cat >> confdefs.h <<\EOF
-#define HAVE_ALLOCA 1
-EOF
-
-fi
-
-if test $ac_cv_func_alloca_works = no; then
- # The SVR3 libPW and SVR4 libucb both contain incompatible functions
- # that cause trouble. Some versions do not even contain alloca or
- # contain a buggy version. If you still want to use their alloca,
- # use ar to extract alloca.o from them instead of compiling alloca.c.
- ALLOCA=alloca.${ac_objext}
- cat >> confdefs.h <<\EOF
-#define C_ALLOCA 1
-EOF
-
-
-echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
-echo "configure:2143: checking whether alloca needs Cray hooks" >&5
+ echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6
+echo "configure:2300: checking whether alloca needs Cray hooks" >&5
if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2148 "configure"
+#line 2305 "configure"
#include "confdefs.h"
#if defined(CRAY) && ! defined(CRAY2)
webecray
@@ -2167,14 +2324,14 @@ fi
echo "$ac_t""$ac_cv_os_cray" 1>&6
if test $ac_cv_os_cray = yes; then
-for ac_func in _getb67 GETB67 getb67; do
- echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2173: checking for $ac_func" >&5
+ for ac_func in _getb67 GETB67 getb67; do
+ echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2330: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2178 "configure"
+#line 2335 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2197,7 +2354,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2201: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2358: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2214,17 +2371,16 @@ if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
cat >> confdefs.h <<EOF
#define CRAY_STACKSEG_END $ac_func
EOF
-
break
else
echo "$ac_t""no" 1>&6
fi
-done
+ done
fi
echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6
-echo "configure:2228: checking stack direction for C alloca" >&5
+echo "configure:2384: checking stack direction for C alloca" >&5
if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2232,7 +2388,7 @@ else
ac_cv_c_stack_direction=0
else
cat > conftest.$ac_ext <<EOF
-#line 2236 "configure"
+#line 2392 "configure"
#include "confdefs.h"
find_stack_direction ()
{
@@ -2251,7 +2407,7 @@ main ()
exit (find_stack_direction() < 0);
}
EOF
-if { (eval echo configure:2255: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2411: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_c_stack_direction=1
else
@@ -2270,122 +2426,14 @@ cat >> confdefs.h <<EOF
#define STACK_DIRECTION $ac_cv_c_stack_direction
EOF
-fi
-
- ;;
- esac
- echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:2280: checking for ANSI C header files" >&5
-if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
- echo $ac_n "(cached) $ac_c" 1>&6
-else
- cat > conftest.$ac_ext <<EOF
-#line 2285 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2293: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
- rm -rf conftest*
- ac_cv_header_stdc=yes
-else
- echo "$ac_err" >&5
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -rf conftest*
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-if test $ac_cv_header_stdc = yes; then
- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-cat > conftest.$ac_ext <<EOF
-#line 2310 "configure"
-#include "confdefs.h"
-#include <string.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "memchr" >/dev/null 2>&1; then
- :
-else
- rm -rf conftest*
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-cat > conftest.$ac_ext <<EOF
-#line 2328 "configure"
-#include "confdefs.h"
-#include <stdlib.h>
-EOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- egrep "free" >/dev/null 2>&1; then
- :
-else
- rm -rf conftest*
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-if test "$cross_compiling" = yes; then
- :
-else
- cat > conftest.$ac_ext <<EOF
-#line 2349 "configure"
-#include "confdefs.h"
-#include <ctype.h>
-#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int main () { int i; for (i = 0; i < 256; i++)
-if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
-exit (0); }
-
-EOF
-if { (eval echo configure:2360: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
-then
- :
-else
- echo "configure: failed program was:" >&5
- cat conftest.$ac_ext >&5
- rm -fr conftest*
- ac_cv_header_stdc=no
-fi
-rm -fr conftest*
-fi
-
-fi
-fi
-
-echo "$ac_t""$ac_cv_header_stdc" 1>&6
-if test $ac_cv_header_stdc = yes; then
- cat >> confdefs.h <<\EOF
-#define STDC_HEADERS 1
-EOF
-
-fi
-
-echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:2384: checking for pid_t" >&5
+ echo $ac_n "checking for pid_t""... $ac_c" 1>&6
+echo "configure:2432: checking for pid_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2389 "configure"
+#line 2437 "configure"
#include "confdefs.h"
#include <sys/types.h>
#if STDC_HEADERS
@@ -2414,17 +2462,17 @@ fi
ac_safe=`echo "vfork.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for vfork.h""... $ac_c" 1>&6
-echo "configure:2418: checking for vfork.h" >&5
+echo "configure:2466: checking for vfork.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2423 "configure"
+#line 2471 "configure"
#include "confdefs.h"
#include <vfork.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2428: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2476: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -2449,18 +2497,18 @@ else
fi
echo $ac_n "checking for working vfork""... $ac_c" 1>&6
-echo "configure:2453: checking for working vfork" >&5
+echo "configure:2501: checking for working vfork" >&5
if eval "test \"`echo '$''{'ac_cv_func_vfork_works'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
if test "$cross_compiling" = yes; then
echo $ac_n "checking for vfork""... $ac_c" 1>&6
-echo "configure:2459: checking for vfork" >&5
+echo "configure:2507: checking for vfork" >&5
if eval "test \"`echo '$''{'ac_cv_func_vfork'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2464 "configure"
+#line 2512 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char vfork(); below. */
@@ -2483,7 +2531,7 @@ vfork();
; return 0; }
EOF
-if { (eval echo configure:2487: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2535: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_vfork=yes"
else
@@ -2505,7 +2553,7 @@ fi
ac_cv_func_vfork_works=$ac_cv_func_vfork
else
cat > conftest.$ac_ext <<EOF
-#line 2509 "configure"
+#line 2557 "configure"
#include "confdefs.h"
/* Thanks to Paul Eggert for this test. */
#include <stdio.h>
@@ -2600,7 +2648,7 @@ main() {
}
}
EOF
-if { (eval echo configure:2604: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:2652: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_vfork_works=yes
else
@@ -2625,21 +2673,140 @@ fi
if test $ac_cv_func_vfork_works = no; then
LIBOBJS="$LIBOBJS vfork.o"
fi
+ # We only need _doprnt if we might use it to implement v*printf.
+ if test $ac_cv_func_vprintf != yes \
+ || test $ac_cv_func_vfprintf != yes \
+ || test $ac_cv_func_vsprintf != yes; then
+ for ac_func in _doprnt
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2684: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2689 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2712: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+LIBOBJS="$LIBOBJS ${ac_func}.${ac_objext}"
+fi
+done
+
+
+ else
+ for ac_func in _doprnt
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2742: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2747 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2770: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+ fi
+
for v in $vars; do
echo $ac_n "checking for $v""... $ac_c" 1>&6
-echo "configure:2631: checking for $v" >&5
+echo "configure:2798: checking for $v" >&5
if eval "test \"`echo '$''{'libiberty_cv_var_$v'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2636 "configure"
+#line 2803 "configure"
#include "confdefs.h"
int *p;
int main() {
-extern int $v; p = &$v;
+extern int $v []; p = &$v;
; return 0; }
EOF
-if { (eval echo configure:2643: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2810: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "libiberty_cv_var_$v=yes"
else
@@ -2665,12 +2832,12 @@ EOF
for ac_func in $checkfuncs
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2669: checking for $ac_func" >&5
+echo "configure:2836: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2674 "configure"
+#line 2841 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2693,7 +2860,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2697: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2864: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2719,21 +2886,21 @@ done
fi
-for ac_hdr in unistd.h
+for ac_hdr in stdlib.h unistd.h sys/stat.h sys/types.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2727: checking for $ac_hdr" >&5
+echo "configure:2894: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2732 "configure"
+#line 2899 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2737: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2904: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -2762,12 +2929,12 @@ done
for ac_func in getpagesize
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2766: checking for $ac_func" >&5
+echo "configure:2933: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 2771 "configure"
+#line 2938 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -2790,7 +2957,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:2794: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2961: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -2815,7 +2982,7 @@ fi
done
echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:2819: checking for working mmap" >&5
+echo "configure:2986: checking for working mmap" >&5
if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2823,7 +2990,7 @@ else
ac_cv_func_mmap_fixed_mapped=no
else
cat > conftest.$ac_ext <<EOF
-#line 2827 "configure"
+#line 2994 "configure"
#include "confdefs.h"
/* Thanks to Mike Haertel and Jim Avera for this test.
@@ -2851,11 +3018,24 @@ else
#include <fcntl.h>
#include <sys/mman.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#if HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
/* This mess was copied from the GNU getpagesize.h. */
#ifndef HAVE_GETPAGESIZE
-# ifdef HAVE_UNISTD_H
-# include <unistd.h>
-# endif
/* Assume that all systems that can run configure have sys/param.h. */
# ifndef HAVE_SYS_PARAM_H
@@ -2963,7 +3143,7 @@ main()
}
EOF
-if { (eval echo configure:2967: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3147: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_mmap_fixed_mapped=yes
else
@@ -2987,7 +3167,7 @@ fi
echo $ac_n "checking for working strncmp""... $ac_c" 1>&6
-echo "configure:2991: checking for working strncmp" >&5
+echo "configure:3171: checking for working strncmp" >&5
if eval "test \"`echo '$''{'ac_cv_func_strncmp_works'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -2995,7 +3175,7 @@ else
ac_cv_func_strncmp_works=no
else
cat > conftest.$ac_ext <<EOF
-#line 2999 "configure"
+#line 3179 "configure"
#include "confdefs.h"
/* Test by Jim Wilson and Kaveh Ghazi.
@@ -3040,6 +3220,9 @@ main ()
p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, dev_zero, 0);
if (p == (char *)-1)
+ p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE,
+ MAP_ANON|MAP_PRIVATE, -1, 0);
+ if (p == (char *)-1)
exit (2);
else
{
@@ -3056,7 +3239,7 @@ main ()
}
EOF
-if { (eval echo configure:3060: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3243: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_strncmp_works=yes
else
@@ -3220,6 +3403,12 @@ s%@includedir@%$includedir%g
s%@oldincludedir@%$oldincludedir%g
s%@infodir@%$infodir%g
s%@mandir@%$mandir%g
+s%@MAINT@%$MAINT%g
+s%@NOTMAINT@%$NOTMAINT%g
+s%@MAKEINFO@%$MAKEINFO%g
+s%@BUILD_INFO@%$BUILD_INFO%g
+s%@PERL@%$PERL%g
+s%@HAVE_PERL@%$HAVE_PERL%g
s%@host@%$host%g
s%@host_alias@%$host_alias%g
s%@host_cpu@%$host_cpu%g
@@ -3242,7 +3431,6 @@ s%@host_makefile_frag@%%g
s%@CPP@%$CPP%g
s%@CHECK@%$CHECK%g
s%@LIBOBJS@%$LIBOBJS%g
-s%@ALLOCA@%$ALLOCA%g
s%@INSTALL_DEST@%$INSTALL_DEST%g
CEOF
diff --git a/contrib/binutils/libiberty/configure.in b/contrib/binutils/libiberty/configure.in
index af80e0d..eed222d 100644
--- a/contrib/binutils/libiberty/configure.in
+++ b/contrib/binutils/libiberty/configure.in
@@ -26,6 +26,57 @@ else
fi
AC_CONFIG_AUX_DIR($libiberty_topdir)
+dnl Very limited version of automake's enable-maintainer-mode
+
+AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
+ dnl maintainer-mode is disabled by default
+ AC_ARG_ENABLE(maintainer-mode,
+[ --enable-maintainer-mode
+ enable make rules and dependencies not useful
+ (and sometimes confusing) to the casual installer],
+ maintainer_mode=$enableval,
+ maintainer_mode=no)
+
+AC_MSG_RESULT($maintainer_mode)
+
+if test "$maintainer_mode" = "yes"; then
+ MAINT=''
+ NOTMAINT='#'
+else
+ MAINT='#'
+ NOTMAINT=''
+fi
+AC_SUBST(MAINT)dnl
+AC_SUBST(NOTMAINT)dnl
+
+# Do we have a single-tree copy of texinfo? Even if we do, we can't
+# rely on it - libiberty is built before texinfo.
+AC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo, )
+if test "x$MAKEINFO" = "x"; then
+ MAKEINFO="@echo makeinfo missing; true"
+ BUILD_INFO=
+else
+ BUILD_INFO=info
+ case x"`$MAKEINFO --version | grep 'GNU texinfo'`" in
+ x*\ [[1-3]].* )
+ MAKEINFO="@echo $MAKEINFO is too old, 4.0 or newer required; true"
+ BUILD_INFO=
+ AC_MSG_WARN([
+*** Makeinfo is too old. Info documentation will not be built.])
+ ;;
+ esac
+fi
+AC_SUBST(MAKEINFO)
+AC_SUBST(BUILD_INFO)
+
+AC_CHECK_PROG(PERL, perl, perl, )
+if test x"$PERL" = x""; then
+ HAVE_PERL='#'
+else
+ HAVE_PERL=''
+fi
+AC_SUBST(HAVE_PERL)
+
AC_CANONICAL_HOST
dnl When we start using automake:
@@ -69,12 +120,19 @@ AC_SUBST_FILE(host_makefile_frag)
# It's OK to check for header files. Although the compiler may not be
# able to link anything, it had better be able to at least compile
# something.
-AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h)
+AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h)
AC_HEADER_SYS_WAIT
AC_HEADER_TIME
libiberty_AC_DECLARE_ERRNO
+AC_CHECK_TYPE(uintptr_t, unsigned long)
+
+if test $ac_cv_type_uintptr_t = yes
+then
+ AC_DEFINE(HAVE_UINTPTR_T, 1, [Define if you have the \`uintptr_t' type.])
+fi
+
# This is the list of functions which libiberty will provide if they
# are not available on the host.
@@ -87,6 +145,7 @@ funcs="$funcs bsearch"
funcs="$funcs bzero"
funcs="$funcs calloc"
funcs="$funcs clock"
+funcs="$funcs ffs"
funcs="$funcs getcwd"
funcs="$funcs getpagesize"
funcs="$funcs index"
@@ -134,7 +193,7 @@ if test "x" = "y"; then
AC_CHECK_FUNCS(strcasecmp setenv strchr strdup strncasecmp strrchr strstr)
AC_CHECK_FUNCS(strtod strtol strtoul tmpnam vasprintf vfprintf vprintf)
AC_CHECK_FUNCS(vsprintf waitpid getrusage on_exit psignal strerror strsignal)
- AC_CHECK_FUNCS(sysconf times sbrk gettimeofday)
+ AC_CHECK_FUNCS(sysconf times sbrk gettimeofday ffs)
AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.])
AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.])
AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.])
@@ -142,8 +201,7 @@ fi
# For each of these functions, if the host does not provide the
# function we want to put FN.o in LIBOBJS, and if the host does
-# provide the function, we want to define HAVE_FN in config.h. Also,
-# if the host does not provide alloca, we set ALLOCA to alloca.o
+# provide the function, we want to define HAVE_FN in config.h.
setobjs=
CHECK=
@@ -158,7 +216,6 @@ if test -n "${with_target_subdir}"; then
# newlib provide and which ones we will be expected to provide.
if test "x${with_newlib}" = "xyes"; then
- ALLOCA="alloca.o"
LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o"
for f in $funcs; do
@@ -191,6 +248,13 @@ fi
AC_SUBST(CHECK)
+case "${host}" in
+ *-*-cygwin*)
+ AC_DEFINE_NOAUTOHEADER(HAVE_SYS_ERRLIST)
+ AC_DEFINE_NOAUTOHEADER(HAVE_SYS_NERR)
+ ;;
+esac
+
if test -z "${setobjs}"; then
case "${host}" in
@@ -271,42 +335,37 @@ if test -z "${setobjs}"; then
libiberty_cv_var_sys_errlist=yes
;;
+ *-*-*vms*)
+ # Under VMS, vfork works very different than on Unix. The standard test
+ # won't work, and it isn't easily adaptable. It makes more sense to
+ # just force it.
+ ac_cv_func_vfork_works=yes
+ ;;
+
esac
# We haven't set the list of objects yet. Use the standard autoconf
# tests. This will only work if the compiler works.
AC_PROG_CC_WORKS
AC_REPLACE_FUNCS($funcs)
-
- case "${host}" in
- *-*-interix)
- # On Interix, it wrongly concludes that the MSVC compiler supports alloca.
- # (MSVC does on Win32, not on Interix.)
- # This should be temporary.
-
- ac_cv_header_alloca_h=no
- ac_cv_func_alloca_works=no
- ALLOCA=alloca.o
- cat >> confdefs.h <<\EOF
-#define C_ALLOCA 1
-EOF
- cat >> confdefs.h <<EOF
-#define STACK_DIRECTION -1
-EOF
- ;;
- *)
- AC_FUNC_ALLOCA
- ;;
- esac
-
+ libiberty_AC_FUNC_C_ALLOCA
AC_FUNC_VFORK
if test $ac_cv_func_vfork_works = no; then
LIBOBJS="$LIBOBJS vfork.o"
fi
+ # We only need _doprnt if we might use it to implement v*printf.
+ if test $ac_cv_func_vprintf != yes \
+ || test $ac_cv_func_vfprintf != yes \
+ || test $ac_cv_func_vsprintf != yes; then
+ AC_REPLACE_FUNCS(_doprnt)
+ else
+ AC_CHECK_FUNCS(_doprnt)
+ fi
+
for v in $vars; do
AC_MSG_CHECKING([for $v])
AC_CACHE_VAL(libiberty_cv_var_$v,
- [AC_TRY_LINK([int *p;], [extern int $v; p = &$v;],
+ [AC_TRY_LINK([int *p;], [extern int $v []; p = &$v;],
[eval "libiberty_cv_var_$v=yes"],
[eval "libiberty_cv_var_$v=no"])])
if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
diff --git a/contrib/binutils/libiberty/copying-lib.texi b/contrib/binutils/libiberty/copying-lib.texi
new file mode 100644
index 0000000..940f70e
--- /dev/null
+++ b/contrib/binutils/libiberty/copying-lib.texi
@@ -0,0 +1,565 @@
+@node Library Copying
+@appendixsec GNU LESSER GENERAL PUBLIC LICENSE
+
+@cindex LGPL, Lesser General Public License
+@center Version 2.1, February 1999
+
+@display
+Copyright @copyright{} 1991, 1999 Free Software Foundation, Inc.
+59 Temple Place -- Suite 330, Boston, MA 02111-1307, USA
+
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+as the successor of the GNU Library Public License, version 2, hence the
+version number 2.1.]
+@end display
+
+@appendixsubsec Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software---to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software---typically libraries---of the Free
+Software Foundation and other authors who decide to use it. You can use
+it too, but we suggest you first think carefully about whether this
+license or the ordinary General Public License is the better strategy to
+use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of it
+in new free programs; and that you are informed that you can do these
+things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the @dfn{Lesser} General Public License because it
+does @emph{Less} to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+``work based on the library'' and a ``work that uses the library''. The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+@iftex
+@appendixsubsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+@end iftex
+@ifinfo
+@center GNU LESSER GENERAL PUBLIC LICENSE
+@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+@end ifinfo
+
+@enumerate 0
+@item
+This License Agreement applies to any software library or other program
+which contains a notice placed by the copyright holder or other
+authorized party saying it may be distributed under the terms of this
+Lesser General Public License (also called ``this License''). Each
+licensee is addressed as ``you''.
+
+ A ``library'' means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The ``Library'', below, refers to any such software library or work
+which has been distributed under these terms. A ``work based on the
+Library'' means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term ``modification''.)
+
+ ``Source code'' for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+@item
+You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+@item
+You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+@enumerate a
+@item
+The modified work must itself be a software library.
+
+@item
+You must cause the files modified to carry prominent notices
+stating that you changed the files and the date of any change.
+
+@item
+You must cause the whole of the work to be licensed at no
+charge to all third parties under the terms of this License.
+
+@item
+If a facility in the modified Library refers to a function or a
+table of data to be supplied by an application program that uses
+the facility, other than as an argument passed when the facility
+is invoked, then you must make a good faith effort to ensure that,
+in the event an application does not supply such function or
+table, the facility still operates, and performs whatever part of
+its purpose remains meaningful.
+
+(For example, a function in a library to compute square roots has
+a purpose that is entirely well-defined independent of the
+application. Therefore, Subsection 2d requires that any
+application-supplied function or table used by this function must
+be optional: if the application does not supply it, the square
+root function must still compute square roots.)
+@end enumerate
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+@item
+You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+@item
+You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+@item
+A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a ``work that uses the Library''. Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a ``work that uses the Library'' with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a ``work that uses the
+library''. The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a ``work that uses the Library'' uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+@item
+As an exception to the Sections above, you may also combine or
+link a ``work that uses the Library'' with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+@enumerate a
+@item
+Accompany the work with the complete corresponding
+machine-readable source code for the Library including whatever
+changes were used in the work (which must be distributed under
+Sections 1 and 2 above); and, if the work is an executable linked
+with the Library, with the complete machine-readable ``work that
+uses the Library'', as object code and/or source code, so that the
+user can modify the Library and then relink to produce a modified
+executable containing the modified Library. (It is understood
+that the user who changes the contents of definitions files in the
+Library will not necessarily be able to recompile the application
+to use the modified definitions.)
+
+@item
+Use a suitable shared library mechanism for linking with the Library. A
+suitable mechanism is one that (1) uses at run time a copy of the
+library already present on the user's computer system, rather than
+copying library functions into the executable, and (2) will operate
+properly with a modified version of the library, if the user installs
+one, as long as the modified version is interface-compatible with the
+version that the work was made with.
+
+@item
+Accompany the work with a written offer, valid for at
+least three years, to give the same user the materials
+specified in Subsection 6a, above, for a charge no more
+than the cost of performing this distribution.
+
+@item
+If distribution of the work is made by offering access to copy
+from a designated place, offer equivalent access to copy the above
+specified materials from the same place.
+
+@item
+Verify that the user has already received a copy of these
+materials or that you have already sent this user a copy.
+@end enumerate
+
+ For an executable, the required form of the ``work that uses the
+Library'' must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies the
+executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+@item
+You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+@enumerate a
+@item
+Accompany the combined library with a copy of the same work
+based on the Library, uncombined with any other library
+facilities. This must be distributed under the terms of the
+Sections above.
+
+@item
+Give prominent notice with the combined library of the fact
+that part of it is a work based on the Library, and explaining
+where to find the accompanying uncombined form of the same work.
+@end enumerate
+
+@item
+You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+@item
+You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+@item
+Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+@item
+If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+@item
+If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+@item
+The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+``any later version'', you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+@item
+If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+@iftex
+@heading NO WARRANTY
+@end iftex
+@ifinfo
+@center NO WARRANTY
+@end ifinfo
+
+@item
+BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY ``AS IS'' WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+@item
+IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+@end enumerate
+
+@iftex
+@heading END OF TERMS AND CONDITIONS
+@end iftex
+@ifinfo
+@center END OF TERMS AND CONDITIONS
+@end ifinfo
+
+@page
+@appendixsubsec How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+``copyright'' line and a pointer to where the full notice is found.
+
+@smallexample
+@var{one line to give the library's name and an idea of what it does.}
+Copyright (C) @var{year} @var{name of author}
+
+This library is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or (at
+your option) any later version.
+
+This library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
+USA.
+@end smallexample
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a ``copyright disclaimer'' for the library, if
+necessary. Here is a sample; alter the names:
+
+@smallexample
+Yoyodyne, Inc., hereby disclaims all copyright interest in the library
+`Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+@var{signature of Ty Coon}, 1 April 1990
+Ty Coon, President of Vice
+@end smallexample
+
+That's all there is to it!
diff --git a/contrib/binutils/libiberty/copysign.c b/contrib/binutils/libiberty/copysign.c
index 0b5f8c3..5c48a54 100644
--- a/contrib/binutils/libiberty/copysign.c
+++ b/contrib/binutils/libiberty/copysign.c
@@ -129,6 +129,7 @@ typedef union
} __ieee_float_shape_type;
#endif
+#if defined(__IEEE_BIG_ENDIAN) || defined(__IEEE_LITTLE_ENDIAN)
double DEFUN(copysign, (x, y), double x AND double y)
{
@@ -138,3 +139,14 @@ double DEFUN(copysign, (x, y), double x AND double y)
a.number.sign =b.number.sign;
return a.value;
}
+
+#else
+
+double DEFUN(copysign, (x, y), double x AND double y)
+{
+ if ((x < 0 && y > 0) || (x > 0 && y < 0))
+ return -x;
+ return x;
+}
+
+#endif
diff --git a/contrib/binutils/libiberty/cp-demangle.c b/contrib/binutils/libiberty/cp-demangle.c
index 1cc4847..457a09f 100644
--- a/contrib/binutils/libiberty/cp-demangle.c
+++ b/contrib/binutils/libiberty/cp-demangle.c
@@ -1,5 +1,5 @@
/* Demangler for IA64 / g++ V3 ABI.
- Copyright (C) 2000 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2001 Free Software Foundation, Inc.
Written by Alex Samuel <samuel@codesourcery.com>.
This file is part of GNU CC.
@@ -68,6 +68,9 @@
anonymous namespace. */
#define ANONYMOUS_NAMESPACE_PREFIX "_GLOBAL_"
+/* Character(s) to use for namespace separation in demangled output */
+#define NAMESPACE_SEPARATOR (dm->style == DMGL_JAVA ? "." : "::")
+
/* If flag_verbose is zero, some simplifications will be made to the
output to make it easier to read and supress details that are
generally not of interest to the average C++ programmer.
@@ -166,6 +169,18 @@ struct demangling_def
/* The most recently demangled source-name. */
dyn_string_t last_source_name;
+
+ /* Language style to use for demangled output. */
+ int style;
+
+ /* Set to non-zero iff this name is a constructor. The actual value
+ indicates what sort of constructor this is; see demangle.h. */
+ enum gnu_v3_ctor_kinds is_constructor;
+
+ /* Set to non-zero iff this name is a destructor. The actual value
+ indicates what sort of destructor this is; see demangle.h. */
+ enum gnu_v3_dtor_kinds is_destructor;
+
};
typedef struct demangling_def *demangling_t;
@@ -240,7 +255,7 @@ static void template_arg_list_print
static template_arg_list_t current_template_arg_list
PARAMS ((demangling_t));
static demangling_t demangling_new
- PARAMS ((const char *));
+ PARAMS ((const char *, int));
static void demangling_delete
PARAMS ((demangling_t));
@@ -409,7 +424,7 @@ string_list_delete (node)
while (node != NULL)
{
string_list_t next = node->next;
- free (node);
+ dyn_string_delete ((dyn_string_t) node);
node = next;
}
}
@@ -783,8 +798,9 @@ current_template_arg_list (dm)
Returns NULL if allocation fails. */
static demangling_t
-demangling_new (name)
+demangling_new (name, style)
const char *name;
+ int style;
{
demangling_t dm;
dm = (demangling_t) malloc (sizeof (struct demangling_def));
@@ -807,6 +823,9 @@ demangling_new (name)
dyn_string_delete (dm->last_source_name);
return NULL;
}
+ dm->style = style;
+ dm->is_constructor = 0;
+ dm->is_destructor = 0;
return dm;
}
@@ -918,7 +937,7 @@ static status_t demangle_local_name
static status_t demangle_discriminator
PARAMS ((demangling_t, int));
static status_t cp_demangle
- PARAMS ((const char *, dyn_string_t));
+ PARAMS ((const char *, dyn_string_t, int));
#ifdef IN_LIBGCC2
static status_t cp_demangle_type
PARAMS ((const char*, dyn_string_t));
@@ -1222,7 +1241,7 @@ demangle_prefix (dm, encode_return_type)
{
/* We have another level of scope qualification. */
if (nested)
- RETURN_IF_ERROR (result_add (dm, "::"));
+ RETURN_IF_ERROR (result_add (dm, NAMESPACE_SEPARATOR));
else
nested = 1;
@@ -1538,11 +1557,11 @@ demangle_operator_name (dm, short_name, num_args)
struct operator_code
{
/* The mangled code for this operator. */
- const char *code;
+ const char *const code;
/* The source name of this operator. */
- const char *name;
+ const char *const name;
/* The number of arguments this operator takes. */
- int num_args;
+ const int num_args;
};
static const struct operator_code operators[] =
@@ -1823,11 +1842,27 @@ demangle_special_name (dm)
if (peek == 'G')
{
- /* A guard variable name. Consume the G. */
+ /* Consume the G. */
advance_char (dm);
- RETURN_IF_ERROR (demangle_char (dm, 'V'));
- RETURN_IF_ERROR (result_add (dm, "guard variable for "));
- RETURN_IF_ERROR (demangle_name (dm, &unused));
+ switch (peek_char (dm))
+ {
+ case 'V':
+ /* A guard variable name. */
+ advance_char (dm);
+ RETURN_IF_ERROR (result_add (dm, "guard variable for "));
+ RETURN_IF_ERROR (demangle_name (dm, &unused));
+ break;
+
+ case 'R':
+ /* A reference temporary. */
+ advance_char (dm);
+ RETURN_IF_ERROR (result_add (dm, "reference temporary for "));
+ RETURN_IF_ERROR (demangle_name (dm, &unused));
+ break;
+
+ default:
+ return "Unrecognized <special-name>.";
+ }
}
else if (peek == 'T')
{
@@ -2010,15 +2045,24 @@ demangle_ctor_dtor_name (dm)
{
/* A constructor name. Consume the C. */
advance_char (dm);
- if (peek_char (dm) < '1' || peek_char (dm) > '3')
+ flavor = next_char (dm);
+ if (flavor < '1' || flavor > '3')
return "Unrecognized constructor.";
RETURN_IF_ERROR (result_add_string (dm, dm->last_source_name));
+ switch (flavor)
+ {
+ case '1': dm->is_constructor = gnu_v3_complete_object_ctor;
+ break;
+ case '2': dm->is_constructor = gnu_v3_base_object_ctor;
+ break;
+ case '3': dm->is_constructor = gnu_v3_complete_object_allocating_ctor;
+ break;
+ }
/* Print the flavor of the constructor if in verbose mode. */
- flavor = next_char (dm) - '1';
if (flag_verbose)
{
RETURN_IF_ERROR (result_add (dm, "["));
- RETURN_IF_ERROR (result_add (dm, ctor_flavors[flavor]));
+ RETURN_IF_ERROR (result_add (dm, ctor_flavors[flavor - '1']));
RETURN_IF_ERROR (result_add_char (dm, ']'));
}
}
@@ -2026,16 +2070,25 @@ demangle_ctor_dtor_name (dm)
{
/* A destructor name. Consume the D. */
advance_char (dm);
- if (peek_char (dm) < '0' || peek_char (dm) > '2')
+ flavor = next_char (dm);
+ if (flavor < '0' || flavor > '2')
return "Unrecognized destructor.";
RETURN_IF_ERROR (result_add_char (dm, '~'));
RETURN_IF_ERROR (result_add_string (dm, dm->last_source_name));
+ switch (flavor)
+ {
+ case '0': dm->is_destructor = gnu_v3_deleting_dtor;
+ break;
+ case '1': dm->is_destructor = gnu_v3_complete_object_dtor;
+ break;
+ case '2': dm->is_destructor = gnu_v3_base_object_dtor;
+ break;
+ }
/* Print the flavor of the destructor if in verbose mode. */
- flavor = next_char (dm) - '0';
if (flag_verbose)
{
RETURN_IF_ERROR (result_add (dm, " ["));
- RETURN_IF_ERROR (result_add (dm, dtor_flavors[flavor]));
+ RETURN_IF_ERROR (result_add (dm, dtor_flavors[flavor - '0']));
RETURN_IF_ERROR (result_add_char (dm, ']'));
}
}
@@ -2093,8 +2146,10 @@ demangle_type_ptr (dm, insert_pos, substitution_start)
RETURN_IF_ERROR (demangle_type_ptr (dm, insert_pos,
substitution_start));
/* Insert an asterisk where we're told to; it doesn't
- necessarily go at the end. */
- RETURN_IF_ERROR (result_insert_char (dm, *insert_pos, '*'));
+ necessarily go at the end. If we're doing Java style output,
+ there is no pointer symbol. */
+ if (dm->style != DMGL_JAVA)
+ RETURN_IF_ERROR (result_insert_char (dm, *insert_pos, '*'));
/* The next (outermost) pointer or reference character should go
after this one. */
++(*insert_pos);
@@ -2469,6 +2524,39 @@ static const char *const builtin_type_names[26] =
"..." /* z */
};
+/* Java source names of builtin types. Types that arn't valid in Java
+ are also included here - we don't fail if someone attempts to demangle a
+ C++ symbol in Java style. */
+static const char *const java_builtin_type_names[26] =
+{
+ "signed char", /* a */
+ "boolean", /* C++ "bool" */ /* b */
+ "byte", /* C++ "char" */ /* c */
+ "double", /* d */
+ "long double", /* e */
+ "float", /* f */
+ "__float128", /* g */
+ "unsigned char", /* h */
+ "int", /* i */
+ "unsigned", /* j */
+ NULL, /* k */
+ "long", /* l */
+ "unsigned long", /* m */
+ "__int128", /* n */
+ "unsigned __int128", /* o */
+ NULL, /* p */
+ NULL, /* q */
+ NULL, /* r */
+ "short", /* s */
+ "unsigned short", /* t */
+ NULL, /* u */
+ "void", /* v */
+ "char", /* C++ "wchar_t" */ /* w */
+ "long", /* C++ "long long" */ /* x */
+ "unsigned long long", /* y */
+ "..." /* z */
+};
+
/* Demangles and emits a <builtin-type>.
<builtin-type> ::= v # void
@@ -2511,7 +2599,12 @@ demangle_builtin_type (dm)
}
else if (code >= 'a' && code <= 'z')
{
- const char *type_name = builtin_type_names[code - 'a'];
+ const char *type_name;
+ /* Java uses different names for some built-in types. */
+ if (dm->style == DMGL_JAVA)
+ type_name = java_builtin_type_names[code - 'a'];
+ else
+ type_name = builtin_type_names[code - 'a'];
if (type_name == NULL)
return "Unrecognized <builtin-type> code.";
@@ -3369,15 +3462,11 @@ demangle_discriminator (dm, suppress_first)
/* Write the discriminator. The mangled number is two
less than the discriminator ordinal, counting from
zero. */
- RETURN_IF_ERROR (int_to_dyn_string (discriminator + 2,
+ RETURN_IF_ERROR (int_to_dyn_string (discriminator + 1,
(dyn_string_t) dm->result));
}
else
- {
- if (flag_verbose)
- /* A missing digit correspond to one. */
- RETURN_IF_ERROR (result_add_char (dm, '1'));
- }
+ return STATUS_ERROR;
if (flag_verbose)
RETURN_IF_ERROR (result_add_char (dm, ']'));
}
@@ -3395,16 +3484,17 @@ demangle_discriminator (dm, suppress_first)
an error message, and the contents of RESULT are unchanged. */
static status_t
-cp_demangle (name, result)
+cp_demangle (name, result, style)
const char *name;
dyn_string_t result;
+ int style;
{
status_t status;
int length = strlen (name);
if (length > 2 && name[0] == '_' && name[1] == 'Z')
{
- demangling_t dm = demangling_new (name);
+ demangling_t dm = demangling_new (name, style);
if (dm == NULL)
return STATUS_ALLOCATION_FAILED;
@@ -3551,7 +3641,7 @@ __cxa_demangle (mangled_name, output_buffer, length, status)
if (mangled_name[0] == '_' && mangled_name[1] == 'Z')
/* MANGLED_NAME apprears to be a function or variable name.
Demangle it accordingly. */
- result = cp_demangle (mangled_name, &demangled_name);
+ result = cp_demangle (mangled_name, &demangled_name, 0);
else
/* Try to demangled MANGLED_NAME as the name of a type. */
result = cp_demangle_type (mangled_name, &demangled_name);
@@ -3610,7 +3700,7 @@ cplus_demangle_v3 (mangled)
/* Create a dyn_string to hold the demangled name. */
demangled = dyn_string_new (0);
/* Attempt the demangling. */
- status = cp_demangle ((char *) mangled, demangled);
+ status = cp_demangle ((char *) mangled, demangled, 0);
if (STATUS_NO_ERROR (status))
/* Demangling succeeded. */
@@ -3634,8 +3724,194 @@ cplus_demangle_v3 (mangled)
}
}
+/* 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[]. */
+
+char *
+java_demangle_v3 (mangled)
+ const char* mangled;
+{
+ dyn_string_t demangled;
+ char *next;
+ char *end;
+ int len;
+ status_t status;
+ int nesting = 0;
+ char *cplus_demangled;
+ char *return_value;
+
+ /* Create a dyn_string to hold the demangled name. */
+ demangled = dyn_string_new (0);
+
+ /* Attempt the demangling. */
+ status = cp_demangle ((char *) mangled, demangled, DMGL_JAVA);
+
+ if (STATUS_NO_ERROR (status))
+ /* Demangling succeeded. */
+ {
+ /* Grab the demangled result from the dyn_string. */
+ cplus_demangled = dyn_string_release (demangled);
+ }
+ else if (status == STATUS_ALLOCATION_FAILED)
+ {
+ fprintf (stderr, "Memory allocation failed.\n");
+ abort ();
+ }
+ else
+ /* Demangling failed. */
+ {
+ dyn_string_delete (demangled);
+ return NULL;
+ }
+
+ len = strlen (cplus_demangled);
+ next = cplus_demangled;
+ end = next + len;
+ demangled = NULL;
+
+ /* Replace occurances of JArray<TYPE> with TYPE[]. */
+ while (next < end)
+ {
+ char *open_str = strstr (next, "JArray<");
+ char *close_str = NULL;
+ if (nesting > 0)
+ close_str = strchr (next, '>');
+
+ if (open_str != NULL && (close_str == NULL || close_str > open_str))
+ {
+ ++nesting;
+
+ if (!demangled)
+ demangled = dyn_string_new(len);
+
+ /* Copy prepending symbols, if any. */
+ if (open_str > next)
+ {
+ open_str[0] = 0;
+ dyn_string_append_cstr (demangled, next);
+ }
+ next = open_str + 7;
+ }
+ else if (close_str != NULL)
+ {
+ --nesting;
+
+ /* Copy prepending type symbol, if any. Squash any spurious
+ whitespace. */
+ if (close_str > next && next[0] != ' ')
+ {
+ close_str[0] = 0;
+ dyn_string_append_cstr (demangled, next);
+ }
+ dyn_string_append_cstr (demangled, "[]");
+ next = close_str + 1;
+ }
+ else
+ {
+ /* There are no more arrays. Copy the rest of the symbol, or
+ simply return the original symbol if no changes were made. */
+ if (next == cplus_demangled)
+ return cplus_demangled;
+
+ dyn_string_append_cstr (demangled, next);
+ next = end;
+ }
+ }
+
+ free (cplus_demangled);
+
+ return_value = dyn_string_release (demangled);
+ return return_value;
+}
+
#endif /* IN_LIBGCC2 */
+
+/* Demangle NAME in the G++ V3 ABI demangling style, and return either
+ zero, indicating that some error occurred, or a demangling_t
+ holding the results. */
+static demangling_t
+demangle_v3_with_details (name)
+ const char *name;
+{
+ demangling_t dm;
+ status_t status;
+
+ if (strncmp (name, "_Z", 2))
+ return 0;
+
+ dm = demangling_new (name, DMGL_GNU_V3);
+ if (dm == NULL)
+ {
+ fprintf (stderr, "Memory allocation failed.\n");
+ abort ();
+ }
+
+ status = result_push (dm);
+ if (! STATUS_NO_ERROR (status))
+ {
+ demangling_delete (dm);
+ fprintf (stderr, "%s\n", status);
+ abort ();
+ }
+
+ status = demangle_mangled_name (dm);
+ if (STATUS_NO_ERROR (status))
+ return dm;
+
+ demangling_delete (dm);
+ return 0;
+}
+
+
+/* Return non-zero iff NAME is the mangled form of a constructor name
+ in the G++ V3 ABI demangling style. Specifically, return:
+ - '1' if NAME is a complete object constructor,
+ - '2' if NAME is a base object constructor, or
+ - '3' if NAME is a complete object allocating constructor. */
+enum gnu_v3_ctor_kinds
+is_gnu_v3_mangled_ctor (name)
+ const char *name;
+{
+ demangling_t dm = demangle_v3_with_details (name);
+
+ if (dm)
+ {
+ enum gnu_v3_ctor_kinds result = dm->is_constructor;
+ demangling_delete (dm);
+ return result;
+ }
+ else
+ return 0;
+}
+
+
+/* Return non-zero iff NAME is the mangled form of a destructor name
+ in the G++ V3 ABI demangling style. Specifically, return:
+ - '0' if NAME is a deleting destructor,
+ - '1' if NAME is a complete object destructor, or
+ - '2' if NAME is a base object destructor. */
+enum gnu_v3_dtor_kinds
+is_gnu_v3_mangled_dtor (name)
+ const char *name;
+{
+ demangling_t dm = demangle_v3_with_details (name);
+
+ if (dm)
+ {
+ enum gnu_v3_dtor_kinds result = dm->is_destructor;
+ demangling_delete (dm);
+ return result;
+ }
+ else
+ return 0;
+}
+
+
#ifdef STANDALONE_DEMANGLER
#include "getopt.h"
@@ -3669,7 +3945,7 @@ print_usage (fp, exit_value)
}
/* Option specification for getopt_long. */
-static struct option long_options[] =
+static const struct option long_options[] =
{
{ "help", no_argument, NULL, 'h' },
{ "strict", no_argument, NULL, 's' },
@@ -3771,7 +4047,7 @@ main (argc, argv)
}
/* Attempt to demangle the name. */
- status = cp_demangle (dyn_string_buf (mangled), demangled);
+ status = cp_demangle (dyn_string_buf (mangled), demangled, 0);
/* If the demangling succeeded, great! Print out the
demangled version. */
@@ -3810,7 +4086,7 @@ main (argc, argv)
for (i = optind; i < argc; ++i)
{
/* Attempt to demangle. */
- status = cp_demangle (argv[i], result);
+ status = cp_demangle (argv[i], result, 0);
/* If it worked, print the demangled name. */
if (STATUS_NO_ERROR (status))
@@ -3818,7 +4094,7 @@ main (argc, argv)
/* Abort on allocaiton failures. */
else if (status == STATUS_ALLOCATION_FAILED)
{
- fprintf (stderr, "Memory allocaiton failed.\n");
+ fprintf (stderr, "Memory allocation failed.\n");
abort ();
}
/* If not, print the error message to stderr instead. */
diff --git a/contrib/binutils/libiberty/cplus-dem.c b/contrib/binutils/libiberty/cplus-dem.c
index a42f45e..5af8826 100644
--- a/contrib/binutils/libiberty/cplus-dem.c
+++ b/contrib/binutils/libiberty/cplus-dem.c
@@ -1,6 +1,6 @@
/* Demangler for GNU C++
Copyright 1989, 1991, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000 Free Software Foundation, Inc.
+ 2000, 2001 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.uucp)
Rewritten by Fred Fish (fnf@cygnus.com) for ARM and Lucid demangling
Modified by Satish Pai (pai@apollo.hp.com) for HP demangling
@@ -63,25 +63,6 @@ static char *ada_demangle PARAMS ((const char *, int));
extern void fancy_abort PARAMS ((void)) ATTRIBUTE_NORETURN;
-static const char *mystrstr PARAMS ((const char *, const char *));
-
-static const char *
-mystrstr (s1, s2)
- const char *s1, *s2;
-{
- register const char *p = s1;
- register int len = strlen (s2);
-
- for (; (p = strchr (p, *s2)) != 0; p++)
- {
- if (strncmp (p, s2, len) == 0)
- {
- return (p);
- }
- }
- return (0);
-}
-
/* In order to allow a single demangler executable to demangle strings
using various common values of CPLUS_MARKER, as well as any specific
one set at compile time, we maintain a string containing all the
@@ -157,9 +138,9 @@ struct work_stuff
static const struct optable
{
- const char *in;
- const char *out;
- int flags;
+ const char *const in;
+ const char *const out;
+ const int flags;
} optable[] = {
{"nw", " new", DMGL_ANSI}, /* new (1.92, ansi) */
{"dl", " delete", DMGL_ANSI}, /* new (1.92, ansi) */
@@ -256,9 +237,15 @@ typedef enum type_kind_t
tk_real
} type_kind_t;
-struct demangler_engine libiberty_demanglers[] =
+const struct demangler_engine libiberty_demanglers[] =
{
{
+ NO_DEMANGLING_STYLE_STRING,
+ no_demangling,
+ "Demangling disabled"
+ }
+ ,
+ {
AUTO_DEMANGLING_STYLE_STRING,
auto_demangling,
"Automatic selection based on executable"
@@ -568,6 +555,9 @@ consume_count (type)
(*type)++;
}
+ if (count < 0)
+ count = -1;
+
return (count);
}
@@ -847,7 +837,7 @@ enum demangling_styles
cplus_demangle_set_style (style)
enum demangling_styles style;
{
- struct demangler_engine *demangler = libiberty_demanglers;
+ const struct demangler_engine *demangler = libiberty_demanglers;
for (; demangler->demangling_style != unknown_demangling; ++demangler)
if (style == demangler->demangling_style)
@@ -865,7 +855,7 @@ enum demangling_styles
cplus_demangle_name_to_style (name)
const char *name;
{
- struct demangler_engine *demangler = libiberty_demanglers;
+ const struct demangler_engine *demangler = libiberty_demanglers;
for (; demangler->demangling_style != unknown_demangling; ++demangler)
if (strcmp (name, demangler->demangling_style_name) == 0)
@@ -877,7 +867,7 @@ cplus_demangle_name_to_style (name)
/* char *cplus_demangle (const char *mangled, int options)
If MANGLED is a mangled function name produced by GNU C++, then
- a pointer to a malloced string giving a C++ representation
+ a pointer to a @code{malloc}ed string giving a C++ representation
of the name will be returned; otherwise NULL will be returned.
It is the caller's responsibility to free the string which
is returned.
@@ -909,6 +899,10 @@ cplus_demangle (mangled, options)
{
char *ret;
struct work_stuff work[1];
+
+ if (current_demangling_style == no_demangling)
+ return xstrdup (mangled);
+
memset ((char *) work, 0, sizeof (work));
work->options = options;
if ((work->options & DMGL_STYLE_MASK) == 0)
@@ -922,6 +916,13 @@ cplus_demangle (mangled, options)
return ret;
}
+ if (JAVA_DEMANGLING)
+ {
+ ret = java_demangle_v3 (mangled);
+ if (ret)
+ return ret;
+ }
+
if (GNAT_DEMANGLING)
return ada_demangle(mangled,options);
@@ -2233,7 +2234,7 @@ arm_pt (work, mangled, n, anchor, args)
{
/* Check if ARM template with "__pt__" in it ("parameterized type") */
/* Allow HP also here, because HP's cfront compiler follows ARM to some extent */
- if ((ARM_DEMANGLING || HP_DEMANGLING) && (*anchor = mystrstr (mangled, "__pt__")))
+ if ((ARM_DEMANGLING || HP_DEMANGLING) && (*anchor = strstr (mangled, "__pt__")))
{
int len;
*args = *anchor + 6;
@@ -2248,9 +2249,9 @@ arm_pt (work, mangled, n, anchor, args)
}
if (AUTO_DEMANGLING || EDG_DEMANGLING)
{
- if ((*anchor = mystrstr (mangled, "__tm__"))
- || (*anchor = mystrstr (mangled, "__ps__"))
- || (*anchor = mystrstr (mangled, "__pt__")))
+ if ((*anchor = strstr (mangled, "__tm__"))
+ || (*anchor = strstr (mangled, "__ps__"))
+ || (*anchor = strstr (mangled, "__pt__")))
{
int len;
*args = *anchor + 6;
@@ -2263,7 +2264,7 @@ arm_pt (work, mangled, n, anchor, args)
return 1;
}
}
- else if ((*anchor = mystrstr (mangled, "__S")))
+ else if ((*anchor = strstr (mangled, "__S")))
{
int len;
*args = *anchor + 3;
@@ -2564,7 +2565,7 @@ iterate_demangle_function (work, mangled, declp, scan)
/* Do not iterate for some demangling modes, or if there's only one
"__"-sequence. This is the normal case. */
if (ARM_DEMANGLING || LUCID_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING
- || mystrstr (scan + 2, "__") == NULL)
+ || strstr (scan + 2, "__") == NULL)
{
demangle_function_name (work, mangled, declp, scan);
return 1;
@@ -2707,7 +2708,7 @@ demangle_prefix (work, mangled, declp)
/* This block of code is a reduction in strength time optimization
of:
- scan = mystrstr (*mangled, "__"); */
+ scan = strstr (*mangled, "__"); */
{
scan = *mangled;
@@ -2799,7 +2800,7 @@ demangle_prefix (work, mangled, declp)
{
scan++;
}
- if ((scan = mystrstr (scan, "__")) == NULL || (*(scan + 2) == '\0'))
+ if ((scan = strstr (scan, "__")) == NULL || (*(scan + 2) == '\0'))
{
/* No separator (I.E. "__not_mangled"), or empty signature
(I.E. "__not_mangled_either__") */
@@ -4902,7 +4903,7 @@ static void
print_demangler_list (stream)
FILE *stream;
{
- struct demangler_engine *demangler;
+ const struct demangler_engine *demangler;
fprintf (stream, "{%s", libiberty_demanglers->demangling_style_name);
@@ -4946,11 +4947,10 @@ extern int prepends_underscore;
int strip_underscore = 0;
-static struct option long_options[] = {
+static const struct option long_options[] = {
{"strip-underscores", no_argument, 0, '_'},
{"format", required_argument, 0, 's'},
{"help", no_argument, 0, 'h'},
- {"java", no_argument, 0, 'j'},
{"no-strip-underscores", no_argument, 0, 'n'},
{"version", no_argument, 0, 'v'},
{0, no_argument, 0, 0}
@@ -5044,12 +5044,13 @@ main (argc, argv)
char *result;
int c;
const char *valid_symbols;
+ enum demangling_styles style = auto_demangling;
program_name = argv[0];
strip_underscore = prepends_underscore;
- while ((c = getopt_long (argc, argv, "_ns:j", long_options, (int *) 0)) != EOF)
+ while ((c = getopt_long (argc, argv, "_ns:", long_options, (int *) 0)) != EOF)
{
switch (c)
{
@@ -5067,13 +5068,8 @@ main (argc, argv)
case '_':
strip_underscore = 1;
break;
- case 'j':
- flags |= DMGL_JAVA;
- break;
case 's':
{
- enum demangling_styles style;
-
style = cplus_demangle_name_to_style (optarg);
if (style == unknown_demangling)
{
@@ -5137,7 +5133,7 @@ main (argc, argv)
{
int skip_first = 0;
- if (mbuffer[0] == '.')
+ if (mbuffer[0] == '.' || mbuffer[0] == '$')
++skip_first;
if (strip_underscore && mbuffer[skip_first] == '_')
++skip_first;
@@ -5146,7 +5142,7 @@ main (argc, argv)
skip_first = i;
mbuffer[i] = 0;
-
+ flags |= (int) style;
result = cplus_demangle (mbuffer + skip_first, flags);
if (result)
{
diff --git a/contrib/binutils/libiberty/fdmatch.c b/contrib/binutils/libiberty/fdmatch.c
index 7af039f..979c214 100644
--- a/contrib/binutils/libiberty/fdmatch.c
+++ b/contrib/binutils/libiberty/fdmatch.c
@@ -20,25 +20,19 @@ Boston, MA 02111-1307, USA. */
/*
-NAME
-
- fdmatch -- see if two file descriptors refer to same file
-
-SYNOPSIS
-
- int fdmatch (int fd1, int fd2)
-
-DESCRIPTION
-
- Check to see if two open file descriptors refer to the same file.
- This is useful, for example, when we have an open file descriptor
- for an unnamed file, and the name of a file that we believe to
- correspond to that fd. This can happen when we are exec'd with
- an already open file (stdout for example) or from the SVR4 /proc
- calls that return open file descriptors for mapped address spaces.
- All we have to do is open the file by name and check the two file
- descriptors for a match, which is done by comparing major&minor
- device numbers and inode numbers.
+@deftypefn Extension int fdmatch (int @var{fd1}, int @var{fd2})
+
+Check to see if two open file descriptors refer to the same file.
+This is useful, for example, when we have an open file descriptor for
+an unnamed file, and the name of a file that we believe to correspond
+to that fd. This can happen when we are exec'd with an already open
+file (@code{stdout} for example) or from the SVR4 @file{/proc} calls
+that return open file descriptors for mapped address spaces. All we
+have to do is open the file by name and check the two file descriptors
+for a match, which is done by comparing major and minor device numbers
+and inode numbers.
+
+@end deftypefn
BUGS
diff --git a/contrib/binutils/libiberty/ffs.c b/contrib/binutils/libiberty/ffs.c
new file mode 100644
index 0000000..de047e2
--- /dev/null
+++ b/contrib/binutils/libiberty/ffs.c
@@ -0,0 +1,27 @@
+/* ffs -- Find the first bit set in the parameter
+
+@deftypefn Supplemental int ffs (int @var{valu})
+
+Find the first (least significant) bit set in @var{valu}. Bits are
+numbered from right to left, starting with bit 1 (corresponding to the
+value 1). If @var{valu} is zero, zero is returned.
+
+@end deftypefn
+
+*/
+
+int
+ffs (valu)
+ register int valu;
+{
+ register int bit;
+
+ if (valu == 0)
+ return 0;
+
+ for (bit = 1; !(valu & 1); bit++)
+ valu >>= 1;
+
+ return bit;
+}
+
diff --git a/contrib/binutils/libiberty/fibheap.c b/contrib/binutils/libiberty/fibheap.c
new file mode 100644
index 0000000..0ba9b8d
--- /dev/null
+++ b/contrib/binutils/libiberty/fibheap.c
@@ -0,0 +1,523 @@
+/* A Fibonacci heap datatype.
+ Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Contributed by Daniel Berlin (dan@cgsoftware.com).
+
+This file is part of GNU CC.
+
+GNU CC 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.
+
+GNU CC is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#include "libiberty.h"
+#include "fibheap.h"
+
+
+#define FIBHEAPKEY_MIN LONG_MIN
+
+static void fibheap_ins_root PARAMS ((fibheap_t, fibnode_t));
+static void fibheap_rem_root PARAMS ((fibheap_t, fibnode_t));
+static void fibheap_consolidate PARAMS ((fibheap_t));
+static void fibheap_link PARAMS ((fibheap_t, fibnode_t, fibnode_t));
+static void fibheap_cut PARAMS ((fibheap_t, fibnode_t, fibnode_t));
+static void fibheap_cascading_cut PARAMS ((fibheap_t, fibnode_t));
+static fibnode_t fibheap_extr_min_node PARAMS ((fibheap_t));
+static int fibheap_compare PARAMS ((fibheap_t, fibnode_t, fibnode_t));
+static int fibheap_comp_data PARAMS ((fibheap_t, fibheapkey_t, void *,
+ fibnode_t));
+static fibnode_t fibnode_new PARAMS ((void));
+static void fibnode_insert_after PARAMS ((fibnode_t, fibnode_t));
+#define fibnode_insert_before(a, b) fibnode_insert_after (a->left, b)
+static fibnode_t fibnode_remove PARAMS ((fibnode_t));
+
+
+/* Create a new fibonacci heap. */
+fibheap_t
+fibheap_new ()
+{
+ return (fibheap_t) xcalloc (1, sizeof (struct fibheap));
+}
+
+/* Create a new fibonacci heap node. */
+static fibnode_t
+fibnode_new ()
+{
+ fibnode_t node;
+
+ node = xcalloc (1, sizeof *node);
+ node->left = node;
+ node->right = node;
+
+ return node;
+}
+
+static inline int
+fibheap_compare (heap, a, b)
+ fibheap_t heap ATTRIBUTE_UNUSED;
+ fibnode_t a;
+ fibnode_t b;
+{
+ if (a->key < b->key)
+ return -1;
+ if (a->key > b->key)
+ return 1;
+ return 0;
+}
+
+static inline int
+fibheap_comp_data (heap, key, data, b)
+ fibheap_t heap;
+ fibheapkey_t key;
+ void *data;
+ fibnode_t b;
+{
+ struct fibnode a;
+
+ a.key = key;
+ a.data = data;
+
+ return fibheap_compare (heap, &a, b);
+}
+
+/* Insert DATA, with priority KEY, into HEAP. */
+fibnode_t
+fibheap_insert (heap, key, data)
+ fibheap_t heap;
+ fibheapkey_t key;
+ void *data;
+{
+ fibnode_t node;
+
+ /* Create the new node. */
+ node = fibnode_new ();
+
+ /* Set the node's data. */
+ node->data = data;
+ node->key = key;
+
+ /* Insert it into the root list. */
+ fibheap_ins_root (heap, node);
+
+ /* If their was no minimum, or this key is less than the min,
+ it's the new min. */
+ if (heap->min == NULL || node->key < heap->min->key)
+ heap->min = node;
+
+ heap->nodes++;
+
+ return node;
+}
+
+/* Return the data of the minimum node (if we know it). */
+void *
+fibheap_min (heap)
+ fibheap_t heap;
+{
+ /* If there is no min, we can't easily return it. */
+ if (heap->min == NULL)
+ return NULL;
+ return heap->min->data;
+}
+
+/* Return the key of the minimum node (if we know it). */
+fibheapkey_t
+fibheap_min_key (heap)
+ fibheap_t heap;
+{
+ /* If there is no min, we can't easily return it. */
+ if (heap->min == NULL)
+ return 0;
+ return heap->min->key;
+}
+
+/* Union HEAPA and HEAPB into a new heap. */
+fibheap_t
+fibheap_union (heapa, heapb)
+ fibheap_t heapa;
+ fibheap_t heapb;
+{
+ fibnode_t a_root, b_root, temp;
+
+ /* If one of the heaps is empty, the union is just the other heap. */
+ if ((a_root = heapa->root) == NULL)
+ {
+ free (heapa);
+ return heapb;
+ }
+ if ((b_root = heapb->root) == NULL)
+ {
+ free (heapb);
+ return heapa;
+ }
+
+ /* Merge them to the next nodes on the opposite chain. */
+ a_root->left->right = b_root;
+ b_root->left->right = a_root;
+ temp = a_root->left;
+ a_root->left = b_root->left;
+ b_root->left = temp;
+ heapa->nodes += heapb->nodes;
+
+ /* And set the new minimum, if it's changed. */
+ if (fibheap_compare (heapa, heapb->min, heapa->min) < 0)
+ heapa->min = heapb->min;
+
+ free (heapb);
+ return heapa;
+}
+
+/* Extract the data of the minimum node from HEAP. */
+void *
+fibheap_extract_min (heap)
+ fibheap_t heap;
+{
+ fibnode_t z;
+ void *ret = NULL;
+
+ /* If we don't have a min set, it means we have no nodes. */
+ if (heap->min != NULL)
+ {
+ /* Otherwise, extract the min node, free the node, and return the
+ node's data. */
+ z = fibheap_extr_min_node (heap);
+ ret = z->data;
+ free (z);
+ }
+
+ return ret;
+}
+
+/* Replace both the KEY and the DATA associated with NODE. */
+void *
+fibheap_replace_key_data (heap, node, key, data)
+ fibheap_t heap;
+ fibnode_t node;
+ fibheapkey_t key;
+ void *data;
+{
+ void *odata;
+ int okey;
+ fibnode_t y;
+
+ /* If we wanted to, we could actually do a real increase by redeleting and
+ inserting. However, this would require O (log n) time. So just bail out
+ for now. */
+ if (fibheap_comp_data (heap, key, data, node) > 0)
+ return NULL;
+
+ odata = node->data;
+ okey = node->key;
+ node->data = data;
+ node->key = key;
+ y = node->parent;
+
+ if (okey == key)
+ return odata;
+
+ /* These two compares are specifically <= 0 to make sure that in the case
+ of equality, a node we replaced the data on, becomes the new min. This
+ is needed so that delete's call to extractmin gets the right node. */
+ if (y != NULL && fibheap_compare (heap, node, y) <= 0)
+ {
+ fibheap_cut (heap, node, y);
+ fibheap_cascading_cut (heap, y);
+ }
+
+ if (fibheap_compare (heap, node, heap->min) <= 0)
+ heap->min = node;
+
+ return odata;
+}
+
+/* Replace the DATA associated with NODE. */
+void *
+fibheap_replace_data (heap, node, data)
+ fibheap_t heap;
+ fibnode_t node;
+ void *data;
+{
+ return fibheap_replace_key_data (heap, node, node->key, data);
+}
+
+/* Replace the KEY associated with NODE. */
+fibheapkey_t
+fibheap_replace_key (heap, node, key)
+ fibheap_t heap;
+ fibnode_t node;
+ fibheapkey_t key;
+{
+ int okey = node->key;
+ fibheap_replace_key_data (heap, node, key, node->data);
+ return okey;
+}
+
+/* Delete NODE from HEAP. */
+void *
+fibheap_delete_node (heap, node)
+ fibheap_t heap;
+ fibnode_t node;
+{
+ void *ret = node->data;
+
+ /* To perform delete, we just make it the min key, and extract. */
+ fibheap_replace_key (heap, node, FIBHEAPKEY_MIN);
+ fibheap_extract_min (heap);
+
+ return ret;
+}
+
+/* Delete HEAP. */
+void
+fibheap_delete (heap)
+ fibheap_t heap;
+{
+ while (heap->min != NULL)
+ free (fibheap_extr_min_node (heap));
+
+ free (heap);
+}
+
+/* Determine if HEAP is empty. */
+int
+fibheap_empty (heap)
+ fibheap_t heap;
+{
+ return heap->nodes == 0;
+}
+
+/* Extract the minimum node of the heap. */
+static fibnode_t
+fibheap_extr_min_node (heap)
+ fibheap_t heap;
+{
+ fibnode_t ret = heap->min;
+ fibnode_t x, y, orig;
+
+ /* Attach the child list of the minimum node to the root list of the heap.
+ If there is no child list, we don't do squat. */
+ for (x = ret->child, orig = NULL; x != orig && x != NULL; x = y)
+ {
+ if (orig == NULL)
+ orig = x;
+ y = x->right;
+ x->parent = NULL;
+ fibheap_ins_root (heap, x);
+ }
+
+ /* Remove the old root. */
+ fibheap_rem_root (heap, ret);
+ heap->nodes--;
+
+ /* If we are left with no nodes, then the min is NULL. */
+ if (heap->nodes == 0)
+ heap->min = NULL;
+ else
+ {
+ /* Otherwise, consolidate to find new minimum, as well as do the reorg
+ work that needs to be done. */
+ heap->min = ret->right;
+ fibheap_consolidate (heap);
+ }
+
+ return ret;
+}
+
+/* Insert NODE into the root list of HEAP. */
+static void
+fibheap_ins_root (heap, node)
+ fibheap_t heap;
+ fibnode_t node;
+{
+ /* If the heap is currently empty, the new node becomes the singleton
+ circular root list. */
+ if (heap->root == NULL)
+ {
+ heap->root = node;
+ node->left = node;
+ node->right = node;
+ return;
+ }
+
+ /* Otherwise, insert it in the circular root list between the root
+ and it's right node. */
+ fibnode_insert_after (heap->root, node);
+}
+
+/* Remove NODE from the rootlist of HEAP. */
+static void
+fibheap_rem_root (heap, node)
+ fibheap_t heap;
+ fibnode_t node;
+{
+ if (node->left == node)
+ heap->root = NULL;
+ else
+ heap->root = fibnode_remove (node);
+}
+
+/* Consolidate the heap. */
+static void
+fibheap_consolidate (heap)
+ fibheap_t heap;
+{
+ fibnode_t a[1 + 8 * sizeof (long)];
+ fibnode_t w;
+ fibnode_t y;
+ fibnode_t x;
+ int i;
+ int d;
+ int D;
+
+ D = 1 + 8 * sizeof (long);
+
+ memset (a, 0, sizeof (fibnode_t) * D);
+
+ while ((w = heap->root) != NULL)
+ {
+ x = w;
+ fibheap_rem_root (heap, w);
+ d = x->degree;
+ while (a[d] != NULL)
+ {
+ y = a[d];
+ if (fibheap_compare (heap, x, y) > 0)
+ {
+ fibnode_t temp;
+ temp = x;
+ x = y;
+ y = temp;
+ }
+ fibheap_link (heap, y, x);
+ a[d] = NULL;
+ d++;
+ }
+ a[d] = x;
+ }
+ heap->min = NULL;
+ for (i = 0; i < D; i++)
+ if (a[i] != NULL)
+ {
+ fibheap_ins_root (heap, a[i]);
+ if (heap->min == NULL || fibheap_compare (heap, a[i], heap->min) < 0)
+ heap->min = a[i];
+ }
+}
+
+/* Make NODE a child of PARENT. */
+static void
+fibheap_link (heap, node, parent)
+ fibheap_t heap ATTRIBUTE_UNUSED;
+ fibnode_t node;
+ fibnode_t parent;
+{
+ if (parent->child == NULL)
+ parent->child = node;
+ else
+ fibnode_insert_before (parent->child, node);
+ node->parent = parent;
+ parent->degree++;
+ node->mark = 0;
+}
+
+/* Remove NODE from PARENT's child list. */
+static void
+fibheap_cut (heap, node, parent)
+ fibheap_t heap;
+ fibnode_t node;
+ fibnode_t parent;
+{
+ fibnode_remove (node);
+ parent->degree--;
+ fibheap_ins_root (heap, node);
+ node->parent = NULL;
+ node->mark = 0;
+}
+
+static void
+fibheap_cascading_cut (heap, y)
+ fibheap_t heap;
+ fibnode_t y;
+{
+ fibnode_t z;
+
+ while ((z = y->parent) != NULL)
+ {
+ if (y->mark == 0)
+ {
+ y->mark = 1;
+ return;
+ }
+ else
+ {
+ fibheap_cut (heap, y, z);
+ y = z;
+ }
+ }
+}
+
+static void
+fibnode_insert_after (a, b)
+ fibnode_t a;
+ fibnode_t b;
+{
+ if (a == a->right)
+ {
+ a->right = b;
+ a->left = b;
+ b->right = a;
+ b->left = a;
+ }
+ else
+ {
+ b->right = a->right;
+ a->right->left = b;
+ a->right = b;
+ b->left = a;
+ }
+}
+
+static fibnode_t
+fibnode_remove (node)
+ fibnode_t node;
+{
+ fibnode_t ret;
+
+ if (node == node->left)
+ ret = NULL;
+ else
+ ret = node->left;
+
+ if (node->parent != NULL && node->parent->child == node)
+ node->parent->child = ret;
+
+ node->right->left = node->left;
+ node->left->right = node->right;
+
+ node->parent = NULL;
+ node->left = node;
+ node->right = node;
+
+ return ret;
+}
diff --git a/contrib/binutils/libiberty/floatformat.c b/contrib/binutils/libiberty/floatformat.c
index 3cb78f5..b5d0121 100644
--- a/contrib/binutils/libiberty/floatformat.c
+++ b/contrib/binutils/libiberty/floatformat.c
@@ -66,7 +66,7 @@ const struct floatformat floatformat_ieee_double_littlebyte_bigword =
{
floatformat_littlebyte_bigword, 64, 0, 1, 11, 1023, 2047, 12, 52,
floatformat_intbit_no,
- "floatformat_ieee_double_little"
+ "floatformat_ieee_double_littlebyte_bigword"
};
const struct floatformat floatformat_i387_ext =
@@ -91,17 +91,17 @@ const struct floatformat floatformat_i960_ext =
};
const struct floatformat floatformat_m88110_ext =
{
-#ifdef HARRIS_FLOAT_FORMAT
+ floatformat_big, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,
+ floatformat_intbit_yes,
+ "floatformat_m88110_ext"
+};
+const struct floatformat floatformat_m88110_harris_ext =
+{
/* Harris uses raw format 128 bytes long, but the number is just an ieee
double, and the last 64 bits are wasted. */
floatformat_big,128, 0, 1, 11, 0x3ff, 0x7ff, 12, 52,
floatformat_intbit_no,
- "floatformat_m88110_ext(harris)"
-#else
- floatformat_big, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,
- floatformat_intbit_yes,
- "floatformat_m88110_ext"
-#endif /* HARRIS_FLOAT_FORMAT */
+ "floatformat_m88110_ext_harris"
};
const struct floatformat floatformat_arm_ext =
{
@@ -110,6 +110,44 @@ const struct floatformat floatformat_arm_ext =
floatformat_intbit_yes,
"floatformat_arm_ext"
};
+const struct floatformat floatformat_arm_ext_big =
+{
+ /* Bits 1 to 16 are unused. */
+ floatformat_big, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64,
+ floatformat_intbit_yes,
+ "floatformat_arm_ext_big"
+};
+const struct floatformat floatformat_arm_ext_littlebyte_bigword =
+{
+ /* Bits 1 to 16 are unused. */
+ floatformat_littlebyte_bigword, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64,
+ floatformat_intbit_yes,
+ "floatformat_arm_ext_littlebyte_bigword"
+};
+const struct floatformat floatformat_ia64_spill_big =
+{
+ floatformat_big, 128, 0, 1, 17, 65535, 0x1ffff, 18, 64,
+ floatformat_intbit_yes,
+ "floatformat_ia64_spill_big"
+};
+const struct floatformat floatformat_ia64_spill_little =
+{
+ floatformat_little, 128, 0, 1, 17, 65535, 0x1ffff, 18, 64,
+ floatformat_intbit_yes,
+ "floatformat_ia64_spill_little"
+};
+const struct floatformat floatformat_ia64_quad_big =
+{
+ floatformat_big, 128, 0, 1, 15, 16383, 0x7fff, 16, 112,
+ floatformat_intbit_no,
+ "floatformat_ia64_quad_big"
+};
+const struct floatformat floatformat_ia64_quad_little =
+{
+ floatformat_little, 128, 0, 1, 15, 16383, 0x7fff, 16, 112,
+ floatformat_intbit_no,
+ "floatformat_ia64_quad_little"
+};
static unsigned long get_field PARAMS ((unsigned char *,
enum floatformat_byteorders,
diff --git a/contrib/binutils/libiberty/fnmatch.txh b/contrib/binutils/libiberty/fnmatch.txh
new file mode 100644
index 0000000..92e11bc
--- /dev/null
+++ b/contrib/binutils/libiberty/fnmatch.txh
@@ -0,0 +1,48 @@
+@deftypefn Replacement int fnmatch (const char *@var{pattern}, const char *@var{string}, int @var{flags})
+
+Matches @var{string} against @var{pattern}, returning zero if it
+matches, @code{FNM_NOMATCH} if not. @var{pattern} may contain the
+wildcards @code{?} to match any one character, @code{*} to match any
+zero or more characters, or a set of alternate characters in square
+brackets, like @samp{[a-gt8]}, which match one character (@code{a}
+through @code{g}, or @code{t}, or @code{8}, in this example) if that one
+character is in the set. A set may be inverted (i.e., match anything
+except what's in the set) by giving @code{^} or @code{!} as the first
+character in the set. To include those characters in the set, list them
+as anything other than the first character of the set. To include a
+dash in the set, list it last in the set. A backslash character makes
+the following character not special, so for example you could match
+against a literal asterisk with @samp{\*}. To match a literal
+backslash, use @samp{\\}.
+
+@code{flags} controls various aspects of the matching process, and is a
+boolean OR of zero or more of the following values (defined in
+@code{<fnmatch.h>}):
+
+@table @code
+
+@item FNM_PATHNAME
+@itemx FNM_FILE_NAME
+@var{string} is assumed to be a path name. No wildcard will ever match
+@code{/}.
+
+@item FNM_NOESCAPE
+Do not interpret backslashes as quoting the following special character.
+
+@item FNM_PERIOD
+A leading period (at the beginning of @var{string}, or if
+@code{FNM_PATHNAME} after a slash) is not matched by @code{*} or
+@code{?} but must be matched explicitly.
+
+@item FNM_LEADING_DIR
+Means that @var{string} also matches @var{pattern} if some initial part
+of @var{string} matches, and is followed by @code{/} and zero or more
+characters. For example, @samp{foo*} would match either @samp{foobar}
+or @samp{foobar/grill}.
+
+@item FNM_CASEFOLD
+Ignores case when performing the comparison.
+
+@end table
+
+@end deftypefn
diff --git a/contrib/binutils/libiberty/functions.texi b/contrib/binutils/libiberty/functions.texi
new file mode 100644
index 0000000..af7760d
--- /dev/null
+++ b/contrib/binutils/libiberty/functions.texi
@@ -0,0 +1,937 @@
+@c Automatically generated from *.c and others (the comments before
+@c each entry tell you which file and where in that file). DO NOT EDIT!
+@c Edit the *.c files, configure with --enable-maintainer-mode,
+@c and let gather-docs build you a new copy.
+
+@c alloca.c:26
+@deftypefn Replacement void* alloca (size_t @var{size})
+
+This function allocates memory which will be automatically reclaimed
+after the procedure exits. The @libib{} implementation does not free
+the memory immediately but will do so eventually during subsequent
+calls to this function. Memory is allocated using @code{xmalloc} under
+normal circumstances.
+
+The header file @file{alloca-conf.h} can be used in conjunction with the
+GNU Autoconf test @code{AC_FUNC_ALLOCA} to test for and properly make
+available this function. The @code{AC_FUNC_ALLOCA} test requires that
+client code use a block of preprocessor code to be safe (see the Autoconf
+manual for more); this header incorporates that logic and more, including
+the possibility of a GCC built-in function.
+
+@end deftypefn
+
+@c asprintf.c:33
+@deftypefn Extension int asprintf (char **@var{resptr}, const char *@var{format}, ...)
+
+Like @code{sprintf}, but instead of passing a pointer to a buffer, you
+pass a pointer to a pointer. This function will compute the size of
+the buffer needed, allocate memory with @code{malloc}, and store a
+pointer to the allocated memory in @code{*@var{resptr}}. The value
+returned is the same as @code{sprintf} would return. If memory could
+not be allocated, zero is returned and @code{NULL} is stored in
+@code{*@var{resptr}}.
+
+@end deftypefn
+
+@c atexit.c:6
+@deftypefn Supplemental int atexit (void (*@var{f})())
+
+Causes function @var{f} to be called at exit. Returns 0.
+
+@end deftypefn
+
+@c basename.c:6
+@deftypefn Supplemental char* basename (const char *@var{name})
+
+Returns a pointer to the last component of pathname @var{name}.
+Behavior is undefined if the pathname ends in a directory separator.
+
+@end deftypefn
+
+@c bcmp.c:6
+@deftypefn Supplemental int bcmp (char *@var{x}, char *@var{y}, int @var{count})
+
+Compares the first @var{count} bytes of two areas of memory. Returns
+zero if they are the same, nonzero otherwise. Returns zero if
+@var{count} is zero. A nonzero result only indicates a difference,
+it does not indicate any sorting order (say, by having a positive
+result mean @var{x} sorts before @var{y}).
+
+@end deftypefn
+
+@c bcopy.c:3
+@deftypefn Supplemental void bcopy (char *@var{in}, char *@var{out}, int @var{length})
+
+Copies @var{length} bytes from memory region @var{in} to region
+@var{out}. The use of @code{bcopy} is deprecated in new programs.
+
+@end deftypefn
+
+@c bsearch.c:33
+@deftypefn Supplemental void* bsearch (const void *@var{key}, const void *@var{base}, size_t @var{nmemb}, size_t @var{size}, int (*@var{compar})(const void *, const void *))
+
+Performs a search over an array of @var{nmemb} elements pointed to by
+@var{base} for a member that matches the object pointed to by @var{key}.
+The size of each member is specified by @var{size}. The array contents
+should be sorted in ascending order according to the @var{compar}
+comparison function. This routine should take two arguments pointing to
+the @var{key} and to an array member, in that order, and should return an
+integer less than, equal to, or greater than zero if the @var{key} object
+is respectively less than, matching, or greater than the array member.
+
+@end deftypefn
+
+@c argv.c:139
+@deftypefn Extension char** buildargv (char *@var{sp})
+
+Given a pointer to a string, parse the string extracting fields
+separated by whitespace and optionally enclosed within either single
+or double quotes (which are stripped off), and build a vector of
+pointers to copies of the string for each field. The input string
+remains unchanged. The last element of the vector is followed by a
+@code{NULL} element.
+
+All of the memory for the pointer array and copies of the string
+is obtained from @code{malloc}. All of the memory can be returned to the
+system with the single function call @code{freeargv}, which takes the
+returned result of @code{buildargv}, as it's argument.
+
+Returns a pointer to the argument vector if successful. Returns
+@code{NULL} if @var{sp} is @code{NULL} or if there is insufficient
+memory to complete building the argument vector.
+
+If the input is a null string (as opposed to a @code{NULL} pointer),
+then buildarg returns an argument vector that has one arg, a null
+string.
+
+@end deftypefn
+
+@c bzero.c:6
+@deftypefn Supplemental void bzero (char *@var{mem}, int @var{count})
+
+Zeros @var{count} bytes starting at @var{mem}. Use of this function
+is deprecated in favor of @code{memset}.
+
+@end deftypefn
+
+@c calloc.c:6
+@deftypefn Supplemental void* calloc (size_t @var{nelem}, size_t @var{elsize})
+
+Uses @code{malloc} to allocate storage for @var{nelem} objects of
+@var{elsize} bytes each, then zeros the memory.
+
+@end deftypefn
+
+@c choose-temp.c:42
+@deftypefn Extension char* choose_temp_base (void)
+
+Return a prefix for temporary file names or @code{NULL} if unable to
+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
+not recommended.
+
+@end deftypefn
+
+@c make-temp-file.c:88
+@deftypefn Replacement char* choose_tmpdir ()
+
+Returns a pointer to a directory path suitable for creating temporary
+files in.
+
+@end deftypefn
+
+@c clock.c:27
+@deftypefn Supplemental long clock (void)
+
+Returns an approximation of the CPU time used by the process as a
+@code{clock_t}; divide this number by @samp{CLOCKS_PER_SEC} to get the
+number of seconds used.
+
+@end deftypefn
+
+@c concat.c:24
+@deftypefn Extension char* concat (const char *@var{s1}, const char *@var{s2}, @dots{}, @code{NULL})
+
+Concatenate zero or more of strings and return the result in freshly
+@code{xmalloc}ed memory. Returns @code{NULL} if insufficient memory is
+available. The argument list is terminated by the first @code{NULL}
+pointer encountered. Pointers to empty strings are ignored.
+
+@end deftypefn
+
+@c argv.c:65
+@deftypefn Extension char** dupargv (char **@var{vector})
+
+Duplicate an argument vector. Simply scans through @var{vector},
+duplicating each argument until the terminating @code{NULL} is found.
+Returns a pointer to the argument vector if successful. Returns
+@code{NULL} if there is insufficient memory to complete building the
+argument vector.
+
+@end deftypefn
+
+@c strerror.c:566
+@deftypefn Extension int errno_max (void)
+
+Returns the maximum @code{errno} value for which a corresponding
+symbolic name or message is available. Note that in the case where we
+use the @code{sys_errlist} supplied by the system, it is possible for
+there to be more symbolic names than messages, or vice versa. In
+fact, the manual page for @code{perror(3C)} explicitly warns that one
+should check the size of the table (@code{sys_nerr}) before indexing
+it, since new error codes may be added to the system before they are
+added to the table. Thus @code{sys_nerr} might be smaller than value
+implied by the largest @code{errno} value defined in @code{<errno.h>}.
+
+We return the maximum value that can be used to obtain a meaningful
+symbolic name or message.
+
+@end deftypefn
+
+@c fdmatch.c:23
+@deftypefn Extension int fdmatch (int @var{fd1}, int @var{fd2})
+
+Check to see if two open file descriptors refer to the same file.
+This is useful, for example, when we have an open file descriptor for
+an unnamed file, and the name of a file that we believe to correspond
+to that fd. This can happen when we are exec'd with an already open
+file (@code{stdout} for example) or from the SVR4 @file{/proc} calls
+that return open file descriptors for mapped address spaces. All we
+have to do is open the file by name and check the two file descriptors
+for a match, which is done by comparing major and minor device numbers
+and inode numbers.
+
+@end deftypefn
+
+@c ffs.c:3
+@deftypefn Supplemental int ffs (int @var{valu})
+
+Find the first (least significant) bit set in @var{valu}. Bits are
+numbered from right to left, starting with bit 1 (corresponding to the
+value 1). If @var{valu} is zero, zero is returned.
+
+@end deftypefn
+
+@c fnmatch.txh:1
+@deftypefn Replacement int fnmatch (const char *@var{pattern}, const char *@var{string}, int @var{flags})
+
+Matches @var{string} against @var{pattern}, returning zero if it
+matches, @code{FNM_NOMATCH} if not. @var{pattern} may contain the
+wildcards @code{?} to match any one character, @code{*} to match any
+zero or more characters, or a set of alternate characters in square
+brackets, like @samp{[a-gt8]}, which match one character (@code{a}
+through @code{g}, or @code{t}, or @code{8}, in this example) if that one
+character is in the set. A set may be inverted (i.e., match anything
+except what's in the set) by giving @code{^} or @code{!} as the first
+character in the set. To include those characters in the set, list them
+as anything other than the first character of the set. To include a
+dash in the set, list it last in the set. A backslash character makes
+the following character not special, so for example you could match
+against a literal asterisk with @samp{\*}. To match a literal
+backslash, use @samp{\\}.
+
+@code{flags} controls various aspects of the matching process, and is a
+boolean OR of zero or more of the following values (defined in
+@code{<fnmatch.h>}):
+
+@table @code
+
+@item FNM_PATHNAME
+@itemx FNM_FILE_NAME
+@var{string} is assumed to be a path name. No wildcard will ever match
+@code{/}.
+
+@item FNM_NOESCAPE
+Do not interpret backslashes as quoting the following special character.
+
+@item FNM_PERIOD
+A leading period (at the beginning of @var{string}, or if
+@code{FNM_PATHNAME} after a slash) is not matched by @code{*} or
+@code{?} but must be matched explicitly.
+
+@item FNM_LEADING_DIR
+Means that @var{string} also matches @var{pattern} if some initial part
+of @var{string} matches, and is followed by @code{/} and zero or more
+characters. For example, @samp{foo*} would match either @samp{foobar}
+or @samp{foobar/grill}.
+
+@item FNM_CASEFOLD
+Ignores case when performing the comparison.
+
+@end table
+
+@end deftypefn
+
+@c argv.c:111
+@deftypefn Extension void freeargv (char **@var{vector})
+
+Free an argument vector that was built using @code{buildargv}. Simply
+scans through @var{vector}, freeing the memory for each argument until
+the terminating @code{NULL} is found, and then frees @var{vector}
+itself.
+
+@end deftypefn
+
+@c getruntime.c:78
+@deftypefn Replacement long get_run_time (void)
+
+Returns the time used so far, in microseconds. If possible, this is
+the time used by this process, else it is the elapsed time since the
+process started.
+
+@end deftypefn
+
+@c getcwd.c:6
+@deftypefn Supplemental char* getcwd (char *@var{pathname}, int @var{len})
+
+Copy the absolute pathname for the current working directory into
+@var{pathname}, which is assumed to point to a buffer of at least
+@var{len} bytes, and return a pointer to the buffer. If the current
+directory's path doesn't fit in @var{len} characters, the result is
+@code{NULL} and @code{errno} is set. If @var{pathname} is a null pointer,
+@code{getcwd} will obtain @var{len} bytes of space using
+@code{malloc}.
+
+@end deftypefn
+
+@c getpagesize.c:5
+@deftypefn Supplemental int getpagesize (void)
+
+Returns the number of bytes in a page of memory. This is the
+granularity of many of the system memory management routines. No
+guarantee is made as to whether or not it is the same as the basic
+memory management hardware page size.
+
+@end deftypefn
+
+@c getpwd.c:5
+@deftypefn Supplemental char* getpwd (void)
+
+Returns the current working directory. This implementation caches the
+result on the assumption that the process will not call @code{chdir}
+between calls to @code{getpwd}.
+
+@end deftypefn
+
+@c index.c:5
+@deftypefn Supplemental char* index (char *@var{s}, int @var{c})
+
+Returns a pointer to the first occurrence of the character @var{c} in
+the string @var{s}, or @code{NULL} if not found. The use of @code{index} is
+deprecated in new programs in favor of @code{strchr}.
+
+@end deftypefn
+
+@c insque.c:6
+@deftypefn Supplemental void insque (struct qelem *@var{elem}, struct qelem *@var{pred})
+@deftypefnx Supplemental void remque (struct qelem *@var{elem})
+
+Routines to manipulate queues built from doubly linked lists. The
+@code{insque} routine inserts @var{elem} in the queue immediately
+after @var{pred}. The @code{remque} routine removes @var{elem} from
+its containing queue. These routines expect to be passed pointers to
+structures which have as their first members a forward pointer and a
+back pointer, like this prototype (although no prototype is provided):
+
+@example
+struct qelem @{
+ struct qelem *q_forw;
+ struct qelem *q_back;
+ char q_data[];
+@};
+@end example
+
+@end deftypefn
+
+@c lbasename.c:23
+@deftypefn Replacement {const char*} lbasename (const char *@var{name})
+
+Given a pointer to a string containing a typical pathname
+(@samp{/usr/src/cmd/ls/ls.c} for example), returns a pointer to the
+last component of the pathname (@samp{ls.c} in this case). The
+returned pointer is guaranteed to lie within the original
+string. This latter fact is not true of many vendor C
+libraries, which return special strings or modify the passed
+strings for particular input.
+
+In particular, the empty string returns the same empty string,
+and a path ending in @code{/} returns the empty string after it.
+
+@end deftypefn
+
+@c make-temp-file.c:138
+@deftypefn Replacement char* make_temp_file (const char *@var{suffix})
+
+Return a temporary file name (as a string) or @code{NULL} if unable to
+create one. @var{suffix} is a suffix to append to the file name. The
+string is @code{malloc}ed, and the temporary file has been created.
+
+@end deftypefn
+
+@c memchr.c:3
+@deftypefn Supplemental void* memchr (const void *@var{s}, int @var{c}, size_t @var{n})
+
+This function searches memory starting at @code{*@var{s}} for the
+character @var{c}. The search only ends with the first occurrence of
+@var{c}, or after @var{length} characters; in particular, a null
+character does not terminate the search. If the character @var{c} is
+found within @var{length} characters of @code{*@var{s}}, a pointer
+to the character is returned. If @var{c} is not found, then @code{NULL} is
+returned.
+
+@end deftypefn
+
+@c memcmp.c:6
+@deftypefn Supplemental int memcmp (const void *@var{x}, const void *@var{y}, size_t @var{count})
+
+Compares the first @var{count} bytes of two areas of memory. Returns
+zero if they are the same, a value less than zero if @var{x} is
+lexically less than @var{y}, or a value greater than zero if @var{x}
+is lexically greater than @var{y}. Note that lexical order is determined
+as if comparing unsigned char arrays.
+
+@end deftypefn
+
+@c memcpy.c:6
+@deftypefn Supplemental void* memcpy (void *@var{out}, const void *@var{in}, size_t @var{length})
+
+Copies @var{length} bytes from memory region @var{in} to region
+@var{out}. Returns a pointer to @var{out}.
+
+@end deftypefn
+
+@c memmove.c:6
+@deftypefn Supplemental void* memmove (void *@var{from}, const void *@var{to}, size_t @var{count})
+
+Copies @var{count} bytes from memory area @var{from} to memory area
+@var{to}, returning a pointer to @var{to}.
+
+@end deftypefn
+
+@c memset.c:6
+@deftypefn Supplemental void* memset (void *@var{s}, int @var{c}, size_t @var{count})
+
+Sets the first @var{count} bytes of @var{s} to the constant byte
+@var{c}, returning a pointer to @var{s}.
+
+@end deftypefn
+
+@c mkstemps.c:54
+@deftypefn Replacement int mkstemps (char *@var{template}, int @var{suffix_len})
+
+Generate a unique temporary file name from @var{template}.
+@var{template} has the form:
+
+@example
+ @var{path}/ccXXXXXX@var{suffix}
+@end example
+
+@var{suffix_len} tells us how long @var{suffix} is (it can be zero
+length). The last six characters of @var{template} before @var{suffix}
+must be @samp{XXXXXX}; they are replaced with a string that makes the
+filename unique. Returns a file descriptor open on the file for
+reading and writing.
+
+@end deftypefn
+
+@c pexecute.c:67
+@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)
+
+Executes a program.
+
+@var{program} and @var{argv} are the arguments to
+@code{execv}/@code{execvp}.
+
+@var{this_pname} is name of the calling program (i.e., @code{argv[0]}).
+
+@var{temp_base} is the path name, sans suffix, of a temporary file to
+use if needed. This is currently only needed for MS-DOS ports that
+don't use @code{go32} (do any still exist?). Ports that don't need it
+can pass @code{NULL}.
+
+(@code{@var{flags} & PEXECUTE_SEARCH}) is non-zero if @env{PATH} should be searched
+(??? It's not clear that GCC passes this flag correctly). (@code{@var{flags} &
+PEXECUTE_FIRST}) is nonzero for the first process in chain.
+(@code{@var{flags} & PEXECUTE_FIRST}) is nonzero for the last process
+in chain. The first/last flags could be simplified to only mark the
+last of a chain of processes but that requires the caller to always
+mark the last one (and not give up early if some error occurs).
+It's more robust to require the caller to mark both ends of the chain.
+
+The result is the pid on systems like Unix where we
+@code{fork}/@code{exec} and on systems like WIN32 and OS/2 where we
+use @code{spawn}. It is up to the caller to wait for the child.
+
+The result is the @code{WEXITSTATUS} on systems like MS-DOS where we
+@code{spawn} and wait for the child here.
+
+Upon failure, @var{errmsg_fmt} and @var{errmsg_arg} are set to the
+text of the error message with an optional argument (if not needed,
+@var{errmsg_arg} is set to @code{NULL}), and @minus{}1 is returned.
+@code{errno} is available to the caller to use.
+
+@end deftypefn
+
+@c strsignal.c:547
+@deftypefn Supplemental void psignal (unsigned @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},
+followed by a newline.
+
+@end deftypefn
+
+@c putenv.c:21
+@deftypefn Supplemental int putenv (const char *@var{string})
+
+Uses @code{setenv} or @code{unsetenv} to put @var{string} into
+the environment or remove it. If @var{string} is of the form
+@samp{name=value} the string is added; if no @samp{=} is present the
+name is unset/removed.
+
+@end deftypefn
+
+@c pexecute.c:104
+@deftypefn Extension int pwait (int @var{pid}, int *@var{status}, int @var{flags})
+
+Waits for a program started by @code{pexecute} to finish.
+
+@var{pid} is the process id of the task to wait for. @var{status} is
+the `status' argument to wait. @var{flags} is currently unused (allows
+future enhancement without breaking upward compatibility). Pass 0 for now.
+
+The result is the pid of the child reaped, or -1 for failure
+(@code{errno} says why).
+
+On systems that don't support waiting for a particular child, @var{pid} is
+ignored. On systems like MS-DOS that don't really multitask @code{pwait}
+is just a mechanism to provide a consistent interface for the caller.
+
+@end deftypefn
+
+@c random.c:39
+@deftypefn Supplement {long int} random (void)
+@deftypefnx Supplement void srandom (unsigned int @var{seed})
+@deftypefnx Supplement void* initstate (unsigned int @var{seed}, void *@var{arg_state}, unsigned long @var{n})
+@deftypefnx Supplement void* setstate (void *@var{arg_state})
+
+Random number functions. @code{random} returns a random number in the
+range 0 to @code{LONG_MAX}. @code{srandom} initializes the random
+number generator to some starting point determined by @var{seed}
+(else, the values returned by @code{random} are always the same for each
+run of the program). @code{initstate} and @code{setstate} allow fine-grained
+control over the state of the random number generator.
+
+@end deftypefn
+
+@c concat.c:177
+@deftypefn Extension char* reconcat (char *@var{optr}, const char *@var{s1}, @dots{}, @code{NULL})
+
+Same as @code{concat}, except that if @var{optr} is not @code{NULL} it
+is freed after the string is created. This is intended to be useful
+when you're extending an existing string or building up a string in a
+loop:
+
+@example
+ str = reconcat (str, "pre-", str, NULL);
+@end example
+
+@end deftypefn
+
+@c rename.c:6
+@deftypefn Supplemental int rename (const char *@var{old}, const char *@var{new})
+
+Renames a file from @var{old} to @var{new}. If @var{new} already
+exists, it is removed.
+
+@end deftypefn
+
+@c rindex.c:5
+@deftypefn Supplemental char* rindex (const char *@var{s}, int @var{c})
+
+Returns a pointer to the last occurrence of the character @var{c} in
+the string @var{s}, or @code{NULL} if not found. The use of @code{rindex} is
+deprecated in new programs in favor of @code{strrchr}.
+
+@end deftypefn
+
+@c setenv.c:22
+@deftypefn Supplemental int setenv (const char *@var{name}, const char *@var{value}, int @var{overwrite})
+@deftypefnx Supplemental void unsetenv (const char *@var{name})
+
+@code{setenv} adds @var{name} to the environment with value
+@var{value}. If the name was already present in the environment,
+the new value will be stored only if @var{overwrite} is nonzero.
+The companion @code{unsetenv} function removes @var{name} from the
+environment. This implementation is not safe for multithreaded code.
+
+@end deftypefn
+
+@c strsignal.c:353
+@deftypefn Extension int signo_max (void)
+
+Returns the maximum signal value for which a corresponding symbolic
+name or message is available. Note that in the case where we use the
+@code{sys_siglist} supplied by the system, it is possible for there to
+be more symbolic names than messages, or vice versa. In fact, the
+manual page for @code{psignal(3b)} explicitly warns that one should
+check the size of the table (@code{NSIG}) before indexing it, since
+new signal codes may be added to the system before they are added to
+the table. Thus @code{NSIG} might be smaller than value implied by
+the largest signo value defined in @code{<signal.h>}.
+
+We return the maximum value that can be used to obtain a meaningful
+symbolic name or message.
+
+@end deftypefn
+
+@c sigsetmask.c:8
+@deftypefn Supplemental int sigsetmask (int @var{set})
+
+Sets the signal mask to the one provided in @var{set} and returns
+the old mask (which, for libiberty's implementation, will always
+be the value @code{1}).
+
+@end deftypefn
+
+@c spaces.c:22
+@deftypefn Extension char* spaces (int @var{count})
+
+Returns a pointer to a memory region filled with the specified
+number of spaces and null terminated. The returned pointer is
+valid until at least the next call.
+
+@end deftypefn
+
+@c strcasecmp.c:15
+@deftypefn Supplemental int strcasecmp (const char *@var{s1}, const char *@var{s2})
+
+A case-insensitive @code{strcmp}.
+
+@end deftypefn
+
+@c strchr.c:6
+@deftypefn Supplemental char* strchr (const char *@var{s}, int @var{c})
+
+Returns a pointer to the first occurrence of the character @var{c} in
+the string @var{s}, or @code{NULL} if not found. If @var{c} is itself the
+null character, the results are undefined.
+
+@end deftypefn
+
+@c strdup.c:3
+@deftypefn Supplemental char* strdup (const char *@var{s})
+
+Returns a pointer to a copy of @var{s} in memory obtained from
+@code{malloc}, or @code{NULL} if insufficient memory was available.
+
+@end deftypefn
+
+@c strerror.c:670
+@deftypefn Replacement {const char*} strerrno (int @var{errnum})
+
+Given an error number returned from a system call (typically returned
+in @code{errno}), returns a pointer to a string containing the
+symbolic name of that error number, as found in @code{<errno.h>}.
+
+If the supplied error number is within the valid range of indices for
+symbolic names, but no name is available for the particular error
+number, then returns the string @samp{Error @var{num}}, where @var{num}
+is the error number.
+
+If the supplied error number is not within the range of valid
+indices, then returns @code{NULL}.
+
+The contents of the location pointed to are only guaranteed to be
+valid until the next call to @code{strerrno}.
+
+@end deftypefn
+
+@c strerror.c:602
+@deftypefn Supplemental char* strerror (int @var{errnoval})
+
+Maps an @code{errno} number to an error message string, the contents
+of which are implementation defined. On systems which have the
+external variables @code{sys_nerr} and @code{sys_errlist}, these
+strings will be the same as the ones used by @code{perror}.
+
+If the supplied error number is within the valid range of indices for
+the @code{sys_errlist}, but no message is available for the particular
+error number, then returns the string @samp{Error @var{num}}, where
+@var{num} is the error number.
+
+If the supplied error number is not a valid index into
+@code{sys_errlist}, returns @code{NULL}.
+
+The returned string is only guaranteed to be valid only until the
+next call to @code{strerror}.
+
+@end deftypefn
+
+@c strncasecmp.c:15
+@deftypefn Supplemental int strncasecmp (const char *@var{s1}, const char *@var{s2})
+
+A case-insensitive @code{strncmp}.
+
+@end deftypefn
+
+@c strncmp.c:6
+@deftypefn Supplemental int strncmp (const char *@var{s1}, const char *@var{s2}, size_t @var{n})
+
+Compares the first @var{n} bytes of two strings, returning a value as
+@code{strcmp}.
+
+@end deftypefn
+
+@c strrchr.c:6
+@deftypefn Supplemental char* strrchr (const char *@var{s}, int @var{c})
+
+Returns a pointer to the last occurrence of the character @var{c} in
+the string @var{s}, or @code{NULL} if not found. If @var{c} is itself the
+null character, the results are undefined.
+
+@end deftypefn
+
+@c strsignal.c:388
+@deftypefn Supplemental {const char *} strsignal (int @var{signo})
+
+Maps an signal number to an signal message string, the contents of
+which are implementation defined. On systems which have the external
+variable @code{sys_siglist}, these strings will be the same as the
+ones used by @code{psignal()}.
+
+If the supplied signal number is within the valid range of indices for
+the @code{sys_siglist}, but no message is available for the particular
+signal number, then returns the string @samp{Signal @var{num}}, where
+@var{num} is the signal number.
+
+If the supplied signal number is not a valid index into
+@code{sys_siglist}, returns @code{NULL}.
+
+The returned string is only guaranteed to be valid only until the next
+call to @code{strsignal}.
+
+@end deftypefn
+
+@c strsignal.c:452
+@deftypefn Extension {const char*} strsigno (int @var{signo})
+
+Given an signal number, returns a pointer to a string containing the
+symbolic name of that signal number, as found in @code{<signal.h>}.
+
+If the supplied signal number is within the valid range of indices for
+symbolic names, but no name is available for the particular signal
+number, then returns the string @samp{Signal @var{num}}, where
+@var{num} is the signal number.
+
+If the supplied signal number is not within the range of valid
+indices, then returns @code{NULL}.
+
+The contents of the location pointed to are only guaranteed to be
+valid until the next call to @code{strsigno}.
+
+@end deftypefn
+
+@c strstr.c:6
+@deftypefn Supplemental char* strstr (const char *@var{string}, const char *@var{sub})
+
+This function searches for the substring @var{sub} in the string
+@var{string}, not including the terminating null characters. A pointer
+to the first occurrence of @var{sub} is returned, or @code{NULL} if the
+substring is absent. If @var{sub} points to a string with zero
+length, the function returns @var{string}.
+
+@end deftypefn
+
+@c strtod.c:27
+@deftypefn Supplemental double strtod (const char *@var{string}, char **@var{endptr})
+
+This ISO C function converts the initial portion of @var{string} to a
+@code{double}. If @var{endptr} is not @code{NULL}, a pointer to the
+character after the last character used in the conversion is stored in
+the location referenced by @var{endptr}. If no conversion is
+performed, zero is returned and the value of @var{string} is stored in
+the location referenced by @var{endptr}.
+
+@end deftypefn
+
+@c strerror.c:730
+@deftypefn Extension int strtoerrno (const char *@var{name})
+
+Given the symbolic name of a error number (e.g., @code{EACCES}), map it
+to an errno value. If no translation is found, returns 0.
+
+@end deftypefn
+
+@c strtol.c:33
+@deftypefn Supplemental {long int} strtol (const char *@var{string}, char **@var{endptr}, int @var{base})
+@deftypefnx Supplemental {unsigned long int} strtoul (const char *@var{string}, char **@var{endptr}, int @var{base})
+
+The @code{strtol} function converts the string in @var{string} to a
+long integer value according to the given @var{base}, which must be
+between 2 and 36 inclusive, or be the special value 0. If @var{base}
+is 0, @code{strtol} will look for the prefixes @code{0} and @code{0x}
+to indicate bases 8 and 16, respectively, else default to base 10.
+When the base is 16 (either explicitly or implicitly), a prefix of
+@code{0x} is allowed. The handling of @var{endptr} is as that of
+@code{strtod} above. The @code{strtoul} function is the same, except
+that the converted value is unsigned.
+
+@end deftypefn
+
+@c strsignal.c:507
+@deftypefn Extension int strtosigno (const char *@var{name})
+
+Given the symbolic name of a signal, map it to a signal number. If no
+translation is found, returns 0.
+
+@end deftypefn
+
+@c tmpnam.c:3
+@deftypefn Supplemental char* tmpnam (char *@var{s})
+
+This function attempts to create a name for a temporary file, which
+will be a valid file name yet not exist when @code{tmpnam} checks for
+it. @var{s} must point to a buffer of at least @code{L_tmpnam} bytes,
+or be @code{NULL}. Use of this function creates a security risk, and it must
+not be used in new projects. Use @code{mkstemp} instead.
+
+@end deftypefn
+
+@c vasprintf.c:48
+@deftypefn Extension int vasprintf (char **@var{resptr}, const char *@var{format}, va_list @var{args})
+
+Like @code{vsprintf}, but instead of passing a pointer to a buffer,
+you pass a pointer to a pointer. This function will compute the size
+of the buffer needed, allocate memory with @code{malloc}, and store a
+pointer to the allocated memory in @code{*@var{resptr}}. The value
+returned is the same as @code{vsprintf} would return. If memory could
+not be allocated, zero is returned and @code{NULL} is stored in
+@code{*@var{resptr}}.
+
+@end deftypefn
+
+@c vfork.c:6
+@deftypefn Supplemental int vfork (void)
+
+Emulates @code{vfork} by calling @code{fork} and returning its value.
+
+@end deftypefn
+
+@c vprintf.c:3
+@deftypefn Supplemental int vprintf (const char *@var{format}, va_list @var{ap})
+@deftypefnx Supplemental int vfprintf (FILE *@var{stream}, const char *@var{format}, va_list @var{ap})
+@deftypefnx Supplemental int vsprintf (char *@var{str}, const char *@var{format}, va_list @var{ap})
+
+These functions are the same as @code{printf}, @code{fprintf}, and
+@code{sprintf}, respectively, except that they are called with a
+@code{va_list} instead of a variable number of arguments. Note that
+they do not call @code{va_end}; this is the application's
+responsibility. In @libib{} they are implemented in terms of the
+nonstandard but common function @code{_doprnt}.
+
+@end deftypefn
+
+@c waitpid.c:3
+@deftypefn Supplemental int waitpid (int @var{pid}, int *@var{status}, int)
+
+This is a wrapper around the @code{wait} function. Any ``special''
+values of @var{pid} depend on your implementation of @code{wait}, as
+does the return value. The third argument is unused in @libib{}.
+
+@end deftypefn
+
+@c xatexit.c:11
+@deftypefun int xatexit (void (*@var{fn}) (void))
+
+Behaves as the standard @code{atexit} function, but with no limit on
+the number of registered functions. Returns 0 on success, or @minus{}1 on
+failure. If you use @code{xatexit} to register functions, you must use
+@code{xexit} to terminate your program.
+
+@end deftypefun
+
+@c xmalloc.c:38
+@deftypefn Replacement void* xcalloc (size_t @var{nelem}, size_t @var{elsize})
+
+Allocate memory without fail, and set it to zero. This routine functions
+like @code{calloc}, but will behave the same as @code{xmalloc} if memory
+cannot be found.
+
+@end deftypefn
+
+@c xexit.c:22
+@deftypefn Replacement void xexit (int @var{code})
+
+Terminates the program. If any functions have been registered with
+the @code{xatexit} replacement function, they will be called first.
+Termination is handled via the system's normal @code{exit} call.
+
+@end deftypefn
+
+@c xmalloc.c:22
+@deftypefn Replacement void* xmalloc (size_t)
+
+Allocate memory without fail. If @code{malloc} fails, this will print
+a message to @code{stderr} (using the name set by
+@code{xmalloc_set_program_name},
+if any) and then call @code{xexit}. Note that it is therefore safe for
+a program to contain @code{#define malloc xmalloc} in its source.
+
+@end deftypefn
+
+@c xmalloc.c:53
+@deftypefn Replacement void xmalloc_failed (size_t)
+
+This function is not meant to be called by client code, and is listed
+here for completeness only. If any of the allocation routines fail, this
+function will be called to print an error message and terminate execution.
+
+@end deftypefn
+
+@c xmalloc.c:46
+@deftypefn Replacement void xmalloc_set_program_name (const char *@var{name})
+
+You can use this to set the name of the program used by
+@code{xmalloc_failed} when printing a failure message.
+
+@end deftypefn
+
+@c xmemdup.c:7
+@deftypefn Replacement void* xmemdup (void *@var{input}, size_t @var{copy_size}, size_t @var{alloc_size})
+
+Duplicates a region of memory without fail. First, @var{alloc_size} bytes
+are allocated, then @var{copy_size} bytes from @var{input} are copied into
+it, and the new memory is returned. If fewer bytes are copied than were
+allocated, the remaining memory is zeroed.
+
+@end deftypefn
+
+@c xmalloc.c:32
+@deftypefn Replacement void* xrealloc (void *@var{ptr}, size_t @var{size})
+Reallocate memory without fail. This routine functions like @code{realloc},
+but will behave the same as @code{xmalloc} if memory cannot be found.
+
+@end deftypefn
+
+@c xstrdup.c:7
+@deftypefn Replacement char* xstrdup (const char *@var{s})
+
+Duplicates a character string without fail, using @code{xmalloc} to
+obtain memory.
+
+@end deftypefn
+
+@c xstrerror.c:7
+@deftypefn Replacement char* xstrerror (int @var{errnum})
+
+Behaves exactly like the standard @code{strerror} function, but
+will never return a @code{NULL} pointer.
+
+@end deftypefn
+
+
diff --git a/contrib/binutils/libiberty/gather-docs b/contrib/binutils/libiberty/gather-docs
new file mode 100644
index 0000000..b272c02
--- /dev/null
+++ b/contrib/binutils/libiberty/gather-docs
@@ -0,0 +1,128 @@
+#!/usr/bin/perl
+# -*- perl -*-
+
+# Copyright (C) 2001
+# Free Software Foundation
+#
+# This file is part of the libiberty library.
+# Libiberty is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# Libiberty is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with libiberty; see the file COPYING.LIB. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+#
+# Originally written by DJ Delorie <dj@redhat.com>
+
+
+
+# This program looks for texinfo snippets in source files and other
+# files, and builds per-category files with entries sorted in
+# alphabetical order.
+
+# The syntax it looks for is lines starting with '@def' in *.c and
+# other files (see TEXIFILES in Makefile.in). Entries are terminated
+# at the next @def* (which begins a new entry) or, for C files, a line
+# that begins with '*/' without leading spaces (this assumes that the
+# texinfo snippet is within a C-style /* */ comment).
+
+#
+
+
+
+if ($ARGV[0] eq "-v") {
+ $verbose = 1;
+ shift;
+}
+
+$srcdir = shift;
+$outfile = shift;
+
+if ($outfile !~ /\S/ || ! -f "$srcdir/Makefile.in" ) {
+ print STDERR "Usage: gather-docs [-v] srcdir outfile.txi [files with snippets in them ...]\n";
+ exit 1;
+}
+
+$errors = 0;
+
+for $in (@ARGV) {
+
+ if (!open(IN, "$srcdir/$in")) {
+ print STDERR "Cannot open $srcdir/$in for reading: $!\n";
+ $errors ++;
+
+ } else {
+ $first = 1;
+ $pertinent = 0;
+ $man_mode = 0;
+ $line = 0;
+
+ while (<IN>) {
+ $line ++;
+ $pertinent = 1 if /^\@def[a-z]*[a-wyz] /;
+ $pertinent = 0 if /^\*\//;
+ next unless $pertinent;
+
+ if (/^\@def[a-z]*[a-wyz] /) {
+
+ ($name) = m/[^\(]* ([^\( \t\r\n]+) *\(/;
+ $name =~ s/[ ]*$//;
+ $key = $name;
+ $key =~ tr/A-Z/a-z/;
+ $key =~ s/[^a-z0-9]+/ /g;
+ $name{$key} = $node;
+ $lines{$key} = '';
+ $src_file{$key} = $in;
+ $src_line{$key} = $line;
+ print "\nReading $in :" if $verbose && $first;
+ $first = 0;
+ print " $name" if $verbose;
+ $node_lines{$key} .= $_;
+
+ } else {
+ $node_lines{$key} .= $_;
+ }
+
+ $pertinent = 0 if /^\@end def/;
+ }
+ close (IN);
+ }
+}
+
+print "\n" if $verbose;
+exit $errors if $errors;
+
+if (!open (OUT, "> $outfile")) {
+ print STDERR "Cannot open $outfile for writing: $!\n";
+ $errors ++;
+ next;
+}
+print "Writing $outfile\n" if $verbose;
+
+print OUT "\@c Automatically generated from *.c and others (the comments before\n";
+print OUT "\@c each entry tell you which file and where in that file). DO NOT EDIT!\n";
+print OUT "\@c Edit the *.c files, configure with --enable-maintainer-mode,\n";
+print OUT "\@c and let gather-docs build you a new copy.\n\n";
+
+for $key (sort keys %name) {
+ print OUT "\@c $src_file{$key}:$src_line{$key}\n";
+ print OUT $node_lines{$key};
+ print OUT "\n";
+}
+
+if (! print OUT "\n") {
+ print STDERR "Disk full writing $srcdir/$cat.texi\n";
+ $errors ++;
+}
+
+close (OUT);
+
+exit $errors;
diff --git a/contrib/binutils/libiberty/getcwd.c b/contrib/binutils/libiberty/getcwd.c
index 3445563..465b4e0 100644
--- a/contrib/binutils/libiberty/getcwd.c
+++ b/contrib/binutils/libiberty/getcwd.c
@@ -2,24 +2,18 @@
This function is in the public domain. */
/*
-NAME
- getcwd -- get absolute pathname for current working directory
-SYNOPSIS
- char *getcwd (char pathname[len], len)
+@deftypefn Supplemental char* getcwd (char *@var{pathname}, int @var{len})
-DESCRIPTION
- Copy the absolute pathname for the current working directory into
- the supplied buffer and return a pointer to the buffer. If the
- current directory's path doesn't fit in LEN characters, the result
- is NULL and errno is set.
+Copy the absolute pathname for the current working directory into
+@var{pathname}, which is assumed to point to a buffer of at least
+@var{len} bytes, and return a pointer to the buffer. If the current
+directory's path doesn't fit in @var{len} characters, the result is
+@code{NULL} and @code{errno} is set. If @var{pathname} is a null pointer,
+@code{getcwd} will obtain @var{len} bytes of space using
+@code{malloc}.
- If pathname is a null pointer, getcwd() will obtain size bytes of
- space using malloc.
-
-BUGS
- Emulated via the getwd() call, which is reasonable for most
- systems that do not have getcwd().
+@end deftypefn
*/
diff --git a/contrib/binutils/libiberty/getopt.c b/contrib/binutils/libiberty/getopt.c
index fd302b6..2402a39 100644
--- a/contrib/binutils/libiberty/getopt.c
+++ b/contrib/binutils/libiberty/getopt.c
@@ -82,7 +82,7 @@
#ifndef _
/* This is for other GNU distributions with internationalized messages.
When compiling libc, the _ macro is predefined. */
-# ifdef HAVE_LIBINTL_H
+# if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
# include <libintl.h>
# define _(msgid) gettext (msgid)
# else
diff --git a/contrib/binutils/libiberty/getpagesize.c b/contrib/binutils/libiberty/getpagesize.c
index 564d6c0..eed9680 100644
--- a/contrib/binutils/libiberty/getpagesize.c
+++ b/contrib/binutils/libiberty/getpagesize.c
@@ -2,20 +2,14 @@
/*
-NAME
+@deftypefn Supplemental int getpagesize (void)
- getpagesize -- return the number of bytes in page of memory
+Returns the number of bytes in a page of memory. This is the
+granularity of many of the system memory management routines. No
+guarantee is made as to whether or not it is the same as the basic
+memory management hardware page size.
-SYNOPSIS
-
- int getpagesize (void)
-
-DESCRIPTION
-
- Returns the number of bytes in a page of memory. This is the
- granularity of many of the system memory management routines.
- No guarantee is made as to whether or not it is the same as the
- basic memory management hardware page size.
+@end deftypefn
BUGS
diff --git a/contrib/binutils/libiberty/getpwd.c b/contrib/binutils/libiberty/getpwd.c
index de6e039..f508b1e 100644
--- a/contrib/binutils/libiberty/getpwd.c
+++ b/contrib/binutils/libiberty/getpwd.c
@@ -1,5 +1,17 @@
/* getpwd.c - get the working directory */
+/*
+
+@deftypefn Supplemental char* getpwd (void)
+
+Returns the current working directory. This implementation caches the
+result on the assumption that the process will not call @code{chdir}
+between calls to @code{getpwd}.
+
+@end deftypefn
+
+*/
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/contrib/binutils/libiberty/getruntime.c b/contrib/binutils/libiberty/getruntime.c
index 4abfa83..9301deb 100644
--- a/contrib/binutils/libiberty/getruntime.c
+++ b/contrib/binutils/libiberty/getruntime.c
@@ -73,6 +73,18 @@ Boston, MA 02111-1307, USA. */
#endif
#endif
+/*
+
+@deftypefn Replacement long get_run_time (void)
+
+Returns the time used so far, in microseconds. If possible, this is
+the time used by this process, else it is the elapsed time since the
+process started.
+
+@end deftypefn
+
+*/
+
long
get_run_time ()
{
diff --git a/contrib/binutils/libiberty/hashtab.c b/contrib/binutils/libiberty/hashtab.c
index 122ed43..36ad6e4 100644
--- a/contrib/binutils/libiberty/hashtab.c
+++ b/contrib/binutils/libiberty/hashtab.c
@@ -1,5 +1,5 @@
/* An expandable hash tables datatype.
- Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
Contributed by Vladimir Makarov (vmakarov@cygnus.com).
This file is part of the libiberty library.
@@ -80,46 +80,47 @@ higher_prime_number (n)
{
/* These are primes that are near, but slightly smaller than, a
power of two. */
- static unsigned long primes[] = {
- 2,
- 7,
- 13,
- 31,
- 61,
- 127,
- 251,
- 509,
- 1021,
- 2039,
- 4093,
- 8191,
- 16381,
- 32749,
- 65521,
- 131071,
- 262139,
- 524287,
- 1048573,
- 2097143,
- 4194301,
- 8388593,
- 16777213,
- 33554393,
- 67108859,
- 134217689,
- 268435399,
- 536870909,
- 1073741789,
- 2147483647,
- 4294967291
+ static const unsigned long primes[] = {
+ (unsigned long) 2,
+ (unsigned long) 7,
+ (unsigned long) 13,
+ (unsigned long) 31,
+ (unsigned long) 61,
+ (unsigned long) 127,
+ (unsigned long) 251,
+ (unsigned long) 509,
+ (unsigned long) 1021,
+ (unsigned long) 2039,
+ (unsigned long) 4093,
+ (unsigned long) 8191,
+ (unsigned long) 16381,
+ (unsigned long) 32749,
+ (unsigned long) 65521,
+ (unsigned long) 131071,
+ (unsigned long) 262139,
+ (unsigned long) 524287,
+ (unsigned long) 1048573,
+ (unsigned long) 2097143,
+ (unsigned long) 4194301,
+ (unsigned long) 8388593,
+ (unsigned long) 16777213,
+ (unsigned long) 33554393,
+ (unsigned long) 67108859,
+ (unsigned long) 134217689,
+ (unsigned long) 268435399,
+ (unsigned long) 536870909,
+ (unsigned long) 1073741789,
+ (unsigned long) 2147483647,
+ /* 4294967291L */
+ ((unsigned long) 2147483647) + ((unsigned long) 2147483644),
};
- unsigned long* low = &primes[0];
- unsigned long* high = &primes[sizeof(primes) / sizeof(primes[0])];
+ const unsigned long *low = &primes[0];
+ const unsigned long *high = &primes[sizeof(primes) / sizeof(primes[0])];
while (low != high)
{
- unsigned long* mid = low + (high - low) / 2;
+ const unsigned long *mid = low + (high - low) / 2;
if (n > *mid)
low = mid + 1;
else
@@ -560,3 +561,42 @@ htab_collisions (htab)
return (double) htab->collisions / (double) htab->searches;
}
+
+/* Hash P as a null-terminated string.
+
+ Copied from gcc/hashtable.c. Zack had the following to say with respect
+ to applicability, though note that unlike hashtable.c, this hash table
+ implementation re-hashes rather than chain buckets.
+
+ http://gcc.gnu.org/ml/gcc-patches/2001-08/msg01021.html
+ From: Zack Weinberg <zackw@panix.com>
+ Date: Fri, 17 Aug 2001 02:15:56 -0400
+
+ I got it by extracting all the identifiers from all the source code
+ I had lying around in mid-1999, and testing many recurrences of
+ the form "H_n = H_{n-1} * K + c_n * L + M" where K, L, M were either
+ prime numbers or the appropriate identity. This was the best one.
+ I don't remember exactly what constituted "best", except I was
+ looking at bucket-length distributions mostly.
+
+ So it should be very good at hashing identifiers, but might not be
+ as good at arbitrary strings.
+
+ I'll add that it thoroughly trounces the hash functions recommended
+ for this use at http://burtleburtle.net/bob/hash/index.html, both
+ on speed and bucket distribution. I haven't tried it against the
+ function they just started using for Perl's hashes. */
+
+hashval_t
+htab_hash_string (p)
+ const PTR p;
+{
+ const unsigned char *str = (const unsigned char *) p;
+ hashval_t r = 0;
+ unsigned char c;
+
+ while ((c = *str++) != 0)
+ r = r * 67 + c - 113;
+
+ return r;
+}
diff --git a/contrib/binutils/libiberty/hex.c b/contrib/binutils/libiberty/hex.c
index 3a2eef0..3ba04ba 100644
--- a/contrib/binutils/libiberty/hex.c
+++ b/contrib/binutils/libiberty/hex.c
@@ -1,5 +1,5 @@
/* Hex character manipulation support.
- Copyright (C) 1995 Free Software Foundation, Inc.
+ Copyright (C) 1995, 2001 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
@@ -17,17 +17,95 @@ License along with libiberty; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <stdio.h> /* for EOF */
#include "libiberty.h"
-char _hex_value[_hex_array_size];
-
-void hex_init ()
+/* Provided for ABI compatibility. */
+void
+hex_init ()
{
- int i;
- for (i = 0; i < _hex_array_size; i++)
- _hex_value[i] = _hex_bad;
- for (i = 0; i < 10; i++)
- _hex_value['0' + i] = i;
- for (i = 0; i < 6; i++)
- _hex_value['a' + i] = _hex_value['A' + i] = 10 + i;
}
+
+/* Are we ASCII? */
+#if '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \
+ && 'A' == 0x41 && 'a' == 0x61 && '!' == 0x21 \
+ && EOF == -1
+
+const char _hex_value[_hex_array_size] =
+{
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* NUL SOH STX ETX */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* EOT ENQ ACK BEL */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* BS HT LF VT */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* FF CR SO SI */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* DLE DC1 DC2 DC3 */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* DC4 NAK SYN ETB */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* CAN EM SUB ESC */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* FS GS RS US */
+
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* SP ! " # */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* $ % & ' */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* ( ) * + */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* , - . / */
+ 0, 1, 2, 3, /* 0 1 2 3 */
+ 4, 5, 6, 7, /* 4 5 6 7 */
+ 8, 9, _hex_bad, _hex_bad, /* 8 9 : ; */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* < = > ? */
+
+ _hex_bad, 10, 11, 12, /* @ A B C */
+ 13, 14, 15, _hex_bad, /* D E F G */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* H I J K */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* L M N O */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* P Q R S */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* T U V W */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* X Y Z [ */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* \ ] ^ _ */
+
+ _hex_bad, 10, 11, 12, /* ` a b c */
+ 13, 14, 15, _hex_bad, /* d e f g */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* h i j k */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* l m n o */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* p q r s */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* t u v w */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* x y z { */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad, /* | } ~ DEL */
+
+ /* The high half of unsigned char, all values are _hex_bad. */
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+ _hex_bad, _hex_bad, _hex_bad, _hex_bad,
+};
+#else
+ #error "Unsupported host character set"
+#endif /* not ASCII */
diff --git a/contrib/binutils/libiberty/index.c b/contrib/binutils/libiberty/index.c
index e5a00f5..a2e2727 100644
--- a/contrib/binutils/libiberty/index.c
+++ b/contrib/binutils/libiberty/index.c
@@ -1,5 +1,17 @@
/* Stub implementation of (obsolete) index(). */
+/*
+
+@deftypefn Supplemental char* index (char *@var{s}, int @var{c})
+
+Returns a pointer to the first occurrence of the character @var{c} in
+the string @var{s}, or @code{NULL} if not found. The use of @code{index} is
+deprecated in new programs in favor of @code{strchr}.
+
+@end deftypefn
+
+*/
+
extern char * strchr();
char *
diff --git a/contrib/binutils/libiberty/insque.c b/contrib/binutils/libiberty/insque.c
index 775019f..c0c1180 100644
--- a/contrib/binutils/libiberty/insque.c
+++ b/contrib/binutils/libiberty/insque.c
@@ -2,24 +2,27 @@
This file is in the public domain. */
/*
-NAME
- insque, remque -- insert, remove an element from a queue
-SYNOPSIS
- struct qelem {
- struct qelem *q_forw;
- struct qelem *q_back;
- char q_data[];
- };
+@deftypefn Supplemental void insque (struct qelem *@var{elem}, struct qelem *@var{pred})
+@deftypefnx Supplemental void remque (struct qelem *@var{elem})
- void insque (struct qelem *elem, struct qelem *pred)
+Routines to manipulate queues built from doubly linked lists. The
+@code{insque} routine inserts @var{elem} in the queue immediately
+after @var{pred}. The @code{remque} routine removes @var{elem} from
+its containing queue. These routines expect to be passed pointers to
+structures which have as their first members a forward pointer and a
+back pointer, like this prototype (although no prototype is provided):
- void remque (struct qelem *elem)
+@example
+struct qelem @{
+ struct qelem *q_forw;
+ struct qelem *q_back;
+ char q_data[];
+@};
+@end example
+
+@end deftypefn
-DESCRIPTION
- Routines to manipulate queues built from doubly linked lists.
- The insque routine inserts ELEM in the queue immediately after
- PRED. The remque routine removes ELEM from its containing queue.
*/
diff --git a/contrib/binutils/libiberty/lbasename.c b/contrib/binutils/libiberty/lbasename.c
index 7f87049..cea0253 100644
--- a/contrib/binutils/libiberty/lbasename.c
+++ b/contrib/binutils/libiberty/lbasename.c
@@ -19,23 +19,22 @@ not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/*
-NAME
- lbasename -- return pointer to last component of a pathname
-
-SYNOPSIS
- char *lbasename (const char *name)
-
-DESCRIPTION
- Given a pointer to a string containing a typical pathname
- (/usr/src/cmd/ls/ls.c for example), returns a pointer to the
- last component of the pathname ("ls.c" in this case). The
- returned pointer is guaranteed to lie within the original
- string. This latter fact is not true of many vendor C
- libraries, which return special strings or modify the passed
- strings for particular input.
-
- In particular, the empty string returns the same empty string,
- and a path ending in '/' returns the empty string after it.
+
+@deftypefn Replacement {const char*} lbasename (const char *@var{name})
+
+Given a pointer to a string containing a typical pathname
+(@samp{/usr/src/cmd/ls/ls.c} for example), returns a pointer to the
+last component of the pathname (@samp{ls.c} in this case). The
+returned pointer is guaranteed to lie within the original
+string. This latter fact is not true of many vendor C
+libraries, which return special strings or modify the passed
+strings for particular input.
+
+In particular, the empty string returns the same empty string,
+and a path ending in @code{/} returns the empty string after it.
+
+@end deftypefn
+
*/
#include "ansidecl.h"
@@ -69,7 +68,7 @@ DESCRIPTION
# endif
#endif
-char *
+const char *
lbasename (name)
const char *name;
{
@@ -85,5 +84,5 @@ lbasename (name)
if (IS_DIR_SEPARATOR (*name))
base = name + 1;
- return (char *) base;
+ return base;
}
diff --git a/contrib/binutils/libiberty/libiberty.texi b/contrib/binutils/libiberty/libiberty.texi
new file mode 100644
index 0000000..4b60d6a
--- /dev/null
+++ b/contrib/binutils/libiberty/libiberty.texi
@@ -0,0 +1,324 @@
+\input texinfo @c -*-texinfo-*-
+@c %**start of header
+@setfilename libiberty.info
+@settitle @sc{gnu} libiberty
+@c %**end of header
+
+@syncodeindex fn cp
+@syncodeindex vr cp
+@syncodeindex pg cp
+
+@finalout
+@c %**end of header
+
+@dircategory GNU libraries
+@direntry
+* Libiberty: (libiberty). Library of utility functions which
+ are missing or broken on some systems.
+@end direntry
+
+@macro libib
+@code{libiberty}
+@end macro
+
+@c The edition date is written in three locations. Search for 'thedate'.
+@ifinfo
+This manual describes the GNU @libib library of utility subroutines.
+This edition accompanies GCC 3, September 2001.
+
+Copyright @copyright{} 2001 Free Software Foundation, Inc.
+
+ Permission is granted to copy, distribute and/or modify this document
+ under the terms of the GNU Free Documentation License, Version 1.1
+ or any later version published by the Free Software Foundation;
+ with no Invariant Sections, with no Front-Cover Texts, and with no
+ Back-Cover Texts. A copy of the license is included in the
+ section entitled ``GNU Free Documentation License''.
+
+@ignore
+Permission is granted to process this file through TeX and print the
+results, provided the printed document carries a copying permission
+notice identical to this one except for the removal of this paragraph
+(this paragraph not being relevant to the printed manual).
+
+@end ignore
+@end ifinfo
+
+
+@c The edition date is written in three locations. Search for 'thedate'.
+@titlepage
+@title @sc{gnu} libiberty
+@subtitle September 2001
+@subtitle for GCC 3
+@author Phil Edwards et al.
+@page
+
+
+@vskip 0pt plus 1filll
+Copyright @copyright{} 2001 Free Software Foundation, Inc.
+
+ Permission is granted to copy, distribute and/or modify this document
+ under the terms of the GNU Free Documentation License, Version 1.1
+ or any later version published by the Free Software Foundation;
+ with no Invariant Sections, with no Front-Cover Texts, and with no
+ Back-Cover Texts. A copy of the license is included in the
+ section entitled ``GNU Free Documentation License''.
+
+@end titlepage
+@contents
+@page
+
+@ifnottex
+@node Top,Using,,
+@top Introduction
+
+The @libib{} library is a collection of subroutines used by various
+GNU programs. It is available under the Library General Public
+License; for more information, see @ref{Library Copying}.
+
+@c The edition date is written in three locations. Search for 'thedate'.
+This edition accompanies GCC 3, September 2001.
+
+@end ifnottex
+
+@menu
+* Using:: How to use libiberty in your code.
+
+* Overview:: Overview of available function groups.
+
+* Functions:: Available functions, macros, and global variables.
+
+* Obstacks:: Object Stacks.
+
+* Licenses:: The various licenses under which libiberty sources are
+ distributed.
+
+* Index:: Index of functions and categories.
+@end menu
+
+@node Using
+@chapter Using
+@cindex using libiberty
+@cindex libiberty usage
+@cindex how to use
+
+@c THIS SECTION IS CRAP AND NEEDS REWRITING BADLY.
+
+To date, @libib{} is generally not installed on its own. It has evolved
+over years but does not have its own version number nor release schedule.
+
+Possibly the easiest way to use @libib{} in your projects is to drop the
+@libib{} code into your project's sources, and to build the library along
+with your own sources; the library would then be linked in at the end. This
+prevents any possible version mismatches with other copies of libiberty
+elsewhere on the system.
+
+Passing @option{--enable-install-libiberty} to the @command{configure}
+script when building @libib{} causes the header files and archive library
+to be installed when @kbd{make install} is run. This option also takes
+an (optional) argument to specify the installation location, in the same
+manner as @option{--prefix}.
+
+For your own projects, an approach which offers stability and flexibility
+is to include @libib{} with your code, but allow the end user to optionally
+choose to use a previously-installed version instead. In this way the
+user may choose (for example) to install @libib{} as part of GCC, and use
+that version for all software built with that compiler. (This approach
+has proven useful with software using the GNU @code{readline} library.)
+
+Making use of @libib{} code usually requires that you include one or more
+header files from the @libib{} distribution. (They will be named as
+necessary in the function descriptions.) At link time, you will need to
+add @option{-liberty} to your link command invocation.
+
+
+@node Overview
+@chapter Overview
+
+Functions contained in @libib{} can be divided into three general categories.
+
+
+@menu
+* Supplemental Functions:: Providing functions which don't exist
+ on older operating systems.
+
+* Replacement Functions:: These functions are sometimes buggy or
+ unpredictable on some operating systems.
+
+* Extensions:: Functions which provide useful extensions
+ or safety wrappers around existing code.
+@end menu
+
+@node Supplemental Functions
+@section Supplemental Functions
+@cindex supplemental functions
+@cindex functions, supplemental
+@cindex functions, missing
+
+Certain operating systems do not provide functions which have since
+become standardized, or at least common. For example, the Single
+Unix Specification Version 2 requires that the @code{basename}
+function be provided, but an OS which predates that specification
+might not have this function. This should not prevent well-written
+code from running on such a system.
+
+Similarly, some functions exist only among a particular ``flavor''
+or ``family'' of operating systems. As an example, the @code{bzero}
+function is often not present on systems outside the BSD-derived
+family of systems.
+
+Many such functions are provided in @libib{}. They are quickly
+listed here with little description, as systems which lack them
+become less and less common. Each function @var{foo} is implemented
+in @file{@var{foo}.c} but not declared in any @libib{} header file; more
+comments and caveats for each function's implementation are often
+available in the source file. Generally, the function can simply
+be declared as @code{extern}.
+
+
+
+@node Replacement Functions
+@section Replacement Functions
+@cindex replacement functions
+@cindex functions, replacement
+
+Some functions have extremely limited implementations on different
+platforms. Other functions are tedious to use correctly; for example,
+proper use of @code{malloc} calls for the return value to be checked and
+appropriate action taken if memory has been exhausted. A group of
+``replacement functions'' is available in @libib{} to address these issues
+for some of the most commonly used subroutines.
+
+All of these functions are declared in the @file{libiberty.h} header
+file. Many of the implementations will use preprocessor macros set by
+GNU Autoconf, if you decide to make use of that program. Some of these
+functions may call one another.
+
+
+@menu
+* Memory Allocation:: Testing and handling failed memory
+ requests automatically.
+* Exit Handlers:: Calling routines on program exit.
+* Error Reporting:: Mapping errno and signal numbers to
+ more useful string formats.
+@end menu
+
+@node Memory Allocation
+@subsection Memory Allocation
+@cindex memory allocation
+
+The functions beginning with the letter @samp{x} are wrappers around
+standard functions; the functions provided by the system environment
+are called and their results checked before the results are passed back
+to client code. If the standard functions fail, these wrappers will
+terminate the program. Thus, these versions can be used with impunity.
+
+
+@node Exit Handlers
+@subsection Exit Handlers
+@cindex exit handlers
+
+The existence and implementation of the @code{atexit} routine varies
+amongst the flavors of Unix. @libib{} provides an unvarying dependable
+implementation via @code{xatexit} and @code{xexit}.
+
+
+@node Error Reporting
+@subsection Error Reporting
+@cindex error reporting
+
+These are a set of routines to facilitate programming with the system
+@code{errno} interface. The @libib{} source file @file{strerror.c}
+contains a good deal of documentation for these functions.
+
+@c signal stuff
+
+
+@node Extensions
+@section Extensions
+@cindex extensions
+@cindex functions, extension
+
+@libib{} includes additional functionality above and beyond standard
+functions, which has proven generically useful in GNU programs, such as
+obstacks and regex. These functions are often copied from other
+projects as they gain popularity, and are included here to provide a
+central location from which to use, maintain, and distribute them.
+
+@menu
+* Obstacks:: Stacks of arbitrary objects.
+@end menu
+
+@c This is generated from the glibc manual using a make-obstacks-texi.sh
+@c script of Phil's. Hope it's accurate.
+@include obstacks.texi
+
+@node Functions
+@chapter Function, Variable, and Macro Listing.
+@include functions.texi
+
+@node Licenses
+@appendix Licenses
+
+@menu
+
+* Library Copying:: The GNU Library General Public License
+* BSD:: Regents of the University of California
+
+@end menu
+
+@c This takes care of Library Copying. It is the copying-lib.texi from the
+@c GNU web site, with its @node line altered to make makeinfo shut up.
+@include copying-lib.texi
+
+@page
+@node BSD
+@appendixsec BSD
+
+Copyright @copyright{} 1990 Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+@enumerate
+
+@item
+Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+@item
+Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+@item
+[rescinded 22 July 1999]
+
+@item
+Neither the name of the University nor the names of its contributors
+may be used to endorse or promote products derived from this software
+without specific prior written permission.
+
+@end enumerate
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGE.
+
+@node Index
+@unnumbered Index
+
+@printindex cp
+
+@bye
+
diff --git a/contrib/binutils/libiberty/maint-tool b/contrib/binutils/libiberty/maint-tool
new file mode 100644
index 0000000..ceeb48d
--- /dev/null
+++ b/contrib/binutils/libiberty/maint-tool
@@ -0,0 +1,278 @@
+#!/usr/bin/perl
+# -*- perl -*-
+
+# Copyright (C) 2001
+# Free Software Foundation
+#
+# This file is part of the libiberty library.
+# Libiberty is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# Libiberty is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with libiberty; see the file COPYING.LIB. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+#
+# Originally written by DJ Delorie <dj@redhat.com>
+
+
+# This is a trivial script which checks the lists of C and O files in
+# the Makefile for consistency.
+
+$mode = shift;
+$srcdir = ".";
+
+if ($mode eq "-s") {
+ $srcdir = shift;
+ $mode = shift;
+}
+
+&missing() if $mode eq "missing";
+&undoc() if $mode eq "undoc";
+&deps() if $mode eq "deps";
+
+exit 0;
+
+format STDOUT =
+^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~
+$out
+ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~
+$out
+.
+
+######################################################################
+
+sub missing {
+
+ opendir(S, $srcdir);
+ while ($f = readdir S) {
+ $have{$f} = 1;
+ }
+ closedir(S);
+ opendir(S, ".");
+ while ($f = readdir S) {
+ $have{$f} = 1;
+ }
+ closedir(S);
+
+ for $a (@ARGV) {
+ $listed{$a} = 1;
+ $have{$a} = 0;
+ }
+
+ for $f (sort keys %have) {
+ next unless $have{$f};
+ if ($f =~ /\.c$/) {
+ print "S $f\n";
+ }
+ }
+ for $f (sort keys %listed) {
+ if ($f =~ /(.*)\.c$/) {
+ $base = $1;
+ if (! $listed{"$base.o"}) {
+ print "O $f\n";
+ }
+ }
+ }
+}
+
+######################################################################
+
+sub undoc {
+
+ opendir(S, $srcdir);
+ while ($file = readdir S) {
+ if ($file =~ /\.texi$/) {
+ open(T, "$srcdir/$file");
+ while (<T>) {
+ if (/^\@deftype[^\(]* ([^\s\(]+) *\(/) {
+ $documented{$1} = 1;
+ }
+ }
+ close(T);
+ }
+ if ($file =~ /\.c$/) {
+ open(C, "$srcdir/$file");
+ while (<C>) {
+ if (/\@undocumented (\S+)/) {
+ $documented{$1} = 1;
+ }
+ if (/^static /) {
+ if (! /[\(;]/) {
+ s/[\r\n]+$/ /;
+ $_ .= <C>;
+ }
+ while ($_ =~ /\([^\)]*$/) {
+ s/[\r\n]+$/ /;
+ $_ .= <C>;
+ }
+ }
+ s/ VPARAMS([ \(])/$1/;
+ s/PREFIX\(([^\)]*)\)/byte_$1/;
+ if (/^static [^\(]* ([^\s\(]+) *\(.*\)$/) {
+ $documented{$1} = 1;
+ }
+ }
+ }
+ }
+ closedir(D);
+
+ # $out = join(' ', sort keys %documented);
+ # write;
+ # print "\n";
+
+ system "etags $srcdir/*.c $srcdir/../include/*.h";
+ open(TAGS, "TAGS");
+ while (<TAGS>) {
+ s/[\r\n]+$//;
+ if (/^\014$/) {
+ $filename = <TAGS>;
+ $filename =~ s/[\r\n]+$//;
+ $filename =~ s/,\d+$//;
+ $filename =~ s@.*[/\\]@@;
+ next;
+ }
+ if ($filename =~ /\.c$/ ) {
+ next unless /^[_a-zA-Z]/;
+ } else {
+ next unless /^\# *define/;
+ s/\# *define *//;
+ }
+ next if $filename =~ /mpw\.c/;
+
+ s/ VPARAMS//;
+ s/ *\177.*//;
+ s/,$//;
+ s/DEFUN\(//;
+ s/\(//;
+
+ next if /^static /;
+ next if /\s/;
+ next if /^_/;
+ next if $documented{$_};
+ next if /_H_?$/;
+
+ if ($seen_in{$_} ne $filename) {
+ $saw{$_} ++;
+ }
+ $seen_in{$_} = $filename;
+ }
+
+ for $k (keys %saw) {
+ delete $saw{$k} if $saw{$k} > 1;
+ }
+
+ for $k (sort keys %saw) {
+ $fromfile{$seen_in{$k}} .= " " if $fromfile{$seen_in{$k}};
+ $fromfile{$seen_in{$k}} .= $k;
+ }
+
+ for $f (sort keys %fromfile) {
+ $out = "$f: $fromfile{$f}";
+ write;
+ }
+}
+
+######################################################################
+
+sub deps_for {
+ my($f) = @_;
+ my(%d);
+ open(F, $f);
+ %d = ();
+ while (<F>) {
+ if (/^#\s*include\s+["<](.*)[">]/) {
+ $d{$1} = 1;
+ }
+ }
+ close(F);
+ return keys %d;
+}
+
+sub canonicalize {
+ my ($p) = @_;
+ 0 while $p =~ s@/\./@/@g;
+ 0 while $p =~ s@^\./@@g;
+ 0 while $p =~ s@/[^/]+/\.\./@/@g;
+ return $p;
+}
+
+sub locals_first {
+ my ($a,$b) = @_;
+ return -1 if $a eq "config.h";
+ return 1 if $b eq "config.h";
+ return $a cmp $b;
+}
+
+sub deps {
+
+ $incdir = shift @ARGV;
+
+ opendir(INC, $incdir);
+ while ($f = readdir INC) {
+ next unless $f =~ /\.h$/;
+ $mine{$f} = "\$(INCDIR)/$f";
+ $deps{$f} = join(' ', &deps_for("$incdir/$f"));
+ }
+ $mine{'config.h'} = "config.h";
+
+ open(IN, "$srcdir/Makefile.in");
+ open(OUT, ">$srcdir/Makefile.tmp");
+ while (<IN>) {
+ last if /remainder of this file/;
+ print OUT;
+ }
+ print OUT "# The dependencies in the remainder of this file are automatically\n";
+ print OUT "# generated by \"make maint-deps\". Manual edits will be lost.\n\n";
+
+ opendir(S, $srcdir);
+ for $f (sort readdir S) {
+ if ($f =~ /\.c$/) {
+
+ %scanned = ();
+ @pending = &deps_for("$srcdir/$f");
+ while (@pending) {
+ @tmp = @pending;
+ @pending = ();
+ for $p (@tmp) {
+ next unless $mine{$p};
+ if (!$scanned{$p}) {
+ push(@pending, split(' ', $deps{$p}));
+ $scanned{$p} = 1;
+ }
+ }
+ }
+ @deps = sort { &locals_first($a,$b) } keys %scanned;
+ $obj = $f;
+ $obj =~ s/\.c$/.o/;
+ $obj = "$obj:";
+ if ($#deps >= 0) {
+ print OUT $obj;
+ $len = length($obj);
+ for $dt (@deps) {
+ $d = $mine{$dt};
+ if ($len + length($d) > 70) {
+ printf OUT " \\\n\t$d";
+ $len = 8 + length($d);
+ } else {
+ print OUT " $d";
+ $len += length($d) + 1;
+ }
+ }
+ print OUT "\n";
+ }
+ }
+ }
+ closedir(S);
+ close(IN);
+ close(OUT);
+
+ rename("$srcdir/Makefile.tmp", "$srcdir/Makefile.in");
+}
diff --git a/contrib/binutils/libiberty/make-temp-file.c b/contrib/binutils/libiberty/make-temp-file.c
new file mode 100644
index 0000000..8833504
--- /dev/null
+++ b/contrib/binutils/libiberty/make-temp-file.c
@@ -0,0 +1,179 @@
+/* Utility to pick a temporary filename prefix.
+ Copyright (C) 1996, 1997, 1998, 2001 Free Software Foundation, Inc.
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+Libiberty is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB. If not,
+write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h> /* May get P_tmpdir. */
+#include <sys/types.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_SYS_FILE_H
+#include <sys/file.h> /* May get R_OK, etc. on some systems. */
+#endif
+
+#ifndef R_OK
+#define R_OK 4
+#define W_OK 2
+#define X_OK 1
+#endif
+
+#include "libiberty.h"
+extern int mkstemps PARAMS ((char *, int));
+
+/* '/' works just fine on MS-DOS based systems. */
+#ifndef DIR_SEPARATOR
+#define DIR_SEPARATOR '/'
+#endif
+
+/* Name of temporary file.
+ mktemp requires 6 trailing X's. */
+#define TEMP_FILE "ccXXXXXX"
+#define TEMP_FILE_LEN (sizeof(TEMP_FILE) - 1)
+
+/* Subroutine of choose_tmpdir.
+ If BASE is non-NULL, return it.
+ Otherwise it checks if DIR is a usable directory.
+ If success, DIR is returned.
+ Otherwise NULL is returned. */
+
+static inline const char *try PARAMS ((const char *, const char *));
+
+static inline const char *
+try (dir, base)
+ const char *dir, *base;
+{
+ if (base != 0)
+ return base;
+ if (dir != 0
+ && access (dir, R_OK | W_OK | X_OK) == 0)
+ return dir;
+ return 0;
+}
+
+static const char tmp[] = { DIR_SEPARATOR, 't', 'm', 'p', 0 };
+static const char usrtmp[] =
+{ DIR_SEPARATOR, 'u', 's', 'r', DIR_SEPARATOR, 't', 'm', 'p', 0 };
+static const char vartmp[] =
+{ DIR_SEPARATOR, 'v', 'a', 'r', DIR_SEPARATOR, 't', 'm', 'p', 0 };
+
+static char *memoized_tmpdir;
+
+/*
+
+@deftypefn Replacement char* choose_tmpdir ()
+
+Returns a pointer to a directory path suitable for creating temporary
+files in.
+
+@end deftypefn
+
+*/
+
+char *
+choose_tmpdir ()
+{
+ const char *base = 0;
+ char *tmpdir;
+ unsigned int len;
+
+ if (memoized_tmpdir)
+ return memoized_tmpdir;
+
+ base = try (getenv ("TMPDIR"), base);
+ base = try (getenv ("TMP"), base);
+ base = try (getenv ("TEMP"), base);
+
+#ifdef P_tmpdir
+ base = try (P_tmpdir, base);
+#endif
+
+ /* Try /var/tmp, /usr/tmp, then /tmp. */
+ base = try (vartmp, base);
+ base = try (usrtmp, base);
+ base = try (tmp, base);
+
+ /* If all else fails, use the current directory! */
+ if (base == 0)
+ base = ".";
+
+ /* Append DIR_SEPARATOR to the directory we've chosen
+ and return it. */
+ len = strlen (base);
+ tmpdir = xmalloc (len + 2);
+ strcpy (tmpdir, base);
+ tmpdir[len] = DIR_SEPARATOR;
+ tmpdir[len+1] = '\0';
+
+ memoized_tmpdir = tmpdir;
+ return tmpdir;
+}
+
+/*
+
+@deftypefn Replacement char* make_temp_file (const char *@var{suffix})
+
+Return a temporary file name (as a string) or @code{NULL} if unable to
+create one. @var{suffix} is a suffix to append to the file name. The
+string is @code{malloc}ed, and the temporary file has been created.
+
+@end deftypefn
+
+*/
+
+char *
+make_temp_file (suffix)
+ const char *suffix;
+{
+ const char *base = choose_tmpdir ();
+ char *temp_filename;
+ int base_len, suffix_len;
+ int fd;
+
+ if (suffix == 0)
+ suffix = "";
+
+ base_len = strlen (base);
+ suffix_len = strlen (suffix);
+
+ temp_filename = xmalloc (base_len
+ + TEMP_FILE_LEN
+ + suffix_len + 1);
+ strcpy (temp_filename, base);
+ strcpy (temp_filename + base_len, TEMP_FILE);
+ strcpy (temp_filename + base_len + TEMP_FILE_LEN, suffix);
+
+ fd = mkstemps (temp_filename, suffix_len);
+ /* If mkstemps failed, then something bad is happening. Maybe we should
+ issue a message about a possible security attack in progress? */
+ if (fd == -1)
+ abort ();
+ /* Similarly if we can not close the file. */
+ if (close (fd))
+ abort ();
+ return temp_filename;
+}
diff --git a/contrib/binutils/libiberty/md5.c b/contrib/binutils/libiberty/md5.c
index 20c3cd1..9450586 100644
--- a/contrib/binutils/libiberty/md5.c
+++ b/contrib/binutils/libiberty/md5.c
@@ -65,10 +65,10 @@ void
md5_init_ctx (ctx)
struct md5_ctx *ctx;
{
- ctx->A = 0x67452301;
- ctx->B = 0xefcdab89;
- ctx->C = 0x98badcfe;
- ctx->D = 0x10325476;
+ ctx->A = (md5_uint32) 0x67452301;
+ ctx->B = (md5_uint32) 0xefcdab89;
+ ctx->C = (md5_uint32) 0x98badcfe;
+ ctx->D = (md5_uint32) 0x10325476;
ctx->total[0] = ctx->total[1] = 0;
ctx->buflen = 0;
@@ -322,22 +322,22 @@ md5_process_block (buffer, len, ctx)
*/
/* Round 1. */
- OP (A, B, C, D, 7, 0xd76aa478);
- OP (D, A, B, C, 12, 0xe8c7b756);
- OP (C, D, A, B, 17, 0x242070db);
- OP (B, C, D, A, 22, 0xc1bdceee);
- OP (A, B, C, D, 7, 0xf57c0faf);
- OP (D, A, B, C, 12, 0x4787c62a);
- OP (C, D, A, B, 17, 0xa8304613);
- OP (B, C, D, A, 22, 0xfd469501);
- OP (A, B, C, D, 7, 0x698098d8);
- OP (D, A, B, C, 12, 0x8b44f7af);
- OP (C, D, A, B, 17, 0xffff5bb1);
- OP (B, C, D, A, 22, 0x895cd7be);
- OP (A, B, C, D, 7, 0x6b901122);
- OP (D, A, B, C, 12, 0xfd987193);
- OP (C, D, A, B, 17, 0xa679438e);
- OP (B, C, D, A, 22, 0x49b40821);
+ OP (A, B, C, D, 7, (md5_uint32) 0xd76aa478);
+ OP (D, A, B, C, 12, (md5_uint32) 0xe8c7b756);
+ OP (C, D, A, B, 17, (md5_uint32) 0x242070db);
+ OP (B, C, D, A, 22, (md5_uint32) 0xc1bdceee);
+ OP (A, B, C, D, 7, (md5_uint32) 0xf57c0faf);
+ OP (D, A, B, C, 12, (md5_uint32) 0x4787c62a);
+ OP (C, D, A, B, 17, (md5_uint32) 0xa8304613);
+ OP (B, C, D, A, 22, (md5_uint32) 0xfd469501);
+ OP (A, B, C, D, 7, (md5_uint32) 0x698098d8);
+ OP (D, A, B, C, 12, (md5_uint32) 0x8b44f7af);
+ OP (C, D, A, B, 17, (md5_uint32) 0xffff5bb1);
+ OP (B, C, D, A, 22, (md5_uint32) 0x895cd7be);
+ OP (A, B, C, D, 7, (md5_uint32) 0x6b901122);
+ OP (D, A, B, C, 12, (md5_uint32) 0xfd987193);
+ OP (C, D, A, B, 17, (md5_uint32) 0xa679438e);
+ OP (B, C, D, A, 22, (md5_uint32) 0x49b40821);
/* For the second to fourth round we have the possibly swapped words
in CORRECT_WORDS. Redefine the macro to take an additional first
@@ -353,58 +353,58 @@ md5_process_block (buffer, len, ctx)
while (0)
/* Round 2. */
- OP (FG, A, B, C, D, 1, 5, 0xf61e2562);
- OP (FG, D, A, B, C, 6, 9, 0xc040b340);
- OP (FG, C, D, A, B, 11, 14, 0x265e5a51);
- OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa);
- OP (FG, A, B, C, D, 5, 5, 0xd62f105d);
- OP (FG, D, A, B, C, 10, 9, 0x02441453);
- OP (FG, C, D, A, B, 15, 14, 0xd8a1e681);
- OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8);
- OP (FG, A, B, C, D, 9, 5, 0x21e1cde6);
- OP (FG, D, A, B, C, 14, 9, 0xc33707d6);
- OP (FG, C, D, A, B, 3, 14, 0xf4d50d87);
- OP (FG, B, C, D, A, 8, 20, 0x455a14ed);
- OP (FG, A, B, C, D, 13, 5, 0xa9e3e905);
- OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8);
- OP (FG, C, D, A, B, 7, 14, 0x676f02d9);
- OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a);
+ OP (FG, A, B, C, D, 1, 5, (md5_uint32) 0xf61e2562);
+ OP (FG, D, A, B, C, 6, 9, (md5_uint32) 0xc040b340);
+ OP (FG, C, D, A, B, 11, 14, (md5_uint32) 0x265e5a51);
+ OP (FG, B, C, D, A, 0, 20, (md5_uint32) 0xe9b6c7aa);
+ OP (FG, A, B, C, D, 5, 5, (md5_uint32) 0xd62f105d);
+ OP (FG, D, A, B, C, 10, 9, (md5_uint32) 0x02441453);
+ OP (FG, C, D, A, B, 15, 14, (md5_uint32) 0xd8a1e681);
+ OP (FG, B, C, D, A, 4, 20, (md5_uint32) 0xe7d3fbc8);
+ OP (FG, A, B, C, D, 9, 5, (md5_uint32) 0x21e1cde6);
+ OP (FG, D, A, B, C, 14, 9, (md5_uint32) 0xc33707d6);
+ OP (FG, C, D, A, B, 3, 14, (md5_uint32) 0xf4d50d87);
+ OP (FG, B, C, D, A, 8, 20, (md5_uint32) 0x455a14ed);
+ OP (FG, A, B, C, D, 13, 5, (md5_uint32) 0xa9e3e905);
+ OP (FG, D, A, B, C, 2, 9, (md5_uint32) 0xfcefa3f8);
+ OP (FG, C, D, A, B, 7, 14, (md5_uint32) 0x676f02d9);
+ OP (FG, B, C, D, A, 12, 20, (md5_uint32) 0x8d2a4c8a);
/* Round 3. */
- OP (FH, A, B, C, D, 5, 4, 0xfffa3942);
- OP (FH, D, A, B, C, 8, 11, 0x8771f681);
- OP (FH, C, D, A, B, 11, 16, 0x6d9d6122);
- OP (FH, B, C, D, A, 14, 23, 0xfde5380c);
- OP (FH, A, B, C, D, 1, 4, 0xa4beea44);
- OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9);
- OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60);
- OP (FH, B, C, D, A, 10, 23, 0xbebfbc70);
- OP (FH, A, B, C, D, 13, 4, 0x289b7ec6);
- OP (FH, D, A, B, C, 0, 11, 0xeaa127fa);
- OP (FH, C, D, A, B, 3, 16, 0xd4ef3085);
- OP (FH, B, C, D, A, 6, 23, 0x04881d05);
- OP (FH, A, B, C, D, 9, 4, 0xd9d4d039);
- OP (FH, D, A, B, C, 12, 11, 0xe6db99e5);
- OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8);
- OP (FH, B, C, D, A, 2, 23, 0xc4ac5665);
+ OP (FH, A, B, C, D, 5, 4, (md5_uint32) 0xfffa3942);
+ OP (FH, D, A, B, C, 8, 11, (md5_uint32) 0x8771f681);
+ OP (FH, C, D, A, B, 11, 16, (md5_uint32) 0x6d9d6122);
+ OP (FH, B, C, D, A, 14, 23, (md5_uint32) 0xfde5380c);
+ OP (FH, A, B, C, D, 1, 4, (md5_uint32) 0xa4beea44);
+ OP (FH, D, A, B, C, 4, 11, (md5_uint32) 0x4bdecfa9);
+ OP (FH, C, D, A, B, 7, 16, (md5_uint32) 0xf6bb4b60);
+ OP (FH, B, C, D, A, 10, 23, (md5_uint32) 0xbebfbc70);
+ OP (FH, A, B, C, D, 13, 4, (md5_uint32) 0x289b7ec6);
+ OP (FH, D, A, B, C, 0, 11, (md5_uint32) 0xeaa127fa);
+ OP (FH, C, D, A, B, 3, 16, (md5_uint32) 0xd4ef3085);
+ OP (FH, B, C, D, A, 6, 23, (md5_uint32) 0x04881d05);
+ OP (FH, A, B, C, D, 9, 4, (md5_uint32) 0xd9d4d039);
+ OP (FH, D, A, B, C, 12, 11, (md5_uint32) 0xe6db99e5);
+ OP (FH, C, D, A, B, 15, 16, (md5_uint32) 0x1fa27cf8);
+ OP (FH, B, C, D, A, 2, 23, (md5_uint32) 0xc4ac5665);
/* Round 4. */
- OP (FI, A, B, C, D, 0, 6, 0xf4292244);
- OP (FI, D, A, B, C, 7, 10, 0x432aff97);
- OP (FI, C, D, A, B, 14, 15, 0xab9423a7);
- OP (FI, B, C, D, A, 5, 21, 0xfc93a039);
- OP (FI, A, B, C, D, 12, 6, 0x655b59c3);
- OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92);
- OP (FI, C, D, A, B, 10, 15, 0xffeff47d);
- OP (FI, B, C, D, A, 1, 21, 0x85845dd1);
- OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f);
- OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0);
- OP (FI, C, D, A, B, 6, 15, 0xa3014314);
- OP (FI, B, C, D, A, 13, 21, 0x4e0811a1);
- OP (FI, A, B, C, D, 4, 6, 0xf7537e82);
- OP (FI, D, A, B, C, 11, 10, 0xbd3af235);
- OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb);
- OP (FI, B, C, D, A, 9, 21, 0xeb86d391);
+ OP (FI, A, B, C, D, 0, 6, (md5_uint32) 0xf4292244);
+ OP (FI, D, A, B, C, 7, 10, (md5_uint32) 0x432aff97);
+ OP (FI, C, D, A, B, 14, 15, (md5_uint32) 0xab9423a7);
+ OP (FI, B, C, D, A, 5, 21, (md5_uint32) 0xfc93a039);
+ OP (FI, A, B, C, D, 12, 6, (md5_uint32) 0x655b59c3);
+ OP (FI, D, A, B, C, 3, 10, (md5_uint32) 0x8f0ccc92);
+ OP (FI, C, D, A, B, 10, 15, (md5_uint32) 0xffeff47d);
+ OP (FI, B, C, D, A, 1, 21, (md5_uint32) 0x85845dd1);
+ OP (FI, A, B, C, D, 8, 6, (md5_uint32) 0x6fa87e4f);
+ OP (FI, D, A, B, C, 15, 10, (md5_uint32) 0xfe2ce6e0);
+ OP (FI, C, D, A, B, 6, 15, (md5_uint32) 0xa3014314);
+ OP (FI, B, C, D, A, 13, 21, (md5_uint32) 0x4e0811a1);
+ OP (FI, A, B, C, D, 4, 6, (md5_uint32) 0xf7537e82);
+ OP (FI, D, A, B, C, 11, 10, (md5_uint32) 0xbd3af235);
+ OP (FI, C, D, A, B, 2, 15, (md5_uint32) 0x2ad7d2bb);
+ OP (FI, B, C, D, A, 9, 21, (md5_uint32) 0xeb86d391);
/* Add the starting values of the context. */
A += A_save;
diff --git a/contrib/binutils/libiberty/memchr.c b/contrib/binutils/libiberty/memchr.c
index cce3003..f94bea0 100644
--- a/contrib/binutils/libiberty/memchr.c
+++ b/contrib/binutils/libiberty/memchr.c
@@ -1,37 +1,16 @@
/*
-FUNCTION
- <<memchr>>---find character in memory
-INDEX
- memchr
+@deftypefn Supplemental void* memchr (const void *@var{s}, int @var{c}, size_t @var{n})
-ANSI_SYNOPSIS
- #include <string.h>
- void *memchr(const void *<[src]>, int <[c]>, size_t <[length]>);
+This function searches memory starting at @code{*@var{s}} for the
+character @var{c}. The search only ends with the first occurrence of
+@var{c}, or after @var{length} characters; in particular, a null
+character does not terminate the search. If the character @var{c} is
+found within @var{length} characters of @code{*@var{s}}, a pointer
+to the character is returned. If @var{c} is not found, then @code{NULL} is
+returned.
-TRAD_SYNOPSIS
- #include <string.h>
- void *memchr(<[src]>, <[c]>, <[length]>)
- void *<[src]>;
- void *<[c]>;
- size_t <[length]>;
-
-DESCRIPTION
- This function searches memory starting at <<*<[src]>>> for the
- character <[c]>. The search only ends with the first
- occurrence of <[c]>, or after <[length]> characters; in
- particular, <<NULL>> does not terminate the search.
-
-RETURNS
- If the character <[c]> is found within <[length]> characters
- of <<*<[src]>>>, a pointer to the character is returned. If
- <[c]> is not found, then <<NULL>> is returned.
-
-PORTABILITY
-<<memchr>> requires no supporting OS subroutines.
-
-QUICKREF
- memchr ansi pure
+@end deftypefn
*/
@@ -50,7 +29,7 @@ memchr (src_void, c, length)
{
const unsigned char *src = (const unsigned char *)src_void;
- while (--length >= 0)
+ while (length-- > 0)
{
if (*src == c)
return (PTR)src;
diff --git a/contrib/binutils/libiberty/memcmp.c b/contrib/binutils/libiberty/memcmp.c
index 0fd21ca..d8d3997 100644
--- a/contrib/binutils/libiberty/memcmp.c
+++ b/contrib/binutils/libiberty/memcmp.c
@@ -2,16 +2,17 @@
This function is in the public domain. */
/*
-NAME
- memcmp -- compare two memory regions
-SYNOPSIS
- int memcmp (const void *from, const void *to, size_t count)
+@deftypefn Supplemental int memcmp (const void *@var{x}, const void *@var{y}, size_t @var{count})
+
+Compares the first @var{count} bytes of two areas of memory. Returns
+zero if they are the same, a value less than zero if @var{x} is
+lexically less than @var{y}, or a value greater than zero if @var{x}
+is lexically greater than @var{y}. Note that lexical order is determined
+as if comparing unsigned char arrays.
+
+@end deftypefn
-DESCRIPTION
- Compare two memory regions and return less than,
- equal to, or greater than zero, according to lexicographical
- ordering of the compared regions.
*/
#include <ansidecl.h>
diff --git a/contrib/binutils/libiberty/memcpy.c b/contrib/binutils/libiberty/memcpy.c
index 707a9f5..0f2bac7 100644
--- a/contrib/binutils/libiberty/memcpy.c
+++ b/contrib/binutils/libiberty/memcpy.c
@@ -2,15 +2,14 @@
This function is in the public domain. */
/*
-NAME
- memcpy -- copy memory regions of arbitary length
-SYNOPSIS
- void* memcpy (void *out, const void *in, size_t n);
+@deftypefn Supplemental void* memcpy (void *@var{out}, const void *@var{in}, size_t @var{length})
+
+Copies @var{length} bytes from memory region @var{in} to region
+@var{out}. Returns a pointer to @var{out}.
+
+@end deftypefn
-DESCRIPTION
- Copy LENGTH bytes from memory region pointed to by IN to memory
- region pointed to by OUT.
*/
#include <ansidecl.h>
diff --git a/contrib/binutils/libiberty/memmove.c b/contrib/binutils/libiberty/memmove.c
index 176c326..3ec7320 100644
--- a/contrib/binutils/libiberty/memmove.c
+++ b/contrib/binutils/libiberty/memmove.c
@@ -1,5 +1,17 @@
/* Wrapper to implement ANSI C's memmove using BSD's bcopy. */
/* This function is in the public domain. --Per Bothner. */
+
+/*
+
+@deftypefn Supplemental void* memmove (void *@var{from}, const void *@var{to}, size_t @var{count})
+
+Copies @var{count} bytes from memory area @var{from} to memory area
+@var{to}, returning a pointer to @var{to}.
+
+@end deftypefn
+
+*/
+
#include <ansidecl.h>
#ifdef __STDC__
#include <stddef.h>
diff --git a/contrib/binutils/libiberty/memset.c b/contrib/binutils/libiberty/memset.c
index 5f54831..489ca17 100644
--- a/contrib/binutils/libiberty/memset.c
+++ b/contrib/binutils/libiberty/memset.c
@@ -1,6 +1,17 @@
/* memset
This implementation is in the public domain. */
+/*
+
+@deftypefn Supplemental void* memset (void *@var{s}, int @var{c}, size_t @var{count})
+
+Sets the first @var{count} bytes of @var{s} to the constant byte
+@var{c}, returning a pointer to @var{s}.
+
+@end deftypefn
+
+*/
+
#include <ansidecl.h>
#ifdef __STDC__
#include <stddef.h>
diff --git a/contrib/binutils/libiberty/mkstemps.c b/contrib/binutils/libiberty/mkstemps.c
index 4b89162..1f6600a 100644
--- a/contrib/binutils/libiberty/mkstemps.c
+++ b/contrib/binutils/libiberty/mkstemps.c
@@ -49,18 +49,27 @@ typedef unsigned long gcc_uint64_t;
#define TMP_MAX 16384
#endif
-/* Generate a unique temporary file name from TEMPLATE.
+/*
- TEMPLATE has the form:
+@deftypefn Replacement int mkstemps (char *@var{template}, int @var{suffix_len})
- <path>/ccXXXXXX<suffix>
+Generate a unique temporary file name from @var{template}.
+@var{template} has the form:
- SUFFIX_LEN tells us how long <suffix> is (it can be zero length).
+@example
+ @var{path}/ccXXXXXX@var{suffix}
+@end example
- The last six characters of TEMPLATE before <suffix> must be "XXXXXX";
- they are replaced with a string that makes the filename unique.
+@var{suffix_len} tells us how long @var{suffix} is (it can be zero
+length). The last six characters of @var{template} before @var{suffix}
+must be @samp{XXXXXX}; they are replaced with a string that makes the
+filename unique. Returns a file descriptor open on the file for
+reading and writing.
+
+@end deftypefn
+
+*/
- Returns a file descriptor open on the file for reading and writing. */
int
mkstemps (template, suffix_len)
char *template;
@@ -112,7 +121,11 @@ mkstemps (template, suffix_len)
v /= 62;
XXXXXX[5] = letters[v % 62];
+#ifdef VMS
+ fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600, "fop=tmd");
+#else
fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600);
+#endif
if (fd >= 0)
/* The file does not exist. */
return fd;
diff --git a/contrib/binutils/libiberty/obstack.c b/contrib/binutils/libiberty/obstack.c
index 0d4a4c8..02560c9 100644
--- a/contrib/binutils/libiberty/obstack.c
+++ b/contrib/binutils/libiberty/obstack.c
@@ -451,7 +451,7 @@ _obstack_memory_used (h)
/* Define the error handler. */
#ifndef _
-# ifdef HAVE_LIBINTL_H
+# if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
# include <libintl.h>
# ifndef _
# define _(Str) gettext (Str)
diff --git a/contrib/binutils/libiberty/obstacks.texi b/contrib/binutils/libiberty/obstacks.texi
new file mode 100644
index 0000000..9bddf7c
--- /dev/null
+++ b/contrib/binutils/libiberty/obstacks.texi
@@ -0,0 +1,758 @@
+@node Obstacks,Licenses,Functions,Top
+@chapter Obstacks
+@cindex obstacks
+
+An @dfn{obstack} is a pool of memory containing a stack of objects. You
+can create any number of separate obstacks, and then allocate objects in
+specified obstacks. Within each obstack, the last object allocated must
+always be the first one freed, but distinct obstacks are independent of
+each other.
+
+Aside from this one constraint of order of freeing, obstacks are totally
+general: an obstack can contain any number of objects of any size. They
+are implemented with macros, so allocation is usually very fast as long as
+the objects are usually small. And the only space overhead per object is
+the padding needed to start each object on a suitable boundary.
+
+@menu
+* Creating Obstacks:: How to declare an obstack in your program.
+* Preparing for Obstacks:: Preparations needed before you can
+ use obstacks.
+* Allocation in an Obstack:: Allocating objects in an obstack.
+* Freeing Obstack Objects:: Freeing objects in an obstack.
+* Obstack Functions:: The obstack functions are both
+ functions and macros.
+* Growing Objects:: Making an object bigger by stages.
+* Extra Fast Growing:: Extra-high-efficiency (though more
+ complicated) growing objects.
+* Status of an Obstack:: Inquiries about the status of an obstack.
+* Obstacks Data Alignment:: Controlling alignment of objects in obstacks.
+* Obstack Chunks:: How obstacks obtain and release chunks;
+ efficiency considerations.
+* Summary of Obstacks::
+@end menu
+
+@node Creating Obstacks
+@section Creating Obstacks
+
+The utilities for manipulating obstacks are declared in the header
+file @file{obstack.h}.
+@pindex obstack.h
+
+@comment obstack.h
+@comment GNU
+@deftp {Data Type} {struct obstack}
+An obstack is represented by a data structure of type @code{struct
+obstack}. This structure has a small fixed size; it records the status
+of the obstack and how to find the space in which objects are allocated.
+It does not contain any of the objects themselves. You should not try
+to access the contents of the structure directly; use only the functions
+described in this chapter.
+@end deftp
+
+You can declare variables of type @code{struct obstack} and use them as
+obstacks, or you can allocate obstacks dynamically like any other kind
+of object. Dynamic allocation of obstacks allows your program to have a
+variable number of different stacks. (You can even allocate an
+obstack structure in another obstack, but this is rarely useful.)
+
+All the functions that work with obstacks require you to specify which
+obstack to use. You do this with a pointer of type @code{struct obstack
+*}. In the following, we often say ``an obstack'' when strictly
+speaking the object at hand is such a pointer.
+
+The objects in the obstack are packed into large blocks called
+@dfn{chunks}. The @code{struct obstack} structure points to a chain of
+the chunks currently in use.
+
+The obstack library obtains a new chunk whenever you allocate an object
+that won't fit in the previous chunk. Since the obstack library manages
+chunks automatically, you don't need to pay much attention to them, but
+you do need to supply a function which the obstack library should use to
+get a chunk. Usually you supply a function which uses @code{malloc}
+directly or indirectly. You must also supply a function to free a chunk.
+These matters are described in the following section.
+
+@node Preparing for Obstacks
+@section Preparing for Using Obstacks
+
+Each source file in which you plan to use the obstack functions
+must include the header file @file{obstack.h}, like this:
+
+@smallexample
+#include <obstack.h>
+@end smallexample
+
+@findex obstack_chunk_alloc
+@findex obstack_chunk_free
+Also, if the source file uses the macro @code{obstack_init}, it must
+declare or define two functions or macros that will be called by the
+obstack library. One, @code{obstack_chunk_alloc}, is used to allocate
+the chunks of memory into which objects are packed. The other,
+@code{obstack_chunk_free}, is used to return chunks when the objects in
+them are freed. These macros should appear before any use of obstacks
+in the source file.
+
+Usually these are defined to use @code{malloc} via the intermediary
+@code{xmalloc} (@pxref{Unconstrained Allocation, , , libc, The GNU C Library Reference Manual}). This is done with
+the following pair of macro definitions:
+
+@smallexample
+#define obstack_chunk_alloc xmalloc
+#define obstack_chunk_free free
+@end smallexample
+
+@noindent
+Though the memory you get using obstacks really comes from @code{malloc},
+using obstacks is faster because @code{malloc} is called less often, for
+larger blocks of memory. @xref{Obstack Chunks}, for full details.
+
+At run time, before the program can use a @code{struct obstack} object
+as an obstack, it must initialize the obstack by calling
+@code{obstack_init}.
+
+@comment obstack.h
+@comment GNU
+@deftypefun int obstack_init (struct obstack *@var{obstack-ptr})
+Initialize obstack @var{obstack-ptr} for allocation of objects. This
+function calls the obstack's @code{obstack_chunk_alloc} function. If
+allocation of memory fails, the function pointed to by
+@code{obstack_alloc_failed_handler} is called. The @code{obstack_init}
+function always returns 1 (Compatibility notice: Former versions of
+obstack returned 0 if allocation failed).
+@end deftypefun
+
+Here are two examples of how to allocate the space for an obstack and
+initialize it. First, an obstack that is a static variable:
+
+@smallexample
+static struct obstack myobstack;
+@dots{}
+obstack_init (&myobstack);
+@end smallexample
+
+@noindent
+Second, an obstack that is itself dynamically allocated:
+
+@smallexample
+struct obstack *myobstack_ptr
+ = (struct obstack *) xmalloc (sizeof (struct obstack));
+
+obstack_init (myobstack_ptr);
+@end smallexample
+
+@comment obstack.h
+@comment GNU
+@defvar obstack_alloc_failed_handler
+The value of this variable is a pointer to a function that
+@code{obstack} uses when @code{obstack_chunk_alloc} fails to allocate
+memory. The default action is to print a message and abort.
+You should supply a function that either calls @code{exit}
+(@pxref{Program Termination, , , libc, The GNU C Library Reference Manual}) or @code{longjmp} (@pxref{Non-Local
+Exits, , , libc, The GNU C Library Reference Manual}) and doesn't return.
+
+@smallexample
+void my_obstack_alloc_failed (void)
+@dots{}
+obstack_alloc_failed_handler = &my_obstack_alloc_failed;
+@end smallexample
+
+@end defvar
+
+@node Allocation in an Obstack
+@section Allocation in an Obstack
+@cindex allocation (obstacks)
+
+The most direct way to allocate an object in an obstack is with
+@code{obstack_alloc}, which is invoked almost like @code{malloc}.
+
+@comment obstack.h
+@comment GNU
+@deftypefun {void *} obstack_alloc (struct obstack *@var{obstack-ptr}, int @var{size})
+This allocates an uninitialized block of @var{size} bytes in an obstack
+and returns its address. Here @var{obstack-ptr} specifies which obstack
+to allocate the block in; it is the address of the @code{struct obstack}
+object which represents the obstack. Each obstack function or macro
+requires you to specify an @var{obstack-ptr} as the first argument.
+
+This function calls the obstack's @code{obstack_chunk_alloc} function if
+it needs to allocate a new chunk of memory; it calls
+@code{obstack_alloc_failed_handler} if allocation of memory by
+@code{obstack_chunk_alloc} failed.
+@end deftypefun
+
+For example, here is a function that allocates a copy of a string @var{str}
+in a specific obstack, which is in the variable @code{string_obstack}:
+
+@smallexample
+struct obstack string_obstack;
+
+char *
+copystring (char *string)
+@{
+ size_t len = strlen (string) + 1;
+ char *s = (char *) obstack_alloc (&string_obstack, len);
+ memcpy (s, string, len);
+ return s;
+@}
+@end smallexample
+
+To allocate a block with specified contents, use the function
+@code{obstack_copy}, declared like this:
+
+@comment obstack.h
+@comment GNU
+@deftypefun {void *} obstack_copy (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size})
+This allocates a block and initializes it by copying @var{size}
+bytes of data starting at @var{address}. It calls
+@code{obstack_alloc_failed_handler} if allocation of memory by
+@code{obstack_chunk_alloc} failed.
+@end deftypefun
+
+@comment obstack.h
+@comment GNU
+@deftypefun {void *} obstack_copy0 (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size})
+Like @code{obstack_copy}, but appends an extra byte containing a null
+character. This extra byte is not counted in the argument @var{size}.
+@end deftypefun
+
+The @code{obstack_copy0} function is convenient for copying a sequence
+of characters into an obstack as a null-terminated string. Here is an
+example of its use:
+
+@smallexample
+char *
+obstack_savestring (char *addr, int size)
+@{
+ return obstack_copy0 (&myobstack, addr, size);
+@}
+@end smallexample
+
+@noindent
+Contrast this with the previous example of @code{savestring} using
+@code{malloc} (@pxref{Basic Allocation, , , libc, The GNU C Library Reference Manual}).
+
+@node Freeing Obstack Objects
+@section Freeing Objects in an Obstack
+@cindex freeing (obstacks)
+
+To free an object allocated in an obstack, use the function
+@code{obstack_free}. Since the obstack is a stack of objects, freeing
+one object automatically frees all other objects allocated more recently
+in the same obstack.
+
+@comment obstack.h
+@comment GNU
+@deftypefun void obstack_free (struct obstack *@var{obstack-ptr}, void *@var{object})
+If @var{object} is a null pointer, everything allocated in the obstack
+is freed. Otherwise, @var{object} must be the address of an object
+allocated in the obstack. Then @var{object} is freed, along with
+everything allocated in @var{obstack} since @var{object}.
+@end deftypefun
+
+Note that if @var{object} is a null pointer, the result is an
+uninitialized obstack. To free all memory in an obstack but leave it
+valid for further allocation, call @code{obstack_free} with the address
+of the first object allocated on the obstack:
+
+@smallexample
+obstack_free (obstack_ptr, first_object_allocated_ptr);
+@end smallexample
+
+Recall that the objects in an obstack are grouped into chunks. When all
+the objects in a chunk become free, the obstack library automatically
+frees the chunk (@pxref{Preparing for Obstacks}). Then other
+obstacks, or non-obstack allocation, can reuse the space of the chunk.
+
+@node Obstack Functions
+@section Obstack Functions and Macros
+@cindex macros
+
+The interfaces for using obstacks may be defined either as functions or
+as macros, depending on the compiler. The obstack facility works with
+all C compilers, including both @w{ISO C} and traditional C, but there are
+precautions you must take if you plan to use compilers other than GNU C.
+
+If you are using an old-fashioned @w{non-ISO C} compiler, all the obstack
+``functions'' are actually defined only as macros. You can call these
+macros like functions, but you cannot use them in any other way (for
+example, you cannot take their address).
+
+Calling the macros requires a special precaution: namely, the first
+operand (the obstack pointer) may not contain any side effects, because
+it may be computed more than once. For example, if you write this:
+
+@smallexample
+obstack_alloc (get_obstack (), 4);
+@end smallexample
+
+@noindent
+you will find that @code{get_obstack} may be called several times.
+If you use @code{*obstack_list_ptr++} as the obstack pointer argument,
+you will get very strange results since the incrementation may occur
+several times.
+
+In @w{ISO C}, each function has both a macro definition and a function
+definition. The function definition is used if you take the address of the
+function without calling it. An ordinary call uses the macro definition by
+default, but you can request the function definition instead by writing the
+function name in parentheses, as shown here:
+
+@smallexample
+char *x;
+void *(*funcp) ();
+/* @r{Use the macro}. */
+x = (char *) obstack_alloc (obptr, size);
+/* @r{Call the function}. */
+x = (char *) (obstack_alloc) (obptr, size);
+/* @r{Take the address of the function}. */
+funcp = obstack_alloc;
+@end smallexample
+
+@noindent
+This is the same situation that exists in @w{ISO C} for the standard library
+functions. @xref{Macro Definitions, , , libc, The GNU C Library Reference Manual}.
+
+@strong{Warning:} When you do use the macros, you must observe the
+precaution of avoiding side effects in the first operand, even in @w{ISO C}.
+
+If you use the GNU C compiler, this precaution is not necessary, because
+various language extensions in GNU C permit defining the macros so as to
+compute each argument only once.
+
+@node Growing Objects
+@section Growing Objects
+@cindex growing objects (in obstacks)
+@cindex changing the size of a block (obstacks)
+
+Because memory in obstack chunks is used sequentially, it is possible to
+build up an object step by step, adding one or more bytes at a time to the
+end of the object. With this technique, you do not need to know how much
+data you will put in the object until you come to the end of it. We call
+this the technique of @dfn{growing objects}. The special functions
+for adding data to the growing object are described in this section.
+
+You don't need to do anything special when you start to grow an object.
+Using one of the functions to add data to the object automatically
+starts it. However, it is necessary to say explicitly when the object is
+finished. This is done with the function @code{obstack_finish}.
+
+The actual address of the object thus built up is not known until the
+object is finished. Until then, it always remains possible that you will
+add so much data that the object must be copied into a new chunk.
+
+While the obstack is in use for a growing object, you cannot use it for
+ordinary allocation of another object. If you try to do so, the space
+already added to the growing object will become part of the other object.
+
+@comment obstack.h
+@comment GNU
+@deftypefun void obstack_blank (struct obstack *@var{obstack-ptr}, int @var{size})
+The most basic function for adding to a growing object is
+@code{obstack_blank}, which adds space without initializing it.
+@end deftypefun
+
+@comment obstack.h
+@comment GNU
+@deftypefun void obstack_grow (struct obstack *@var{obstack-ptr}, void *@var{data}, int @var{size})
+To add a block of initialized space, use @code{obstack_grow}, which is
+the growing-object analogue of @code{obstack_copy}. It adds @var{size}
+bytes of data to the growing object, copying the contents from
+@var{data}.
+@end deftypefun
+
+@comment obstack.h
+@comment GNU
+@deftypefun void obstack_grow0 (struct obstack *@var{obstack-ptr}, void *@var{data}, int @var{size})
+This is the growing-object analogue of @code{obstack_copy0}. It adds
+@var{size} bytes copied from @var{data}, followed by an additional null
+character.
+@end deftypefun
+
+@comment obstack.h
+@comment GNU
+@deftypefun void obstack_1grow (struct obstack *@var{obstack-ptr}, char @var{c})
+To add one character at a time, use the function @code{obstack_1grow}.
+It adds a single byte containing @var{c} to the growing object.
+@end deftypefun
+
+@comment obstack.h
+@comment GNU
+@deftypefun void obstack_ptr_grow (struct obstack *@var{obstack-ptr}, void *@var{data})
+Adding the value of a pointer one can use the function
+@code{obstack_ptr_grow}. It adds @code{sizeof (void *)} bytes
+containing the value of @var{data}.
+@end deftypefun
+
+@comment obstack.h
+@comment GNU
+@deftypefun void obstack_int_grow (struct obstack *@var{obstack-ptr}, int @var{data})
+A single value of type @code{int} can be added by using the
+@code{obstack_int_grow} function. It adds @code{sizeof (int)} bytes to
+the growing object and initializes them with the value of @var{data}.
+@end deftypefun
+
+@comment obstack.h
+@comment GNU
+@deftypefun {void *} obstack_finish (struct obstack *@var{obstack-ptr})
+When you are finished growing the object, use the function
+@code{obstack_finish} to close it off and return its final address.
+
+Once you have finished the object, the obstack is available for ordinary
+allocation or for growing another object.
+
+This function can return a null pointer under the same conditions as
+@code{obstack_alloc} (@pxref{Allocation in an Obstack}).
+@end deftypefun
+
+When you build an object by growing it, you will probably need to know
+afterward how long it became. You need not keep track of this as you grow
+the object, because you can find out the length from the obstack just
+before finishing the object with the function @code{obstack_object_size},
+declared as follows:
+
+@comment obstack.h
+@comment GNU
+@deftypefun int obstack_object_size (struct obstack *@var{obstack-ptr})
+This function returns the current size of the growing object, in bytes.
+Remember to call this function @emph{before} finishing the object.
+After it is finished, @code{obstack_object_size} will return zero.
+@end deftypefun
+
+If you have started growing an object and wish to cancel it, you should
+finish it and then free it, like this:
+
+@smallexample
+obstack_free (obstack_ptr, obstack_finish (obstack_ptr));
+@end smallexample
+
+@noindent
+This has no effect if no object was growing.
+
+@cindex shrinking objects
+You can use @code{obstack_blank} with a negative size argument to make
+the current object smaller. Just don't try to shrink it beyond zero
+length---there's no telling what will happen if you do that.
+
+@node Extra Fast Growing
+@section Extra Fast Growing Objects
+@cindex efficiency and obstacks
+
+The usual functions for growing objects incur overhead for checking
+whether there is room for the new growth in the current chunk. If you
+are frequently constructing objects in small steps of growth, this
+overhead can be significant.
+
+You can reduce the overhead by using special ``fast growth''
+functions that grow the object without checking. In order to have a
+robust program, you must do the checking yourself. If you do this checking
+in the simplest way each time you are about to add data to the object, you
+have not saved anything, because that is what the ordinary growth
+functions do. But if you can arrange to check less often, or check
+more efficiently, then you make the program faster.
+
+The function @code{obstack_room} returns the amount of room available
+in the current chunk. It is declared as follows:
+
+@comment obstack.h
+@comment GNU
+@deftypefun int obstack_room (struct obstack *@var{obstack-ptr})
+This returns the number of bytes that can be added safely to the current
+growing object (or to an object about to be started) in obstack
+@var{obstack} using the fast growth functions.
+@end deftypefun
+
+While you know there is room, you can use these fast growth functions
+for adding data to a growing object:
+
+@comment obstack.h
+@comment GNU
+@deftypefun void obstack_1grow_fast (struct obstack *@var{obstack-ptr}, char @var{c})
+The function @code{obstack_1grow_fast} adds one byte containing the
+character @var{c} to the growing object in obstack @var{obstack-ptr}.
+@end deftypefun
+
+@comment obstack.h
+@comment GNU
+@deftypefun void obstack_ptr_grow_fast (struct obstack *@var{obstack-ptr}, void *@var{data})
+The function @code{obstack_ptr_grow_fast} adds @code{sizeof (void *)}
+bytes containing the value of @var{data} to the growing object in
+obstack @var{obstack-ptr}.
+@end deftypefun
+
+@comment obstack.h
+@comment GNU
+@deftypefun void obstack_int_grow_fast (struct obstack *@var{obstack-ptr}, int @var{data})
+The function @code{obstack_int_grow_fast} adds @code{sizeof (int)} bytes
+containing the value of @var{data} to the growing object in obstack
+@var{obstack-ptr}.
+@end deftypefun
+
+@comment obstack.h
+@comment GNU
+@deftypefun void obstack_blank_fast (struct obstack *@var{obstack-ptr}, int @var{size})
+The function @code{obstack_blank_fast} adds @var{size} bytes to the
+growing object in obstack @var{obstack-ptr} without initializing them.
+@end deftypefun
+
+When you check for space using @code{obstack_room} and there is not
+enough room for what you want to add, the fast growth functions
+are not safe. In this case, simply use the corresponding ordinary
+growth function instead. Very soon this will copy the object to a
+new chunk; then there will be lots of room available again.
+
+So, each time you use an ordinary growth function, check afterward for
+sufficient space using @code{obstack_room}. Once the object is copied
+to a new chunk, there will be plenty of space again, so the program will
+start using the fast growth functions again.
+
+Here is an example:
+
+@smallexample
+@group
+void
+add_string (struct obstack *obstack, const char *ptr, int len)
+@{
+ while (len > 0)
+ @{
+ int room = obstack_room (obstack);
+ if (room == 0)
+ @{
+ /* @r{Not enough room. Add one character slowly,}
+ @r{which may copy to a new chunk and make room.} */
+ obstack_1grow (obstack, *ptr++);
+ len--;
+ @}
+ else
+ @{
+ if (room > len)
+ room = len;
+ /* @r{Add fast as much as we have room for.} */
+ len -= room;
+ while (room-- > 0)
+ obstack_1grow_fast (obstack, *ptr++);
+ @}
+ @}
+@}
+@end group
+@end smallexample
+
+@node Status of an Obstack
+@section Status of an Obstack
+@cindex obstack status
+@cindex status of obstack
+
+Here are functions that provide information on the current status of
+allocation in an obstack. You can use them to learn about an object while
+still growing it.
+
+@comment obstack.h
+@comment GNU
+@deftypefun {void *} obstack_base (struct obstack *@var{obstack-ptr})
+This function returns the tentative address of the beginning of the
+currently growing object in @var{obstack-ptr}. If you finish the object
+immediately, it will have that address. If you make it larger first, it
+may outgrow the current chunk---then its address will change!
+
+If no object is growing, this value says where the next object you
+allocate will start (once again assuming it fits in the current
+chunk).
+@end deftypefun
+
+@comment obstack.h
+@comment GNU
+@deftypefun {void *} obstack_next_free (struct obstack *@var{obstack-ptr})
+This function returns the address of the first free byte in the current
+chunk of obstack @var{obstack-ptr}. This is the end of the currently
+growing object. If no object is growing, @code{obstack_next_free}
+returns the same value as @code{obstack_base}.
+@end deftypefun
+
+@comment obstack.h
+@comment GNU
+@deftypefun int obstack_object_size (struct obstack *@var{obstack-ptr})
+This function returns the size in bytes of the currently growing object.
+This is equivalent to
+
+@smallexample
+obstack_next_free (@var{obstack-ptr}) - obstack_base (@var{obstack-ptr})
+@end smallexample
+@end deftypefun
+
+@node Obstacks Data Alignment
+@section Alignment of Data in Obstacks
+@cindex alignment (in obstacks)
+
+Each obstack has an @dfn{alignment boundary}; each object allocated in
+the obstack automatically starts on an address that is a multiple of the
+specified boundary. By default, this boundary is 4 bytes.
+
+To access an obstack's alignment boundary, use the macro
+@code{obstack_alignment_mask}, whose function prototype looks like
+this:
+
+@comment obstack.h
+@comment GNU
+@deftypefn Macro int obstack_alignment_mask (struct obstack *@var{obstack-ptr})
+The value is a bit mask; a bit that is 1 indicates that the corresponding
+bit in the address of an object should be 0. The mask value should be one
+less than a power of 2; the effect is that all object addresses are
+multiples of that power of 2. The default value of the mask is 3, so that
+addresses are multiples of 4. A mask value of 0 means an object can start
+on any multiple of 1 (that is, no alignment is required).
+
+The expansion of the macro @code{obstack_alignment_mask} is an lvalue,
+so you can alter the mask by assignment. For example, this statement:
+
+@smallexample
+obstack_alignment_mask (obstack_ptr) = 0;
+@end smallexample
+
+@noindent
+has the effect of turning off alignment processing in the specified obstack.
+@end deftypefn
+
+Note that a change in alignment mask does not take effect until
+@emph{after} the next time an object is allocated or finished in the
+obstack. If you are not growing an object, you can make the new
+alignment mask take effect immediately by calling @code{obstack_finish}.
+This will finish a zero-length object and then do proper alignment for
+the next object.
+
+@node Obstack Chunks
+@section Obstack Chunks
+@cindex efficiency of chunks
+@cindex chunks
+
+Obstacks work by allocating space for themselves in large chunks, and
+then parceling out space in the chunks to satisfy your requests. Chunks
+are normally 4096 bytes long unless you specify a different chunk size.
+The chunk size includes 8 bytes of overhead that are not actually used
+for storing objects. Regardless of the specified size, longer chunks
+will be allocated when necessary for long objects.
+
+The obstack library allocates chunks by calling the function
+@code{obstack_chunk_alloc}, which you must define. When a chunk is no
+longer needed because you have freed all the objects in it, the obstack
+library frees the chunk by calling @code{obstack_chunk_free}, which you
+must also define.
+
+These two must be defined (as macros) or declared (as functions) in each
+source file that uses @code{obstack_init} (@pxref{Creating Obstacks}).
+Most often they are defined as macros like this:
+
+@smallexample
+#define obstack_chunk_alloc malloc
+#define obstack_chunk_free free
+@end smallexample
+
+Note that these are simple macros (no arguments). Macro definitions with
+arguments will not work! It is necessary that @code{obstack_chunk_alloc}
+or @code{obstack_chunk_free}, alone, expand into a function name if it is
+not itself a function name.
+
+If you allocate chunks with @code{malloc}, the chunk size should be a
+power of 2. The default chunk size, 4096, was chosen because it is long
+enough to satisfy many typical requests on the obstack yet short enough
+not to waste too much memory in the portion of the last chunk not yet used.
+
+@comment obstack.h
+@comment GNU
+@deftypefn Macro int obstack_chunk_size (struct obstack *@var{obstack-ptr})
+This returns the chunk size of the given obstack.
+@end deftypefn
+
+Since this macro expands to an lvalue, you can specify a new chunk size by
+assigning it a new value. Doing so does not affect the chunks already
+allocated, but will change the size of chunks allocated for that particular
+obstack in the future. It is unlikely to be useful to make the chunk size
+smaller, but making it larger might improve efficiency if you are
+allocating many objects whose size is comparable to the chunk size. Here
+is how to do so cleanly:
+
+@smallexample
+if (obstack_chunk_size (obstack_ptr) < @var{new-chunk-size})
+ obstack_chunk_size (obstack_ptr) = @var{new-chunk-size};
+@end smallexample
+
+@node Summary of Obstacks
+@section Summary of Obstack Functions
+
+Here is a summary of all the functions associated with obstacks. Each
+takes the address of an obstack (@code{struct obstack *}) as its first
+argument.
+
+@table @code
+@item void obstack_init (struct obstack *@var{obstack-ptr})
+Initialize use of an obstack. @xref{Creating Obstacks}.
+
+@item void *obstack_alloc (struct obstack *@var{obstack-ptr}, int @var{size})
+Allocate an object of @var{size} uninitialized bytes.
+@xref{Allocation in an Obstack}.
+
+@item void *obstack_copy (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size})
+Allocate an object of @var{size} bytes, with contents copied from
+@var{address}. @xref{Allocation in an Obstack}.
+
+@item void *obstack_copy0 (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size})
+Allocate an object of @var{size}+1 bytes, with @var{size} of them copied
+from @var{address}, followed by a null character at the end.
+@xref{Allocation in an Obstack}.
+
+@item void obstack_free (struct obstack *@var{obstack-ptr}, void *@var{object})
+Free @var{object} (and everything allocated in the specified obstack
+more recently than @var{object}). @xref{Freeing Obstack Objects}.
+
+@item void obstack_blank (struct obstack *@var{obstack-ptr}, int @var{size})
+Add @var{size} uninitialized bytes to a growing object.
+@xref{Growing Objects}.
+
+@item void obstack_grow (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size})
+Add @var{size} bytes, copied from @var{address}, to a growing object.
+@xref{Growing Objects}.
+
+@item void obstack_grow0 (struct obstack *@var{obstack-ptr}, void *@var{address}, int @var{size})
+Add @var{size} bytes, copied from @var{address}, to a growing object,
+and then add another byte containing a null character. @xref{Growing
+Objects}.
+
+@item void obstack_1grow (struct obstack *@var{obstack-ptr}, char @var{data-char})
+Add one byte containing @var{data-char} to a growing object.
+@xref{Growing Objects}.
+
+@item void *obstack_finish (struct obstack *@var{obstack-ptr})
+Finalize the object that is growing and return its permanent address.
+@xref{Growing Objects}.
+
+@item int obstack_object_size (struct obstack *@var{obstack-ptr})
+Get the current size of the currently growing object. @xref{Growing
+Objects}.
+
+@item void obstack_blank_fast (struct obstack *@var{obstack-ptr}, int @var{size})
+Add @var{size} uninitialized bytes to a growing object without checking
+that there is enough room. @xref{Extra Fast Growing}.
+
+@item void obstack_1grow_fast (struct obstack *@var{obstack-ptr}, char @var{data-char})
+Add one byte containing @var{data-char} to a growing object without
+checking that there is enough room. @xref{Extra Fast Growing}.
+
+@item int obstack_room (struct obstack *@var{obstack-ptr})
+Get the amount of room now available for growing the current object.
+@xref{Extra Fast Growing}.
+
+@item int obstack_alignment_mask (struct obstack *@var{obstack-ptr})
+The mask used for aligning the beginning of an object. This is an
+lvalue. @xref{Obstacks Data Alignment}.
+
+@item int obstack_chunk_size (struct obstack *@var{obstack-ptr})
+The size for allocating chunks. This is an lvalue. @xref{Obstack Chunks}.
+
+@item void *obstack_base (struct obstack *@var{obstack-ptr})
+Tentative starting address of the currently growing object.
+@xref{Status of an Obstack}.
+
+@item void *obstack_next_free (struct obstack *@var{obstack-ptr})
+Address just after the end of the currently growing object.
+@xref{Status of an Obstack}.
+@end table
+
diff --git a/contrib/binutils/libiberty/partition.c b/contrib/binutils/libiberty/partition.c
index a5a7349..0715472 100644
--- a/contrib/binutils/libiberty/partition.c
+++ b/contrib/binutils/libiberty/partition.c
@@ -1,5 +1,5 @@
-/* List implentation of a partition of consecutive integers.
- Copyright (C) 2000 Free Software Foundation, Inc.
+/* List implementation of a partition of consecutive integers.
+ Copyright (C) 2000, 2001 Free Software Foundation, Inc.
Contributed by CodeSourcery, LLC.
This file is part of GNU CC.
diff --git a/contrib/binutils/libiberty/pexecute.c b/contrib/binutils/libiberty/pexecute.c
index 32943af..347c4db 100644
--- a/contrib/binutils/libiberty/pexecute.c
+++ b/contrib/binutils/libiberty/pexecute.c
@@ -64,53 +64,66 @@ static char *install_error_msg = "installation problem, cannot exec `%s'";
/* pexecute: execute a program.
- PROGRAM and ARGV are the arguments to execv/execvp.
+@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)
- THIS_PNAME is name of the calling program (i.e. argv[0]).
+Executes a program.
- TEMP_BASE is the path name, sans suffix, of a temporary file to use
- if needed. This is currently only needed for MSDOS ports that don't use
- GO32 (do any still exist?). Ports that don't need it can pass NULL.
+@var{program} and @var{argv} are the arguments to
+@code{execv}/@code{execvp}.
- (FLAGS & PEXECUTE_SEARCH) is non-zero if $PATH should be searched
- (??? It's not clear that GCC passes this flag correctly).
- (FLAGS & PEXECUTE_FIRST) is nonzero for the first process in chain.
- (FLAGS & PEXECUTE_FIRST) is nonzero for the last process in chain.
- FIRST_LAST could be simplified to only mark the last of a chain of processes
- but that requires the caller to always mark the last one (and not give up
- early if some error occurs). It's more robust to require the caller to
- mark both ends of the chain.
+@var{this_pname} is name of the calling program (i.e., @code{argv[0]}).
- The result is the pid on systems like Unix where we fork/exec and on systems
- like WIN32 and OS2 where we use spawn. It is up to the caller to wait for
- the child.
+@var{temp_base} is the path name, sans suffix, of a temporary file to
+use if needed. This is currently only needed for MS-DOS ports that
+don't use @code{go32} (do any still exist?). Ports that don't need it
+can pass @code{NULL}.
- The result is the WEXITSTATUS on systems like MSDOS where we spawn and wait
- for the child here.
+(@code{@var{flags} & PEXECUTE_SEARCH}) is non-zero if @env{PATH} should be searched
+(??? It's not clear that GCC passes this flag correctly). (@code{@var{flags} &
+PEXECUTE_FIRST}) is nonzero for the first process in chain.
+(@code{@var{flags} & PEXECUTE_FIRST}) is nonzero for the last process
+in chain. The first/last flags could be simplified to only mark the
+last of a chain of processes but that requires the caller to always
+mark the last one (and not give up early if some error occurs).
+It's more robust to require the caller to mark both ends of the chain.
- Upon failure, ERRMSG_FMT and ERRMSG_ARG are set to the text of the error
- message with an optional argument (if not needed, ERRMSG_ARG is set to
- NULL), and -1 is returned. `errno' is available to the caller to use.
+The result is the pid on systems like Unix where we
+@code{fork}/@code{exec} and on systems like WIN32 and OS/2 where we
+use @code{spawn}. It is up to the caller to wait for the child.
- pwait: cover function for wait.
+The result is the @code{WEXITSTATUS} on systems like MS-DOS where we
+@code{spawn} and wait for the child here.
- PID is the process id of the task to wait for.
- STATUS is the `status' argument to wait.
- FLAGS is currently unused (allows future enhancement without breaking
- upward compatibility). Pass 0 for now.
+Upon failure, @var{errmsg_fmt} and @var{errmsg_arg} are set to the
+text of the error message with an optional argument (if not needed,
+@var{errmsg_arg} is set to @code{NULL}), and @minus{}1 is returned.
+@code{errno} is available to the caller to use.
- The result is the pid of the child reaped,
- or -1 for failure (errno says why).
+@end deftypefn
- On systems that don't support waiting for a particular child, PID is
- ignored. On systems like MSDOS that don't really multitask pwait
- is just a mechanism to provide a consistent interface for the caller.
+@deftypefn Extension int pwait (int @var{pid}, int *@var{status}, int @var{flags})
+
+Waits for a program started by @code{pexecute} to finish.
+
+@var{pid} is the process id of the task to wait for. @var{status} is
+the `status' argument to wait. @var{flags} is currently unused (allows
+future enhancement without breaking upward compatibility). Pass 0 for now.
+
+The result is the pid of the child reaped, or -1 for failure
+(@code{errno} says why).
+
+On systems that don't support waiting for a particular child, @var{pid} is
+ignored. On systems like MS-DOS that don't really multitask @code{pwait}
+is just a mechanism to provide a consistent interface for the caller.
+
+@end deftypefn
+
+@undocumented pfinish
pfinish: finish generation of script
pfinish is necessary for systems like MPW where a script is generated that
- runs the requested programs.
-*/
+ runs the requested programs. */
#ifdef __MSDOS__
@@ -254,7 +267,7 @@ extern int _spawnvp ();
/* This is a kludge to get around the Microsoft C spawn functions' propensity
to remove the outermost set of double quotes from all arguments. */
-const char * const *
+static const char * const *
fix_argv (argvec)
char **argvec;
{
diff --git a/contrib/binutils/libiberty/putenv.c b/contrib/binutils/libiberty/putenv.c
index 9d56922..6d027dc 100644
--- a/contrib/binutils/libiberty/putenv.c
+++ b/contrib/binutils/libiberty/putenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1994, 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1994, 1995, 1996, 2002 Free Software Foundation, Inc.
This file based on putenv.c in the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,6 +16,19 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+/*
+
+@deftypefn Supplemental int putenv (const char *@var{string})
+
+Uses @code{setenv} or @code{unsetenv} to put @var{string} into
+the environment or remove it. If @var{string} is of the form
+@samp{name=value} the string is added; if no @samp{=} is present the
+name is unset/removed.
+
+@end deftypefn
+
+*/
+
#if defined (_AIX) && !defined (__GNUC__)
#pragma alloca
#endif
@@ -26,6 +39,8 @@
#include "ansidecl.h"
+#define putenv libiberty_putenv
+
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
@@ -45,6 +60,8 @@ extern char *alloca ();
# endif /* alloca */
#endif /* HAVE_ALLOCA_H */
+#undef putenv
+
/* Below this point, it's verbatim code from the glibc-2.0 implementation */
diff --git a/contrib/binutils/libiberty/random.c b/contrib/binutils/libiberty/random.c
index ef00da0..48035f0 100644
--- a/contrib/binutils/libiberty/random.c
+++ b/contrib/binutils/libiberty/random.c
@@ -34,6 +34,24 @@
* It was reworked for the GNU C Library by Roland McGrath.
*/
+/*
+
+@deftypefn Supplement {long int} random (void)
+@deftypefnx Supplement void srandom (unsigned int @var{seed})
+@deftypefnx Supplement void* initstate (unsigned int @var{seed}, void *@var{arg_state}, unsigned long @var{n})
+@deftypefnx Supplement void* setstate (void *@var{arg_state})
+
+Random number functions. @code{random} returns a random number in the
+range 0 to @code{LONG_MAX}. @code{srandom} initializes the random
+number generator to some starting point determined by @var{seed}
+(else, the values returned by @code{random} are always the same for each
+run of the program). @code{initstate} and @code{setstate} allow fine-grained
+control over the state of the random number generator.
+
+@end deftypefn
+
+*/
+
#include <errno.h>
#if 0
diff --git a/contrib/binutils/libiberty/regex.c b/contrib/binutils/libiberty/regex.c
new file mode 100644
index 0000000..a64cd562
--- /dev/null
+++ b/contrib/binutils/libiberty/regex.c
@@ -0,0 +1,8373 @@
+/* Extended regular expression matching and search library,
+ version 0.12.
+ (Implements POSIX draft P1003.2/D11.2, except for some of the
+ internationalization features.)
+ Copyright (C) 1993-1999, 2000, 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* This file has been modified for usage in libiberty. It includes "xregex.h"
+ instead of <regex.h>. The "xregex.h" header file renames all external
+ routines with an "x" prefix so they do not collide with the native regex
+ routines or with other components regex routines. */
+/* AIX requires this to be the first thing in the file. */
+#if defined _AIX && !defined REGEX_MALLOC
+ #pragma alloca
+#endif
+
+#undef _GNU_SOURCE
+#define _GNU_SOURCE
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifndef PARAMS
+# if defined __GNUC__ || (defined __STDC__ && __STDC__)
+# define PARAMS(args) args
+# else
+# define PARAMS(args) ()
+# endif /* GCC. */
+#endif /* Not PARAMS. */
+
+#ifndef INSIDE_RECURSION
+
+# if defined STDC_HEADERS && !defined emacs
+# include <stddef.h>
+# else
+/* We need this for `regex.h', and perhaps for the Emacs include files. */
+# include <sys/types.h>
+# endif
+
+# define WIDE_CHAR_SUPPORT (HAVE_WCTYPE_H && HAVE_WCHAR_H && HAVE_BTOWC)
+
+/* For platform which support the ISO C amendement 1 functionality we
+ support user defined character classes. */
+# if defined _LIBC || WIDE_CHAR_SUPPORT
+/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
+# include <wchar.h>
+# include <wctype.h>
+# endif
+
+# ifdef _LIBC
+/* We have to keep the namespace clean. */
+# define regfree(preg) __regfree (preg)
+# define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef)
+# define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags)
+# define regerror(errcode, preg, errbuf, errbuf_size) \
+ __regerror(errcode, preg, errbuf, errbuf_size)
+# define re_set_registers(bu, re, nu, st, en) \
+ __re_set_registers (bu, re, nu, st, en)
+# define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \
+ __re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
+# define re_match(bufp, string, size, pos, regs) \
+ __re_match (bufp, string, size, pos, regs)
+# define re_search(bufp, string, size, startpos, range, regs) \
+ __re_search (bufp, string, size, startpos, range, regs)
+# define re_compile_pattern(pattern, length, bufp) \
+ __re_compile_pattern (pattern, length, bufp)
+# define re_set_syntax(syntax) __re_set_syntax (syntax)
+# define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \
+ __re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop)
+# define re_compile_fastmap(bufp) __re_compile_fastmap (bufp)
+
+# define btowc __btowc
+
+/* We are also using some library internals. */
+# include <locale/localeinfo.h>
+# include <locale/elem-hash.h>
+# include <langinfo.h>
+# include <locale/coll-lookup.h>
+# endif
+
+/* This is for other GNU distributions with internationalized messages. */
+# if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC
+# include <libintl.h>
+# ifdef _LIBC
+# undef gettext
+# define gettext(msgid) __dcgettext ("libc", msgid, LC_MESSAGES)
+# endif
+# else
+# define gettext(msgid) (msgid)
+# endif
+
+# ifndef gettext_noop
+/* This define is so xgettext can find the internationalizable
+ strings. */
+# define gettext_noop(String) String
+# endif
+
+/* The `emacs' switch turns on certain matching commands
+ that make sense only in Emacs. */
+# ifdef emacs
+
+# include "lisp.h"
+# include "buffer.h"
+# include "syntax.h"
+
+# else /* not emacs */
+
+/* If we are not linking with Emacs proper,
+ we can't use the relocating allocator
+ even if config.h says that we can. */
+# undef REL_ALLOC
+
+# if defined STDC_HEADERS || defined _LIBC
+# include <stdlib.h>
+# else
+char *malloc ();
+char *realloc ();
+# endif
+
+/* When used in Emacs's lib-src, we need to get bzero and bcopy somehow.
+ If nothing else has been done, use the method below. */
+# ifdef INHIBIT_STRING_HEADER
+# if !(defined HAVE_BZERO && defined HAVE_BCOPY)
+# if !defined bzero && !defined bcopy
+# undef INHIBIT_STRING_HEADER
+# endif
+# endif
+# endif
+
+/* This is the normal way of making sure we have a bcopy and a bzero.
+ This is used in most programs--a few other programs avoid this
+ by defining INHIBIT_STRING_HEADER. */
+# ifndef INHIBIT_STRING_HEADER
+# if defined HAVE_STRING_H || defined STDC_HEADERS || defined _LIBC
+# include <string.h>
+# ifndef bzero
+# ifndef _LIBC
+# define bzero(s, n) (memset (s, '\0', n), (s))
+# else
+# define bzero(s, n) __bzero (s, n)
+# endif
+# endif
+# else
+# include <strings.h>
+# ifndef memcmp
+# define memcmp(s1, s2, n) bcmp (s1, s2, n)
+# endif
+# ifndef memcpy
+# define memcpy(d, s, n) (bcopy (s, d, n), (d))
+# endif
+# endif
+# endif
+
+/* Define the syntax stuff for \<, \>, etc. */
+
+/* This must be nonzero for the wordchar and notwordchar pattern
+ commands in re_match_2. */
+# ifndef Sword
+# define Sword 1
+# endif
+
+# ifdef SWITCH_ENUM_BUG
+# define SWITCH_ENUM_CAST(x) ((int)(x))
+# else
+# define SWITCH_ENUM_CAST(x) (x)
+# endif
+
+# endif /* not emacs */
+
+# if defined _LIBC || HAVE_LIMITS_H
+# include <limits.h>
+# endif
+
+# ifndef MB_LEN_MAX
+# define MB_LEN_MAX 1
+# endif
+
+/* Get the interface, including the syntax bits. */
+# include "xregex.h" /* change for libiberty */
+
+/* isalpha etc. are used for the character classes. */
+# include <ctype.h>
+
+/* Jim Meyering writes:
+
+ "... Some ctype macros are valid only for character codes that
+ isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when
+ using /bin/cc or gcc but without giving an ansi option). So, all
+ ctype uses should be through macros like ISPRINT... If
+ STDC_HEADERS is defined, then autoconf has verified that the ctype
+ macros don't need to be guarded with references to isascii. ...
+ Defining isascii to 1 should let any compiler worth its salt
+ eliminate the && through constant folding."
+ Solaris defines some of these symbols so we must undefine them first. */
+
+# undef ISASCII
+# if defined STDC_HEADERS || (!defined isascii && !defined HAVE_ISASCII)
+# define ISASCII(c) 1
+# else
+# define ISASCII(c) isascii(c)
+# endif
+
+# ifdef isblank
+# define ISBLANK(c) (ISASCII (c) && isblank (c))
+# else
+# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
+# endif
+# ifdef isgraph
+# define ISGRAPH(c) (ISASCII (c) && isgraph (c))
+# else
+# define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c))
+# endif
+
+# undef ISPRINT
+# define ISPRINT(c) (ISASCII (c) && isprint (c))
+# define ISDIGIT(c) (ISASCII (c) && isdigit (c))
+# define ISALNUM(c) (ISASCII (c) && isalnum (c))
+# define ISALPHA(c) (ISASCII (c) && isalpha (c))
+# define ISCNTRL(c) (ISASCII (c) && iscntrl (c))
+# define ISLOWER(c) (ISASCII (c) && islower (c))
+# define ISPUNCT(c) (ISASCII (c) && ispunct (c))
+# define ISSPACE(c) (ISASCII (c) && isspace (c))
+# define ISUPPER(c) (ISASCII (c) && isupper (c))
+# define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))
+
+# ifdef _tolower
+# define TOLOWER(c) _tolower(c)
+# else
+# define TOLOWER(c) tolower(c)
+# endif
+
+# ifndef NULL
+# define NULL (void *)0
+# endif
+
+/* We remove any previous definition of `SIGN_EXTEND_CHAR',
+ since ours (we hope) works properly with all combinations of
+ machines, compilers, `char' and `unsigned char' argument types.
+ (Per Bothner suggested the basic approach.) */
+# undef SIGN_EXTEND_CHAR
+# if __STDC__
+# define SIGN_EXTEND_CHAR(c) ((signed char) (c))
+# else /* not __STDC__ */
+/* As in Harbison and Steele. */
+# define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128)
+# endif
+
+# ifndef emacs
+/* How many characters in the character set. */
+# define CHAR_SET_SIZE 256
+
+# ifdef SYNTAX_TABLE
+
+extern char *re_syntax_table;
+
+# else /* not SYNTAX_TABLE */
+
+static char re_syntax_table[CHAR_SET_SIZE];
+
+static void init_syntax_once PARAMS ((void));
+
+static void
+init_syntax_once ()
+{
+ register int c;
+ static int done = 0;
+
+ if (done)
+ return;
+ bzero (re_syntax_table, sizeof re_syntax_table);
+
+ for (c = 0; c < CHAR_SET_SIZE; ++c)
+ if (ISALNUM (c))
+ re_syntax_table[c] = Sword;
+
+ re_syntax_table['_'] = Sword;
+
+ done = 1;
+}
+
+# endif /* not SYNTAX_TABLE */
+
+# define SYNTAX(c) re_syntax_table[(unsigned char) (c)]
+
+# endif /* emacs */
+
+/* Integer type for pointers. */
+# if !defined _LIBC && !defined HAVE_UINTPTR_T
+typedef unsigned long int uintptr_t;
+# endif
+
+/* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we
+ use `alloca' instead of `malloc'. This is because using malloc in
+ re_search* or re_match* could cause memory leaks when C-g is used in
+ Emacs; also, malloc is slower and causes storage fragmentation. On
+ the other hand, malloc is more portable, and easier to debug.
+
+ Because we sometimes use alloca, some routines have to be macros,
+ not functions -- `alloca'-allocated space disappears at the end of the
+ function it is called in. */
+
+# ifdef REGEX_MALLOC
+
+# define REGEX_ALLOCATE malloc
+# define REGEX_REALLOCATE(source, osize, nsize) realloc (source, nsize)
+# define REGEX_FREE free
+
+# else /* not REGEX_MALLOC */
+
+/* Emacs already defines alloca, sometimes. */
+# ifndef alloca
+
+/* Make alloca work the best possible way. */
+# ifdef __GNUC__
+# define alloca __builtin_alloca
+# else /* not __GNUC__ */
+# if HAVE_ALLOCA_H
+# include <alloca.h>
+# endif /* HAVE_ALLOCA_H */
+# endif /* not __GNUC__ */
+
+# endif /* not alloca */
+
+# define REGEX_ALLOCATE alloca
+
+/* Assumes a `char *destination' variable. */
+# define REGEX_REALLOCATE(source, osize, nsize) \
+ (destination = (char *) alloca (nsize), \
+ memcpy (destination, source, osize))
+
+/* No need to do anything to free, after alloca. */
+# define REGEX_FREE(arg) ((void)0) /* Do nothing! But inhibit gcc warning. */
+
+# endif /* not REGEX_MALLOC */
+
+/* Define how to allocate the failure stack. */
+
+# if defined REL_ALLOC && defined REGEX_MALLOC
+
+# define REGEX_ALLOCATE_STACK(size) \
+ r_alloc (&failure_stack_ptr, (size))
+# define REGEX_REALLOCATE_STACK(source, osize, nsize) \
+ r_re_alloc (&failure_stack_ptr, (nsize))
+# define REGEX_FREE_STACK(ptr) \
+ r_alloc_free (&failure_stack_ptr)
+
+# else /* not using relocating allocator */
+
+# ifdef REGEX_MALLOC
+
+# define REGEX_ALLOCATE_STACK malloc
+# define REGEX_REALLOCATE_STACK(source, osize, nsize) realloc (source, nsize)
+# define REGEX_FREE_STACK free
+
+# else /* not REGEX_MALLOC */
+
+# define REGEX_ALLOCATE_STACK alloca
+
+# define REGEX_REALLOCATE_STACK(source, osize, nsize) \
+ REGEX_REALLOCATE (source, osize, nsize)
+/* No need to explicitly free anything. */
+# define REGEX_FREE_STACK(arg)
+
+# endif /* not REGEX_MALLOC */
+# endif /* not using relocating allocator */
+
+
+/* True if `size1' is non-NULL and PTR is pointing anywhere inside
+ `string1' or just past its end. This works if PTR is NULL, which is
+ a good thing. */
+# define FIRST_STRING_P(ptr) \
+ (size1 && string1 <= (ptr) && (ptr) <= string1 + size1)
+
+/* (Re)Allocate N items of type T using malloc, or fail. */
+# define TALLOC(n, t) ((t *) malloc ((n) * sizeof (t)))
+# define RETALLOC(addr, n, t) ((addr) = (t *) realloc (addr, (n) * sizeof (t)))
+# define RETALLOC_IF(addr, n, t) \
+ if (addr) RETALLOC((addr), (n), t); else (addr) = TALLOC ((n), t)
+# define REGEX_TALLOC(n, t) ((t *) REGEX_ALLOCATE ((n) * sizeof (t)))
+
+# define BYTEWIDTH 8 /* In bits. */
+
+# define STREQ(s1, s2) ((strcmp (s1, s2) == 0))
+
+# undef MAX
+# undef MIN
+# define MAX(a, b) ((a) > (b) ? (a) : (b))
+# define MIN(a, b) ((a) < (b) ? (a) : (b))
+
+typedef char boolean;
+# define false 0
+# define true 1
+
+static reg_errcode_t byte_regex_compile _RE_ARGS ((const char *pattern, size_t size,
+ reg_syntax_t syntax,
+ struct re_pattern_buffer *bufp));
+
+static int byte_re_match_2_internal PARAMS ((struct re_pattern_buffer *bufp,
+ const char *string1, int size1,
+ const char *string2, int size2,
+ int pos,
+ struct re_registers *regs,
+ int stop));
+static int byte_re_search_2 PARAMS ((struct re_pattern_buffer *bufp,
+ const char *string1, int size1,
+ const char *string2, int size2,
+ int startpos, int range,
+ struct re_registers *regs, int stop));
+static int byte_re_compile_fastmap PARAMS ((struct re_pattern_buffer *bufp));
+
+#ifdef MBS_SUPPORT
+static reg_errcode_t wcs_regex_compile _RE_ARGS ((const char *pattern, size_t size,
+ reg_syntax_t syntax,
+ struct re_pattern_buffer *bufp));
+
+
+static int wcs_re_match_2_internal PARAMS ((struct re_pattern_buffer *bufp,
+ const char *cstring1, int csize1,
+ const char *cstring2, int csize2,
+ int pos,
+ struct re_registers *regs,
+ int stop,
+ wchar_t *string1, int size1,
+ wchar_t *string2, int size2,
+ int *mbs_offset1, int *mbs_offset2));
+static int wcs_re_search_2 PARAMS ((struct re_pattern_buffer *bufp,
+ const char *string1, int size1,
+ const char *string2, int size2,
+ int startpos, int range,
+ struct re_registers *regs, int stop));
+static int wcs_re_compile_fastmap PARAMS ((struct re_pattern_buffer *bufp));
+#endif
+
+/* These are the command codes that appear in compiled regular
+ expressions. Some opcodes are followed by argument bytes. A
+ command code can specify any interpretation whatsoever for its
+ arguments. Zero bytes may appear in the compiled regular expression. */
+
+typedef enum
+{
+ no_op = 0,
+
+ /* Succeed right away--no more backtracking. */
+ succeed,
+
+ /* Followed by one byte giving n, then by n literal bytes. */
+ exactn,
+
+# ifdef MBS_SUPPORT
+ /* Same as exactn, but contains binary data. */
+ exactn_bin,
+# endif
+
+ /* Matches any (more or less) character. */
+ anychar,
+
+ /* Matches any one char belonging to specified set. First
+ following byte is number of bitmap bytes. Then come bytes
+ for a bitmap saying which chars are in. Bits in each byte
+ are ordered low-bit-first. A character is in the set if its
+ bit is 1. A character too large to have a bit in the map is
+ automatically not in the set. */
+ /* ifdef MBS_SUPPORT, following element is length of character
+ classes, length of collating symbols, length of equivalence
+ classes, length of character ranges, and length of characters.
+ Next, character class element, collating symbols elements,
+ equivalence class elements, range elements, and character
+ elements follow.
+ See regex_compile function. */
+ charset,
+
+ /* Same parameters as charset, but match any character that is
+ not one of those specified. */
+ charset_not,
+
+ /* Start remembering the text that is matched, for storing in a
+ register. Followed by one byte with the register number, in
+ the range 0 to one less than the pattern buffer's re_nsub
+ field. Then followed by one byte with the number of groups
+ inner to this one. (This last has to be part of the
+ start_memory only because we need it in the on_failure_jump
+ of re_match_2.) */
+ start_memory,
+
+ /* Stop remembering the text that is matched and store it in a
+ memory register. Followed by one byte with the register
+ number, in the range 0 to one less than `re_nsub' in the
+ pattern buffer, and one byte with the number of inner groups,
+ just like `start_memory'. (We need the number of inner
+ groups here because we don't have any easy way of finding the
+ corresponding start_memory when we're at a stop_memory.) */
+ stop_memory,
+
+ /* Match a duplicate of something remembered. Followed by one
+ byte containing the register number. */
+ duplicate,
+
+ /* Fail unless at beginning of line. */
+ begline,
+
+ /* Fail unless at end of line. */
+ endline,
+
+ /* Succeeds if at beginning of buffer (if emacs) or at beginning
+ of string to be matched (if not). */
+ begbuf,
+
+ /* Analogously, for end of buffer/string. */
+ endbuf,
+
+ /* Followed by two byte relative address to which to jump. */
+ jump,
+
+ /* Same as jump, but marks the end of an alternative. */
+ jump_past_alt,
+
+ /* Followed by two-byte relative address of place to resume at
+ in case of failure. */
+ /* ifdef MBS_SUPPORT, the size of address is 1. */
+ on_failure_jump,
+
+ /* Like on_failure_jump, but pushes a placeholder instead of the
+ current string position when executed. */
+ on_failure_keep_string_jump,
+
+ /* Throw away latest failure point and then jump to following
+ two-byte relative address. */
+ /* ifdef MBS_SUPPORT, the size of address is 1. */
+ pop_failure_jump,
+
+ /* Change to pop_failure_jump if know won't have to backtrack to
+ match; otherwise change to jump. This is used to jump
+ back to the beginning of a repeat. If what follows this jump
+ clearly won't match what the repeat does, such that we can be
+ sure that there is no use backtracking out of repetitions
+ already matched, then we change it to a pop_failure_jump.
+ Followed by two-byte address. */
+ /* ifdef MBS_SUPPORT, the size of address is 1. */
+ maybe_pop_jump,
+
+ /* Jump to following two-byte address, and push a dummy failure
+ point. This failure point will be thrown away if an attempt
+ is made to use it for a failure. A `+' construct makes this
+ before the first repeat. Also used as an intermediary kind
+ of jump when compiling an alternative. */
+ /* ifdef MBS_SUPPORT, the size of address is 1. */
+ dummy_failure_jump,
+
+ /* Push a dummy failure point and continue. Used at the end of
+ alternatives. */
+ push_dummy_failure,
+
+ /* Followed by two-byte relative address and two-byte number n.
+ After matching N times, jump to the address upon failure. */
+ /* ifdef MBS_SUPPORT, the size of address is 1. */
+ succeed_n,
+
+ /* Followed by two-byte relative address, and two-byte number n.
+ Jump to the address N times, then fail. */
+ /* ifdef MBS_SUPPORT, the size of address is 1. */
+ jump_n,
+
+ /* Set the following two-byte relative address to the
+ subsequent two-byte number. The address *includes* the two
+ bytes of number. */
+ /* ifdef MBS_SUPPORT, the size of address is 1. */
+ set_number_at,
+
+ wordchar, /* Matches any word-constituent character. */
+ notwordchar, /* Matches any char that is not a word-constituent. */
+
+ wordbeg, /* Succeeds if at word beginning. */
+ wordend, /* Succeeds if at word end. */
+
+ wordbound, /* Succeeds if at a word boundary. */
+ notwordbound /* Succeeds if not at a word boundary. */
+
+# ifdef emacs
+ ,before_dot, /* Succeeds if before point. */
+ at_dot, /* Succeeds if at point. */
+ after_dot, /* Succeeds if after point. */
+
+ /* Matches any character whose syntax is specified. Followed by
+ a byte which contains a syntax code, e.g., Sword. */
+ syntaxspec,
+
+ /* Matches any character whose syntax is not that specified. */
+ notsyntaxspec
+# endif /* emacs */
+} re_opcode_t;
+#endif /* not INSIDE_RECURSION */
+
+
+#ifdef BYTE
+# define CHAR_T char
+# define UCHAR_T unsigned char
+# define COMPILED_BUFFER_VAR bufp->buffer
+# define OFFSET_ADDRESS_SIZE 2
+# if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
+# define PREFIX(name) byte_##name
+# else
+# define PREFIX(name) byte_/**/name
+# endif
+# define ARG_PREFIX(name) name
+# define PUT_CHAR(c) putchar (c)
+#else
+# ifdef WCHAR
+# define CHAR_T wchar_t
+# define UCHAR_T wchar_t
+# define COMPILED_BUFFER_VAR wc_buffer
+# define OFFSET_ADDRESS_SIZE 1 /* the size which STORE_NUMBER macro use */
+# define CHAR_CLASS_SIZE ((__alignof__(wctype_t)+sizeof(wctype_t))/sizeof(CHAR_T)+1)
+# if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
+# define PREFIX(name) wcs_##name
+# define ARG_PREFIX(name) c##name
+# else
+# define PREFIX(name) wcs_/**/name
+# define ARG_PREFIX(name) c/**/name
+# endif
+/* Should we use wide stream?? */
+# define PUT_CHAR(c) printf ("%C", c);
+# define TRUE 1
+# define FALSE 0
+# else
+# ifdef MBS_SUPPORT
+# define WCHAR
+# define INSIDE_RECURSION
+# include "regex.c"
+# undef INSIDE_RECURSION
+# endif
+# define BYTE
+# define INSIDE_RECURSION
+# include "regex.c"
+# undef INSIDE_RECURSION
+# endif
+#endif
+
+#ifdef INSIDE_RECURSION
+/* Common operations on the compiled pattern. */
+
+/* Store NUMBER in two contiguous bytes starting at DESTINATION. */
+/* ifdef MBS_SUPPORT, we store NUMBER in 1 element. */
+
+# ifdef WCHAR
+# define STORE_NUMBER(destination, number) \
+ do { \
+ *(destination) = (UCHAR_T)(number); \
+ } while (0)
+# else /* BYTE */
+# define STORE_NUMBER(destination, number) \
+ do { \
+ (destination)[0] = (number) & 0377; \
+ (destination)[1] = (number) >> 8; \
+ } while (0)
+# endif /* WCHAR */
+
+/* Same as STORE_NUMBER, except increment DESTINATION to
+ the byte after where the number is stored. Therefore, DESTINATION
+ must be an lvalue. */
+/* ifdef MBS_SUPPORT, we store NUMBER in 1 element. */
+
+# define STORE_NUMBER_AND_INCR(destination, number) \
+ do { \
+ STORE_NUMBER (destination, number); \
+ (destination) += OFFSET_ADDRESS_SIZE; \
+ } while (0)
+
+/* Put into DESTINATION a number stored in two contiguous bytes starting
+ at SOURCE. */
+/* ifdef MBS_SUPPORT, we store NUMBER in 1 element. */
+
+# ifdef WCHAR
+# define EXTRACT_NUMBER(destination, source) \
+ do { \
+ (destination) = *(source); \
+ } while (0)
+# else /* BYTE */
+# define EXTRACT_NUMBER(destination, source) \
+ do { \
+ (destination) = *(source) & 0377; \
+ (destination) += SIGN_EXTEND_CHAR (*((source) + 1)) << 8; \
+ } while (0)
+# endif
+
+# ifdef DEBUG
+static void PREFIX(extract_number) _RE_ARGS ((int *dest, UCHAR_T *source));
+static void
+PREFIX(extract_number) (dest, source)
+ int *dest;
+ UCHAR_T *source;
+{
+# ifdef WCHAR
+ *dest = *source;
+# else /* BYTE */
+ int temp = SIGN_EXTEND_CHAR (*(source + 1));
+ *dest = *source & 0377;
+ *dest += temp << 8;
+# endif
+}
+
+# ifndef EXTRACT_MACROS /* To debug the macros. */
+# undef EXTRACT_NUMBER
+# define EXTRACT_NUMBER(dest, src) PREFIX(extract_number) (&dest, src)
+# endif /* not EXTRACT_MACROS */
+
+# endif /* DEBUG */
+
+/* Same as EXTRACT_NUMBER, except increment SOURCE to after the number.
+ SOURCE must be an lvalue. */
+
+# define EXTRACT_NUMBER_AND_INCR(destination, source) \
+ do { \
+ EXTRACT_NUMBER (destination, source); \
+ (source) += OFFSET_ADDRESS_SIZE; \
+ } while (0)
+
+# ifdef DEBUG
+static void PREFIX(extract_number_and_incr) _RE_ARGS ((int *destination,
+ UCHAR_T **source));
+static void
+PREFIX(extract_number_and_incr) (destination, source)
+ int *destination;
+ UCHAR_T **source;
+{
+ PREFIX(extract_number) (destination, *source);
+ *source += OFFSET_ADDRESS_SIZE;
+}
+
+# ifndef EXTRACT_MACROS
+# undef EXTRACT_NUMBER_AND_INCR
+# define EXTRACT_NUMBER_AND_INCR(dest, src) \
+ PREFIX(extract_number_and_incr) (&dest, &src)
+# endif /* not EXTRACT_MACROS */
+
+# endif /* DEBUG */
+
+
+
+/* If DEBUG is defined, Regex prints many voluminous messages about what
+ it is doing (if the variable `debug' is nonzero). If linked with the
+ main program in `iregex.c', you can enter patterns and strings
+ interactively. And if linked with the main program in `main.c' and
+ the other test files, you can run the already-written tests. */
+
+# ifdef DEBUG
+
+# ifndef DEFINED_ONCE
+
+/* We use standard I/O for debugging. */
+# include <stdio.h>
+
+/* It is useful to test things that ``must'' be true when debugging. */
+# include <assert.h>
+
+static int debug;
+
+# define DEBUG_STATEMENT(e) e
+# define DEBUG_PRINT1(x) if (debug) printf (x)
+# define DEBUG_PRINT2(x1, x2) if (debug) printf (x1, x2)
+# define DEBUG_PRINT3(x1, x2, x3) if (debug) printf (x1, x2, x3)
+# define DEBUG_PRINT4(x1, x2, x3, x4) if (debug) printf (x1, x2, x3, x4)
+# endif /* not DEFINED_ONCE */
+
+# define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) \
+ if (debug) PREFIX(print_partial_compiled_pattern) (s, e)
+# define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2) \
+ if (debug) PREFIX(print_double_string) (w, s1, sz1, s2, sz2)
+
+
+/* Print the fastmap in human-readable form. */
+
+# ifndef DEFINED_ONCE
+void
+print_fastmap (fastmap)
+ char *fastmap;
+{
+ unsigned was_a_range = 0;
+ unsigned i = 0;
+
+ while (i < (1 << BYTEWIDTH))
+ {
+ if (fastmap[i++])
+ {
+ was_a_range = 0;
+ putchar (i - 1);
+ while (i < (1 << BYTEWIDTH) && fastmap[i])
+ {
+ was_a_range = 1;
+ i++;
+ }
+ if (was_a_range)
+ {
+ printf ("-");
+ putchar (i - 1);
+ }
+ }
+ }
+ putchar ('\n');
+}
+# endif /* not DEFINED_ONCE */
+
+
+/* Print a compiled pattern string in human-readable form, starting at
+ the START pointer into it and ending just before the pointer END. */
+
+void
+PREFIX(print_partial_compiled_pattern) (start, end)
+ UCHAR_T *start;
+ UCHAR_T *end;
+{
+ int mcnt, mcnt2;
+ UCHAR_T *p1;
+ UCHAR_T *p = start;
+ UCHAR_T *pend = end;
+
+ if (start == NULL)
+ {
+ printf ("(null)\n");
+ return;
+ }
+
+ /* Loop over pattern commands. */
+ while (p < pend)
+ {
+# ifdef _LIBC
+ printf ("%td:\t", p - start);
+# else
+ printf ("%ld:\t", (long int) (p - start));
+# endif
+
+ switch ((re_opcode_t) *p++)
+ {
+ case no_op:
+ printf ("/no_op");
+ break;
+
+ case exactn:
+ mcnt = *p++;
+ printf ("/exactn/%d", mcnt);
+ do
+ {
+ putchar ('/');
+ PUT_CHAR (*p++);
+ }
+ while (--mcnt);
+ break;
+
+# ifdef MBS_SUPPORT
+ case exactn_bin:
+ mcnt = *p++;
+ printf ("/exactn_bin/%d", mcnt);
+ do
+ {
+ printf("/%lx", (long int) *p++);
+ }
+ while (--mcnt);
+ break;
+# endif /* MBS_SUPPORT */
+
+ case start_memory:
+ mcnt = *p++;
+ printf ("/start_memory/%d/%ld", mcnt, (long int) *p++);
+ break;
+
+ case stop_memory:
+ mcnt = *p++;
+ printf ("/stop_memory/%d/%ld", mcnt, (long int) *p++);
+ break;
+
+ case duplicate:
+ printf ("/duplicate/%ld", (long int) *p++);
+ break;
+
+ case anychar:
+ printf ("/anychar");
+ break;
+
+ case charset:
+ case charset_not:
+ {
+# ifdef WCHAR
+ int i, length;
+ wchar_t *workp = p;
+ printf ("/charset [%s",
+ (re_opcode_t) *(workp - 1) == charset_not ? "^" : "");
+ p += 5;
+ length = *workp++; /* the length of char_classes */
+ for (i=0 ; i<length ; i++)
+ printf("[:%lx:]", (long int) *p++);
+ length = *workp++; /* the length of collating_symbol */
+ for (i=0 ; i<length ;)
+ {
+ printf("[.");
+ while(*p != 0)
+ PUT_CHAR((i++,*p++));
+ i++,p++;
+ printf(".]");
+ }
+ length = *workp++; /* the length of equivalence_class */
+ for (i=0 ; i<length ;)
+ {
+ printf("[=");
+ while(*p != 0)
+ PUT_CHAR((i++,*p++));
+ i++,p++;
+ printf("=]");
+ }
+ length = *workp++; /* the length of char_range */
+ for (i=0 ; i<length ; i++)
+ {
+ wchar_t range_start = *p++;
+ wchar_t range_end = *p++;
+ printf("%C-%C", range_start, range_end);
+ }
+ length = *workp++; /* the length of char */
+ for (i=0 ; i<length ; i++)
+ printf("%C", *p++);
+ putchar (']');
+# else
+ register int c, last = -100;
+ register int in_range = 0;
+
+ printf ("/charset [%s",
+ (re_opcode_t) *(p - 1) == charset_not ? "^" : "");
+
+ assert (p + *p < pend);
+
+ for (c = 0; c < 256; c++)
+ if (c / 8 < *p
+ && (p[1 + (c/8)] & (1 << (c % 8))))
+ {
+ /* Are we starting a range? */
+ if (last + 1 == c && ! in_range)
+ {
+ putchar ('-');
+ in_range = 1;
+ }
+ /* Have we broken a range? */
+ else if (last + 1 != c && in_range)
+ {
+ putchar (last);
+ in_range = 0;
+ }
+
+ if (! in_range)
+ putchar (c);
+
+ last = c;
+ }
+
+ if (in_range)
+ putchar (last);
+
+ putchar (']');
+
+ p += 1 + *p;
+# endif /* WCHAR */
+ }
+ break;
+
+ case begline:
+ printf ("/begline");
+ break;
+
+ case endline:
+ printf ("/endline");
+ break;
+
+ case on_failure_jump:
+ PREFIX(extract_number_and_incr) (&mcnt, &p);
+# ifdef _LIBC
+ printf ("/on_failure_jump to %td", p + mcnt - start);
+# else
+ printf ("/on_failure_jump to %ld", (long int) (p + mcnt - start));
+# endif
+ break;
+
+ case on_failure_keep_string_jump:
+ PREFIX(extract_number_and_incr) (&mcnt, &p);
+# ifdef _LIBC
+ printf ("/on_failure_keep_string_jump to %td", p + mcnt - start);
+# else
+ printf ("/on_failure_keep_string_jump to %ld",
+ (long int) (p + mcnt - start));
+# endif
+ break;
+
+ case dummy_failure_jump:
+ PREFIX(extract_number_and_incr) (&mcnt, &p);
+# ifdef _LIBC
+ printf ("/dummy_failure_jump to %td", p + mcnt - start);
+# else
+ printf ("/dummy_failure_jump to %ld", (long int) (p + mcnt - start));
+# endif
+ break;
+
+ case push_dummy_failure:
+ printf ("/push_dummy_failure");
+ break;
+
+ case maybe_pop_jump:
+ PREFIX(extract_number_and_incr) (&mcnt, &p);
+# ifdef _LIBC
+ printf ("/maybe_pop_jump to %td", p + mcnt - start);
+# else
+ printf ("/maybe_pop_jump to %ld", (long int) (p + mcnt - start));
+# endif
+ break;
+
+ case pop_failure_jump:
+ PREFIX(extract_number_and_incr) (&mcnt, &p);
+# ifdef _LIBC
+ printf ("/pop_failure_jump to %td", p + mcnt - start);
+# else
+ printf ("/pop_failure_jump to %ld", (long int) (p + mcnt - start));
+# endif
+ break;
+
+ case jump_past_alt:
+ PREFIX(extract_number_and_incr) (&mcnt, &p);
+# ifdef _LIBC
+ printf ("/jump_past_alt to %td", p + mcnt - start);
+# else
+ printf ("/jump_past_alt to %ld", (long int) (p + mcnt - start));
+# endif
+ break;
+
+ case jump:
+ PREFIX(extract_number_and_incr) (&mcnt, &p);
+# ifdef _LIBC
+ printf ("/jump to %td", p + mcnt - start);
+# else
+ printf ("/jump to %ld", (long int) (p + mcnt - start));
+# endif
+ break;
+
+ case succeed_n:
+ PREFIX(extract_number_and_incr) (&mcnt, &p);
+ p1 = p + mcnt;
+ PREFIX(extract_number_and_incr) (&mcnt2, &p);
+# ifdef _LIBC
+ printf ("/succeed_n to %td, %d times", p1 - start, mcnt2);
+# else
+ printf ("/succeed_n to %ld, %d times",
+ (long int) (p1 - start), mcnt2);
+# endif
+ break;
+
+ case jump_n:
+ PREFIX(extract_number_and_incr) (&mcnt, &p);
+ p1 = p + mcnt;
+ PREFIX(extract_number_and_incr) (&mcnt2, &p);
+ printf ("/jump_n to %d, %d times", p1 - start, mcnt2);
+ break;
+
+ case set_number_at:
+ PREFIX(extract_number_and_incr) (&mcnt, &p);
+ p1 = p + mcnt;
+ PREFIX(extract_number_and_incr) (&mcnt2, &p);
+# ifdef _LIBC
+ printf ("/set_number_at location %td to %d", p1 - start, mcnt2);
+# else
+ printf ("/set_number_at location %ld to %d",
+ (long int) (p1 - start), mcnt2);
+# endif
+ break;
+
+ case wordbound:
+ printf ("/wordbound");
+ break;
+
+ case notwordbound:
+ printf ("/notwordbound");
+ break;
+
+ case wordbeg:
+ printf ("/wordbeg");
+ break;
+
+ case wordend:
+ printf ("/wordend");
+ break;
+
+# ifdef emacs
+ case before_dot:
+ printf ("/before_dot");
+ break;
+
+ case at_dot:
+ printf ("/at_dot");
+ break;
+
+ case after_dot:
+ printf ("/after_dot");
+ break;
+
+ case syntaxspec:
+ printf ("/syntaxspec");
+ mcnt = *p++;
+ printf ("/%d", mcnt);
+ break;
+
+ case notsyntaxspec:
+ printf ("/notsyntaxspec");
+ mcnt = *p++;
+ printf ("/%d", mcnt);
+ break;
+# endif /* emacs */
+
+ case wordchar:
+ printf ("/wordchar");
+ break;
+
+ case notwordchar:
+ printf ("/notwordchar");
+ break;
+
+ case begbuf:
+ printf ("/begbuf");
+ break;
+
+ case endbuf:
+ printf ("/endbuf");
+ break;
+
+ default:
+ printf ("?%ld", (long int) *(p-1));
+ }
+
+ putchar ('\n');
+ }
+
+# ifdef _LIBC
+ printf ("%td:\tend of pattern.\n", p - start);
+# else
+ printf ("%ld:\tend of pattern.\n", (long int) (p - start));
+# endif
+}
+
+
+void
+PREFIX(print_compiled_pattern) (bufp)
+ struct re_pattern_buffer *bufp;
+{
+ UCHAR_T *buffer = (UCHAR_T*) bufp->buffer;
+
+ PREFIX(print_partial_compiled_pattern) (buffer, buffer
+ + bufp->used / sizeof(UCHAR_T));
+ printf ("%ld bytes used/%ld bytes allocated.\n",
+ bufp->used, bufp->allocated);
+
+ if (bufp->fastmap_accurate && bufp->fastmap)
+ {
+ printf ("fastmap: ");
+ print_fastmap (bufp->fastmap);
+ }
+
+# ifdef _LIBC
+ printf ("re_nsub: %Zd\t", bufp->re_nsub);
+# else
+ printf ("re_nsub: %ld\t", (long int) bufp->re_nsub);
+# endif
+ printf ("regs_alloc: %d\t", bufp->regs_allocated);
+ printf ("can_be_null: %d\t", bufp->can_be_null);
+ printf ("newline_anchor: %d\n", bufp->newline_anchor);
+ printf ("no_sub: %d\t", bufp->no_sub);
+ printf ("not_bol: %d\t", bufp->not_bol);
+ printf ("not_eol: %d\t", bufp->not_eol);
+ printf ("syntax: %lx\n", bufp->syntax);
+ /* Perhaps we should print the translate table? */
+}
+
+
+void
+PREFIX(print_double_string) (where, string1, size1, string2, size2)
+ const CHAR_T *where;
+ const CHAR_T *string1;
+ const CHAR_T *string2;
+ int size1;
+ int size2;
+{
+ int this_char;
+
+ if (where == NULL)
+ printf ("(null)");
+ else
+ {
+ int cnt;
+
+ if (FIRST_STRING_P (where))
+ {
+ for (this_char = where - string1; this_char < size1; this_char++)
+ PUT_CHAR (string1[this_char]);
+
+ where = string2;
+ }
+
+ cnt = 0;
+ for (this_char = where - string2; this_char < size2; this_char++)
+ {
+ PUT_CHAR (string2[this_char]);
+ if (++cnt > 100)
+ {
+ fputs ("...", stdout);
+ break;
+ }
+ }
+ }
+}
+
+# ifndef DEFINED_ONCE
+void
+printchar (c)
+ int c;
+{
+ putc (c, stderr);
+}
+# endif
+
+# else /* not DEBUG */
+
+# ifndef DEFINED_ONCE
+# undef assert
+# define assert(e)
+
+# define DEBUG_STATEMENT(e)
+# define DEBUG_PRINT1(x)
+# define DEBUG_PRINT2(x1, x2)
+# define DEBUG_PRINT3(x1, x2, x3)
+# define DEBUG_PRINT4(x1, x2, x3, x4)
+# endif /* not DEFINED_ONCE */
+# define DEBUG_PRINT_COMPILED_PATTERN(p, s, e)
+# define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2)
+
+# endif /* not DEBUG */
+
+
+
+# ifdef WCHAR
+/* This convert a multibyte string to a wide character string.
+ And write their correspondances to offset_buffer(see below)
+ and write whether each wchar_t is binary data to is_binary.
+ This assume invalid multibyte sequences as binary data.
+ We assume offset_buffer and is_binary is already allocated
+ enough space. */
+
+static size_t convert_mbs_to_wcs (CHAR_T *dest, const unsigned char* src,
+ size_t len, int *offset_buffer,
+ char *is_binary);
+static size_t
+convert_mbs_to_wcs (dest, src, len, offset_buffer, is_binary)
+ CHAR_T *dest;
+ const unsigned char* src;
+ size_t len; /* the length of multibyte string. */
+
+ /* It hold correspondances between src(char string) and
+ dest(wchar_t string) for optimization.
+ e.g. src = "xxxyzz"
+ dest = {'X', 'Y', 'Z'}
+ (each "xxx", "y" and "zz" represent one multibyte character
+ corresponding to 'X', 'Y' and 'Z'.)
+ offset_buffer = {0, 0+3("xxx"), 0+3+1("y"), 0+3+1+2("zz")}
+ = {0, 3, 4, 6}
+ */
+ int *offset_buffer;
+ char *is_binary;
+{
+ wchar_t *pdest = dest;
+ const unsigned char *psrc = src;
+ size_t wc_count = 0;
+
+ mbstate_t mbs;
+ int i, consumed;
+ size_t mb_remain = len;
+ size_t mb_count = 0;
+
+ /* Initialize the conversion state. */
+ memset (&mbs, 0, sizeof (mbstate_t));
+
+ offset_buffer[0] = 0;
+ for( ; mb_remain > 0 ; ++wc_count, ++pdest, mb_remain -= consumed,
+ psrc += consumed)
+ {
+#ifdef _LIBC
+ consumed = __mbrtowc (pdest, psrc, mb_remain, &mbs);
+#else
+ consumed = mbrtowc (pdest, psrc, mb_remain, &mbs);
+#endif
+
+ if (consumed <= 0)
+ /* failed to convert. maybe src contains binary data.
+ So we consume 1 byte manualy. */
+ {
+ *pdest = *psrc;
+ consumed = 1;
+ is_binary[wc_count] = TRUE;
+ }
+ else
+ is_binary[wc_count] = FALSE;
+ /* In sjis encoding, we use yen sign as escape character in
+ place of reverse solidus. So we convert 0x5c(yen sign in
+ sjis) to not 0xa5(yen sign in UCS2) but 0x5c(reverse
+ solidus in UCS2). */
+ if (consumed == 1 && (int) *psrc == 0x5c && (int) *pdest == 0xa5)
+ *pdest = (wchar_t) *psrc;
+
+ offset_buffer[wc_count + 1] = mb_count += consumed;
+ }
+
+ /* Fill remain of the buffer with sentinel. */
+ for (i = wc_count + 1 ; i <= len ; i++)
+ offset_buffer[i] = mb_count + 1;
+
+ return wc_count;
+}
+
+# endif /* WCHAR */
+
+#else /* not INSIDE_RECURSION */
+
+/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can
+ also be assigned to arbitrarily: each pattern buffer stores its own
+ syntax, so it can be changed between regex compilations. */
+/* This has no initializer because initialized variables in Emacs
+ become read-only after dumping. */
+reg_syntax_t re_syntax_options;
+
+
+/* Specify the precise syntax of regexps for compilation. This provides
+ for compatibility for various utilities which historically have
+ different, incompatible syntaxes.
+
+ The argument SYNTAX is a bit mask comprised of the various bits
+ defined in regex.h. We return the old syntax. */
+
+reg_syntax_t
+re_set_syntax (syntax)
+ reg_syntax_t syntax;
+{
+ reg_syntax_t ret = re_syntax_options;
+
+ re_syntax_options = syntax;
+# ifdef DEBUG
+ if (syntax & RE_DEBUG)
+ debug = 1;
+ else if (debug) /* was on but now is not */
+ debug = 0;
+# endif /* DEBUG */
+ return ret;
+}
+# ifdef _LIBC
+weak_alias (__re_set_syntax, re_set_syntax)
+# endif
+
+/* This table gives an error message for each of the error codes listed
+ in regex.h. Obviously the order here has to be same as there.
+ POSIX doesn't require that we do anything for REG_NOERROR,
+ but why not be nice? */
+
+static const char re_error_msgid[] =
+ {
+# define REG_NOERROR_IDX 0
+ gettext_noop ("Success") /* REG_NOERROR */
+ "\0"
+# define REG_NOMATCH_IDX (REG_NOERROR_IDX + sizeof "Success")
+ gettext_noop ("No match") /* REG_NOMATCH */
+ "\0"
+# define REG_BADPAT_IDX (REG_NOMATCH_IDX + sizeof "No match")
+ gettext_noop ("Invalid regular expression") /* REG_BADPAT */
+ "\0"
+# define REG_ECOLLATE_IDX (REG_BADPAT_IDX + sizeof "Invalid regular expression")
+ gettext_noop ("Invalid collation character") /* REG_ECOLLATE */
+ "\0"
+# define REG_ECTYPE_IDX (REG_ECOLLATE_IDX + sizeof "Invalid collation character")
+ gettext_noop ("Invalid character class name") /* REG_ECTYPE */
+ "\0"
+# define REG_EESCAPE_IDX (REG_ECTYPE_IDX + sizeof "Invalid character class name")
+ gettext_noop ("Trailing backslash") /* REG_EESCAPE */
+ "\0"
+# define REG_ESUBREG_IDX (REG_EESCAPE_IDX + sizeof "Trailing backslash")
+ gettext_noop ("Invalid back reference") /* REG_ESUBREG */
+ "\0"
+# define REG_EBRACK_IDX (REG_ESUBREG_IDX + sizeof "Invalid back reference")
+ gettext_noop ("Unmatched [ or [^") /* REG_EBRACK */
+ "\0"
+# define REG_EPAREN_IDX (REG_EBRACK_IDX + sizeof "Unmatched [ or [^")
+ gettext_noop ("Unmatched ( or \\(") /* REG_EPAREN */
+ "\0"
+# define REG_EBRACE_IDX (REG_EPAREN_IDX + sizeof "Unmatched ( or \\(")
+ gettext_noop ("Unmatched \\{") /* REG_EBRACE */
+ "\0"
+# define REG_BADBR_IDX (REG_EBRACE_IDX + sizeof "Unmatched \\{")
+ gettext_noop ("Invalid content of \\{\\}") /* REG_BADBR */
+ "\0"
+# define REG_ERANGE_IDX (REG_BADBR_IDX + sizeof "Invalid content of \\{\\}")
+ gettext_noop ("Invalid range end") /* REG_ERANGE */
+ "\0"
+# define REG_ESPACE_IDX (REG_ERANGE_IDX + sizeof "Invalid range end")
+ gettext_noop ("Memory exhausted") /* REG_ESPACE */
+ "\0"
+# define REG_BADRPT_IDX (REG_ESPACE_IDX + sizeof "Memory exhausted")
+ gettext_noop ("Invalid preceding regular expression") /* REG_BADRPT */
+ "\0"
+# define REG_EEND_IDX (REG_BADRPT_IDX + sizeof "Invalid preceding regular expression")
+ gettext_noop ("Premature end of regular expression") /* REG_EEND */
+ "\0"
+# define REG_ESIZE_IDX (REG_EEND_IDX + sizeof "Premature end of regular expression")
+ gettext_noop ("Regular expression too big") /* REG_ESIZE */
+ "\0"
+# define REG_ERPAREN_IDX (REG_ESIZE_IDX + sizeof "Regular expression too big")
+ gettext_noop ("Unmatched ) or \\)") /* REG_ERPAREN */
+ };
+
+static const size_t re_error_msgid_idx[] =
+ {
+ REG_NOERROR_IDX,
+ REG_NOMATCH_IDX,
+ REG_BADPAT_IDX,
+ REG_ECOLLATE_IDX,
+ REG_ECTYPE_IDX,
+ REG_EESCAPE_IDX,
+ REG_ESUBREG_IDX,
+ REG_EBRACK_IDX,
+ REG_EPAREN_IDX,
+ REG_EBRACE_IDX,
+ REG_BADBR_IDX,
+ REG_ERANGE_IDX,
+ REG_ESPACE_IDX,
+ REG_BADRPT_IDX,
+ REG_EEND_IDX,
+ REG_ESIZE_IDX,
+ REG_ERPAREN_IDX
+ };
+
+#endif /* INSIDE_RECURSION */
+
+#ifndef DEFINED_ONCE
+/* Avoiding alloca during matching, to placate r_alloc. */
+
+/* Define MATCH_MAY_ALLOCATE unless we need to make sure that the
+ searching and matching functions should not call alloca. On some
+ systems, alloca is implemented in terms of malloc, and if we're
+ using the relocating allocator routines, then malloc could cause a
+ relocation, which might (if the strings being searched are in the
+ ralloc heap) shift the data out from underneath the regexp
+ routines.
+
+ Here's another reason to avoid allocation: Emacs
+ processes input from X in a signal handler; processing X input may
+ call malloc; if input arrives while a matching routine is calling
+ malloc, then we're scrod. But Emacs can't just block input while
+ calling matching routines; then we don't notice interrupts when
+ they come in. So, Emacs blocks input around all regexp calls
+ except the matching calls, which it leaves unprotected, in the
+ faith that they will not malloc. */
+
+/* Normally, this is fine. */
+# define MATCH_MAY_ALLOCATE
+
+/* When using GNU C, we are not REALLY using the C alloca, no matter
+ what config.h may say. So don't take precautions for it. */
+# ifdef __GNUC__
+# undef C_ALLOCA
+# endif
+
+/* The match routines may not allocate if (1) they would do it with malloc
+ and (2) it's not safe for them to use malloc.
+ Note that if REL_ALLOC is defined, matching would not use malloc for the
+ failure stack, but we would still use it for the register vectors;
+ so REL_ALLOC should not affect this. */
+# if (defined C_ALLOCA || defined REGEX_MALLOC) && defined emacs
+# undef MATCH_MAY_ALLOCATE
+# endif
+#endif /* not DEFINED_ONCE */
+
+#ifdef INSIDE_RECURSION
+/* Failure stack declarations and macros; both re_compile_fastmap and
+ re_match_2 use a failure stack. These have to be macros because of
+ REGEX_ALLOCATE_STACK. */
+
+
+/* Number of failure points for which to initially allocate space
+ when matching. If this number is exceeded, we allocate more
+ space, so it is not a hard limit. */
+# ifndef INIT_FAILURE_ALLOC
+# define INIT_FAILURE_ALLOC 5
+# endif
+
+/* Roughly the maximum number of failure points on the stack. Would be
+ exactly that if always used MAX_FAILURE_ITEMS items each time we failed.
+ This is a variable only so users of regex can assign to it; we never
+ change it ourselves. */
+
+# ifdef INT_IS_16BIT
+
+# ifndef DEFINED_ONCE
+# if defined MATCH_MAY_ALLOCATE
+/* 4400 was enough to cause a crash on Alpha OSF/1,
+ whose default stack limit is 2mb. */
+long int re_max_failures = 4000;
+# else
+long int re_max_failures = 2000;
+# endif
+# endif
+
+union PREFIX(fail_stack_elt)
+{
+ UCHAR_T *pointer;
+ long int integer;
+};
+
+typedef union PREFIX(fail_stack_elt) PREFIX(fail_stack_elt_t);
+
+typedef struct
+{
+ PREFIX(fail_stack_elt_t) *stack;
+ unsigned long int size;
+ unsigned long int avail; /* Offset of next open position. */
+} PREFIX(fail_stack_type);
+
+# else /* not INT_IS_16BIT */
+
+# ifndef DEFINED_ONCE
+# if defined MATCH_MAY_ALLOCATE
+/* 4400 was enough to cause a crash on Alpha OSF/1,
+ whose default stack limit is 2mb. */
+int re_max_failures = 4000;
+# else
+int re_max_failures = 2000;
+# endif
+# endif
+
+union PREFIX(fail_stack_elt)
+{
+ UCHAR_T *pointer;
+ int integer;
+};
+
+typedef union PREFIX(fail_stack_elt) PREFIX(fail_stack_elt_t);
+
+typedef struct
+{
+ PREFIX(fail_stack_elt_t) *stack;
+ unsigned size;
+ unsigned avail; /* Offset of next open position. */
+} PREFIX(fail_stack_type);
+
+# endif /* INT_IS_16BIT */
+
+# ifndef DEFINED_ONCE
+# define FAIL_STACK_EMPTY() (fail_stack.avail == 0)
+# define FAIL_STACK_PTR_EMPTY() (fail_stack_ptr->avail == 0)
+# define FAIL_STACK_FULL() (fail_stack.avail == fail_stack.size)
+# endif
+
+
+/* Define macros to initialize and free the failure stack.
+ Do `return -2' if the alloc fails. */
+
+# ifdef MATCH_MAY_ALLOCATE
+# define INIT_FAIL_STACK() \
+ do { \
+ fail_stack.stack = (PREFIX(fail_stack_elt_t) *) \
+ REGEX_ALLOCATE_STACK (INIT_FAILURE_ALLOC * sizeof (PREFIX(fail_stack_elt_t))); \
+ \
+ if (fail_stack.stack == NULL) \
+ return -2; \
+ \
+ fail_stack.size = INIT_FAILURE_ALLOC; \
+ fail_stack.avail = 0; \
+ } while (0)
+
+# define RESET_FAIL_STACK() REGEX_FREE_STACK (fail_stack.stack)
+# else
+# define INIT_FAIL_STACK() \
+ do { \
+ fail_stack.avail = 0; \
+ } while (0)
+
+# define RESET_FAIL_STACK()
+# endif
+
+
+/* Double the size of FAIL_STACK, up to approximately `re_max_failures' items.
+
+ Return 1 if succeeds, and 0 if either ran out of memory
+ allocating space for it or it was already too large.
+
+ REGEX_REALLOCATE_STACK requires `destination' be declared. */
+
+# define DOUBLE_FAIL_STACK(fail_stack) \
+ ((fail_stack).size > (unsigned) (re_max_failures * MAX_FAILURE_ITEMS) \
+ ? 0 \
+ : ((fail_stack).stack = (PREFIX(fail_stack_elt_t) *) \
+ REGEX_REALLOCATE_STACK ((fail_stack).stack, \
+ (fail_stack).size * sizeof (PREFIX(fail_stack_elt_t)), \
+ ((fail_stack).size << 1) * sizeof (PREFIX(fail_stack_elt_t))),\
+ \
+ (fail_stack).stack == NULL \
+ ? 0 \
+ : ((fail_stack).size <<= 1, \
+ 1)))
+
+
+/* Push pointer POINTER on FAIL_STACK.
+ Return 1 if was able to do so and 0 if ran out of memory allocating
+ space to do so. */
+# define PUSH_PATTERN_OP(POINTER, FAIL_STACK) \
+ ((FAIL_STACK_FULL () \
+ && !DOUBLE_FAIL_STACK (FAIL_STACK)) \
+ ? 0 \
+ : ((FAIL_STACK).stack[(FAIL_STACK).avail++].pointer = POINTER, \
+ 1))
+
+/* Push a pointer value onto the failure stack.
+ Assumes the variable `fail_stack'. Probably should only
+ be called from within `PUSH_FAILURE_POINT'. */
+# define PUSH_FAILURE_POINTER(item) \
+ fail_stack.stack[fail_stack.avail++].pointer = (UCHAR_T *) (item)
+
+/* This pushes an integer-valued item onto the failure stack.
+ Assumes the variable `fail_stack'. Probably should only
+ be called from within `PUSH_FAILURE_POINT'. */
+# define PUSH_FAILURE_INT(item) \
+ fail_stack.stack[fail_stack.avail++].integer = (item)
+
+/* Push a fail_stack_elt_t value onto the failure stack.
+ Assumes the variable `fail_stack'. Probably should only
+ be called from within `PUSH_FAILURE_POINT'. */
+# define PUSH_FAILURE_ELT(item) \
+ fail_stack.stack[fail_stack.avail++] = (item)
+
+/* These three POP... operations complement the three PUSH... operations.
+ All assume that `fail_stack' is nonempty. */
+# define POP_FAILURE_POINTER() fail_stack.stack[--fail_stack.avail].pointer
+# define POP_FAILURE_INT() fail_stack.stack[--fail_stack.avail].integer
+# define POP_FAILURE_ELT() fail_stack.stack[--fail_stack.avail]
+
+/* Used to omit pushing failure point id's when we're not debugging. */
+# ifdef DEBUG
+# define DEBUG_PUSH PUSH_FAILURE_INT
+# define DEBUG_POP(item_addr) *(item_addr) = POP_FAILURE_INT ()
+# else
+# define DEBUG_PUSH(item)
+# define DEBUG_POP(item_addr)
+# endif
+
+
+/* Push the information about the state we will need
+ if we ever fail back to it.
+
+ Requires variables fail_stack, regstart, regend, reg_info, and
+ num_regs_pushed be declared. DOUBLE_FAIL_STACK requires `destination'
+ be declared.
+
+ Does `return FAILURE_CODE' if runs out of memory. */
+
+# define PUSH_FAILURE_POINT(pattern_place, string_place, failure_code) \
+ do { \
+ char *destination; \
+ /* Must be int, so when we don't save any registers, the arithmetic \
+ of 0 + -1 isn't done as unsigned. */ \
+ /* Can't be int, since there is not a shred of a guarantee that int \
+ is wide enough to hold a value of something to which pointer can \
+ be assigned */ \
+ active_reg_t this_reg; \
+ \
+ DEBUG_STATEMENT (failure_id++); \
+ DEBUG_STATEMENT (nfailure_points_pushed++); \
+ DEBUG_PRINT2 ("\nPUSH_FAILURE_POINT #%u:\n", failure_id); \
+ DEBUG_PRINT2 (" Before push, next avail: %d\n", (fail_stack).avail);\
+ DEBUG_PRINT2 (" size: %d\n", (fail_stack).size);\
+ \
+ DEBUG_PRINT2 (" slots needed: %ld\n", NUM_FAILURE_ITEMS); \
+ DEBUG_PRINT2 (" available: %d\n", REMAINING_AVAIL_SLOTS); \
+ \
+ /* Ensure we have enough space allocated for what we will push. */ \
+ while (REMAINING_AVAIL_SLOTS < NUM_FAILURE_ITEMS) \
+ { \
+ if (!DOUBLE_FAIL_STACK (fail_stack)) \
+ return failure_code; \
+ \
+ DEBUG_PRINT2 ("\n Doubled stack; size now: %d\n", \
+ (fail_stack).size); \
+ DEBUG_PRINT2 (" slots available: %d\n", REMAINING_AVAIL_SLOTS);\
+ } \
+ \
+ /* Push the info, starting with the registers. */ \
+ DEBUG_PRINT1 ("\n"); \
+ \
+ if (1) \
+ for (this_reg = lowest_active_reg; this_reg <= highest_active_reg; \
+ this_reg++) \
+ { \
+ DEBUG_PRINT2 (" Pushing reg: %lu\n", this_reg); \
+ DEBUG_STATEMENT (num_regs_pushed++); \
+ \
+ DEBUG_PRINT2 (" start: %p\n", regstart[this_reg]); \
+ PUSH_FAILURE_POINTER (regstart[this_reg]); \
+ \
+ DEBUG_PRINT2 (" end: %p\n", regend[this_reg]); \
+ PUSH_FAILURE_POINTER (regend[this_reg]); \
+ \
+ DEBUG_PRINT2 (" info: %p\n ", \
+ reg_info[this_reg].word.pointer); \
+ DEBUG_PRINT2 (" match_null=%d", \
+ REG_MATCH_NULL_STRING_P (reg_info[this_reg])); \
+ DEBUG_PRINT2 (" active=%d", IS_ACTIVE (reg_info[this_reg])); \
+ DEBUG_PRINT2 (" matched_something=%d", \
+ MATCHED_SOMETHING (reg_info[this_reg])); \
+ DEBUG_PRINT2 (" ever_matched=%d", \
+ EVER_MATCHED_SOMETHING (reg_info[this_reg])); \
+ DEBUG_PRINT1 ("\n"); \
+ PUSH_FAILURE_ELT (reg_info[this_reg].word); \
+ } \
+ \
+ DEBUG_PRINT2 (" Pushing low active reg: %ld\n", lowest_active_reg);\
+ PUSH_FAILURE_INT (lowest_active_reg); \
+ \
+ DEBUG_PRINT2 (" Pushing high active reg: %ld\n", highest_active_reg);\
+ PUSH_FAILURE_INT (highest_active_reg); \
+ \
+ DEBUG_PRINT2 (" Pushing pattern %p:\n", pattern_place); \
+ DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend); \
+ PUSH_FAILURE_POINTER (pattern_place); \
+ \
+ DEBUG_PRINT2 (" Pushing string %p: `", string_place); \
+ DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, \
+ size2); \
+ DEBUG_PRINT1 ("'\n"); \
+ PUSH_FAILURE_POINTER (string_place); \
+ \
+ DEBUG_PRINT2 (" Pushing failure id: %u\n", failure_id); \
+ DEBUG_PUSH (failure_id); \
+ } while (0)
+
+# ifndef DEFINED_ONCE
+/* This is the number of items that are pushed and popped on the stack
+ for each register. */
+# define NUM_REG_ITEMS 3
+
+/* Individual items aside from the registers. */
+# ifdef DEBUG
+# define NUM_NONREG_ITEMS 5 /* Includes failure point id. */
+# else
+# define NUM_NONREG_ITEMS 4
+# endif
+
+/* We push at most this many items on the stack. */
+/* We used to use (num_regs - 1), which is the number of registers
+ this regexp will save; but that was changed to 5
+ to avoid stack overflow for a regexp with lots of parens. */
+# define MAX_FAILURE_ITEMS (5 * NUM_REG_ITEMS + NUM_NONREG_ITEMS)
+
+/* We actually push this many items. */
+# define NUM_FAILURE_ITEMS \
+ (((0 \
+ ? 0 : highest_active_reg - lowest_active_reg + 1) \
+ * NUM_REG_ITEMS) \
+ + NUM_NONREG_ITEMS)
+
+/* How many items can still be added to the stack without overflowing it. */
+# define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail)
+# endif /* not DEFINED_ONCE */
+
+
+/* Pops what PUSH_FAIL_STACK pushes.
+
+ We restore into the parameters, all of which should be lvalues:
+ STR -- the saved data position.
+ PAT -- the saved pattern position.
+ LOW_REG, HIGH_REG -- the highest and lowest active registers.
+ REGSTART, REGEND -- arrays of string positions.
+ REG_INFO -- array of information about each subexpression.
+
+ Also assumes the variables `fail_stack' and (if debugging), `bufp',
+ `pend', `string1', `size1', `string2', and `size2'. */
+# define POP_FAILURE_POINT(str, pat, low_reg, high_reg, regstart, regend, reg_info)\
+{ \
+ DEBUG_STATEMENT (unsigned failure_id;) \
+ active_reg_t this_reg; \
+ const UCHAR_T *string_temp; \
+ \
+ assert (!FAIL_STACK_EMPTY ()); \
+ \
+ /* Remove failure points and point to how many regs pushed. */ \
+ DEBUG_PRINT1 ("POP_FAILURE_POINT:\n"); \
+ DEBUG_PRINT2 (" Before pop, next avail: %d\n", fail_stack.avail); \
+ DEBUG_PRINT2 (" size: %d\n", fail_stack.size); \
+ \
+ assert (fail_stack.avail >= NUM_NONREG_ITEMS); \
+ \
+ DEBUG_POP (&failure_id); \
+ DEBUG_PRINT2 (" Popping failure id: %u\n", failure_id); \
+ \
+ /* If the saved string location is NULL, it came from an \
+ on_failure_keep_string_jump opcode, and we want to throw away the \
+ saved NULL, thus retaining our current position in the string. */ \
+ string_temp = POP_FAILURE_POINTER (); \
+ if (string_temp != NULL) \
+ str = (const CHAR_T *) string_temp; \
+ \
+ DEBUG_PRINT2 (" Popping string %p: `", str); \
+ DEBUG_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2); \
+ DEBUG_PRINT1 ("'\n"); \
+ \
+ pat = (UCHAR_T *) POP_FAILURE_POINTER (); \
+ DEBUG_PRINT2 (" Popping pattern %p:\n", pat); \
+ DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend); \
+ \
+ /* Restore register info. */ \
+ high_reg = (active_reg_t) POP_FAILURE_INT (); \
+ DEBUG_PRINT2 (" Popping high active reg: %ld\n", high_reg); \
+ \
+ low_reg = (active_reg_t) POP_FAILURE_INT (); \
+ DEBUG_PRINT2 (" Popping low active reg: %ld\n", low_reg); \
+ \
+ if (1) \
+ for (this_reg = high_reg; this_reg >= low_reg; this_reg--) \
+ { \
+ DEBUG_PRINT2 (" Popping reg: %ld\n", this_reg); \
+ \
+ reg_info[this_reg].word = POP_FAILURE_ELT (); \
+ DEBUG_PRINT2 (" info: %p\n", \
+ reg_info[this_reg].word.pointer); \
+ \
+ regend[this_reg] = (const CHAR_T *) POP_FAILURE_POINTER (); \
+ DEBUG_PRINT2 (" end: %p\n", regend[this_reg]); \
+ \
+ regstart[this_reg] = (const CHAR_T *) POP_FAILURE_POINTER (); \
+ DEBUG_PRINT2 (" start: %p\n", regstart[this_reg]); \
+ } \
+ else \
+ { \
+ for (this_reg = highest_active_reg; this_reg > high_reg; this_reg--) \
+ { \
+ reg_info[this_reg].word.integer = 0; \
+ regend[this_reg] = 0; \
+ regstart[this_reg] = 0; \
+ } \
+ highest_active_reg = high_reg; \
+ } \
+ \
+ set_regs_matched_done = 0; \
+ DEBUG_STATEMENT (nfailure_points_popped++); \
+} /* POP_FAILURE_POINT */
+
+/* Structure for per-register (a.k.a. per-group) information.
+ Other register information, such as the
+ starting and ending positions (which are addresses), and the list of
+ inner groups (which is a bits list) are maintained in separate
+ variables.
+
+ We are making a (strictly speaking) nonportable assumption here: that
+ the compiler will pack our bit fields into something that fits into
+ the type of `word', i.e., is something that fits into one item on the
+ failure stack. */
+
+
+/* Declarations and macros for re_match_2. */
+
+typedef union
+{
+ PREFIX(fail_stack_elt_t) word;
+ struct
+ {
+ /* This field is one if this group can match the empty string,
+ zero if not. If not yet determined, `MATCH_NULL_UNSET_VALUE'. */
+# define MATCH_NULL_UNSET_VALUE 3
+ unsigned match_null_string_p : 2;
+ unsigned is_active : 1;
+ unsigned matched_something : 1;
+ unsigned ever_matched_something : 1;
+ } bits;
+} PREFIX(register_info_type);
+
+# ifndef DEFINED_ONCE
+# define REG_MATCH_NULL_STRING_P(R) ((R).bits.match_null_string_p)
+# define IS_ACTIVE(R) ((R).bits.is_active)
+# define MATCHED_SOMETHING(R) ((R).bits.matched_something)
+# define EVER_MATCHED_SOMETHING(R) ((R).bits.ever_matched_something)
+
+
+/* Call this when have matched a real character; it sets `matched' flags
+ for the subexpressions which we are currently inside. Also records
+ that those subexprs have matched. */
+# define SET_REGS_MATCHED() \
+ do \
+ { \
+ if (!set_regs_matched_done) \
+ { \
+ active_reg_t r; \
+ set_regs_matched_done = 1; \
+ for (r = lowest_active_reg; r <= highest_active_reg; r++) \
+ { \
+ MATCHED_SOMETHING (reg_info[r]) \
+ = EVER_MATCHED_SOMETHING (reg_info[r]) \
+ = 1; \
+ } \
+ } \
+ } \
+ while (0)
+# endif /* not DEFINED_ONCE */
+
+/* Registers are set to a sentinel when they haven't yet matched. */
+static CHAR_T PREFIX(reg_unset_dummy);
+# define REG_UNSET_VALUE (&PREFIX(reg_unset_dummy))
+# define REG_UNSET(e) ((e) == REG_UNSET_VALUE)
+
+/* Subroutine declarations and macros for regex_compile. */
+static void PREFIX(store_op1) _RE_ARGS ((re_opcode_t op, UCHAR_T *loc, int arg));
+static void PREFIX(store_op2) _RE_ARGS ((re_opcode_t op, UCHAR_T *loc,
+ int arg1, int arg2));
+static void PREFIX(insert_op1) _RE_ARGS ((re_opcode_t op, UCHAR_T *loc,
+ int arg, UCHAR_T *end));
+static void PREFIX(insert_op2) _RE_ARGS ((re_opcode_t op, UCHAR_T *loc,
+ int arg1, int arg2, UCHAR_T *end));
+static boolean PREFIX(at_begline_loc_p) _RE_ARGS ((const CHAR_T *pattern,
+ const CHAR_T *p,
+ reg_syntax_t syntax));
+static boolean PREFIX(at_endline_loc_p) _RE_ARGS ((const CHAR_T *p,
+ const CHAR_T *pend,
+ reg_syntax_t syntax));
+# ifdef WCHAR
+static reg_errcode_t wcs_compile_range _RE_ARGS ((CHAR_T range_start,
+ const CHAR_T **p_ptr,
+ const CHAR_T *pend,
+ char *translate,
+ reg_syntax_t syntax,
+ UCHAR_T *b,
+ CHAR_T *char_set));
+static void insert_space _RE_ARGS ((int num, CHAR_T *loc, CHAR_T *end));
+# else /* BYTE */
+static reg_errcode_t byte_compile_range _RE_ARGS ((unsigned int range_start,
+ const char **p_ptr,
+ const char *pend,
+ char *translate,
+ reg_syntax_t syntax,
+ unsigned char *b));
+# endif /* WCHAR */
+
+/* Fetch the next character in the uncompiled pattern---translating it
+ if necessary. Also cast from a signed character in the constant
+ string passed to us by the user to an unsigned char that we can use
+ as an array index (in, e.g., `translate'). */
+/* ifdef MBS_SUPPORT, we translate only if character <= 0xff,
+ because it is impossible to allocate 4GB array for some encodings
+ which have 4 byte character_set like UCS4. */
+# ifndef PATFETCH
+# ifdef WCHAR
+# define PATFETCH(c) \
+ do {if (p == pend) return REG_EEND; \
+ c = (UCHAR_T) *p++; \
+ if (translate && (c <= 0xff)) c = (UCHAR_T) translate[c]; \
+ } while (0)
+# else /* BYTE */
+# define PATFETCH(c) \
+ do {if (p == pend) return REG_EEND; \
+ c = (unsigned char) *p++; \
+ if (translate) c = (unsigned char) translate[c]; \
+ } while (0)
+# endif /* WCHAR */
+# endif
+
+/* Fetch the next character in the uncompiled pattern, with no
+ translation. */
+# define PATFETCH_RAW(c) \
+ do {if (p == pend) return REG_EEND; \
+ c = (UCHAR_T) *p++; \
+ } while (0)
+
+/* Go backwards one character in the pattern. */
+# define PATUNFETCH p--
+
+
+/* If `translate' is non-null, return translate[D], else just D. We
+ cast the subscript to translate because some data is declared as
+ `char *', to avoid warnings when a string constant is passed. But
+ when we use a character as a subscript we must make it unsigned. */
+/* ifdef MBS_SUPPORT, we translate only if character <= 0xff,
+ because it is impossible to allocate 4GB array for some encodings
+ which have 4 byte character_set like UCS4. */
+
+# ifndef TRANSLATE
+# ifdef WCHAR
+# define TRANSLATE(d) \
+ ((translate && ((UCHAR_T) (d)) <= 0xff) \
+ ? (char) translate[(unsigned char) (d)] : (d))
+# else /* BYTE */
+# define TRANSLATE(d) \
+ (translate ? (char) translate[(unsigned char) (d)] : (d))
+# endif /* WCHAR */
+# endif
+
+
+/* Macros for outputting the compiled pattern into `buffer'. */
+
+/* If the buffer isn't allocated when it comes in, use this. */
+# define INIT_BUF_SIZE (32 * sizeof(UCHAR_T))
+
+/* Make sure we have at least N more bytes of space in buffer. */
+# ifdef WCHAR
+# define GET_BUFFER_SPACE(n) \
+ while (((unsigned long)b - (unsigned long)COMPILED_BUFFER_VAR \
+ + (n)*sizeof(CHAR_T)) > bufp->allocated) \
+ EXTEND_BUFFER ()
+# else /* BYTE */
+# define GET_BUFFER_SPACE(n) \
+ while ((unsigned long) (b - bufp->buffer + (n)) > bufp->allocated) \
+ EXTEND_BUFFER ()
+# endif /* WCHAR */
+
+/* Make sure we have one more byte of buffer space and then add C to it. */
+# define BUF_PUSH(c) \
+ do { \
+ GET_BUFFER_SPACE (1); \
+ *b++ = (UCHAR_T) (c); \
+ } while (0)
+
+
+/* Ensure we have two more bytes of buffer space and then append C1 and C2. */
+# define BUF_PUSH_2(c1, c2) \
+ do { \
+ GET_BUFFER_SPACE (2); \
+ *b++ = (UCHAR_T) (c1); \
+ *b++ = (UCHAR_T) (c2); \
+ } while (0)
+
+
+/* As with BUF_PUSH_2, except for three bytes. */
+# define BUF_PUSH_3(c1, c2, c3) \
+ do { \
+ GET_BUFFER_SPACE (3); \
+ *b++ = (UCHAR_T) (c1); \
+ *b++ = (UCHAR_T) (c2); \
+ *b++ = (UCHAR_T) (c3); \
+ } while (0)
+
+/* Store a jump with opcode OP at LOC to location TO. We store a
+ relative address offset by the three bytes the jump itself occupies. */
+# define STORE_JUMP(op, loc, to) \
+ PREFIX(store_op1) (op, loc, (int) ((to) - (loc) - (1 + OFFSET_ADDRESS_SIZE)))
+
+/* Likewise, for a two-argument jump. */
+# define STORE_JUMP2(op, loc, to, arg) \
+ PREFIX(store_op2) (op, loc, (int) ((to) - (loc) - (1 + OFFSET_ADDRESS_SIZE)), arg)
+
+/* Like `STORE_JUMP', but for inserting. Assume `b' is the buffer end. */
+# define INSERT_JUMP(op, loc, to) \
+ PREFIX(insert_op1) (op, loc, (int) ((to) - (loc) - (1 + OFFSET_ADDRESS_SIZE)), b)
+
+/* Like `STORE_JUMP2', but for inserting. Assume `b' is the buffer end. */
+# define INSERT_JUMP2(op, loc, to, arg) \
+ PREFIX(insert_op2) (op, loc, (int) ((to) - (loc) - (1 + OFFSET_ADDRESS_SIZE)),\
+ arg, b)
+
+/* This is not an arbitrary limit: the arguments which represent offsets
+ into the pattern are two bytes long. So if 2^16 bytes turns out to
+ be too small, many things would have to change. */
+/* Any other compiler which, like MSC, has allocation limit below 2^16
+ bytes will have to use approach similar to what was done below for
+ MSC and drop MAX_BUF_SIZE a bit. Otherwise you may end up
+ reallocating to 0 bytes. Such thing is not going to work too well.
+ You have been warned!! */
+# ifndef DEFINED_ONCE
+# if defined _MSC_VER && !defined WIN32
+/* Microsoft C 16-bit versions limit malloc to approx 65512 bytes.
+ The REALLOC define eliminates a flurry of conversion warnings,
+ but is not required. */
+# define MAX_BUF_SIZE 65500L
+# define REALLOC(p,s) realloc ((p), (size_t) (s))
+# else
+# define MAX_BUF_SIZE (1L << 16)
+# define REALLOC(p,s) realloc ((p), (s))
+# endif
+
+/* Extend the buffer by twice its current size via realloc and
+ reset the pointers that pointed into the old block to point to the
+ correct places in the new one. If extending the buffer results in it
+ being larger than MAX_BUF_SIZE, then flag memory exhausted. */
+# if __BOUNDED_POINTERS__
+# define SET_HIGH_BOUND(P) (__ptrhigh (P) = __ptrlow (P) + bufp->allocated)
+# define MOVE_BUFFER_POINTER(P) \
+ (__ptrlow (P) += incr, SET_HIGH_BOUND (P), __ptrvalue (P) += incr)
+# define ELSE_EXTEND_BUFFER_HIGH_BOUND \
+ else \
+ { \
+ SET_HIGH_BOUND (b); \
+ SET_HIGH_BOUND (begalt); \
+ if (fixup_alt_jump) \
+ SET_HIGH_BOUND (fixup_alt_jump); \
+ if (laststart) \
+ SET_HIGH_BOUND (laststart); \
+ if (pending_exact) \
+ SET_HIGH_BOUND (pending_exact); \
+ }
+# else
+# define MOVE_BUFFER_POINTER(P) (P) += incr
+# define ELSE_EXTEND_BUFFER_HIGH_BOUND
+# endif
+# endif /* not DEFINED_ONCE */
+
+# ifdef WCHAR
+# define EXTEND_BUFFER() \
+ do { \
+ UCHAR_T *old_buffer = COMPILED_BUFFER_VAR; \
+ int wchar_count; \
+ if (bufp->allocated + sizeof(UCHAR_T) > MAX_BUF_SIZE) \
+ return REG_ESIZE; \
+ bufp->allocated <<= 1; \
+ if (bufp->allocated > MAX_BUF_SIZE) \
+ bufp->allocated = MAX_BUF_SIZE; \
+ /* How many characters the new buffer can have? */ \
+ wchar_count = bufp->allocated / sizeof(UCHAR_T); \
+ if (wchar_count == 0) wchar_count = 1; \
+ /* Truncate the buffer to CHAR_T align. */ \
+ bufp->allocated = wchar_count * sizeof(UCHAR_T); \
+ RETALLOC (COMPILED_BUFFER_VAR, wchar_count, UCHAR_T); \
+ bufp->buffer = (char*)COMPILED_BUFFER_VAR; \
+ if (COMPILED_BUFFER_VAR == NULL) \
+ return REG_ESPACE; \
+ /* If the buffer moved, move all the pointers into it. */ \
+ if (old_buffer != COMPILED_BUFFER_VAR) \
+ { \
+ int incr = COMPILED_BUFFER_VAR - old_buffer; \
+ MOVE_BUFFER_POINTER (b); \
+ MOVE_BUFFER_POINTER (begalt); \
+ if (fixup_alt_jump) \
+ MOVE_BUFFER_POINTER (fixup_alt_jump); \
+ if (laststart) \
+ MOVE_BUFFER_POINTER (laststart); \
+ if (pending_exact) \
+ MOVE_BUFFER_POINTER (pending_exact); \
+ } \
+ ELSE_EXTEND_BUFFER_HIGH_BOUND \
+ } while (0)
+# else /* BYTE */
+# define EXTEND_BUFFER() \
+ do { \
+ UCHAR_T *old_buffer = COMPILED_BUFFER_VAR; \
+ if (bufp->allocated == MAX_BUF_SIZE) \
+ return REG_ESIZE; \
+ bufp->allocated <<= 1; \
+ if (bufp->allocated > MAX_BUF_SIZE) \
+ bufp->allocated = MAX_BUF_SIZE; \
+ bufp->buffer = (UCHAR_T *) REALLOC (COMPILED_BUFFER_VAR, \
+ bufp->allocated); \
+ if (COMPILED_BUFFER_VAR == NULL) \
+ return REG_ESPACE; \
+ /* If the buffer moved, move all the pointers into it. */ \
+ if (old_buffer != COMPILED_BUFFER_VAR) \
+ { \
+ int incr = COMPILED_BUFFER_VAR - old_buffer; \
+ MOVE_BUFFER_POINTER (b); \
+ MOVE_BUFFER_POINTER (begalt); \
+ if (fixup_alt_jump) \
+ MOVE_BUFFER_POINTER (fixup_alt_jump); \
+ if (laststart) \
+ MOVE_BUFFER_POINTER (laststart); \
+ if (pending_exact) \
+ MOVE_BUFFER_POINTER (pending_exact); \
+ } \
+ ELSE_EXTEND_BUFFER_HIGH_BOUND \
+ } while (0)
+# endif /* WCHAR */
+
+# ifndef DEFINED_ONCE
+/* Since we have one byte reserved for the register number argument to
+ {start,stop}_memory, the maximum number of groups we can report
+ things about is what fits in that byte. */
+# define MAX_REGNUM 255
+
+/* But patterns can have more than `MAX_REGNUM' registers. We just
+ ignore the excess. */
+typedef unsigned regnum_t;
+
+
+/* Macros for the compile stack. */
+
+/* Since offsets can go either forwards or backwards, this type needs to
+ be able to hold values from -(MAX_BUF_SIZE - 1) to MAX_BUF_SIZE - 1. */
+/* int may be not enough when sizeof(int) == 2. */
+typedef long pattern_offset_t;
+
+typedef struct
+{
+ pattern_offset_t begalt_offset;
+ pattern_offset_t fixup_alt_jump;
+ pattern_offset_t inner_group_offset;
+ pattern_offset_t laststart_offset;
+ regnum_t regnum;
+} compile_stack_elt_t;
+
+
+typedef struct
+{
+ compile_stack_elt_t *stack;
+ unsigned size;
+ unsigned avail; /* Offset of next open position. */
+} compile_stack_type;
+
+
+# define INIT_COMPILE_STACK_SIZE 32
+
+# define COMPILE_STACK_EMPTY (compile_stack.avail == 0)
+# define COMPILE_STACK_FULL (compile_stack.avail == compile_stack.size)
+
+/* The next available element. */
+# define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail])
+
+# endif /* not DEFINED_ONCE */
+
+/* Set the bit for character C in a list. */
+# ifndef DEFINED_ONCE
+# define SET_LIST_BIT(c) \
+ (b[((unsigned char) (c)) / BYTEWIDTH] \
+ |= 1 << (((unsigned char) c) % BYTEWIDTH))
+# endif /* DEFINED_ONCE */
+
+/* Get the next unsigned number in the uncompiled pattern. */
+# define GET_UNSIGNED_NUMBER(num) \
+ { \
+ while (p != pend) \
+ { \
+ PATFETCH (c); \
+ if (c < '0' || c > '9') \
+ break; \
+ if (num <= RE_DUP_MAX) \
+ { \
+ if (num < 0) \
+ num = 0; \
+ num = num * 10 + c - '0'; \
+ } \
+ } \
+ }
+
+# ifndef DEFINED_ONCE
+# if defined _LIBC || WIDE_CHAR_SUPPORT
+/* The GNU C library provides support for user-defined character classes
+ and the functions from ISO C amendement 1. */
+# ifdef CHARCLASS_NAME_MAX
+# define CHAR_CLASS_MAX_LENGTH CHARCLASS_NAME_MAX
+# else
+/* This shouldn't happen but some implementation might still have this
+ problem. Use a reasonable default value. */
+# define CHAR_CLASS_MAX_LENGTH 256
+# endif
+
+# ifdef _LIBC
+# define IS_CHAR_CLASS(string) __wctype (string)
+# else
+# define IS_CHAR_CLASS(string) wctype (string)
+# endif
+# else
+# define CHAR_CLASS_MAX_LENGTH 6 /* Namely, `xdigit'. */
+
+# define IS_CHAR_CLASS(string) \
+ (STREQ (string, "alpha") || STREQ (string, "upper") \
+ || STREQ (string, "lower") || STREQ (string, "digit") \
+ || STREQ (string, "alnum") || STREQ (string, "xdigit") \
+ || STREQ (string, "space") || STREQ (string, "print") \
+ || STREQ (string, "punct") || STREQ (string, "graph") \
+ || STREQ (string, "cntrl") || STREQ (string, "blank"))
+# endif
+# endif /* DEFINED_ONCE */
+
+# ifndef MATCH_MAY_ALLOCATE
+
+/* If we cannot allocate large objects within re_match_2_internal,
+ we make the fail stack and register vectors global.
+ The fail stack, we grow to the maximum size when a regexp
+ is compiled.
+ The register vectors, we adjust in size each time we
+ compile a regexp, according to the number of registers it needs. */
+
+static PREFIX(fail_stack_type) fail_stack;
+
+/* Size with which the following vectors are currently allocated.
+ That is so we can make them bigger as needed,
+ but never make them smaller. */
+# ifdef DEFINED_ONCE
+static int regs_allocated_size;
+
+static const char ** regstart, ** regend;
+static const char ** old_regstart, ** old_regend;
+static const char **best_regstart, **best_regend;
+static const char **reg_dummy;
+# endif /* DEFINED_ONCE */
+
+static PREFIX(register_info_type) *PREFIX(reg_info);
+static PREFIX(register_info_type) *PREFIX(reg_info_dummy);
+
+/* Make the register vectors big enough for NUM_REGS registers,
+ but don't make them smaller. */
+
+static void
+PREFIX(regex_grow_registers) (num_regs)
+ int num_regs;
+{
+ if (num_regs > regs_allocated_size)
+ {
+ RETALLOC_IF (regstart, num_regs, const char *);
+ RETALLOC_IF (regend, num_regs, const char *);
+ RETALLOC_IF (old_regstart, num_regs, const char *);
+ RETALLOC_IF (old_regend, num_regs, const char *);
+ RETALLOC_IF (best_regstart, num_regs, const char *);
+ RETALLOC_IF (best_regend, num_regs, const char *);
+ RETALLOC_IF (PREFIX(reg_info), num_regs, PREFIX(register_info_type));
+ RETALLOC_IF (reg_dummy, num_regs, const char *);
+ RETALLOC_IF (PREFIX(reg_info_dummy), num_regs, PREFIX(register_info_type));
+
+ regs_allocated_size = num_regs;
+ }
+}
+
+# endif /* not MATCH_MAY_ALLOCATE */
+
+# ifndef DEFINED_ONCE
+static boolean group_in_compile_stack _RE_ARGS ((compile_stack_type
+ compile_stack,
+ regnum_t regnum));
+# endif /* not DEFINED_ONCE */
+
+/* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX.
+ Returns one of error codes defined in `regex.h', or zero for success.
+
+ Assumes the `allocated' (and perhaps `buffer') and `translate'
+ fields are set in BUFP on entry.
+
+ If it succeeds, results are put in BUFP (if it returns an error, the
+ contents of BUFP are undefined):
+ `buffer' is the compiled pattern;
+ `syntax' is set to SYNTAX;
+ `used' is set to the length of the compiled pattern;
+ `fastmap_accurate' is zero;
+ `re_nsub' is the number of subexpressions in PATTERN;
+ `not_bol' and `not_eol' are zero;
+
+ The `fastmap' and `newline_anchor' fields are neither
+ examined nor set. */
+
+/* Return, freeing storage we allocated. */
+# ifdef WCHAR
+# define FREE_STACK_RETURN(value) \
+ return (free(pattern), free(mbs_offset), free(is_binary), free (compile_stack.stack), value)
+# else
+# define FREE_STACK_RETURN(value) \
+ return (free (compile_stack.stack), value)
+# endif /* WCHAR */
+
+static reg_errcode_t
+PREFIX(regex_compile) (ARG_PREFIX(pattern), ARG_PREFIX(size), syntax, bufp)
+ const char *ARG_PREFIX(pattern);
+ size_t ARG_PREFIX(size);
+ reg_syntax_t syntax;
+ struct re_pattern_buffer *bufp;
+{
+ /* We fetch characters from PATTERN here. Even though PATTERN is
+ `char *' (i.e., signed), we declare these variables as unsigned, so
+ they can be reliably used as array indices. */
+ register UCHAR_T c, c1;
+
+#ifdef WCHAR
+ /* A temporary space to keep wchar_t pattern and compiled pattern. */
+ CHAR_T *pattern, *COMPILED_BUFFER_VAR;
+ size_t size;
+ /* offset buffer for optimization. See convert_mbs_to_wc. */
+ int *mbs_offset = NULL;
+ /* It hold whether each wchar_t is binary data or not. */
+ char *is_binary = NULL;
+ /* A flag whether exactn is handling binary data or not. */
+ char is_exactn_bin = FALSE;
+#endif /* WCHAR */
+
+ /* A random temporary spot in PATTERN. */
+ const CHAR_T *p1;
+
+ /* Points to the end of the buffer, where we should append. */
+ register UCHAR_T *b;
+
+ /* Keeps track of unclosed groups. */
+ compile_stack_type compile_stack;
+
+ /* Points to the current (ending) position in the pattern. */
+#ifdef WCHAR
+ const CHAR_T *p;
+ const CHAR_T *pend;
+#else /* BYTE */
+ const CHAR_T *p = pattern;
+ const CHAR_T *pend = pattern + size;
+#endif /* WCHAR */
+
+ /* How to translate the characters in the pattern. */
+ RE_TRANSLATE_TYPE translate = bufp->translate;
+
+ /* Address of the count-byte of the most recently inserted `exactn'
+ command. This makes it possible to tell if a new exact-match
+ character can be added to that command or if the character requires
+ a new `exactn' command. */
+ UCHAR_T *pending_exact = 0;
+
+ /* Address of start of the most recently finished expression.
+ This tells, e.g., postfix * where to find the start of its
+ operand. Reset at the beginning of groups and alternatives. */
+ UCHAR_T *laststart = 0;
+
+ /* Address of beginning of regexp, or inside of last group. */
+ UCHAR_T *begalt;
+
+ /* Address of the place where a forward jump should go to the end of
+ the containing expression. Each alternative of an `or' -- except the
+ last -- ends with a forward jump of this sort. */
+ UCHAR_T *fixup_alt_jump = 0;
+
+ /* Counts open-groups as they are encountered. Remembered for the
+ matching close-group on the compile stack, so the same register
+ number is put in the stop_memory as the start_memory. */
+ regnum_t regnum = 0;
+
+#ifdef WCHAR
+ /* Initialize the wchar_t PATTERN and offset_buffer. */
+ p = pend = pattern = TALLOC(csize + 1, CHAR_T);
+ mbs_offset = TALLOC(csize + 1, int);
+ is_binary = TALLOC(csize + 1, char);
+ if (pattern == NULL || mbs_offset == NULL || is_binary == NULL)
+ {
+ free(pattern);
+ free(mbs_offset);
+ free(is_binary);
+ return REG_ESPACE;
+ }
+ pattern[csize] = L'\0'; /* sentinel */
+ size = convert_mbs_to_wcs(pattern, cpattern, csize, mbs_offset, is_binary);
+ pend = p + size;
+ if (size < 0)
+ {
+ free(pattern);
+ free(mbs_offset);
+ free(is_binary);
+ return REG_BADPAT;
+ }
+#endif
+
+#ifdef DEBUG
+ DEBUG_PRINT1 ("\nCompiling pattern: ");
+ if (debug)
+ {
+ unsigned debug_count;
+
+ for (debug_count = 0; debug_count < size; debug_count++)
+ PUT_CHAR (pattern[debug_count]);
+ putchar ('\n');
+ }
+#endif /* DEBUG */
+
+ /* Initialize the compile stack. */
+ compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t);
+ if (compile_stack.stack == NULL)
+ {
+#ifdef WCHAR
+ free(pattern);
+ free(mbs_offset);
+ free(is_binary);
+#endif
+ return REG_ESPACE;
+ }
+
+ compile_stack.size = INIT_COMPILE_STACK_SIZE;
+ compile_stack.avail = 0;
+
+ /* Initialize the pattern buffer. */
+ bufp->syntax = syntax;
+ bufp->fastmap_accurate = 0;
+ bufp->not_bol = bufp->not_eol = 0;
+
+ /* Set `used' to zero, so that if we return an error, the pattern
+ printer (for debugging) will think there's no pattern. We reset it
+ at the end. */
+ bufp->used = 0;
+
+ /* Always count groups, whether or not bufp->no_sub is set. */
+ bufp->re_nsub = 0;
+
+#if !defined emacs && !defined SYNTAX_TABLE
+ /* Initialize the syntax table. */
+ init_syntax_once ();
+#endif
+
+ if (bufp->allocated == 0)
+ {
+ if (bufp->buffer)
+ { /* If zero allocated, but buffer is non-null, try to realloc
+ enough space. This loses if buffer's address is bogus, but
+ that is the user's responsibility. */
+#ifdef WCHAR
+ /* Free bufp->buffer and allocate an array for wchar_t pattern
+ buffer. */
+ free(bufp->buffer);
+ COMPILED_BUFFER_VAR = TALLOC (INIT_BUF_SIZE/sizeof(UCHAR_T),
+ UCHAR_T);
+#else
+ RETALLOC (COMPILED_BUFFER_VAR, INIT_BUF_SIZE, UCHAR_T);
+#endif /* WCHAR */
+ }
+ else
+ { /* Caller did not allocate a buffer. Do it for them. */
+ COMPILED_BUFFER_VAR = TALLOC (INIT_BUF_SIZE / sizeof(UCHAR_T),
+ UCHAR_T);
+ }
+
+ if (!COMPILED_BUFFER_VAR) FREE_STACK_RETURN (REG_ESPACE);
+#ifdef WCHAR
+ bufp->buffer = (char*)COMPILED_BUFFER_VAR;
+#endif /* WCHAR */
+ bufp->allocated = INIT_BUF_SIZE;
+ }
+#ifdef WCHAR
+ else
+ COMPILED_BUFFER_VAR = (UCHAR_T*) bufp->buffer;
+#endif
+
+ begalt = b = COMPILED_BUFFER_VAR;
+
+ /* Loop through the uncompiled pattern until we're at the end. */
+ while (p != pend)
+ {
+ PATFETCH (c);
+
+ switch (c)
+ {
+ case '^':
+ {
+ if ( /* If at start of pattern, it's an operator. */
+ p == pattern + 1
+ /* If context independent, it's an operator. */
+ || syntax & RE_CONTEXT_INDEP_ANCHORS
+ /* Otherwise, depends on what's come before. */
+ || PREFIX(at_begline_loc_p) (pattern, p, syntax))
+ BUF_PUSH (begline);
+ else
+ goto normal_char;
+ }
+ break;
+
+
+ case '$':
+ {
+ if ( /* If at end of pattern, it's an operator. */
+ p == pend
+ /* If context independent, it's an operator. */
+ || syntax & RE_CONTEXT_INDEP_ANCHORS
+ /* Otherwise, depends on what's next. */
+ || PREFIX(at_endline_loc_p) (p, pend, syntax))
+ BUF_PUSH (endline);
+ else
+ goto normal_char;
+ }
+ break;
+
+
+ case '+':
+ case '?':
+ if ((syntax & RE_BK_PLUS_QM)
+ || (syntax & RE_LIMITED_OPS))
+ goto normal_char;
+ handle_plus:
+ case '*':
+ /* If there is no previous pattern... */
+ if (!laststart)
+ {
+ if (syntax & RE_CONTEXT_INVALID_OPS)
+ FREE_STACK_RETURN (REG_BADRPT);
+ else if (!(syntax & RE_CONTEXT_INDEP_OPS))
+ goto normal_char;
+ }
+
+ {
+ /* Are we optimizing this jump? */
+ boolean keep_string_p = false;
+
+ /* 1 means zero (many) matches is allowed. */
+ char zero_times_ok = 0, many_times_ok = 0;
+
+ /* If there is a sequence of repetition chars, collapse it
+ down to just one (the right one). We can't combine
+ interval operators with these because of, e.g., `a{2}*',
+ which should only match an even number of `a's. */
+
+ for (;;)
+ {
+ zero_times_ok |= c != '+';
+ many_times_ok |= c != '?';
+
+ if (p == pend)
+ break;
+
+ PATFETCH (c);
+
+ if (c == '*'
+ || (!(syntax & RE_BK_PLUS_QM) && (c == '+' || c == '?')))
+ ;
+
+ else if (syntax & RE_BK_PLUS_QM && c == '\\')
+ {
+ if (p == pend) FREE_STACK_RETURN (REG_EESCAPE);
+
+ PATFETCH (c1);
+ if (!(c1 == '+' || c1 == '?'))
+ {
+ PATUNFETCH;
+ PATUNFETCH;
+ break;
+ }
+
+ c = c1;
+ }
+ else
+ {
+ PATUNFETCH;
+ break;
+ }
+
+ /* If we get here, we found another repeat character. */
+ }
+
+ /* Star, etc. applied to an empty pattern is equivalent
+ to an empty pattern. */
+ if (!laststart)
+ break;
+
+ /* Now we know whether or not zero matches is allowed
+ and also whether or not two or more matches is allowed. */
+ if (many_times_ok)
+ { /* More than one repetition is allowed, so put in at the
+ end a backward relative jump from `b' to before the next
+ jump we're going to put in below (which jumps from
+ laststart to after this jump).
+
+ But if we are at the `*' in the exact sequence `.*\n',
+ insert an unconditional jump backwards to the .,
+ instead of the beginning of the loop. This way we only
+ push a failure point once, instead of every time
+ through the loop. */
+ assert (p - 1 > pattern);
+
+ /* Allocate the space for the jump. */
+ GET_BUFFER_SPACE (1 + OFFSET_ADDRESS_SIZE);
+
+ /* We know we are not at the first character of the pattern,
+ because laststart was nonzero. And we've already
+ incremented `p', by the way, to be the character after
+ the `*'. Do we have to do something analogous here
+ for null bytes, because of RE_DOT_NOT_NULL? */
+ if (TRANSLATE (*(p - 2)) == TRANSLATE ('.')
+ && zero_times_ok
+ && p < pend && TRANSLATE (*p) == TRANSLATE ('\n')
+ && !(syntax & RE_DOT_NEWLINE))
+ { /* We have .*\n. */
+ STORE_JUMP (jump, b, laststart);
+ keep_string_p = true;
+ }
+ else
+ /* Anything else. */
+ STORE_JUMP (maybe_pop_jump, b, laststart -
+ (1 + OFFSET_ADDRESS_SIZE));
+
+ /* We've added more stuff to the buffer. */
+ b += 1 + OFFSET_ADDRESS_SIZE;
+ }
+
+ /* On failure, jump from laststart to b + 3, which will be the
+ end of the buffer after this jump is inserted. */
+ /* ifdef WCHAR, 'b + 1 + OFFSET_ADDRESS_SIZE' instead of
+ 'b + 3'. */
+ GET_BUFFER_SPACE (1 + OFFSET_ADDRESS_SIZE);
+ INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump
+ : on_failure_jump,
+ laststart, b + 1 + OFFSET_ADDRESS_SIZE);
+ pending_exact = 0;
+ b += 1 + OFFSET_ADDRESS_SIZE;
+
+ if (!zero_times_ok)
+ {
+ /* At least one repetition is required, so insert a
+ `dummy_failure_jump' before the initial
+ `on_failure_jump' instruction of the loop. This
+ effects a skip over that instruction the first time
+ we hit that loop. */
+ GET_BUFFER_SPACE (1 + OFFSET_ADDRESS_SIZE);
+ INSERT_JUMP (dummy_failure_jump, laststart, laststart +
+ 2 + 2 * OFFSET_ADDRESS_SIZE);
+ b += 1 + OFFSET_ADDRESS_SIZE;
+ }
+ }
+ break;
+
+
+ case '.':
+ laststart = b;
+ BUF_PUSH (anychar);
+ break;
+
+
+ case '[':
+ {
+ boolean had_char_class = false;
+#ifdef WCHAR
+ CHAR_T range_start = 0xffffffff;
+#else
+ unsigned int range_start = 0xffffffff;
+#endif
+ if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
+
+#ifdef WCHAR
+ /* We assume a charset(_not) structure as a wchar_t array.
+ charset[0] = (re_opcode_t) charset(_not)
+ charset[1] = l (= length of char_classes)
+ charset[2] = m (= length of collating_symbols)
+ charset[3] = n (= length of equivalence_classes)
+ charset[4] = o (= length of char_ranges)
+ charset[5] = p (= length of chars)
+
+ charset[6] = char_class (wctype_t)
+ charset[6+CHAR_CLASS_SIZE] = char_class (wctype_t)
+ ...
+ charset[l+5] = char_class (wctype_t)
+
+ charset[l+6] = collating_symbol (wchar_t)
+ ...
+ charset[l+m+5] = collating_symbol (wchar_t)
+ ifdef _LIBC we use the index if
+ _NL_COLLATE_SYMB_EXTRAMB instead of
+ wchar_t string.
+
+ charset[l+m+6] = equivalence_classes (wchar_t)
+ ...
+ charset[l+m+n+5] = equivalence_classes (wchar_t)
+ ifdef _LIBC we use the index in
+ _NL_COLLATE_WEIGHT instead of
+ wchar_t string.
+
+ charset[l+m+n+6] = range_start
+ charset[l+m+n+7] = range_end
+ ...
+ charset[l+m+n+2o+4] = range_start
+ charset[l+m+n+2o+5] = range_end
+ ifdef _LIBC we use the value looked up
+ in _NL_COLLATE_COLLSEQ instead of
+ wchar_t character.
+
+ charset[l+m+n+2o+6] = char
+ ...
+ charset[l+m+n+2o+p+5] = char
+
+ */
+
+ /* We need at least 6 spaces: the opcode, the length of
+ char_classes, the length of collating_symbols, the length of
+ equivalence_classes, the length of char_ranges, the length of
+ chars. */
+ GET_BUFFER_SPACE (6);
+
+ /* Save b as laststart. And We use laststart as the pointer
+ to the first element of the charset here.
+ In other words, laststart[i] indicates charset[i]. */
+ laststart = b;
+
+ /* We test `*p == '^' twice, instead of using an if
+ statement, so we only need one BUF_PUSH. */
+ BUF_PUSH (*p == '^' ? charset_not : charset);
+ if (*p == '^')
+ p++;
+
+ /* Push the length of char_classes, the length of
+ collating_symbols, the length of equivalence_classes, the
+ length of char_ranges and the length of chars. */
+ BUF_PUSH_3 (0, 0, 0);
+ BUF_PUSH_2 (0, 0);
+
+ /* Remember the first position in the bracket expression. */
+ p1 = p;
+
+ /* charset_not matches newline according to a syntax bit. */
+ if ((re_opcode_t) b[-6] == charset_not
+ && (syntax & RE_HAT_LISTS_NOT_NEWLINE))
+ {
+ BUF_PUSH('\n');
+ laststart[5]++; /* Update the length of characters */
+ }
+
+ /* Read in characters and ranges, setting map bits. */
+ for (;;)
+ {
+ if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
+
+ PATFETCH (c);
+
+ /* \ might escape characters inside [...] and [^...]. */
+ if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\')
+ {
+ if (p == pend) FREE_STACK_RETURN (REG_EESCAPE);
+
+ PATFETCH (c1);
+ BUF_PUSH(c1);
+ laststart[5]++; /* Update the length of chars */
+ range_start = c1;
+ continue;
+ }
+
+ /* Could be the end of the bracket expression. If it's
+ not (i.e., when the bracket expression is `[]' so
+ far), the ']' character bit gets set way below. */
+ if (c == ']' && p != p1 + 1)
+ break;
+
+ /* Look ahead to see if it's a range when the last thing
+ was a character class. */
+ if (had_char_class && c == '-' && *p != ']')
+ FREE_STACK_RETURN (REG_ERANGE);
+
+ /* Look ahead to see if it's a range when the last thing
+ was a character: if this is a hyphen not at the
+ beginning or the end of a list, then it's the range
+ operator. */
+ if (c == '-'
+ && !(p - 2 >= pattern && p[-2] == '[')
+ && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^')
+ && *p != ']')
+ {
+ reg_errcode_t ret;
+ /* Allocate the space for range_start and range_end. */
+ GET_BUFFER_SPACE (2);
+ /* Update the pointer to indicate end of buffer. */
+ b += 2;
+ ret = wcs_compile_range (range_start, &p, pend, translate,
+ syntax, b, laststart);
+ if (ret != REG_NOERROR) FREE_STACK_RETURN (ret);
+ range_start = 0xffffffff;
+ }
+ else if (p[0] == '-' && p[1] != ']')
+ { /* This handles ranges made up of characters only. */
+ reg_errcode_t ret;
+
+ /* Move past the `-'. */
+ PATFETCH (c1);
+ /* Allocate the space for range_start and range_end. */
+ GET_BUFFER_SPACE (2);
+ /* Update the pointer to indicate end of buffer. */
+ b += 2;
+ ret = wcs_compile_range (c, &p, pend, translate, syntax, b,
+ laststart);
+ if (ret != REG_NOERROR) FREE_STACK_RETURN (ret);
+ range_start = 0xffffffff;
+ }
+
+ /* See if we're at the beginning of a possible character
+ class. */
+ else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':')
+ { /* Leave room for the null. */
+ char str[CHAR_CLASS_MAX_LENGTH + 1];
+
+ PATFETCH (c);
+ c1 = 0;
+
+ /* If pattern is `[[:'. */
+ if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
+
+ for (;;)
+ {
+ PATFETCH (c);
+ if ((c == ':' && *p == ']') || p == pend)
+ break;
+ if (c1 < CHAR_CLASS_MAX_LENGTH)
+ str[c1++] = c;
+ else
+ /* This is in any case an invalid class name. */
+ str[0] = '\0';
+ }
+ str[c1] = '\0';
+
+ /* If isn't a word bracketed by `[:' and `:]':
+ undo the ending character, the letters, and leave
+ the leading `:' and `[' (but store them as character). */
+ if (c == ':' && *p == ']')
+ {
+ wctype_t wt;
+ uintptr_t alignedp;
+
+ /* Query the character class as wctype_t. */
+ wt = IS_CHAR_CLASS (str);
+ if (wt == 0)
+ FREE_STACK_RETURN (REG_ECTYPE);
+
+ /* Throw away the ] at the end of the character
+ class. */
+ PATFETCH (c);
+
+ if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
+
+ /* Allocate the space for character class. */
+ GET_BUFFER_SPACE(CHAR_CLASS_SIZE);
+ /* Update the pointer to indicate end of buffer. */
+ b += CHAR_CLASS_SIZE;
+ /* Move data which follow character classes
+ not to violate the data. */
+ insert_space(CHAR_CLASS_SIZE,
+ laststart + 6 + laststart[1],
+ b - 1);
+ alignedp = ((uintptr_t)(laststart + 6 + laststart[1])
+ + __alignof__(wctype_t) - 1)
+ & ~(uintptr_t)(__alignof__(wctype_t) - 1);
+ /* Store the character class. */
+ *((wctype_t*)alignedp) = wt;
+ /* Update length of char_classes */
+ laststart[1] += CHAR_CLASS_SIZE;
+
+ had_char_class = true;
+ }
+ else
+ {
+ c1++;
+ while (c1--)
+ PATUNFETCH;
+ BUF_PUSH ('[');
+ BUF_PUSH (':');
+ laststart[5] += 2; /* Update the length of characters */
+ range_start = ':';
+ had_char_class = false;
+ }
+ }
+ else if (syntax & RE_CHAR_CLASSES && c == '[' && (*p == '='
+ || *p == '.'))
+ {
+ CHAR_T str[128]; /* Should be large enough. */
+ CHAR_T delim = *p; /* '=' or '.' */
+# ifdef _LIBC
+ uint32_t nrules =
+ _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+# endif
+ PATFETCH (c);
+ c1 = 0;
+
+ /* If pattern is `[[=' or '[[.'. */
+ if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
+
+ for (;;)
+ {
+ PATFETCH (c);
+ if ((c == delim && *p == ']') || p == pend)
+ break;
+ if (c1 < sizeof (str) - 1)
+ str[c1++] = c;
+ else
+ /* This is in any case an invalid class name. */
+ str[0] = '\0';
+ }
+ str[c1] = '\0';
+
+ if (c == delim && *p == ']' && str[0] != '\0')
+ {
+ unsigned int i, offset;
+ /* If we have no collation data we use the default
+ collation in which each character is in a class
+ by itself. It also means that ASCII is the
+ character set and therefore we cannot have character
+ with more than one byte in the multibyte
+ representation. */
+
+ /* If not defined _LIBC, we push the name and
+ `\0' for the sake of matching performance. */
+ int datasize = c1 + 1;
+
+# ifdef _LIBC
+ int32_t idx = 0;
+ if (nrules == 0)
+# endif
+ {
+ if (c1 != 1)
+ FREE_STACK_RETURN (REG_ECOLLATE);
+ }
+# ifdef _LIBC
+ else
+ {
+ const int32_t *table;
+ const int32_t *weights;
+ const int32_t *extra;
+ const int32_t *indirect;
+ wint_t *cp;
+
+ /* This #include defines a local function! */
+# include <locale/weightwc.h>
+
+ if(delim == '=')
+ {
+ /* We push the index for equivalence class. */
+ cp = (wint_t*)str;
+
+ table = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_TABLEWC);
+ weights = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_WEIGHTWC);
+ extra = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_EXTRAWC);
+ indirect = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_INDIRECTWC);
+
+ idx = findidx ((const wint_t**)&cp);
+ if (idx == 0 || cp < (wint_t*) str + c1)
+ /* This is no valid character. */
+ FREE_STACK_RETURN (REG_ECOLLATE);
+
+ str[0] = (wchar_t)idx;
+ }
+ else /* delim == '.' */
+ {
+ /* We push collation sequence value
+ for collating symbol. */
+ int32_t table_size;
+ const int32_t *symb_table;
+ const unsigned char *extra;
+ int32_t idx;
+ int32_t elem;
+ int32_t second;
+ int32_t hash;
+ char char_str[c1];
+
+ /* We have to convert the name to a single-byte
+ string. This is possible since the names
+ consist of ASCII characters and the internal
+ representation is UCS4. */
+ for (i = 0; i < c1; ++i)
+ char_str[i] = str[i];
+
+ table_size =
+ _NL_CURRENT_WORD (LC_COLLATE,
+ _NL_COLLATE_SYMB_HASH_SIZEMB);
+ symb_table = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_SYMB_TABLEMB);
+ extra = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_SYMB_EXTRAMB);
+
+ /* Locate the character in the hashing table. */
+ hash = elem_hash (char_str, c1);
+
+ idx = 0;
+ elem = hash % table_size;
+ second = hash % (table_size - 2);
+ while (symb_table[2 * elem] != 0)
+ {
+ /* First compare the hashing value. */
+ if (symb_table[2 * elem] == hash
+ && c1 == extra[symb_table[2 * elem + 1]]
+ && memcmp (char_str,
+ &extra[symb_table[2 * elem + 1]
+ + 1], c1) == 0)
+ {
+ /* Yep, this is the entry. */
+ idx = symb_table[2 * elem + 1];
+ idx += 1 + extra[idx];
+ break;
+ }
+
+ /* Next entry. */
+ elem += second;
+ }
+
+ if (symb_table[2 * elem] != 0)
+ {
+ /* Compute the index of the byte sequence
+ in the table. */
+ idx += 1 + extra[idx];
+ /* Adjust for the alignment. */
+ idx = (idx + 3) & ~3;
+
+ str[0] = (wchar_t) idx + 4;
+ }
+ else if (symb_table[2 * elem] == 0 && c1 == 1)
+ {
+ /* No valid character. Match it as a
+ single byte character. */
+ had_char_class = false;
+ BUF_PUSH(str[0]);
+ /* Update the length of characters */
+ laststart[5]++;
+ range_start = str[0];
+
+ /* Throw away the ] at the end of the
+ collating symbol. */
+ PATFETCH (c);
+ /* exit from the switch block. */
+ continue;
+ }
+ else
+ FREE_STACK_RETURN (REG_ECOLLATE);
+ }
+ datasize = 1;
+ }
+# endif
+ /* Throw away the ] at the end of the equivalence
+ class (or collating symbol). */
+ PATFETCH (c);
+
+ /* Allocate the space for the equivalence class
+ (or collating symbol) (and '\0' if needed). */
+ GET_BUFFER_SPACE(datasize);
+ /* Update the pointer to indicate end of buffer. */
+ b += datasize;
+
+ if (delim == '=')
+ { /* equivalence class */
+ /* Calculate the offset of char_ranges,
+ which is next to equivalence_classes. */
+ offset = laststart[1] + laststart[2]
+ + laststart[3] +6;
+ /* Insert space. */
+ insert_space(datasize, laststart + offset, b - 1);
+
+ /* Write the equivalence_class and \0. */
+ for (i = 0 ; i < datasize ; i++)
+ laststart[offset + i] = str[i];
+
+ /* Update the length of equivalence_classes. */
+ laststart[3] += datasize;
+ had_char_class = true;
+ }
+ else /* delim == '.' */
+ { /* collating symbol */
+ /* Calculate the offset of the equivalence_classes,
+ which is next to collating_symbols. */
+ offset = laststart[1] + laststart[2] + 6;
+ /* Insert space and write the collationg_symbol
+ and \0. */
+ insert_space(datasize, laststart + offset, b-1);
+ for (i = 0 ; i < datasize ; i++)
+ laststart[offset + i] = str[i];
+
+ /* In re_match_2_internal if range_start < -1, we
+ assume -range_start is the offset of the
+ collating symbol which is specified as
+ the character of the range start. So we assign
+ -(laststart[1] + laststart[2] + 6) to
+ range_start. */
+ range_start = -(laststart[1] + laststart[2] + 6);
+ /* Update the length of collating_symbol. */
+ laststart[2] += datasize;
+ had_char_class = false;
+ }
+ }
+ else
+ {
+ c1++;
+ while (c1--)
+ PATUNFETCH;
+ BUF_PUSH ('[');
+ BUF_PUSH (delim);
+ laststart[5] += 2; /* Update the length of characters */
+ range_start = delim;
+ had_char_class = false;
+ }
+ }
+ else
+ {
+ had_char_class = false;
+ BUF_PUSH(c);
+ laststart[5]++; /* Update the length of characters */
+ range_start = c;
+ }
+ }
+
+#else /* BYTE */
+ /* Ensure that we have enough space to push a charset: the
+ opcode, the length count, and the bitset; 34 bytes in all. */
+ GET_BUFFER_SPACE (34);
+
+ laststart = b;
+
+ /* We test `*p == '^' twice, instead of using an if
+ statement, so we only need one BUF_PUSH. */
+ BUF_PUSH (*p == '^' ? charset_not : charset);
+ if (*p == '^')
+ p++;
+
+ /* Remember the first position in the bracket expression. */
+ p1 = p;
+
+ /* Push the number of bytes in the bitmap. */
+ BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH);
+
+ /* Clear the whole map. */
+ bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH);
+
+ /* charset_not matches newline according to a syntax bit. */
+ if ((re_opcode_t) b[-2] == charset_not
+ && (syntax & RE_HAT_LISTS_NOT_NEWLINE))
+ SET_LIST_BIT ('\n');
+
+ /* Read in characters and ranges, setting map bits. */
+ for (;;)
+ {
+ if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
+
+ PATFETCH (c);
+
+ /* \ might escape characters inside [...] and [^...]. */
+ if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\')
+ {
+ if (p == pend) FREE_STACK_RETURN (REG_EESCAPE);
+
+ PATFETCH (c1);
+ SET_LIST_BIT (c1);
+ range_start = c1;
+ continue;
+ }
+
+ /* Could be the end of the bracket expression. If it's
+ not (i.e., when the bracket expression is `[]' so
+ far), the ']' character bit gets set way below. */
+ if (c == ']' && p != p1 + 1)
+ break;
+
+ /* Look ahead to see if it's a range when the last thing
+ was a character class. */
+ if (had_char_class && c == '-' && *p != ']')
+ FREE_STACK_RETURN (REG_ERANGE);
+
+ /* Look ahead to see if it's a range when the last thing
+ was a character: if this is a hyphen not at the
+ beginning or the end of a list, then it's the range
+ operator. */
+ if (c == '-'
+ && !(p - 2 >= pattern && p[-2] == '[')
+ && !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^')
+ && *p != ']')
+ {
+ reg_errcode_t ret
+ = byte_compile_range (range_start, &p, pend, translate,
+ syntax, b);
+ if (ret != REG_NOERROR) FREE_STACK_RETURN (ret);
+ range_start = 0xffffffff;
+ }
+
+ else if (p[0] == '-' && p[1] != ']')
+ { /* This handles ranges made up of characters only. */
+ reg_errcode_t ret;
+
+ /* Move past the `-'. */
+ PATFETCH (c1);
+
+ ret = byte_compile_range (c, &p, pend, translate, syntax, b);
+ if (ret != REG_NOERROR) FREE_STACK_RETURN (ret);
+ range_start = 0xffffffff;
+ }
+
+ /* See if we're at the beginning of a possible character
+ class. */
+
+ else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':')
+ { /* Leave room for the null. */
+ char str[CHAR_CLASS_MAX_LENGTH + 1];
+
+ PATFETCH (c);
+ c1 = 0;
+
+ /* If pattern is `[[:'. */
+ if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
+
+ for (;;)
+ {
+ PATFETCH (c);
+ if ((c == ':' && *p == ']') || p == pend)
+ break;
+ if (c1 < CHAR_CLASS_MAX_LENGTH)
+ str[c1++] = c;
+ else
+ /* This is in any case an invalid class name. */
+ str[0] = '\0';
+ }
+ str[c1] = '\0';
+
+ /* If isn't a word bracketed by `[:' and `:]':
+ undo the ending character, the letters, and leave
+ the leading `:' and `[' (but set bits for them). */
+ if (c == ':' && *p == ']')
+ {
+# if defined _LIBC || WIDE_CHAR_SUPPORT
+ boolean is_lower = STREQ (str, "lower");
+ boolean is_upper = STREQ (str, "upper");
+ wctype_t wt;
+ int ch;
+
+ wt = IS_CHAR_CLASS (str);
+ if (wt == 0)
+ FREE_STACK_RETURN (REG_ECTYPE);
+
+ /* Throw away the ] at the end of the character
+ class. */
+ PATFETCH (c);
+
+ if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
+
+ for (ch = 0; ch < 1 << BYTEWIDTH; ++ch)
+ {
+# ifdef _LIBC
+ if (__iswctype (__btowc (ch), wt))
+ SET_LIST_BIT (ch);
+# else
+ if (iswctype (btowc (ch), wt))
+ SET_LIST_BIT (ch);
+# endif
+
+ if (translate && (is_upper || is_lower)
+ && (ISUPPER (ch) || ISLOWER (ch)))
+ SET_LIST_BIT (ch);
+ }
+
+ had_char_class = true;
+# else
+ int ch;
+ boolean is_alnum = STREQ (str, "alnum");
+ boolean is_alpha = STREQ (str, "alpha");
+ boolean is_blank = STREQ (str, "blank");
+ boolean is_cntrl = STREQ (str, "cntrl");
+ boolean is_digit = STREQ (str, "digit");
+ boolean is_graph = STREQ (str, "graph");
+ boolean is_lower = STREQ (str, "lower");
+ boolean is_print = STREQ (str, "print");
+ boolean is_punct = STREQ (str, "punct");
+ boolean is_space = STREQ (str, "space");
+ boolean is_upper = STREQ (str, "upper");
+ boolean is_xdigit = STREQ (str, "xdigit");
+
+ if (!IS_CHAR_CLASS (str))
+ FREE_STACK_RETURN (REG_ECTYPE);
+
+ /* Throw away the ] at the end of the character
+ class. */
+ PATFETCH (c);
+
+ if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
+
+ for (ch = 0; ch < 1 << BYTEWIDTH; ch++)
+ {
+ /* This was split into 3 if's to
+ avoid an arbitrary limit in some compiler. */
+ if ( (is_alnum && ISALNUM (ch))
+ || (is_alpha && ISALPHA (ch))
+ || (is_blank && ISBLANK (ch))
+ || (is_cntrl && ISCNTRL (ch)))
+ SET_LIST_BIT (ch);
+ if ( (is_digit && ISDIGIT (ch))
+ || (is_graph && ISGRAPH (ch))
+ || (is_lower && ISLOWER (ch))
+ || (is_print && ISPRINT (ch)))
+ SET_LIST_BIT (ch);
+ if ( (is_punct && ISPUNCT (ch))
+ || (is_space && ISSPACE (ch))
+ || (is_upper && ISUPPER (ch))
+ || (is_xdigit && ISXDIGIT (ch)))
+ SET_LIST_BIT (ch);
+ if ( translate && (is_upper || is_lower)
+ && (ISUPPER (ch) || ISLOWER (ch)))
+ SET_LIST_BIT (ch);
+ }
+ had_char_class = true;
+# endif /* libc || wctype.h */
+ }
+ else
+ {
+ c1++;
+ while (c1--)
+ PATUNFETCH;
+ SET_LIST_BIT ('[');
+ SET_LIST_BIT (':');
+ range_start = ':';
+ had_char_class = false;
+ }
+ }
+ else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == '=')
+ {
+ unsigned char str[MB_LEN_MAX + 1];
+# ifdef _LIBC
+ uint32_t nrules =
+ _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+# endif
+
+ PATFETCH (c);
+ c1 = 0;
+
+ /* If pattern is `[[='. */
+ if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
+
+ for (;;)
+ {
+ PATFETCH (c);
+ if ((c == '=' && *p == ']') || p == pend)
+ break;
+ if (c1 < MB_LEN_MAX)
+ str[c1++] = c;
+ else
+ /* This is in any case an invalid class name. */
+ str[0] = '\0';
+ }
+ str[c1] = '\0';
+
+ if (c == '=' && *p == ']' && str[0] != '\0')
+ {
+ /* If we have no collation data we use the default
+ collation in which each character is in a class
+ by itself. It also means that ASCII is the
+ character set and therefore we cannot have character
+ with more than one byte in the multibyte
+ representation. */
+# ifdef _LIBC
+ if (nrules == 0)
+# endif
+ {
+ if (c1 != 1)
+ FREE_STACK_RETURN (REG_ECOLLATE);
+
+ /* Throw away the ] at the end of the equivalence
+ class. */
+ PATFETCH (c);
+
+ /* Set the bit for the character. */
+ SET_LIST_BIT (str[0]);
+ }
+# ifdef _LIBC
+ else
+ {
+ /* Try to match the byte sequence in `str' against
+ those known to the collate implementation.
+ First find out whether the bytes in `str' are
+ actually from exactly one character. */
+ const int32_t *table;
+ const unsigned char *weights;
+ const unsigned char *extra;
+ const int32_t *indirect;
+ int32_t idx;
+ const unsigned char *cp = str;
+ int ch;
+
+ /* This #include defines a local function! */
+# include <locale/weight.h>
+
+ table = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB);
+ weights = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB);
+ extra = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB);
+ indirect = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB);
+
+ idx = findidx (&cp);
+ if (idx == 0 || cp < str + c1)
+ /* This is no valid character. */
+ FREE_STACK_RETURN (REG_ECOLLATE);
+
+ /* Throw away the ] at the end of the equivalence
+ class. */
+ PATFETCH (c);
+
+ /* Now we have to go throught the whole table
+ and find all characters which have the same
+ first level weight.
+
+ XXX Note that this is not entirely correct.
+ we would have to match multibyte sequences
+ but this is not possible with the current
+ implementation. */
+ for (ch = 1; ch < 256; ++ch)
+ /* XXX This test would have to be changed if we
+ would allow matching multibyte sequences. */
+ if (table[ch] > 0)
+ {
+ int32_t idx2 = table[ch];
+ size_t len = weights[idx2];
+
+ /* Test whether the lenghts match. */
+ if (weights[idx] == len)
+ {
+ /* They do. New compare the bytes of
+ the weight. */
+ size_t cnt = 0;
+
+ while (cnt < len
+ && (weights[idx + 1 + cnt]
+ == weights[idx2 + 1 + cnt]))
+ ++cnt;
+
+ if (cnt == len)
+ /* They match. Mark the character as
+ acceptable. */
+ SET_LIST_BIT (ch);
+ }
+ }
+ }
+# endif
+ had_char_class = true;
+ }
+ else
+ {
+ c1++;
+ while (c1--)
+ PATUNFETCH;
+ SET_LIST_BIT ('[');
+ SET_LIST_BIT ('=');
+ range_start = '=';
+ had_char_class = false;
+ }
+ }
+ else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == '.')
+ {
+ unsigned char str[128]; /* Should be large enough. */
+# ifdef _LIBC
+ uint32_t nrules =
+ _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+# endif
+
+ PATFETCH (c);
+ c1 = 0;
+
+ /* If pattern is `[[.'. */
+ if (p == pend) FREE_STACK_RETURN (REG_EBRACK);
+
+ for (;;)
+ {
+ PATFETCH (c);
+ if ((c == '.' && *p == ']') || p == pend)
+ break;
+ if (c1 < sizeof (str))
+ str[c1++] = c;
+ else
+ /* This is in any case an invalid class name. */
+ str[0] = '\0';
+ }
+ str[c1] = '\0';
+
+ if (c == '.' && *p == ']' && str[0] != '\0')
+ {
+ /* If we have no collation data we use the default
+ collation in which each character is the name
+ for its own class which contains only the one
+ character. It also means that ASCII is the
+ character set and therefore we cannot have character
+ with more than one byte in the multibyte
+ representation. */
+# ifdef _LIBC
+ if (nrules == 0)
+# endif
+ {
+ if (c1 != 1)
+ FREE_STACK_RETURN (REG_ECOLLATE);
+
+ /* Throw away the ] at the end of the equivalence
+ class. */
+ PATFETCH (c);
+
+ /* Set the bit for the character. */
+ SET_LIST_BIT (str[0]);
+ range_start = ((const unsigned char *) str)[0];
+ }
+# ifdef _LIBC
+ else
+ {
+ /* Try to match the byte sequence in `str' against
+ those known to the collate implementation.
+ First find out whether the bytes in `str' are
+ actually from exactly one character. */
+ int32_t table_size;
+ const int32_t *symb_table;
+ const unsigned char *extra;
+ int32_t idx;
+ int32_t elem;
+ int32_t second;
+ int32_t hash;
+
+ table_size =
+ _NL_CURRENT_WORD (LC_COLLATE,
+ _NL_COLLATE_SYMB_HASH_SIZEMB);
+ symb_table = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_SYMB_TABLEMB);
+ extra = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_SYMB_EXTRAMB);
+
+ /* Locate the character in the hashing table. */
+ hash = elem_hash (str, c1);
+
+ idx = 0;
+ elem = hash % table_size;
+ second = hash % (table_size - 2);
+ while (symb_table[2 * elem] != 0)
+ {
+ /* First compare the hashing value. */
+ if (symb_table[2 * elem] == hash
+ && c1 == extra[symb_table[2 * elem + 1]]
+ && memcmp (str,
+ &extra[symb_table[2 * elem + 1]
+ + 1],
+ c1) == 0)
+ {
+ /* Yep, this is the entry. */
+ idx = symb_table[2 * elem + 1];
+ idx += 1 + extra[idx];
+ break;
+ }
+
+ /* Next entry. */
+ elem += second;
+ }
+
+ if (symb_table[2 * elem] == 0)
+ /* This is no valid character. */
+ FREE_STACK_RETURN (REG_ECOLLATE);
+
+ /* Throw away the ] at the end of the equivalence
+ class. */
+ PATFETCH (c);
+
+ /* Now add the multibyte character(s) we found
+ to the accept list.
+
+ XXX Note that this is not entirely correct.
+ we would have to match multibyte sequences
+ but this is not possible with the current
+ implementation. Also, we have to match
+ collating symbols, which expand to more than
+ one file, as a whole and not allow the
+ individual bytes. */
+ c1 = extra[idx++];
+ if (c1 == 1)
+ range_start = extra[idx];
+ while (c1-- > 0)
+ {
+ SET_LIST_BIT (extra[idx]);
+ ++idx;
+ }
+ }
+# endif
+ had_char_class = false;
+ }
+ else
+ {
+ c1++;
+ while (c1--)
+ PATUNFETCH;
+ SET_LIST_BIT ('[');
+ SET_LIST_BIT ('.');
+ range_start = '.';
+ had_char_class = false;
+ }
+ }
+ else
+ {
+ had_char_class = false;
+ SET_LIST_BIT (c);
+ range_start = c;
+ }
+ }
+
+ /* Discard any (non)matching list bytes that are all 0 at the
+ end of the map. Decrease the map-length byte too. */
+ while ((int) b[-1] > 0 && b[b[-1] - 1] == 0)
+ b[-1]--;
+ b += b[-1];
+#endif /* WCHAR */
+ }
+ break;
+
+
+ case '(':
+ if (syntax & RE_NO_BK_PARENS)
+ goto handle_open;
+ else
+ goto normal_char;
+
+
+ case ')':
+ if (syntax & RE_NO_BK_PARENS)
+ goto handle_close;
+ else
+ goto normal_char;
+
+
+ case '\n':
+ if (syntax & RE_NEWLINE_ALT)
+ goto handle_alt;
+ else
+ goto normal_char;
+
+
+ case '|':
+ if (syntax & RE_NO_BK_VBAR)
+ goto handle_alt;
+ else
+ goto normal_char;
+
+
+ case '{':
+ if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES)
+ goto handle_interval;
+ else
+ goto normal_char;
+
+
+ case '\\':
+ if (p == pend) FREE_STACK_RETURN (REG_EESCAPE);
+
+ /* Do not translate the character after the \, so that we can
+ distinguish, e.g., \B from \b, even if we normally would
+ translate, e.g., B to b. */
+ PATFETCH_RAW (c);
+
+ switch (c)
+ {
+ case '(':
+ if (syntax & RE_NO_BK_PARENS)
+ goto normal_backslash;
+
+ handle_open:
+ bufp->re_nsub++;
+ regnum++;
+
+ if (COMPILE_STACK_FULL)
+ {
+ RETALLOC (compile_stack.stack, compile_stack.size << 1,
+ compile_stack_elt_t);
+ if (compile_stack.stack == NULL) return REG_ESPACE;
+
+ compile_stack.size <<= 1;
+ }
+
+ /* These are the values to restore when we hit end of this
+ group. They are all relative offsets, so that if the
+ whole pattern moves because of realloc, they will still
+ be valid. */
+ COMPILE_STACK_TOP.begalt_offset = begalt - COMPILED_BUFFER_VAR;
+ COMPILE_STACK_TOP.fixup_alt_jump
+ = fixup_alt_jump ? fixup_alt_jump - COMPILED_BUFFER_VAR + 1 : 0;
+ COMPILE_STACK_TOP.laststart_offset = b - COMPILED_BUFFER_VAR;
+ COMPILE_STACK_TOP.regnum = regnum;
+
+ /* We will eventually replace the 0 with the number of
+ groups inner to this one. But do not push a
+ start_memory for groups beyond the last one we can
+ represent in the compiled pattern. */
+ if (regnum <= MAX_REGNUM)
+ {
+ COMPILE_STACK_TOP.inner_group_offset = b
+ - COMPILED_BUFFER_VAR + 2;
+ BUF_PUSH_3 (start_memory, regnum, 0);
+ }
+
+ compile_stack.avail++;
+
+ fixup_alt_jump = 0;
+ laststart = 0;
+ begalt = b;
+ /* If we've reached MAX_REGNUM groups, then this open
+ won't actually generate any code, so we'll have to
+ clear pending_exact explicitly. */
+ pending_exact = 0;
+ break;
+
+
+ case ')':
+ if (syntax & RE_NO_BK_PARENS) goto normal_backslash;
+
+ if (COMPILE_STACK_EMPTY)
+ {
+ if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)
+ goto normal_backslash;
+ else
+ FREE_STACK_RETURN (REG_ERPAREN);
+ }
+
+ handle_close:
+ if (fixup_alt_jump)
+ { /* Push a dummy failure point at the end of the
+ alternative for a possible future
+ `pop_failure_jump' to pop. See comments at
+ `push_dummy_failure' in `re_match_2'. */
+ BUF_PUSH (push_dummy_failure);
+
+ /* We allocated space for this jump when we assigned
+ to `fixup_alt_jump', in the `handle_alt' case below. */
+ STORE_JUMP (jump_past_alt, fixup_alt_jump, b - 1);
+ }
+
+ /* See similar code for backslashed left paren above. */
+ if (COMPILE_STACK_EMPTY)
+ {
+ if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)
+ goto normal_char;
+ else
+ FREE_STACK_RETURN (REG_ERPAREN);
+ }
+
+ /* Since we just checked for an empty stack above, this
+ ``can't happen''. */
+ assert (compile_stack.avail != 0);
+ {
+ /* We don't just want to restore into `regnum', because
+ later groups should continue to be numbered higher,
+ as in `(ab)c(de)' -- the second group is #2. */
+ regnum_t this_group_regnum;
+
+ compile_stack.avail--;
+ begalt = COMPILED_BUFFER_VAR + COMPILE_STACK_TOP.begalt_offset;
+ fixup_alt_jump
+ = COMPILE_STACK_TOP.fixup_alt_jump
+ ? COMPILED_BUFFER_VAR + COMPILE_STACK_TOP.fixup_alt_jump - 1
+ : 0;
+ laststart = COMPILED_BUFFER_VAR + COMPILE_STACK_TOP.laststart_offset;
+ this_group_regnum = COMPILE_STACK_TOP.regnum;
+ /* If we've reached MAX_REGNUM groups, then this open
+ won't actually generate any code, so we'll have to
+ clear pending_exact explicitly. */
+ pending_exact = 0;
+
+ /* We're at the end of the group, so now we know how many
+ groups were inside this one. */
+ if (this_group_regnum <= MAX_REGNUM)
+ {
+ UCHAR_T *inner_group_loc
+ = COMPILED_BUFFER_VAR + COMPILE_STACK_TOP.inner_group_offset;
+
+ *inner_group_loc = regnum - this_group_regnum;
+ BUF_PUSH_3 (stop_memory, this_group_regnum,
+ regnum - this_group_regnum);
+ }
+ }
+ break;
+
+
+ case '|': /* `\|'. */
+ if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR)
+ goto normal_backslash;
+ handle_alt:
+ if (syntax & RE_LIMITED_OPS)
+ goto normal_char;
+
+ /* Insert before the previous alternative a jump which
+ jumps to this alternative if the former fails. */
+ GET_BUFFER_SPACE (1 + OFFSET_ADDRESS_SIZE);
+ INSERT_JUMP (on_failure_jump, begalt,
+ b + 2 + 2 * OFFSET_ADDRESS_SIZE);
+ pending_exact = 0;
+ b += 1 + OFFSET_ADDRESS_SIZE;
+
+ /* The alternative before this one has a jump after it
+ which gets executed if it gets matched. Adjust that
+ jump so it will jump to this alternative's analogous
+ jump (put in below, which in turn will jump to the next
+ (if any) alternative's such jump, etc.). The last such
+ jump jumps to the correct final destination. A picture:
+ _____ _____
+ | | | |
+ | v | v
+ a | b | c
+
+ If we are at `b', then fixup_alt_jump right now points to a
+ three-byte space after `a'. We'll put in the jump, set
+ fixup_alt_jump to right after `b', and leave behind three
+ bytes which we'll fill in when we get to after `c'. */
+
+ if (fixup_alt_jump)
+ STORE_JUMP (jump_past_alt, fixup_alt_jump, b);
+
+ /* Mark and leave space for a jump after this alternative,
+ to be filled in later either by next alternative or
+ when know we're at the end of a series of alternatives. */
+ fixup_alt_jump = b;
+ GET_BUFFER_SPACE (1 + OFFSET_ADDRESS_SIZE);
+ b += 1 + OFFSET_ADDRESS_SIZE;
+
+ laststart = 0;
+ begalt = b;
+ break;
+
+
+ case '{':
+ /* If \{ is a literal. */
+ if (!(syntax & RE_INTERVALS)
+ /* If we're at `\{' and it's not the open-interval
+ operator. */
+ || (syntax & RE_NO_BK_BRACES))
+ goto normal_backslash;
+
+ handle_interval:
+ {
+ /* If got here, then the syntax allows intervals. */
+
+ /* At least (most) this many matches must be made. */
+ int lower_bound = -1, upper_bound = -1;
+
+ /* Place in the uncompiled pattern (i.e., just after
+ the '{') to go back to if the interval is invalid. */
+ const CHAR_T *beg_interval = p;
+
+ if (p == pend)
+ goto invalid_interval;
+
+ GET_UNSIGNED_NUMBER (lower_bound);
+
+ if (c == ',')
+ {
+ GET_UNSIGNED_NUMBER (upper_bound);
+ if (upper_bound < 0)
+ upper_bound = RE_DUP_MAX;
+ }
+ else
+ /* Interval such as `{1}' => match exactly once. */
+ upper_bound = lower_bound;
+
+ if (! (0 <= lower_bound && lower_bound <= upper_bound))
+ goto invalid_interval;
+
+ if (!(syntax & RE_NO_BK_BRACES))
+ {
+ if (c != '\\' || p == pend)
+ goto invalid_interval;
+ PATFETCH (c);
+ }
+
+ if (c != '}')
+ goto invalid_interval;
+
+ /* If it's invalid to have no preceding re. */
+ if (!laststart)
+ {
+ if (syntax & RE_CONTEXT_INVALID_OPS
+ && !(syntax & RE_INVALID_INTERVAL_ORD))
+ FREE_STACK_RETURN (REG_BADRPT);
+ else if (syntax & RE_CONTEXT_INDEP_OPS)
+ laststart = b;
+ else
+ goto unfetch_interval;
+ }
+
+ /* We just parsed a valid interval. */
+
+ if (RE_DUP_MAX < upper_bound)
+ FREE_STACK_RETURN (REG_BADBR);
+
+ /* If the upper bound is zero, don't want to succeed at
+ all; jump from `laststart' to `b + 3', which will be
+ the end of the buffer after we insert the jump. */
+ /* ifdef WCHAR, 'b + 1 + OFFSET_ADDRESS_SIZE'
+ instead of 'b + 3'. */
+ if (upper_bound == 0)
+ {
+ GET_BUFFER_SPACE (1 + OFFSET_ADDRESS_SIZE);
+ INSERT_JUMP (jump, laststart, b + 1
+ + OFFSET_ADDRESS_SIZE);
+ b += 1 + OFFSET_ADDRESS_SIZE;
+ }
+
+ /* Otherwise, we have a nontrivial interval. When
+ we're all done, the pattern will look like:
+ set_number_at <jump count> <upper bound>
+ set_number_at <succeed_n count> <lower bound>
+ succeed_n <after jump addr> <succeed_n count>
+ <body of loop>
+ jump_n <succeed_n addr> <jump count>
+ (The upper bound and `jump_n' are omitted if
+ `upper_bound' is 1, though.) */
+ else
+ { /* If the upper bound is > 1, we need to insert
+ more at the end of the loop. */
+ unsigned nbytes = 2 + 4 * OFFSET_ADDRESS_SIZE +
+ (upper_bound > 1) * (2 + 4 * OFFSET_ADDRESS_SIZE);
+
+ GET_BUFFER_SPACE (nbytes);
+
+ /* Initialize lower bound of the `succeed_n', even
+ though it will be set during matching by its
+ attendant `set_number_at' (inserted next),
+ because `re_compile_fastmap' needs to know.
+ Jump to the `jump_n' we might insert below. */
+ INSERT_JUMP2 (succeed_n, laststart,
+ b + 1 + 2 * OFFSET_ADDRESS_SIZE
+ + (upper_bound > 1) * (1 + 2 * OFFSET_ADDRESS_SIZE)
+ , lower_bound);
+ b += 1 + 2 * OFFSET_ADDRESS_SIZE;
+
+ /* Code to initialize the lower bound. Insert
+ before the `succeed_n'. The `5' is the last two
+ bytes of this `set_number_at', plus 3 bytes of
+ the following `succeed_n'. */
+ /* ifdef WCHAR, The '1+2*OFFSET_ADDRESS_SIZE'
+ is the 'set_number_at', plus '1+OFFSET_ADDRESS_SIZE'
+ of the following `succeed_n'. */
+ PREFIX(insert_op2) (set_number_at, laststart, 1
+ + 2 * OFFSET_ADDRESS_SIZE, lower_bound, b);
+ b += 1 + 2 * OFFSET_ADDRESS_SIZE;
+
+ if (upper_bound > 1)
+ { /* More than one repetition is allowed, so
+ append a backward jump to the `succeed_n'
+ that starts this interval.
+
+ When we've reached this during matching,
+ we'll have matched the interval once, so
+ jump back only `upper_bound - 1' times. */
+ STORE_JUMP2 (jump_n, b, laststart
+ + 2 * OFFSET_ADDRESS_SIZE + 1,
+ upper_bound - 1);
+ b += 1 + 2 * OFFSET_ADDRESS_SIZE;
+
+ /* The location we want to set is the second
+ parameter of the `jump_n'; that is `b-2' as
+ an absolute address. `laststart' will be
+ the `set_number_at' we're about to insert;
+ `laststart+3' the number to set, the source
+ for the relative address. But we are
+ inserting into the middle of the pattern --
+ so everything is getting moved up by 5.
+ Conclusion: (b - 2) - (laststart + 3) + 5,
+ i.e., b - laststart.
+
+ We insert this at the beginning of the loop
+ so that if we fail during matching, we'll
+ reinitialize the bounds. */
+ PREFIX(insert_op2) (set_number_at, laststart,
+ b - laststart,
+ upper_bound - 1, b);
+ b += 1 + 2 * OFFSET_ADDRESS_SIZE;
+ }
+ }
+ pending_exact = 0;
+ break;
+
+ invalid_interval:
+ if (!(syntax & RE_INVALID_INTERVAL_ORD))
+ FREE_STACK_RETURN (p == pend ? REG_EBRACE : REG_BADBR);
+ unfetch_interval:
+ /* Match the characters as literals. */
+ p = beg_interval;
+ c = '{';
+ if (syntax & RE_NO_BK_BRACES)
+ goto normal_char;
+ else
+ goto normal_backslash;
+ }
+
+#ifdef emacs
+ /* There is no way to specify the before_dot and after_dot
+ operators. rms says this is ok. --karl */
+ case '=':
+ BUF_PUSH (at_dot);
+ break;
+
+ case 's':
+ laststart = b;
+ PATFETCH (c);
+ BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]);
+ break;
+
+ case 'S':
+ laststart = b;
+ PATFETCH (c);
+ BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]);
+ break;
+#endif /* emacs */
+
+
+ case 'w':
+ if (syntax & RE_NO_GNU_OPS)
+ goto normal_char;
+ laststart = b;
+ BUF_PUSH (wordchar);
+ break;
+
+
+ case 'W':
+ if (syntax & RE_NO_GNU_OPS)
+ goto normal_char;
+ laststart = b;
+ BUF_PUSH (notwordchar);
+ break;
+
+
+ case '<':
+ if (syntax & RE_NO_GNU_OPS)
+ goto normal_char;
+ BUF_PUSH (wordbeg);
+ break;
+
+ case '>':
+ if (syntax & RE_NO_GNU_OPS)
+ goto normal_char;
+ BUF_PUSH (wordend);
+ break;
+
+ case 'b':
+ if (syntax & RE_NO_GNU_OPS)
+ goto normal_char;
+ BUF_PUSH (wordbound);
+ break;
+
+ case 'B':
+ if (syntax & RE_NO_GNU_OPS)
+ goto normal_char;
+ BUF_PUSH (notwordbound);
+ break;
+
+ case '`':
+ if (syntax & RE_NO_GNU_OPS)
+ goto normal_char;
+ BUF_PUSH (begbuf);
+ break;
+
+ case '\'':
+ if (syntax & RE_NO_GNU_OPS)
+ goto normal_char;
+ BUF_PUSH (endbuf);
+ break;
+
+ case '1': case '2': case '3': case '4': case '5':
+ case '6': case '7': case '8': case '9':
+ if (syntax & RE_NO_BK_REFS)
+ goto normal_char;
+
+ c1 = c - '0';
+
+ if (c1 > regnum)
+ FREE_STACK_RETURN (REG_ESUBREG);
+
+ /* Can't back reference to a subexpression if inside of it. */
+ if (group_in_compile_stack (compile_stack, (regnum_t) c1))
+ goto normal_char;
+
+ laststart = b;
+ BUF_PUSH_2 (duplicate, c1);
+ break;
+
+
+ case '+':
+ case '?':
+ if (syntax & RE_BK_PLUS_QM)
+ goto handle_plus;
+ else
+ goto normal_backslash;
+
+ default:
+ normal_backslash:
+ /* You might think it would be useful for \ to mean
+ not to translate; but if we don't translate it
+ it will never match anything. */
+ c = TRANSLATE (c);
+ goto normal_char;
+ }
+ break;
+
+
+ default:
+ /* Expects the character in `c'. */
+ normal_char:
+ /* If no exactn currently being built. */
+ if (!pending_exact
+#ifdef WCHAR
+ /* If last exactn handle binary(or character) and
+ new exactn handle character(or binary). */
+ || is_exactn_bin != is_binary[p - 1 - pattern]
+#endif /* WCHAR */
+
+ /* If last exactn not at current position. */
+ || pending_exact + *pending_exact + 1 != b
+
+ /* We have only one byte following the exactn for the count. */
+ || *pending_exact == (1 << BYTEWIDTH) - 1
+
+ /* If followed by a repetition operator. */
+ || *p == '*' || *p == '^'
+ || ((syntax & RE_BK_PLUS_QM)
+ ? *p == '\\' && (p[1] == '+' || p[1] == '?')
+ : (*p == '+' || *p == '?'))
+ || ((syntax & RE_INTERVALS)
+ && ((syntax & RE_NO_BK_BRACES)
+ ? *p == '{'
+ : (p[0] == '\\' && p[1] == '{'))))
+ {
+ /* Start building a new exactn. */
+
+ laststart = b;
+
+#ifdef WCHAR
+ /* Is this exactn binary data or character? */
+ is_exactn_bin = is_binary[p - 1 - pattern];
+ if (is_exactn_bin)
+ BUF_PUSH_2 (exactn_bin, 0);
+ else
+ BUF_PUSH_2 (exactn, 0);
+#else
+ BUF_PUSH_2 (exactn, 0);
+#endif /* WCHAR */
+ pending_exact = b - 1;
+ }
+
+ BUF_PUSH (c);
+ (*pending_exact)++;
+ break;
+ } /* switch (c) */
+ } /* while p != pend */
+
+
+ /* Through the pattern now. */
+
+ if (fixup_alt_jump)
+ STORE_JUMP (jump_past_alt, fixup_alt_jump, b);
+
+ if (!COMPILE_STACK_EMPTY)
+ FREE_STACK_RETURN (REG_EPAREN);
+
+ /* If we don't want backtracking, force success
+ the first time we reach the end of the compiled pattern. */
+ if (syntax & RE_NO_POSIX_BACKTRACKING)
+ BUF_PUSH (succeed);
+
+#ifdef WCHAR
+ free (pattern);
+ free (mbs_offset);
+ free (is_binary);
+#endif
+ free (compile_stack.stack);
+
+ /* We have succeeded; set the length of the buffer. */
+#ifdef WCHAR
+ bufp->used = (uintptr_t) b - (uintptr_t) COMPILED_BUFFER_VAR;
+#else
+ bufp->used = b - bufp->buffer;
+#endif
+
+#ifdef DEBUG
+ if (debug)
+ {
+ DEBUG_PRINT1 ("\nCompiled pattern: \n");
+ PREFIX(print_compiled_pattern) (bufp);
+ }
+#endif /* DEBUG */
+
+#ifndef MATCH_MAY_ALLOCATE
+ /* Initialize the failure stack to the largest possible stack. This
+ isn't necessary unless we're trying to avoid calling alloca in
+ the search and match routines. */
+ {
+ int num_regs = bufp->re_nsub + 1;
+
+ /* Since DOUBLE_FAIL_STACK refuses to double only if the current size
+ is strictly greater than re_max_failures, the largest possible stack
+ is 2 * re_max_failures failure points. */
+ if (fail_stack.size < (2 * re_max_failures * MAX_FAILURE_ITEMS))
+ {
+ fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS);
+
+# ifdef emacs
+ if (! fail_stack.stack)
+ fail_stack.stack
+ = (PREFIX(fail_stack_elt_t) *) xmalloc (fail_stack.size
+ * sizeof (PREFIX(fail_stack_elt_t)));
+ else
+ fail_stack.stack
+ = (PREFIX(fail_stack_elt_t) *) xrealloc (fail_stack.stack,
+ (fail_stack.size
+ * sizeof (PREFIX(fail_stack_elt_t))));
+# else /* not emacs */
+ if (! fail_stack.stack)
+ fail_stack.stack
+ = (PREFIX(fail_stack_elt_t) *) malloc (fail_stack.size
+ * sizeof (PREFIX(fail_stack_elt_t)));
+ else
+ fail_stack.stack
+ = (PREFIX(fail_stack_elt_t) *) realloc (fail_stack.stack,
+ (fail_stack.size
+ * sizeof (PREFIX(fail_stack_elt_t))));
+# endif /* not emacs */
+ }
+
+ PREFIX(regex_grow_registers) (num_regs);
+ }
+#endif /* not MATCH_MAY_ALLOCATE */
+
+ return REG_NOERROR;
+} /* regex_compile */
+
+/* Subroutines for `regex_compile'. */
+
+/* Store OP at LOC followed by two-byte integer parameter ARG. */
+/* ifdef WCHAR, integer parameter is 1 wchar_t. */
+
+static void
+PREFIX(store_op1) (op, loc, arg)
+ re_opcode_t op;
+ UCHAR_T *loc;
+ int arg;
+{
+ *loc = (UCHAR_T) op;
+ STORE_NUMBER (loc + 1, arg);
+}
+
+
+/* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */
+/* ifdef WCHAR, integer parameter is 1 wchar_t. */
+
+static void
+PREFIX(store_op2) (op, loc, arg1, arg2)
+ re_opcode_t op;
+ UCHAR_T *loc;
+ int arg1, arg2;
+{
+ *loc = (UCHAR_T) op;
+ STORE_NUMBER (loc + 1, arg1);
+ STORE_NUMBER (loc + 1 + OFFSET_ADDRESS_SIZE, arg2);
+}
+
+
+/* Copy the bytes from LOC to END to open up three bytes of space at LOC
+ for OP followed by two-byte integer parameter ARG. */
+/* ifdef WCHAR, integer parameter is 1 wchar_t. */
+
+static void
+PREFIX(insert_op1) (op, loc, arg, end)
+ re_opcode_t op;
+ UCHAR_T *loc;
+ int arg;
+ UCHAR_T *end;
+{
+ register UCHAR_T *pfrom = end;
+ register UCHAR_T *pto = end + 1 + OFFSET_ADDRESS_SIZE;
+
+ while (pfrom != loc)
+ *--pto = *--pfrom;
+
+ PREFIX(store_op1) (op, loc, arg);
+}
+
+
+/* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */
+/* ifdef WCHAR, integer parameter is 1 wchar_t. */
+
+static void
+PREFIX(insert_op2) (op, loc, arg1, arg2, end)
+ re_opcode_t op;
+ UCHAR_T *loc;
+ int arg1, arg2;
+ UCHAR_T *end;
+{
+ register UCHAR_T *pfrom = end;
+ register UCHAR_T *pto = end + 1 + 2 * OFFSET_ADDRESS_SIZE;
+
+ while (pfrom != loc)
+ *--pto = *--pfrom;
+
+ PREFIX(store_op2) (op, loc, arg1, arg2);
+}
+
+
+/* P points to just after a ^ in PATTERN. Return true if that ^ comes
+ after an alternative or a begin-subexpression. We assume there is at
+ least one character before the ^. */
+
+static boolean
+PREFIX(at_begline_loc_p) (pattern, p, syntax)
+ const CHAR_T *pattern, *p;
+ reg_syntax_t syntax;
+{
+ const CHAR_T *prev = p - 2;
+ boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\';
+
+ return
+ /* After a subexpression? */
+ (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash))
+ /* After an alternative? */
+ || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash));
+}
+
+
+/* The dual of at_begline_loc_p. This one is for $. We assume there is
+ at least one character after the $, i.e., `P < PEND'. */
+
+static boolean
+PREFIX(at_endline_loc_p) (p, pend, syntax)
+ const CHAR_T *p, *pend;
+ reg_syntax_t syntax;
+{
+ const CHAR_T *next = p;
+ boolean next_backslash = *next == '\\';
+ const CHAR_T *next_next = p + 1 < pend ? p + 1 : 0;
+
+ return
+ /* Before a subexpression? */
+ (syntax & RE_NO_BK_PARENS ? *next == ')'
+ : next_backslash && next_next && *next_next == ')')
+ /* Before an alternative? */
+ || (syntax & RE_NO_BK_VBAR ? *next == '|'
+ : next_backslash && next_next && *next_next == '|');
+}
+
+#else /* not INSIDE_RECURSION */
+
+/* Returns true if REGNUM is in one of COMPILE_STACK's elements and
+ false if it's not. */
+
+static boolean
+group_in_compile_stack (compile_stack, regnum)
+ compile_stack_type compile_stack;
+ regnum_t regnum;
+{
+ int this_element;
+
+ for (this_element = compile_stack.avail - 1;
+ this_element >= 0;
+ this_element--)
+ if (compile_stack.stack[this_element].regnum == regnum)
+ return true;
+
+ return false;
+}
+#endif /* not INSIDE_RECURSION */
+
+#ifdef INSIDE_RECURSION
+
+#ifdef WCHAR
+/* This insert space, which size is "num", into the pattern at "loc".
+ "end" must point the end of the allocated buffer. */
+static void
+insert_space (num, loc, end)
+ int num;
+ CHAR_T *loc;
+ CHAR_T *end;
+{
+ register CHAR_T *pto = end;
+ register CHAR_T *pfrom = end - num;
+
+ while (pfrom >= loc)
+ *pto-- = *pfrom--;
+}
+#endif /* WCHAR */
+
+#ifdef WCHAR
+static reg_errcode_t
+wcs_compile_range (range_start_char, p_ptr, pend, translate, syntax, b,
+ char_set)
+ CHAR_T range_start_char;
+ const CHAR_T **p_ptr, *pend;
+ CHAR_T *char_set, *b;
+ RE_TRANSLATE_TYPE translate;
+ reg_syntax_t syntax;
+{
+ const CHAR_T *p = *p_ptr;
+ CHAR_T range_start, range_end;
+ reg_errcode_t ret;
+# ifdef _LIBC
+ uint32_t nrules;
+ uint32_t start_val, end_val;
+# endif
+ if (p == pend)
+ return REG_ERANGE;
+
+# ifdef _LIBC
+ nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+ if (nrules != 0)
+ {
+ const char *collseq = (const char *) _NL_CURRENT(LC_COLLATE,
+ _NL_COLLATE_COLLSEQWC);
+ const unsigned char *extra = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB);
+
+ if (range_start_char < -1)
+ {
+ /* range_start is a collating symbol. */
+ int32_t *wextra;
+ /* Retreive the index and get collation sequence value. */
+ wextra = (int32_t*)(extra + char_set[-range_start_char]);
+ start_val = wextra[1 + *wextra];
+ }
+ else
+ start_val = collseq_table_lookup(collseq, TRANSLATE(range_start_char));
+
+ end_val = collseq_table_lookup (collseq, TRANSLATE (p[0]));
+
+ /* Report an error if the range is empty and the syntax prohibits
+ this. */
+ ret = ((syntax & RE_NO_EMPTY_RANGES)
+ && (start_val > end_val))? REG_ERANGE : REG_NOERROR;
+
+ /* Insert space to the end of the char_ranges. */
+ insert_space(2, b - char_set[5] - 2, b - 1);
+ *(b - char_set[5] - 2) = (wchar_t)start_val;
+ *(b - char_set[5] - 1) = (wchar_t)end_val;
+ char_set[4]++; /* ranges_index */
+ }
+ else
+# endif
+ {
+ range_start = (range_start_char >= 0)? TRANSLATE (range_start_char):
+ range_start_char;
+ range_end = TRANSLATE (p[0]);
+ /* Report an error if the range is empty and the syntax prohibits
+ this. */
+ ret = ((syntax & RE_NO_EMPTY_RANGES)
+ && (range_start > range_end))? REG_ERANGE : REG_NOERROR;
+
+ /* Insert space to the end of the char_ranges. */
+ insert_space(2, b - char_set[5] - 2, b - 1);
+ *(b - char_set[5] - 2) = range_start;
+ *(b - char_set[5] - 1) = range_end;
+ char_set[4]++; /* ranges_index */
+ }
+ /* Have to increment the pointer into the pattern string, so the
+ caller isn't still at the ending character. */
+ (*p_ptr)++;
+
+ return ret;
+}
+#else /* BYTE */
+/* Read the ending character of a range (in a bracket expression) from the
+ uncompiled pattern *P_PTR (which ends at PEND). We assume the
+ starting character is in `P[-2]'. (`P[-1]' is the character `-'.)
+ Then we set the translation of all bits between the starting and
+ ending characters (inclusive) in the compiled pattern B.
+
+ Return an error code.
+
+ We use these short variable names so we can use the same macros as
+ `regex_compile' itself. */
+
+static reg_errcode_t
+byte_compile_range (range_start_char, p_ptr, pend, translate, syntax, b)
+ unsigned int range_start_char;
+ const char **p_ptr, *pend;
+ RE_TRANSLATE_TYPE translate;
+ reg_syntax_t syntax;
+ unsigned char *b;
+{
+ unsigned this_char;
+ const char *p = *p_ptr;
+ reg_errcode_t ret;
+# if _LIBC
+ const unsigned char *collseq;
+ unsigned int start_colseq;
+ unsigned int end_colseq;
+# else
+ unsigned end_char;
+# endif
+
+ if (p == pend)
+ return REG_ERANGE;
+
+ /* Have to increment the pointer into the pattern string, so the
+ caller isn't still at the ending character. */
+ (*p_ptr)++;
+
+ /* Report an error if the range is empty and the syntax prohibits this. */
+ ret = syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR;
+
+# if _LIBC
+ collseq = (const unsigned char *) _NL_CURRENT (LC_COLLATE,
+ _NL_COLLATE_COLLSEQMB);
+
+ start_colseq = collseq[(unsigned char) TRANSLATE (range_start_char)];
+ end_colseq = collseq[(unsigned char) TRANSLATE (p[0])];
+ for (this_char = 0; this_char <= (unsigned char) -1; ++this_char)
+ {
+ unsigned int this_colseq = collseq[(unsigned char) TRANSLATE (this_char)];
+
+ if (start_colseq <= this_colseq && this_colseq <= end_colseq)
+ {
+ SET_LIST_BIT (TRANSLATE (this_char));
+ ret = REG_NOERROR;
+ }
+ }
+# else
+ /* Here we see why `this_char' has to be larger than an `unsigned
+ char' -- we would otherwise go into an infinite loop, since all
+ characters <= 0xff. */
+ range_start_char = TRANSLATE (range_start_char);
+ /* TRANSLATE(p[0]) is casted to char (not unsigned char) in TRANSLATE,
+ and some compilers cast it to int implicitly, so following for_loop
+ may fall to (almost) infinite loop.
+ e.g. If translate[p[0]] = 0xff, end_char may equals to 0xffffffff.
+ To avoid this, we cast p[0] to unsigned int and truncate it. */
+ end_char = ((unsigned)TRANSLATE(p[0]) & ((1 << BYTEWIDTH) - 1));
+
+ for (this_char = range_start_char; this_char <= end_char; ++this_char)
+ {
+ SET_LIST_BIT (TRANSLATE (this_char));
+ ret = REG_NOERROR;
+ }
+# endif
+
+ return ret;
+}
+#endif /* WCHAR */
+
+/* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in
+ BUFP. A fastmap records which of the (1 << BYTEWIDTH) possible
+ characters can start a string that matches the pattern. This fastmap
+ is used by re_search to skip quickly over impossible starting points.
+
+ The caller must supply the address of a (1 << BYTEWIDTH)-byte data
+ area as BUFP->fastmap.
+
+ We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in
+ the pattern buffer.
+
+ Returns 0 if we succeed, -2 if an internal error. */
+
+#ifdef WCHAR
+/* local function for re_compile_fastmap.
+ truncate wchar_t character to char. */
+static unsigned char truncate_wchar (CHAR_T c);
+
+static unsigned char
+truncate_wchar (c)
+ CHAR_T c;
+{
+ unsigned char buf[MB_CUR_MAX];
+ mbstate_t state;
+ int retval;
+ memset (&state, '\0', sizeof (state));
+# ifdef _LIBC
+ retval = __wcrtomb (buf, c, &state);
+# else
+ retval = wcrtomb (buf, c, &state);
+# endif
+ return retval > 0 ? buf[0] : (unsigned char) c;
+}
+#endif /* WCHAR */
+
+static int
+PREFIX(re_compile_fastmap) (bufp)
+ struct re_pattern_buffer *bufp;
+{
+ int j, k;
+#ifdef MATCH_MAY_ALLOCATE
+ PREFIX(fail_stack_type) fail_stack;
+#endif
+#ifndef REGEX_MALLOC
+ char *destination;
+#endif
+
+ register char *fastmap = bufp->fastmap;
+
+#ifdef WCHAR
+ /* We need to cast pattern to (wchar_t*), because we casted this compiled
+ pattern to (char*) in regex_compile. */
+ UCHAR_T *pattern = (UCHAR_T*)bufp->buffer;
+ register UCHAR_T *pend = (UCHAR_T*) (bufp->buffer + bufp->used);
+#else /* BYTE */
+ UCHAR_T *pattern = bufp->buffer;
+ register UCHAR_T *pend = pattern + bufp->used;
+#endif /* WCHAR */
+ UCHAR_T *p = pattern;
+
+#ifdef REL_ALLOC
+ /* This holds the pointer to the failure stack, when
+ it is allocated relocatably. */
+ fail_stack_elt_t *failure_stack_ptr;
+#endif
+
+ /* Assume that each path through the pattern can be null until
+ proven otherwise. We set this false at the bottom of switch
+ statement, to which we get only if a particular path doesn't
+ match the empty string. */
+ boolean path_can_be_null = true;
+
+ /* We aren't doing a `succeed_n' to begin with. */
+ boolean succeed_n_p = false;
+
+ assert (fastmap != NULL && p != NULL);
+
+ INIT_FAIL_STACK ();
+ bzero (fastmap, 1 << BYTEWIDTH); /* Assume nothing's valid. */
+ bufp->fastmap_accurate = 1; /* It will be when we're done. */
+ bufp->can_be_null = 0;
+
+ while (1)
+ {
+ if (p == pend || *p == succeed)
+ {
+ /* We have reached the (effective) end of pattern. */
+ if (!FAIL_STACK_EMPTY ())
+ {
+ bufp->can_be_null |= path_can_be_null;
+
+ /* Reset for next path. */
+ path_can_be_null = true;
+
+ p = fail_stack.stack[--fail_stack.avail].pointer;
+
+ continue;
+ }
+ else
+ break;
+ }
+
+ /* We should never be about to go beyond the end of the pattern. */
+ assert (p < pend);
+
+ switch (SWITCH_ENUM_CAST ((re_opcode_t) *p++))
+ {
+
+ /* I guess the idea here is to simply not bother with a fastmap
+ if a backreference is used, since it's too hard to figure out
+ the fastmap for the corresponding group. Setting
+ `can_be_null' stops `re_search_2' from using the fastmap, so
+ that is all we do. */
+ case duplicate:
+ bufp->can_be_null = 1;
+ goto done;
+
+
+ /* Following are the cases which match a character. These end
+ with `break'. */
+
+#ifdef WCHAR
+ case exactn:
+ fastmap[truncate_wchar(p[1])] = 1;
+ break;
+#else /* BYTE */
+ case exactn:
+ fastmap[p[1]] = 1;
+ break;
+#endif /* WCHAR */
+#ifdef MBS_SUPPORT
+ case exactn_bin:
+ fastmap[p[1]] = 1;
+ break;
+#endif
+
+#ifdef WCHAR
+ /* It is hard to distinguish fastmap from (multi byte) characters
+ which depends on current locale. */
+ case charset:
+ case charset_not:
+ case wordchar:
+ case notwordchar:
+ bufp->can_be_null = 1;
+ goto done;
+#else /* BYTE */
+ case charset:
+ for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
+ if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))
+ fastmap[j] = 1;
+ break;
+
+
+ case charset_not:
+ /* Chars beyond end of map must be allowed. */
+ for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++)
+ fastmap[j] = 1;
+
+ for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
+ if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))))
+ fastmap[j] = 1;
+ break;
+
+
+ case wordchar:
+ for (j = 0; j < (1 << BYTEWIDTH); j++)
+ if (SYNTAX (j) == Sword)
+ fastmap[j] = 1;
+ break;
+
+
+ case notwordchar:
+ for (j = 0; j < (1 << BYTEWIDTH); j++)
+ if (SYNTAX (j) != Sword)
+ fastmap[j] = 1;
+ break;
+#endif /* WCHAR */
+
+ case anychar:
+ {
+ int fastmap_newline = fastmap['\n'];
+
+ /* `.' matches anything ... */
+ for (j = 0; j < (1 << BYTEWIDTH); j++)
+ fastmap[j] = 1;
+
+ /* ... except perhaps newline. */
+ if (!(bufp->syntax & RE_DOT_NEWLINE))
+ fastmap['\n'] = fastmap_newline;
+
+ /* Return if we have already set `can_be_null'; if we have,
+ then the fastmap is irrelevant. Something's wrong here. */
+ else if (bufp->can_be_null)
+ goto done;
+
+ /* Otherwise, have to check alternative paths. */
+ break;
+ }
+
+#ifdef emacs
+ case syntaxspec:
+ k = *p++;
+ for (j = 0; j < (1 << BYTEWIDTH); j++)
+ if (SYNTAX (j) == (enum syntaxcode) k)
+ fastmap[j] = 1;
+ break;
+
+
+ case notsyntaxspec:
+ k = *p++;
+ for (j = 0; j < (1 << BYTEWIDTH); j++)
+ if (SYNTAX (j) != (enum syntaxcode) k)
+ fastmap[j] = 1;
+ break;
+
+
+ /* All cases after this match the empty string. These end with
+ `continue'. */
+
+
+ case before_dot:
+ case at_dot:
+ case after_dot:
+ continue;
+#endif /* emacs */
+
+
+ case no_op:
+ case begline:
+ case endline:
+ case begbuf:
+ case endbuf:
+ case wordbound:
+ case notwordbound:
+ case wordbeg:
+ case wordend:
+ case push_dummy_failure:
+ continue;
+
+
+ case jump_n:
+ case pop_failure_jump:
+ case maybe_pop_jump:
+ case jump:
+ case jump_past_alt:
+ case dummy_failure_jump:
+ EXTRACT_NUMBER_AND_INCR (j, p);
+ p += j;
+ if (j > 0)
+ continue;
+
+ /* Jump backward implies we just went through the body of a
+ loop and matched nothing. Opcode jumped to should be
+ `on_failure_jump' or `succeed_n'. Just treat it like an
+ ordinary jump. For a * loop, it has pushed its failure
+ point already; if so, discard that as redundant. */
+ if ((re_opcode_t) *p != on_failure_jump
+ && (re_opcode_t) *p != succeed_n)
+ continue;
+
+ p++;
+ EXTRACT_NUMBER_AND_INCR (j, p);
+ p += j;
+
+ /* If what's on the stack is where we are now, pop it. */
+ if (!FAIL_STACK_EMPTY ()
+ && fail_stack.stack[fail_stack.avail - 1].pointer == p)
+ fail_stack.avail--;
+
+ continue;
+
+
+ case on_failure_jump:
+ case on_failure_keep_string_jump:
+ handle_on_failure_jump:
+ EXTRACT_NUMBER_AND_INCR (j, p);
+
+ /* For some patterns, e.g., `(a?)?', `p+j' here points to the
+ end of the pattern. We don't want to push such a point,
+ since when we restore it above, entering the switch will
+ increment `p' past the end of the pattern. We don't need
+ to push such a point since we obviously won't find any more
+ fastmap entries beyond `pend'. Such a pattern can match
+ the null string, though. */
+ if (p + j < pend)
+ {
+ if (!PUSH_PATTERN_OP (p + j, fail_stack))
+ {
+ RESET_FAIL_STACK ();
+ return -2;
+ }
+ }
+ else
+ bufp->can_be_null = 1;
+
+ if (succeed_n_p)
+ {
+ EXTRACT_NUMBER_AND_INCR (k, p); /* Skip the n. */
+ succeed_n_p = false;
+ }
+
+ continue;
+
+
+ case succeed_n:
+ /* Get to the number of times to succeed. */
+ p += OFFSET_ADDRESS_SIZE;
+
+ /* Increment p past the n for when k != 0. */
+ EXTRACT_NUMBER_AND_INCR (k, p);
+ if (k == 0)
+ {
+ p -= 2 * OFFSET_ADDRESS_SIZE;
+ succeed_n_p = true; /* Spaghetti code alert. */
+ goto handle_on_failure_jump;
+ }
+ continue;
+
+
+ case set_number_at:
+ p += 2 * OFFSET_ADDRESS_SIZE;
+ continue;
+
+
+ case start_memory:
+ case stop_memory:
+ p += 2;
+ continue;
+
+
+ default:
+ abort (); /* We have listed all the cases. */
+ } /* switch *p++ */
+
+ /* Getting here means we have found the possible starting
+ characters for one path of the pattern -- and that the empty
+ string does not match. We need not follow this path further.
+ Instead, look at the next alternative (remembered on the
+ stack), or quit if no more. The test at the top of the loop
+ does these things. */
+ path_can_be_null = false;
+ p = pend;
+ } /* while p */
+
+ /* Set `can_be_null' for the last path (also the first path, if the
+ pattern is empty). */
+ bufp->can_be_null |= path_can_be_null;
+
+ done:
+ RESET_FAIL_STACK ();
+ return 0;
+}
+
+#else /* not INSIDE_RECURSION */
+
+int
+re_compile_fastmap (bufp)
+ struct re_pattern_buffer *bufp;
+{
+# ifdef MBS_SUPPORT
+ if (MB_CUR_MAX != 1)
+ return wcs_re_compile_fastmap(bufp);
+ else
+# endif
+ return byte_re_compile_fastmap(bufp);
+} /* re_compile_fastmap */
+#ifdef _LIBC
+weak_alias (__re_compile_fastmap, re_compile_fastmap)
+#endif
+
+
+/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
+ ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use
+ this memory for recording register information. STARTS and ENDS
+ must be allocated using the malloc library routine, and must each
+ be at least NUM_REGS * sizeof (regoff_t) bytes long.
+
+ If NUM_REGS == 0, then subsequent matches should allocate their own
+ register data.
+
+ Unless this function is called, the first search or match using
+ PATTERN_BUFFER will allocate its own register data, without
+ freeing the old data. */
+
+void
+re_set_registers (bufp, regs, num_regs, starts, ends)
+ struct re_pattern_buffer *bufp;
+ struct re_registers *regs;
+ unsigned num_regs;
+ regoff_t *starts, *ends;
+{
+ if (num_regs)
+ {
+ bufp->regs_allocated = REGS_REALLOCATE;
+ regs->num_regs = num_regs;
+ regs->start = starts;
+ regs->end = ends;
+ }
+ else
+ {
+ bufp->regs_allocated = REGS_UNALLOCATED;
+ regs->num_regs = 0;
+ regs->start = regs->end = (regoff_t *) 0;
+ }
+}
+#ifdef _LIBC
+weak_alias (__re_set_registers, re_set_registers)
+#endif
+
+/* Searching routines. */
+
+/* Like re_search_2, below, but only one string is specified, and
+ doesn't let you say where to stop matching. */
+
+int
+re_search (bufp, string, size, startpos, range, regs)
+ struct re_pattern_buffer *bufp;
+ const char *string;
+ int size, startpos, range;
+ struct re_registers *regs;
+{
+ return re_search_2 (bufp, NULL, 0, string, size, startpos, range,
+ regs, size);
+}
+#ifdef _LIBC
+weak_alias (__re_search, re_search)
+#endif
+
+
+/* Using the compiled pattern in BUFP->buffer, first tries to match the
+ virtual concatenation of STRING1 and STRING2, starting first at index
+ STARTPOS, then at STARTPOS + 1, and so on.
+
+ STRING1 and STRING2 have length SIZE1 and SIZE2, respectively.
+
+ RANGE is how far to scan while trying to match. RANGE = 0 means try
+ only at STARTPOS; in general, the last start tried is STARTPOS +
+ RANGE.
+
+ In REGS, return the indices of the virtual concatenation of STRING1
+ and STRING2 that matched the entire BUFP->buffer and its contained
+ subexpressions.
+
+ Do not consider matching one past the index STOP in the virtual
+ concatenation of STRING1 and STRING2.
+
+ We return either the position in the strings at which the match was
+ found, -1 if no match, or -2 if error (such as failure
+ stack overflow). */
+
+int
+re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
+ struct re_pattern_buffer *bufp;
+ const char *string1, *string2;
+ int size1, size2;
+ int startpos;
+ int range;
+ struct re_registers *regs;
+ int stop;
+{
+# ifdef MBS_SUPPORT
+ if (MB_CUR_MAX != 1)
+ return wcs_re_search_2 (bufp, string1, size1, string2, size2, startpos,
+ range, regs, stop);
+ else
+# endif
+ return byte_re_search_2 (bufp, string1, size1, string2, size2, startpos,
+ range, regs, stop);
+} /* re_search_2 */
+#ifdef _LIBC
+weak_alias (__re_search_2, re_search_2)
+#endif
+
+#endif /* not INSIDE_RECURSION */
+
+#ifdef INSIDE_RECURSION
+
+#ifdef MATCH_MAY_ALLOCATE
+# define FREE_VAR(var) if (var) REGEX_FREE (var); var = NULL
+#else
+# define FREE_VAR(var) if (var) free (var); var = NULL
+#endif
+
+#ifdef WCHAR
+# define MAX_ALLOCA_SIZE 2000
+
+# define FREE_WCS_BUFFERS() \
+ do { \
+ if (size1 > MAX_ALLOCA_SIZE) \
+ { \
+ free (wcs_string1); \
+ free (mbs_offset1); \
+ } \
+ else \
+ { \
+ FREE_VAR (wcs_string1); \
+ FREE_VAR (mbs_offset1); \
+ } \
+ if (size2 > MAX_ALLOCA_SIZE) \
+ { \
+ free (wcs_string2); \
+ free (mbs_offset2); \
+ } \
+ else \
+ { \
+ FREE_VAR (wcs_string2); \
+ FREE_VAR (mbs_offset2); \
+ } \
+ } while (0)
+
+#endif
+
+
+static int
+PREFIX(re_search_2) (bufp, string1, size1, string2, size2, startpos, range,
+ regs, stop)
+ struct re_pattern_buffer *bufp;
+ const char *string1, *string2;
+ int size1, size2;
+ int startpos;
+ int range;
+ struct re_registers *regs;
+ int stop;
+{
+ int val;
+ register char *fastmap = bufp->fastmap;
+ register RE_TRANSLATE_TYPE translate = bufp->translate;
+ int total_size = size1 + size2;
+ int endpos = startpos + range;
+#ifdef WCHAR
+ /* We need wchar_t* buffers correspond to cstring1, cstring2. */
+ wchar_t *wcs_string1 = NULL, *wcs_string2 = NULL;
+ /* We need the size of wchar_t buffers correspond to csize1, csize2. */
+ int wcs_size1 = 0, wcs_size2 = 0;
+ /* offset buffer for optimizatoin. See convert_mbs_to_wc. */
+ int *mbs_offset1 = NULL, *mbs_offset2 = NULL;
+ /* They hold whether each wchar_t is binary data or not. */
+ char *is_binary = NULL;
+#endif /* WCHAR */
+
+ /* Check for out-of-range STARTPOS. */
+ if (startpos < 0 || startpos > total_size)
+ return -1;
+
+ /* Fix up RANGE if it might eventually take us outside
+ the virtual concatenation of STRING1 and STRING2.
+ Make sure we won't move STARTPOS below 0 or above TOTAL_SIZE. */
+ if (endpos < 0)
+ range = 0 - startpos;
+ else if (endpos > total_size)
+ range = total_size - startpos;
+
+ /* If the search isn't to be a backwards one, don't waste time in a
+ search for a pattern that must be anchored. */
+ if (bufp->used > 0 && range > 0
+ && ((re_opcode_t) bufp->buffer[0] == begbuf
+ /* `begline' is like `begbuf' if it cannot match at newlines. */
+ || ((re_opcode_t) bufp->buffer[0] == begline
+ && !bufp->newline_anchor)))
+ {
+ if (startpos > 0)
+ return -1;
+ else
+ range = 1;
+ }
+
+#ifdef emacs
+ /* In a forward search for something that starts with \=.
+ don't keep searching past point. */
+ if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == at_dot && range > 0)
+ {
+ range = PT - startpos;
+ if (range <= 0)
+ return -1;
+ }
+#endif /* emacs */
+
+ /* Update the fastmap now if not correct already. */
+ if (fastmap && !bufp->fastmap_accurate)
+ if (re_compile_fastmap (bufp) == -2)
+ return -2;
+
+#ifdef WCHAR
+ /* Allocate wchar_t array for wcs_string1 and wcs_string2 and
+ fill them with converted string. */
+ if (size1 != 0)
+ {
+ if (size1 > MAX_ALLOCA_SIZE)
+ {
+ wcs_string1 = TALLOC (size1 + 1, CHAR_T);
+ mbs_offset1 = TALLOC (size1 + 1, int);
+ is_binary = TALLOC (size1 + 1, char);
+ }
+ else
+ {
+ wcs_string1 = REGEX_TALLOC (size1 + 1, CHAR_T);
+ mbs_offset1 = REGEX_TALLOC (size1 + 1, int);
+ is_binary = REGEX_TALLOC (size1 + 1, char);
+ }
+ if (!wcs_string1 || !mbs_offset1 || !is_binary)
+ {
+ if (size1 > MAX_ALLOCA_SIZE)
+ {
+ free (wcs_string1);
+ free (mbs_offset1);
+ free (is_binary);
+ }
+ else
+ {
+ FREE_VAR (wcs_string1);
+ FREE_VAR (mbs_offset1);
+ FREE_VAR (is_binary);
+ }
+ return -2;
+ }
+ wcs_size1 = convert_mbs_to_wcs(wcs_string1, string1, size1,
+ mbs_offset1, is_binary);
+ wcs_string1[wcs_size1] = L'\0'; /* for a sentinel */
+ if (size1 > MAX_ALLOCA_SIZE)
+ free (is_binary);
+ else
+ FREE_VAR (is_binary);
+ }
+ if (size2 != 0)
+ {
+ if (size2 > MAX_ALLOCA_SIZE)
+ {
+ wcs_string2 = TALLOC (size2 + 1, CHAR_T);
+ mbs_offset2 = TALLOC (size2 + 1, int);
+ is_binary = TALLOC (size2 + 1, char);
+ }
+ else
+ {
+ wcs_string2 = REGEX_TALLOC (size2 + 1, CHAR_T);
+ mbs_offset2 = REGEX_TALLOC (size2 + 1, int);
+ is_binary = REGEX_TALLOC (size2 + 1, char);
+ }
+ if (!wcs_string2 || !mbs_offset2 || !is_binary)
+ {
+ FREE_WCS_BUFFERS ();
+ if (size2 > MAX_ALLOCA_SIZE)
+ free (is_binary);
+ else
+ FREE_VAR (is_binary);
+ return -2;
+ }
+ wcs_size2 = convert_mbs_to_wcs(wcs_string2, string2, size2,
+ mbs_offset2, is_binary);
+ wcs_string2[wcs_size2] = L'\0'; /* for a sentinel */
+ if (size2 > MAX_ALLOCA_SIZE)
+ free (is_binary);
+ else
+ FREE_VAR (is_binary);
+ }
+#endif /* WCHAR */
+
+
+ /* Loop through the string, looking for a place to start matching. */
+ for (;;)
+ {
+ /* If a fastmap is supplied, skip quickly over characters that
+ cannot be the start of a match. If the pattern can match the
+ null string, however, we don't need to skip characters; we want
+ the first null string. */
+ if (fastmap && startpos < total_size && !bufp->can_be_null)
+ {
+ if (range > 0) /* Searching forwards. */
+ {
+ register const char *d;
+ register int lim = 0;
+ int irange = range;
+
+ if (startpos < size1 && startpos + range >= size1)
+ lim = range - (size1 - startpos);
+
+ d = (startpos >= size1 ? string2 - size1 : string1) + startpos;
+
+ /* Written out as an if-else to avoid testing `translate'
+ inside the loop. */
+ if (translate)
+ while (range > lim
+ && !fastmap[(unsigned char)
+ translate[(unsigned char) *d++]])
+ range--;
+ else
+ while (range > lim && !fastmap[(unsigned char) *d++])
+ range--;
+
+ startpos += irange - range;
+ }
+ else /* Searching backwards. */
+ {
+ register CHAR_T c = (size1 == 0 || startpos >= size1
+ ? string2[startpos - size1]
+ : string1[startpos]);
+
+ if (!fastmap[(unsigned char) TRANSLATE (c)])
+ goto advance;
+ }
+ }
+
+ /* If can't match the null string, and that's all we have left, fail. */
+ if (range >= 0 && startpos == total_size && fastmap
+ && !bufp->can_be_null)
+ {
+#ifdef WCHAR
+ FREE_WCS_BUFFERS ();
+#endif
+ return -1;
+ }
+
+#ifdef WCHAR
+ val = wcs_re_match_2_internal (bufp, string1, size1, string2,
+ size2, startpos, regs, stop,
+ wcs_string1, wcs_size1,
+ wcs_string2, wcs_size2,
+ mbs_offset1, mbs_offset2);
+#else /* BYTE */
+ val = byte_re_match_2_internal (bufp, string1, size1, string2,
+ size2, startpos, regs, stop);
+#endif /* BYTE */
+
+#ifndef REGEX_MALLOC
+# ifdef C_ALLOCA
+ alloca (0);
+# endif
+#endif
+
+ if (val >= 0)
+ {
+#ifdef WCHAR
+ FREE_WCS_BUFFERS ();
+#endif
+ return startpos;
+ }
+
+ if (val == -2)
+ {
+#ifdef WCHAR
+ FREE_WCS_BUFFERS ();
+#endif
+ return -2;
+ }
+
+ advance:
+ if (!range)
+ break;
+ else if (range > 0)
+ {
+ range--;
+ startpos++;
+ }
+ else
+ {
+ range++;
+ startpos--;
+ }
+ }
+#ifdef WCHAR
+ FREE_WCS_BUFFERS ();
+#endif
+ return -1;
+}
+
+#ifdef WCHAR
+/* This converts PTR, a pointer into one of the search wchar_t strings
+ `string1' and `string2' into an multibyte string offset from the
+ beginning of that string. We use mbs_offset to optimize.
+ See convert_mbs_to_wcs. */
+# define POINTER_TO_OFFSET(ptr) \
+ (FIRST_STRING_P (ptr) \
+ ? ((regoff_t)(mbs_offset1 != NULL? mbs_offset1[(ptr)-string1] : 0)) \
+ : ((regoff_t)((mbs_offset2 != NULL? mbs_offset2[(ptr)-string2] : 0) \
+ + csize1)))
+#else /* BYTE */
+/* This converts PTR, a pointer into one of the search strings `string1'
+ and `string2' into an offset from the beginning of that string. */
+# define POINTER_TO_OFFSET(ptr) \
+ (FIRST_STRING_P (ptr) \
+ ? ((regoff_t) ((ptr) - string1)) \
+ : ((regoff_t) ((ptr) - string2 + size1)))
+#endif /* WCHAR */
+
+/* Macros for dealing with the split strings in re_match_2. */
+
+#define MATCHING_IN_FIRST_STRING (dend == end_match_1)
+
+/* Call before fetching a character with *d. This switches over to
+ string2 if necessary. */
+#define PREFETCH() \
+ while (d == dend) \
+ { \
+ /* End of string2 => fail. */ \
+ if (dend == end_match_2) \
+ goto fail; \
+ /* End of string1 => advance to string2. */ \
+ d = string2; \
+ dend = end_match_2; \
+ }
+
+/* Test if at very beginning or at very end of the virtual concatenation
+ of `string1' and `string2'. If only one string, it's `string2'. */
+#define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2)
+#define AT_STRINGS_END(d) ((d) == end2)
+
+
+/* Test if D points to a character which is word-constituent. We have
+ two special cases to check for: if past the end of string1, look at
+ the first character in string2; and if before the beginning of
+ string2, look at the last character in string1. */
+#ifdef WCHAR
+/* Use internationalized API instead of SYNTAX. */
+# define WORDCHAR_P(d) \
+ (iswalnum ((wint_t)((d) == end1 ? *string2 \
+ : (d) == string2 - 1 ? *(end1 - 1) : *(d))) != 0 \
+ || ((d) == end1 ? *string2 \
+ : (d) == string2 - 1 ? *(end1 - 1) : *(d)) == L'_')
+#else /* BYTE */
+# define WORDCHAR_P(d) \
+ (SYNTAX ((d) == end1 ? *string2 \
+ : (d) == string2 - 1 ? *(end1 - 1) : *(d)) \
+ == Sword)
+#endif /* WCHAR */
+
+/* Disabled due to a compiler bug -- see comment at case wordbound */
+#if 0
+/* Test if the character before D and the one at D differ with respect
+ to being word-constituent. */
+#define AT_WORD_BOUNDARY(d) \
+ (AT_STRINGS_BEG (d) || AT_STRINGS_END (d) \
+ || WORDCHAR_P (d - 1) != WORDCHAR_P (d))
+#endif
+
+/* Free everything we malloc. */
+#ifdef MATCH_MAY_ALLOCATE
+# ifdef WCHAR
+# define FREE_VARIABLES() \
+ do { \
+ REGEX_FREE_STACK (fail_stack.stack); \
+ FREE_VAR (regstart); \
+ FREE_VAR (regend); \
+ FREE_VAR (old_regstart); \
+ FREE_VAR (old_regend); \
+ FREE_VAR (best_regstart); \
+ FREE_VAR (best_regend); \
+ FREE_VAR (reg_info); \
+ FREE_VAR (reg_dummy); \
+ FREE_VAR (reg_info_dummy); \
+ if (!cant_free_wcs_buf) \
+ { \
+ FREE_VAR (string1); \
+ FREE_VAR (string2); \
+ FREE_VAR (mbs_offset1); \
+ FREE_VAR (mbs_offset2); \
+ } \
+ } while (0)
+# else /* BYTE */
+# define FREE_VARIABLES() \
+ do { \
+ REGEX_FREE_STACK (fail_stack.stack); \
+ FREE_VAR (regstart); \
+ FREE_VAR (regend); \
+ FREE_VAR (old_regstart); \
+ FREE_VAR (old_regend); \
+ FREE_VAR (best_regstart); \
+ FREE_VAR (best_regend); \
+ FREE_VAR (reg_info); \
+ FREE_VAR (reg_dummy); \
+ FREE_VAR (reg_info_dummy); \
+ } while (0)
+# endif /* WCHAR */
+#else
+# ifdef WCHAR
+# define FREE_VARIABLES() \
+ do { \
+ if (!cant_free_wcs_buf) \
+ { \
+ FREE_VAR (string1); \
+ FREE_VAR (string2); \
+ FREE_VAR (mbs_offset1); \
+ FREE_VAR (mbs_offset2); \
+ } \
+ } while (0)
+# else /* BYTE */
+# define FREE_VARIABLES() ((void)0) /* Do nothing! But inhibit gcc warning. */
+# endif /* WCHAR */
+#endif /* not MATCH_MAY_ALLOCATE */
+
+/* These values must meet several constraints. They must not be valid
+ register values; since we have a limit of 255 registers (because
+ we use only one byte in the pattern for the register number), we can
+ use numbers larger than 255. They must differ by 1, because of
+ NUM_FAILURE_ITEMS above. And the value for the lowest register must
+ be larger than the value for the highest register, so we do not try
+ to actually save any registers when none are active. */
+#define NO_HIGHEST_ACTIVE_REG (1 << BYTEWIDTH)
+#define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1)
+
+#else /* not INSIDE_RECURSION */
+/* Matching routines. */
+
+#ifndef emacs /* Emacs never uses this. */
+/* re_match is like re_match_2 except it takes only a single string. */
+
+int
+re_match (bufp, string, size, pos, regs)
+ struct re_pattern_buffer *bufp;
+ const char *string;
+ int size, pos;
+ struct re_registers *regs;
+{
+ int result;
+# ifdef MBS_SUPPORT
+ if (MB_CUR_MAX != 1)
+ result = wcs_re_match_2_internal (bufp, NULL, 0, string, size,
+ pos, regs, size,
+ NULL, 0, NULL, 0, NULL, NULL);
+ else
+# endif
+ result = byte_re_match_2_internal (bufp, NULL, 0, string, size,
+ pos, regs, size);
+# ifndef REGEX_MALLOC
+# ifdef C_ALLOCA
+ alloca (0);
+# endif
+# endif
+ return result;
+}
+# ifdef _LIBC
+weak_alias (__re_match, re_match)
+# endif
+#endif /* not emacs */
+
+#endif /* not INSIDE_RECURSION */
+
+#ifdef INSIDE_RECURSION
+static boolean PREFIX(group_match_null_string_p) _RE_ARGS ((UCHAR_T **p,
+ UCHAR_T *end,
+ PREFIX(register_info_type) *reg_info));
+static boolean PREFIX(alt_match_null_string_p) _RE_ARGS ((UCHAR_T *p,
+ UCHAR_T *end,
+ PREFIX(register_info_type) *reg_info));
+static boolean PREFIX(common_op_match_null_string_p) _RE_ARGS ((UCHAR_T **p,
+ UCHAR_T *end,
+ PREFIX(register_info_type) *reg_info));
+static int PREFIX(bcmp_translate) _RE_ARGS ((const CHAR_T *s1, const CHAR_T *s2,
+ int len, char *translate));
+#else /* not INSIDE_RECURSION */
+
+/* re_match_2 matches the compiled pattern in BUFP against the
+ the (virtual) concatenation of STRING1 and STRING2 (of length SIZE1
+ and SIZE2, respectively). We start matching at POS, and stop
+ matching at STOP.
+
+ If REGS is non-null and the `no_sub' field of BUFP is nonzero, we
+ store offsets for the substring each group matched in REGS. See the
+ documentation for exactly how many groups we fill.
+
+ We return -1 if no match, -2 if an internal error (such as the
+ failure stack overflowing). Otherwise, we return the length of the
+ matched substring. */
+
+int
+re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
+ struct re_pattern_buffer *bufp;
+ const char *string1, *string2;
+ int size1, size2;
+ int pos;
+ struct re_registers *regs;
+ int stop;
+{
+ int result;
+# ifdef MBS_SUPPORT
+ if (MB_CUR_MAX != 1)
+ result = wcs_re_match_2_internal (bufp, string1, size1, string2, size2,
+ pos, regs, stop,
+ NULL, 0, NULL, 0, NULL, NULL);
+ else
+# endif
+ result = byte_re_match_2_internal (bufp, string1, size1, string2, size2,
+ pos, regs, stop);
+
+#ifndef REGEX_MALLOC
+# ifdef C_ALLOCA
+ alloca (0);
+# endif
+#endif
+ return result;
+}
+#ifdef _LIBC
+weak_alias (__re_match_2, re_match_2)
+#endif
+
+#endif /* not INSIDE_RECURSION */
+
+#ifdef INSIDE_RECURSION
+
+#ifdef WCHAR
+static int count_mbs_length PARAMS ((int *, int));
+
+/* This check the substring (from 0, to length) of the multibyte string,
+ to which offset_buffer correspond. And count how many wchar_t_characters
+ the substring occupy. We use offset_buffer to optimization.
+ See convert_mbs_to_wcs. */
+
+static int
+count_mbs_length(offset_buffer, length)
+ int *offset_buffer;
+ int length;
+{
+ int upper, lower;
+
+ /* Check whether the size is valid. */
+ if (length < 0)
+ return -1;
+
+ if (offset_buffer == NULL)
+ return 0;
+
+ /* If there are no multibyte character, offset_buffer[i] == i.
+ Optmize for this case. */
+ if (offset_buffer[length] == length)
+ return length;
+
+ /* Set up upper with length. (because for all i, offset_buffer[i] >= i) */
+ upper = length;
+ lower = 0;
+
+ while (true)
+ {
+ int middle = (lower + upper) / 2;
+ if (middle == lower || middle == upper)
+ break;
+ if (offset_buffer[middle] > length)
+ upper = middle;
+ else if (offset_buffer[middle] < length)
+ lower = middle;
+ else
+ return middle;
+ }
+
+ return -1;
+}
+#endif /* WCHAR */
+
+/* This is a separate function so that we can force an alloca cleanup
+ afterwards. */
+#ifdef WCHAR
+static int
+wcs_re_match_2_internal (bufp, cstring1, csize1, cstring2, csize2, pos,
+ regs, stop, string1, size1, string2, size2,
+ mbs_offset1, mbs_offset2)
+ struct re_pattern_buffer *bufp;
+ const char *cstring1, *cstring2;
+ int csize1, csize2;
+ int pos;
+ struct re_registers *regs;
+ int stop;
+ /* string1 == string2 == NULL means string1/2, size1/2 and
+ mbs_offset1/2 need seting up in this function. */
+ /* We need wchar_t* buffers correspond to cstring1, cstring2. */
+ wchar_t *string1, *string2;
+ /* We need the size of wchar_t buffers correspond to csize1, csize2. */
+ int size1, size2;
+ /* offset buffer for optimizatoin. See convert_mbs_to_wc. */
+ int *mbs_offset1, *mbs_offset2;
+#else /* BYTE */
+static int
+byte_re_match_2_internal (bufp, string1, size1,string2, size2, pos,
+ regs, stop)
+ struct re_pattern_buffer *bufp;
+ const char *string1, *string2;
+ int size1, size2;
+ int pos;
+ struct re_registers *regs;
+ int stop;
+#endif /* BYTE */
+{
+ /* General temporaries. */
+ int mcnt;
+ UCHAR_T *p1;
+#ifdef WCHAR
+ /* They hold whether each wchar_t is binary data or not. */
+ char *is_binary = NULL;
+ /* If true, we can't free string1/2, mbs_offset1/2. */
+ int cant_free_wcs_buf = 1;
+#endif /* WCHAR */
+
+ /* Just past the end of the corresponding string. */
+ const CHAR_T *end1, *end2;
+
+ /* Pointers into string1 and string2, just past the last characters in
+ each to consider matching. */
+ const CHAR_T *end_match_1, *end_match_2;
+
+ /* Where we are in the data, and the end of the current string. */
+ const CHAR_T *d, *dend;
+
+ /* Where we are in the pattern, and the end of the pattern. */
+#ifdef WCHAR
+ UCHAR_T *pattern, *p;
+ register UCHAR_T *pend;
+#else /* BYTE */
+ UCHAR_T *p = bufp->buffer;
+ register UCHAR_T *pend = p + bufp->used;
+#endif /* WCHAR */
+
+ /* Mark the opcode just after a start_memory, so we can test for an
+ empty subpattern when we get to the stop_memory. */
+ UCHAR_T *just_past_start_mem = 0;
+
+ /* We use this to map every character in the string. */
+ RE_TRANSLATE_TYPE translate = bufp->translate;
+
+ /* Failure point stack. Each place that can handle a failure further
+ down the line pushes a failure point on this stack. It consists of
+ restart, regend, and reg_info for all registers corresponding to
+ the subexpressions we're currently inside, plus the number of such
+ registers, and, finally, two char *'s. The first char * is where
+ to resume scanning the pattern; the second one is where to resume
+ scanning the strings. If the latter is zero, the failure point is
+ a ``dummy''; if a failure happens and the failure point is a dummy,
+ it gets discarded and the next next one is tried. */
+#ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */
+ PREFIX(fail_stack_type) fail_stack;
+#endif
+#ifdef DEBUG
+ static unsigned failure_id;
+ unsigned nfailure_points_pushed = 0, nfailure_points_popped = 0;
+#endif
+
+#ifdef REL_ALLOC
+ /* This holds the pointer to the failure stack, when
+ it is allocated relocatably. */
+ fail_stack_elt_t *failure_stack_ptr;
+#endif
+
+ /* We fill all the registers internally, independent of what we
+ return, for use in backreferences. The number here includes
+ an element for register zero. */
+ size_t num_regs = bufp->re_nsub + 1;
+
+ /* The currently active registers. */
+ active_reg_t lowest_active_reg = NO_LOWEST_ACTIVE_REG;
+ active_reg_t highest_active_reg = NO_HIGHEST_ACTIVE_REG;
+
+ /* Information on the contents of registers. These are pointers into
+ the input strings; they record just what was matched (on this
+ attempt) by a subexpression part of the pattern, that is, the
+ regnum-th regstart pointer points to where in the pattern we began
+ matching and the regnum-th regend points to right after where we
+ stopped matching the regnum-th subexpression. (The zeroth register
+ keeps track of what the whole pattern matches.) */
+#ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */
+ const CHAR_T **regstart, **regend;
+#endif
+
+ /* If a group that's operated upon by a repetition operator fails to
+ match anything, then the register for its start will need to be
+ restored because it will have been set to wherever in the string we
+ are when we last see its open-group operator. Similarly for a
+ register's end. */
+#ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */
+ const CHAR_T **old_regstart, **old_regend;
+#endif
+
+ /* The is_active field of reg_info helps us keep track of which (possibly
+ nested) subexpressions we are currently in. The matched_something
+ field of reg_info[reg_num] helps us tell whether or not we have
+ matched any of the pattern so far this time through the reg_num-th
+ subexpression. These two fields get reset each time through any
+ loop their register is in. */
+#ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global. */
+ PREFIX(register_info_type) *reg_info;
+#endif
+
+ /* The following record the register info as found in the above
+ variables when we find a match better than any we've seen before.
+ This happens as we backtrack through the failure points, which in
+ turn happens only if we have not yet matched the entire string. */
+ unsigned best_regs_set = false;
+#ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */
+ const CHAR_T **best_regstart, **best_regend;
+#endif
+
+ /* Logically, this is `best_regend[0]'. But we don't want to have to
+ allocate space for that if we're not allocating space for anything
+ else (see below). Also, we never need info about register 0 for
+ any of the other register vectors, and it seems rather a kludge to
+ treat `best_regend' differently than the rest. So we keep track of
+ the end of the best match so far in a separate variable. We
+ initialize this to NULL so that when we backtrack the first time
+ and need to test it, it's not garbage. */
+ const CHAR_T *match_end = NULL;
+
+ /* This helps SET_REGS_MATCHED avoid doing redundant work. */
+ int set_regs_matched_done = 0;
+
+ /* Used when we pop values we don't care about. */
+#ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global. */
+ const CHAR_T **reg_dummy;
+ PREFIX(register_info_type) *reg_info_dummy;
+#endif
+
+#ifdef DEBUG
+ /* Counts the total number of registers pushed. */
+ unsigned num_regs_pushed = 0;
+#endif
+
+ DEBUG_PRINT1 ("\n\nEntering re_match_2.\n");
+
+ INIT_FAIL_STACK ();
+
+#ifdef MATCH_MAY_ALLOCATE
+ /* Do not bother to initialize all the register variables if there are
+ no groups in the pattern, as it takes a fair amount of time. If
+ there are groups, we include space for register 0 (the whole
+ pattern), even though we never use it, since it simplifies the
+ array indexing. We should fix this. */
+ if (bufp->re_nsub)
+ {
+ regstart = REGEX_TALLOC (num_regs, const CHAR_T *);
+ regend = REGEX_TALLOC (num_regs, const CHAR_T *);
+ old_regstart = REGEX_TALLOC (num_regs, const CHAR_T *);
+ old_regend = REGEX_TALLOC (num_regs, const CHAR_T *);
+ best_regstart = REGEX_TALLOC (num_regs, const CHAR_T *);
+ best_regend = REGEX_TALLOC (num_regs, const CHAR_T *);
+ reg_info = REGEX_TALLOC (num_regs, PREFIX(register_info_type));
+ reg_dummy = REGEX_TALLOC (num_regs, const CHAR_T *);
+ reg_info_dummy = REGEX_TALLOC (num_regs, PREFIX(register_info_type));
+
+ if (!(regstart && regend && old_regstart && old_regend && reg_info
+ && best_regstart && best_regend && reg_dummy && reg_info_dummy))
+ {
+ FREE_VARIABLES ();
+ return -2;
+ }
+ }
+ else
+ {
+ /* We must initialize all our variables to NULL, so that
+ `FREE_VARIABLES' doesn't try to free them. */
+ regstart = regend = old_regstart = old_regend = best_regstart
+ = best_regend = reg_dummy = NULL;
+ reg_info = reg_info_dummy = (PREFIX(register_info_type) *) NULL;
+ }
+#endif /* MATCH_MAY_ALLOCATE */
+
+ /* The starting position is bogus. */
+#ifdef WCHAR
+ if (pos < 0 || pos > csize1 + csize2)
+#else /* BYTE */
+ if (pos < 0 || pos > size1 + size2)
+#endif
+ {
+ FREE_VARIABLES ();
+ return -1;
+ }
+
+#ifdef WCHAR
+ /* Allocate wchar_t array for string1 and string2 and
+ fill them with converted string. */
+ if (string1 == NULL && string2 == NULL)
+ {
+ /* We need seting up buffers here. */
+
+ /* We must free wcs buffers in this function. */
+ cant_free_wcs_buf = 0;
+
+ if (csize1 != 0)
+ {
+ string1 = REGEX_TALLOC (csize1 + 1, CHAR_T);
+ mbs_offset1 = REGEX_TALLOC (csize1 + 1, int);
+ is_binary = REGEX_TALLOC (csize1 + 1, char);
+ if (!string1 || !mbs_offset1 || !is_binary)
+ {
+ FREE_VAR (string1);
+ FREE_VAR (mbs_offset1);
+ FREE_VAR (is_binary);
+ return -2;
+ }
+ }
+ if (csize2 != 0)
+ {
+ string2 = REGEX_TALLOC (csize2 + 1, CHAR_T);
+ mbs_offset2 = REGEX_TALLOC (csize2 + 1, int);
+ is_binary = REGEX_TALLOC (csize2 + 1, char);
+ if (!string2 || !mbs_offset2 || !is_binary)
+ {
+ FREE_VAR (string1);
+ FREE_VAR (mbs_offset1);
+ FREE_VAR (string2);
+ FREE_VAR (mbs_offset2);
+ FREE_VAR (is_binary);
+ return -2;
+ }
+ size2 = convert_mbs_to_wcs(string2, cstring2, csize2,
+ mbs_offset2, is_binary);
+ string2[size2] = L'\0'; /* for a sentinel */
+ FREE_VAR (is_binary);
+ }
+ }
+
+ /* We need to cast pattern to (wchar_t*), because we casted this compiled
+ pattern to (char*) in regex_compile. */
+ p = pattern = (CHAR_T*)bufp->buffer;
+ pend = (CHAR_T*)(bufp->buffer + bufp->used);
+
+#endif /* WCHAR */
+
+ /* Initialize subexpression text positions to -1 to mark ones that no
+ start_memory/stop_memory has been seen for. Also initialize the
+ register information struct. */
+ for (mcnt = 1; (unsigned) mcnt < num_regs; mcnt++)
+ {
+ regstart[mcnt] = regend[mcnt]
+ = old_regstart[mcnt] = old_regend[mcnt] = REG_UNSET_VALUE;
+
+ REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE;
+ IS_ACTIVE (reg_info[mcnt]) = 0;
+ MATCHED_SOMETHING (reg_info[mcnt]) = 0;
+ EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0;
+ }
+
+ /* We move `string1' into `string2' if the latter's empty -- but not if
+ `string1' is null. */
+ if (size2 == 0 && string1 != NULL)
+ {
+ string2 = string1;
+ size2 = size1;
+ string1 = 0;
+ size1 = 0;
+#ifdef WCHAR
+ mbs_offset2 = mbs_offset1;
+ csize2 = csize1;
+ mbs_offset1 = NULL;
+ csize1 = 0;
+#endif
+ }
+ end1 = string1 + size1;
+ end2 = string2 + size2;
+
+ /* Compute where to stop matching, within the two strings. */
+#ifdef WCHAR
+ if (stop <= csize1)
+ {
+ mcnt = count_mbs_length(mbs_offset1, stop);
+ end_match_1 = string1 + mcnt;
+ end_match_2 = string2;
+ }
+ else
+ {
+ if (stop > csize1 + csize2)
+ stop = csize1 + csize2;
+ end_match_1 = end1;
+ mcnt = count_mbs_length(mbs_offset2, stop-csize1);
+ end_match_2 = string2 + mcnt;
+ }
+ if (mcnt < 0)
+ { /* count_mbs_length return error. */
+ FREE_VARIABLES ();
+ return -1;
+ }
+#else
+ if (stop <= size1)
+ {
+ end_match_1 = string1 + stop;
+ end_match_2 = string2;
+ }
+ else
+ {
+ end_match_1 = end1;
+ end_match_2 = string2 + stop - size1;
+ }
+#endif /* WCHAR */
+
+ /* `p' scans through the pattern as `d' scans through the data.
+ `dend' is the end of the input string that `d' points within. `d'
+ is advanced into the following input string whenever necessary, but
+ this happens before fetching; therefore, at the beginning of the
+ loop, `d' can be pointing at the end of a string, but it cannot
+ equal `string2'. */
+#ifdef WCHAR
+ if (size1 > 0 && pos <= csize1)
+ {
+ mcnt = count_mbs_length(mbs_offset1, pos);
+ d = string1 + mcnt;
+ dend = end_match_1;
+ }
+ else
+ {
+ mcnt = count_mbs_length(mbs_offset2, pos-csize1);
+ d = string2 + mcnt;
+ dend = end_match_2;
+ }
+
+ if (mcnt < 0)
+ { /* count_mbs_length return error. */
+ FREE_VARIABLES ();
+ return -1;
+ }
+#else
+ if (size1 > 0 && pos <= size1)
+ {
+ d = string1 + pos;
+ dend = end_match_1;
+ }
+ else
+ {
+ d = string2 + pos - size1;
+ dend = end_match_2;
+ }
+#endif /* WCHAR */
+
+ DEBUG_PRINT1 ("The compiled pattern is:\n");
+ DEBUG_PRINT_COMPILED_PATTERN (bufp, p, pend);
+ DEBUG_PRINT1 ("The string to match is: `");
+ DEBUG_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2);
+ DEBUG_PRINT1 ("'\n");
+
+ /* This loops over pattern commands. It exits by returning from the
+ function if the match is complete, or it drops through if the match
+ fails at this starting point in the input data. */
+ for (;;)
+ {
+#ifdef _LIBC
+ DEBUG_PRINT2 ("\n%p: ", p);
+#else
+ DEBUG_PRINT2 ("\n0x%x: ", p);
+#endif
+
+ if (p == pend)
+ { /* End of pattern means we might have succeeded. */
+ DEBUG_PRINT1 ("end of pattern ... ");
+
+ /* If we haven't matched the entire string, and we want the
+ longest match, try backtracking. */
+ if (d != end_match_2)
+ {
+ /* 1 if this match ends in the same string (string1 or string2)
+ as the best previous match. */
+ boolean same_str_p = (FIRST_STRING_P (match_end)
+ == MATCHING_IN_FIRST_STRING);
+ /* 1 if this match is the best seen so far. */
+ boolean best_match_p;
+
+ /* AIX compiler got confused when this was combined
+ with the previous declaration. */
+ if (same_str_p)
+ best_match_p = d > match_end;
+ else
+ best_match_p = !MATCHING_IN_FIRST_STRING;
+
+ DEBUG_PRINT1 ("backtracking.\n");
+
+ if (!FAIL_STACK_EMPTY ())
+ { /* More failure points to try. */
+
+ /* If exceeds best match so far, save it. */
+ if (!best_regs_set || best_match_p)
+ {
+ best_regs_set = true;
+ match_end = d;
+
+ DEBUG_PRINT1 ("\nSAVING match as best so far.\n");
+
+ for (mcnt = 1; (unsigned) mcnt < num_regs; mcnt++)
+ {
+ best_regstart[mcnt] = regstart[mcnt];
+ best_regend[mcnt] = regend[mcnt];
+ }
+ }
+ goto fail;
+ }
+
+ /* If no failure points, don't restore garbage. And if
+ last match is real best match, don't restore second
+ best one. */
+ else if (best_regs_set && !best_match_p)
+ {
+ restore_best_regs:
+ /* Restore best match. It may happen that `dend ==
+ end_match_1' while the restored d is in string2.
+ For example, the pattern `x.*y.*z' against the
+ strings `x-' and `y-z-', if the two strings are
+ not consecutive in memory. */
+ DEBUG_PRINT1 ("Restoring best registers.\n");
+
+ d = match_end;
+ dend = ((d >= string1 && d <= end1)
+ ? end_match_1 : end_match_2);
+
+ for (mcnt = 1; (unsigned) mcnt < num_regs; mcnt++)
+ {
+ regstart[mcnt] = best_regstart[mcnt];
+ regend[mcnt] = best_regend[mcnt];
+ }
+ }
+ } /* d != end_match_2 */
+
+ succeed_label:
+ DEBUG_PRINT1 ("Accepting match.\n");
+ /* If caller wants register contents data back, do it. */
+ if (regs && !bufp->no_sub)
+ {
+ /* Have the register data arrays been allocated? */
+ if (bufp->regs_allocated == REGS_UNALLOCATED)
+ { /* No. So allocate them with malloc. We need one
+ extra element beyond `num_regs' for the `-1' marker
+ GNU code uses. */
+ regs->num_regs = MAX (RE_NREGS, num_regs + 1);
+ regs->start = TALLOC (regs->num_regs, regoff_t);
+ regs->end = TALLOC (regs->num_regs, regoff_t);
+ if (regs->start == NULL || regs->end == NULL)
+ {
+ FREE_VARIABLES ();
+ return -2;
+ }
+ bufp->regs_allocated = REGS_REALLOCATE;
+ }
+ else if (bufp->regs_allocated == REGS_REALLOCATE)
+ { /* Yes. If we need more elements than were already
+ allocated, reallocate them. If we need fewer, just
+ leave it alone. */
+ if (regs->num_regs < num_regs + 1)
+ {
+ regs->num_regs = num_regs + 1;
+ RETALLOC (regs->start, regs->num_regs, regoff_t);
+ RETALLOC (regs->end, regs->num_regs, regoff_t);
+ if (regs->start == NULL || regs->end == NULL)
+ {
+ FREE_VARIABLES ();
+ return -2;
+ }
+ }
+ }
+ else
+ {
+ /* These braces fend off a "empty body in an else-statement"
+ warning under GCC when assert expands to nothing. */
+ assert (bufp->regs_allocated == REGS_FIXED);
+ }
+
+ /* Convert the pointer data in `regstart' and `regend' to
+ indices. Register zero has to be set differently,
+ since we haven't kept track of any info for it. */
+ if (regs->num_regs > 0)
+ {
+ regs->start[0] = pos;
+#ifdef WCHAR
+ if (MATCHING_IN_FIRST_STRING)
+ regs->end[0] = mbs_offset1 != NULL ?
+ mbs_offset1[d-string1] : 0;
+ else
+ regs->end[0] = csize1 + (mbs_offset2 != NULL ?
+ mbs_offset2[d-string2] : 0);
+#else
+ regs->end[0] = (MATCHING_IN_FIRST_STRING
+ ? ((regoff_t) (d - string1))
+ : ((regoff_t) (d - string2 + size1)));
+#endif /* WCHAR */
+ }
+
+ /* Go through the first `min (num_regs, regs->num_regs)'
+ registers, since that is all we initialized. */
+ for (mcnt = 1; (unsigned) mcnt < MIN (num_regs, regs->num_regs);
+ mcnt++)
+ {
+ if (REG_UNSET (regstart[mcnt]) || REG_UNSET (regend[mcnt]))
+ regs->start[mcnt] = regs->end[mcnt] = -1;
+ else
+ {
+ regs->start[mcnt]
+ = (regoff_t) POINTER_TO_OFFSET (regstart[mcnt]);
+ regs->end[mcnt]
+ = (regoff_t) POINTER_TO_OFFSET (regend[mcnt]);
+ }
+ }
+
+ /* If the regs structure we return has more elements than
+ were in the pattern, set the extra elements to -1. If
+ we (re)allocated the registers, this is the case,
+ because we always allocate enough to have at least one
+ -1 at the end. */
+ for (mcnt = num_regs; (unsigned) mcnt < regs->num_regs; mcnt++)
+ regs->start[mcnt] = regs->end[mcnt] = -1;
+ } /* regs && !bufp->no_sub */
+
+ DEBUG_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n",
+ nfailure_points_pushed, nfailure_points_popped,
+ nfailure_points_pushed - nfailure_points_popped);
+ DEBUG_PRINT2 ("%u registers pushed.\n", num_regs_pushed);
+
+#ifdef WCHAR
+ if (MATCHING_IN_FIRST_STRING)
+ mcnt = mbs_offset1 != NULL ? mbs_offset1[d-string1] : 0;
+ else
+ mcnt = (mbs_offset2 != NULL ? mbs_offset2[d-string2] : 0) +
+ csize1;
+ mcnt -= pos;
+#else
+ mcnt = d - pos - (MATCHING_IN_FIRST_STRING
+ ? string1
+ : string2 - size1);
+#endif /* WCHAR */
+
+ DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt);
+
+ FREE_VARIABLES ();
+ return mcnt;
+ }
+
+ /* Otherwise match next pattern command. */
+ switch (SWITCH_ENUM_CAST ((re_opcode_t) *p++))
+ {
+ /* Ignore these. Used to ignore the n of succeed_n's which
+ currently have n == 0. */
+ case no_op:
+ DEBUG_PRINT1 ("EXECUTING no_op.\n");
+ break;
+
+ case succeed:
+ DEBUG_PRINT1 ("EXECUTING succeed.\n");
+ goto succeed_label;
+
+ /* Match the next n pattern characters exactly. The following
+ byte in the pattern defines n, and the n bytes after that
+ are the characters to match. */
+ case exactn:
+#ifdef MBS_SUPPORT
+ case exactn_bin:
+#endif
+ mcnt = *p++;
+ DEBUG_PRINT2 ("EXECUTING exactn %d.\n", mcnt);
+
+ /* This is written out as an if-else so we don't waste time
+ testing `translate' inside the loop. */
+ if (translate)
+ {
+ do
+ {
+ PREFETCH ();
+#ifdef WCHAR
+ if (*d <= 0xff)
+ {
+ if ((UCHAR_T) translate[(unsigned char) *d++]
+ != (UCHAR_T) *p++)
+ goto fail;
+ }
+ else
+ {
+ if (*d++ != (CHAR_T) *p++)
+ goto fail;
+ }
+#else
+ if ((UCHAR_T) translate[(unsigned char) *d++]
+ != (UCHAR_T) *p++)
+ goto fail;
+#endif /* WCHAR */
+ }
+ while (--mcnt);
+ }
+ else
+ {
+ do
+ {
+ PREFETCH ();
+ if (*d++ != (CHAR_T) *p++) goto fail;
+ }
+ while (--mcnt);
+ }
+ SET_REGS_MATCHED ();
+ break;
+
+
+ /* Match any character except possibly a newline or a null. */
+ case anychar:
+ DEBUG_PRINT1 ("EXECUTING anychar.\n");
+
+ PREFETCH ();
+
+ if ((!(bufp->syntax & RE_DOT_NEWLINE) && TRANSLATE (*d) == '\n')
+ || (bufp->syntax & RE_DOT_NOT_NULL && TRANSLATE (*d) == '\000'))
+ goto fail;
+
+ SET_REGS_MATCHED ();
+ DEBUG_PRINT2 (" Matched `%ld'.\n", (long int) *d);
+ d++;
+ break;
+
+
+ case charset:
+ case charset_not:
+ {
+ register UCHAR_T c;
+#ifdef WCHAR
+ unsigned int i, char_class_length, coll_symbol_length,
+ equiv_class_length, ranges_length, chars_length, length;
+ CHAR_T *workp, *workp2, *charset_top;
+#define WORK_BUFFER_SIZE 128
+ CHAR_T str_buf[WORK_BUFFER_SIZE];
+# ifdef _LIBC
+ uint32_t nrules;
+# endif /* _LIBC */
+#endif /* WCHAR */
+ boolean not = (re_opcode_t) *(p - 1) == charset_not;
+
+ DEBUG_PRINT2 ("EXECUTING charset%s.\n", not ? "_not" : "");
+ PREFETCH ();
+ c = TRANSLATE (*d); /* The character to match. */
+#ifdef WCHAR
+# ifdef _LIBC
+ nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+# endif /* _LIBC */
+ charset_top = p - 1;
+ char_class_length = *p++;
+ coll_symbol_length = *p++;
+ equiv_class_length = *p++;
+ ranges_length = *p++;
+ chars_length = *p++;
+ /* p points charset[6], so the address of the next instruction
+ (charset[l+m+n+2o+k+p']) equals p[l+m+n+2*o+p'],
+ where l=length of char_classes, m=length of collating_symbol,
+ n=equivalence_class, o=length of char_range,
+ p'=length of character. */
+ workp = p;
+ /* Update p to indicate the next instruction. */
+ p += char_class_length + coll_symbol_length+ equiv_class_length +
+ 2*ranges_length + chars_length;
+
+ /* match with char_class? */
+ for (i = 0; i < char_class_length ; i += CHAR_CLASS_SIZE)
+ {
+ wctype_t wctype;
+ uintptr_t alignedp = ((uintptr_t)workp
+ + __alignof__(wctype_t) - 1)
+ & ~(uintptr_t)(__alignof__(wctype_t) - 1);
+ wctype = *((wctype_t*)alignedp);
+ workp += CHAR_CLASS_SIZE;
+# ifdef _LIBC
+ if (__iswctype((wint_t)c, wctype))
+ goto char_set_matched;
+# else
+ if (iswctype((wint_t)c, wctype))
+ goto char_set_matched;
+# endif
+ }
+
+ /* match with collating_symbol? */
+# ifdef _LIBC
+ if (nrules != 0)
+ {
+ const unsigned char *extra = (const unsigned char *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB);
+
+ for (workp2 = workp + coll_symbol_length ; workp < workp2 ;
+ workp++)
+ {
+ int32_t *wextra;
+ wextra = (int32_t*)(extra + *workp++);
+ for (i = 0; i < *wextra; ++i)
+ if (TRANSLATE(d[i]) != wextra[1 + i])
+ break;
+
+ if (i == *wextra)
+ {
+ /* Update d, however d will be incremented at
+ char_set_matched:, we decrement d here. */
+ d += i - 1;
+ goto char_set_matched;
+ }
+ }
+ }
+ else /* (nrules == 0) */
+# endif
+ /* If we can't look up collation data, we use wcscoll
+ instead. */
+ {
+ for (workp2 = workp + coll_symbol_length ; workp < workp2 ;)
+ {
+ const CHAR_T *backup_d = d, *backup_dend = dend;
+# ifdef _LIBC
+ length = __wcslen (workp);
+# else
+ length = wcslen (workp);
+# endif
+
+ /* If wcscoll(the collating symbol, whole string) > 0,
+ any substring of the string never match with the
+ collating symbol. */
+# ifdef _LIBC
+ if (__wcscoll (workp, d) > 0)
+# else
+ if (wcscoll (workp, d) > 0)
+# endif
+ {
+ workp += length + 1;
+ continue;
+ }
+
+ /* First, we compare the collating symbol with
+ the first character of the string.
+ If it don't match, we add the next character to
+ the compare buffer in turn. */
+ for (i = 0 ; i < WORK_BUFFER_SIZE-1 ; i++, d++)
+ {
+ int match;
+ if (d == dend)
+ {
+ if (dend == end_match_2)
+ break;
+ d = string2;
+ dend = end_match_2;
+ }
+
+ /* add next character to the compare buffer. */
+ str_buf[i] = TRANSLATE(*d);
+ str_buf[i+1] = '\0';
+
+# ifdef _LIBC
+ match = __wcscoll (workp, str_buf);
+# else
+ match = wcscoll (workp, str_buf);
+# endif
+ if (match == 0)
+ goto char_set_matched;
+
+ if (match < 0)
+ /* (str_buf > workp) indicate (str_buf + X > workp),
+ because for all X (str_buf + X > str_buf).
+ So we don't need continue this loop. */
+ break;
+
+ /* Otherwise(str_buf < workp),
+ (str_buf+next_character) may equals (workp).
+ So we continue this loop. */
+ }
+ /* not matched */
+ d = backup_d;
+ dend = backup_dend;
+ workp += length + 1;
+ }
+ }
+ /* match with equivalence_class? */
+# ifdef _LIBC
+ if (nrules != 0)
+ {
+ const CHAR_T *backup_d = d, *backup_dend = dend;
+ /* Try to match the equivalence class against
+ those known to the collate implementation. */
+ const int32_t *table;
+ const int32_t *weights;
+ const int32_t *extra;
+ const int32_t *indirect;
+ int32_t idx, idx2;
+ wint_t *cp;
+ size_t len;
+
+ /* This #include defines a local function! */
+# include <locale/weightwc.h>
+
+ table = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEWC);
+ weights = (const wint_t *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTWC);
+ extra = (const wint_t *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAWC);
+ indirect = (const int32_t *)
+ _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTWC);
+
+ /* Write 1 collating element to str_buf, and
+ get its index. */
+ idx2 = 0;
+
+ for (i = 0 ; idx2 == 0 && i < WORK_BUFFER_SIZE - 1; i++)
+ {
+ cp = (wint_t*)str_buf;
+ if (d == dend)
+ {
+ if (dend == end_match_2)
+ break;
+ d = string2;
+ dend = end_match_2;
+ }
+ str_buf[i] = TRANSLATE(*(d+i));
+ str_buf[i+1] = '\0'; /* sentinel */
+ idx2 = findidx ((const wint_t**)&cp);
+ }
+
+ /* Update d, however d will be incremented at
+ char_set_matched:, we decrement d here. */
+ d = backup_d + ((wchar_t*)cp - (wchar_t*)str_buf - 1);
+ if (d >= dend)
+ {
+ if (dend == end_match_2)
+ d = dend;
+ else
+ {
+ d = string2;
+ dend = end_match_2;
+ }
+ }
+
+ len = weights[idx2];
+
+ for (workp2 = workp + equiv_class_length ; workp < workp2 ;
+ workp++)
+ {
+ idx = (int32_t)*workp;
+ /* We already checked idx != 0 in regex_compile. */
+
+ if (idx2 != 0 && len == weights[idx])
+ {
+ int cnt = 0;
+ while (cnt < len && (weights[idx + 1 + cnt]
+ == weights[idx2 + 1 + cnt]))
+ ++cnt;
+
+ if (cnt == len)
+ goto char_set_matched;
+ }
+ }
+ /* not matched */
+ d = backup_d;
+ dend = backup_dend;
+ }
+ else /* (nrules == 0) */
+# endif
+ /* If we can't look up collation data, we use wcscoll
+ instead. */
+ {
+ for (workp2 = workp + equiv_class_length ; workp < workp2 ;)
+ {
+ const CHAR_T *backup_d = d, *backup_dend = dend;
+# ifdef _LIBC
+ length = __wcslen (workp);
+# else
+ length = wcslen (workp);
+# endif
+
+ /* If wcscoll(the collating symbol, whole string) > 0,
+ any substring of the string never match with the
+ collating symbol. */
+# ifdef _LIBC
+ if (__wcscoll (workp, d) > 0)
+# else
+ if (wcscoll (workp, d) > 0)
+# endif
+ {
+ workp += length + 1;
+ break;
+ }
+
+ /* First, we compare the equivalence class with
+ the first character of the string.
+ If it don't match, we add the next character to
+ the compare buffer in turn. */
+ for (i = 0 ; i < WORK_BUFFER_SIZE - 1 ; i++, d++)
+ {
+ int match;
+ if (d == dend)
+ {
+ if (dend == end_match_2)
+ break;
+ d = string2;
+ dend = end_match_2;
+ }
+
+ /* add next character to the compare buffer. */
+ str_buf[i] = TRANSLATE(*d);
+ str_buf[i+1] = '\0';
+
+# ifdef _LIBC
+ match = __wcscoll (workp, str_buf);
+# else
+ match = wcscoll (workp, str_buf);
+# endif
+
+ if (match == 0)
+ goto char_set_matched;
+
+ if (match < 0)
+ /* (str_buf > workp) indicate (str_buf + X > workp),
+ because for all X (str_buf + X > str_buf).
+ So we don't need continue this loop. */
+ break;
+
+ /* Otherwise(str_buf < workp),
+ (str_buf+next_character) may equals (workp).
+ So we continue this loop. */
+ }
+ /* not matched */
+ d = backup_d;
+ dend = backup_dend;
+ workp += length + 1;
+ }
+ }
+
+ /* match with char_range? */
+# ifdef _LIBC
+ if (nrules != 0)
+ {
+ uint32_t collseqval;
+ const char *collseq = (const char *)
+ _NL_CURRENT(LC_COLLATE, _NL_COLLATE_COLLSEQWC);
+
+ collseqval = collseq_table_lookup (collseq, c);
+
+ for (; workp < p - chars_length ;)
+ {
+ uint32_t start_val, end_val;
+
+ /* We already compute the collation sequence value
+ of the characters (or collating symbols). */
+ start_val = (uint32_t) *workp++; /* range_start */
+ end_val = (uint32_t) *workp++; /* range_end */
+
+ if (start_val <= collseqval && collseqval <= end_val)
+ goto char_set_matched;
+ }
+ }
+ else
+# endif
+ {
+ /* We set range_start_char at str_buf[0], range_end_char
+ at str_buf[4], and compared char at str_buf[2]. */
+ str_buf[1] = 0;
+ str_buf[2] = c;
+ str_buf[3] = 0;
+ str_buf[5] = 0;
+ for (; workp < p - chars_length ;)
+ {
+ wchar_t *range_start_char, *range_end_char;
+
+ /* match if (range_start_char <= c <= range_end_char). */
+
+ /* If range_start(or end) < 0, we assume -range_start(end)
+ is the offset of the collating symbol which is specified
+ as the character of the range start(end). */
+
+ /* range_start */
+ if (*workp < 0)
+ range_start_char = charset_top - (*workp++);
+ else
+ {
+ str_buf[0] = *workp++;
+ range_start_char = str_buf;
+ }
+
+ /* range_end */
+ if (*workp < 0)
+ range_end_char = charset_top - (*workp++);
+ else
+ {
+ str_buf[4] = *workp++;
+ range_end_char = str_buf + 4;
+ }
+
+# ifdef _LIBC
+ if (__wcscoll (range_start_char, str_buf+2) <= 0
+ && __wcscoll (str_buf+2, range_end_char) <= 0)
+# else
+ if (wcscoll (range_start_char, str_buf+2) <= 0
+ && wcscoll (str_buf+2, range_end_char) <= 0)
+# endif
+ goto char_set_matched;
+ }
+ }
+
+ /* match with char? */
+ for (; workp < p ; workp++)
+ if (c == *workp)
+ goto char_set_matched;
+
+ not = !not;
+
+ char_set_matched:
+ if (not) goto fail;
+#else
+ /* Cast to `unsigned' instead of `unsigned char' in case the
+ bit list is a full 32 bytes long. */
+ if (c < (unsigned) (*p * BYTEWIDTH)
+ && p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
+ not = !not;
+
+ p += 1 + *p;
+
+ if (!not) goto fail;
+#undef WORK_BUFFER_SIZE
+#endif /* WCHAR */
+ SET_REGS_MATCHED ();
+ d++;
+ break;
+ }
+
+
+ /* The beginning of a group is represented by start_memory.
+ The arguments are the register number in the next byte, and the
+ number of groups inner to this one in the next. The text
+ matched within the group is recorded (in the internal
+ registers data structure) under the register number. */
+ case start_memory:
+ DEBUG_PRINT3 ("EXECUTING start_memory %ld (%ld):\n",
+ (long int) *p, (long int) p[1]);
+
+ /* Find out if this group can match the empty string. */
+ p1 = p; /* To send to group_match_null_string_p. */
+
+ if (REG_MATCH_NULL_STRING_P (reg_info[*p]) == MATCH_NULL_UNSET_VALUE)
+ REG_MATCH_NULL_STRING_P (reg_info[*p])
+ = PREFIX(group_match_null_string_p) (&p1, pend, reg_info);
+
+ /* Save the position in the string where we were the last time
+ we were at this open-group operator in case the group is
+ operated upon by a repetition operator, e.g., with `(a*)*b'
+ against `ab'; then we want to ignore where we are now in
+ the string in case this attempt to match fails. */
+ old_regstart[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p])
+ ? REG_UNSET (regstart[*p]) ? d : regstart[*p]
+ : regstart[*p];
+ DEBUG_PRINT2 (" old_regstart: %d\n",
+ POINTER_TO_OFFSET (old_regstart[*p]));
+
+ regstart[*p] = d;
+ DEBUG_PRINT2 (" regstart: %d\n", POINTER_TO_OFFSET (regstart[*p]));
+
+ IS_ACTIVE (reg_info[*p]) = 1;
+ MATCHED_SOMETHING (reg_info[*p]) = 0;
+
+ /* Clear this whenever we change the register activity status. */
+ set_regs_matched_done = 0;
+
+ /* This is the new highest active register. */
+ highest_active_reg = *p;
+
+ /* If nothing was active before, this is the new lowest active
+ register. */
+ if (lowest_active_reg == NO_LOWEST_ACTIVE_REG)
+ lowest_active_reg = *p;
+
+ /* Move past the register number and inner group count. */
+ p += 2;
+ just_past_start_mem = p;
+
+ break;
+
+
+ /* The stop_memory opcode represents the end of a group. Its
+ arguments are the same as start_memory's: the register
+ number, and the number of inner groups. */
+ case stop_memory:
+ DEBUG_PRINT3 ("EXECUTING stop_memory %ld (%ld):\n",
+ (long int) *p, (long int) p[1]);
+
+ /* We need to save the string position the last time we were at
+ this close-group operator in case the group is operated
+ upon by a repetition operator, e.g., with `((a*)*(b*)*)*'
+ against `aba'; then we want to ignore where we are now in
+ the string in case this attempt to match fails. */
+ old_regend[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p])
+ ? REG_UNSET (regend[*p]) ? d : regend[*p]
+ : regend[*p];
+ DEBUG_PRINT2 (" old_regend: %d\n",
+ POINTER_TO_OFFSET (old_regend[*p]));
+
+ regend[*p] = d;
+ DEBUG_PRINT2 (" regend: %d\n", POINTER_TO_OFFSET (regend[*p]));
+
+ /* This register isn't active anymore. */
+ IS_ACTIVE (reg_info[*p]) = 0;
+
+ /* Clear this whenever we change the register activity status. */
+ set_regs_matched_done = 0;
+
+ /* If this was the only register active, nothing is active
+ anymore. */
+ if (lowest_active_reg == highest_active_reg)
+ {
+ lowest_active_reg = NO_LOWEST_ACTIVE_REG;
+ highest_active_reg = NO_HIGHEST_ACTIVE_REG;
+ }
+ else
+ { /* We must scan for the new highest active register, since
+ it isn't necessarily one less than now: consider
+ (a(b)c(d(e)f)g). When group 3 ends, after the f), the
+ new highest active register is 1. */
+ UCHAR_T r = *p - 1;
+ while (r > 0 && !IS_ACTIVE (reg_info[r]))
+ r--;
+
+ /* If we end up at register zero, that means that we saved
+ the registers as the result of an `on_failure_jump', not
+ a `start_memory', and we jumped to past the innermost
+ `stop_memory'. For example, in ((.)*) we save
+ registers 1 and 2 as a result of the *, but when we pop
+ back to the second ), we are at the stop_memory 1.
+ Thus, nothing is active. */
+ if (r == 0)
+ {
+ lowest_active_reg = NO_LOWEST_ACTIVE_REG;
+ highest_active_reg = NO_HIGHEST_ACTIVE_REG;
+ }
+ else
+ highest_active_reg = r;
+ }
+
+ /* If just failed to match something this time around with a
+ group that's operated on by a repetition operator, try to
+ force exit from the ``loop'', and restore the register
+ information for this group that we had before trying this
+ last match. */
+ if ((!MATCHED_SOMETHING (reg_info[*p])
+ || just_past_start_mem == p - 1)
+ && (p + 2) < pend)
+ {
+ boolean is_a_jump_n = false;
+
+ p1 = p + 2;
+ mcnt = 0;
+ switch ((re_opcode_t) *p1++)
+ {
+ case jump_n:
+ is_a_jump_n = true;
+ case pop_failure_jump:
+ case maybe_pop_jump:
+ case jump:
+ case dummy_failure_jump:
+ EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+ if (is_a_jump_n)
+ p1 += OFFSET_ADDRESS_SIZE;
+ break;
+
+ default:
+ /* do nothing */ ;
+ }
+ p1 += mcnt;
+
+ /* If the next operation is a jump backwards in the pattern
+ to an on_failure_jump right before the start_memory
+ corresponding to this stop_memory, exit from the loop
+ by forcing a failure after pushing on the stack the
+ on_failure_jump's jump in the pattern, and d. */
+ if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump
+ && (re_opcode_t) p1[1+OFFSET_ADDRESS_SIZE] == start_memory
+ && p1[2+OFFSET_ADDRESS_SIZE] == *p)
+ {
+ /* If this group ever matched anything, then restore
+ what its registers were before trying this last
+ failed match, e.g., with `(a*)*b' against `ab' for
+ regstart[1], and, e.g., with `((a*)*(b*)*)*'
+ against `aba' for regend[3].
+
+ Also restore the registers for inner groups for,
+ e.g., `((a*)(b*))*' against `aba' (register 3 would
+ otherwise get trashed). */
+
+ if (EVER_MATCHED_SOMETHING (reg_info[*p]))
+ {
+ unsigned r;
+
+ EVER_MATCHED_SOMETHING (reg_info[*p]) = 0;
+
+ /* Restore this and inner groups' (if any) registers. */
+ for (r = *p; r < (unsigned) *p + (unsigned) *(p + 1);
+ r++)
+ {
+ regstart[r] = old_regstart[r];
+
+ /* xx why this test? */
+ if (old_regend[r] >= regstart[r])
+ regend[r] = old_regend[r];
+ }
+ }
+ p1++;
+ EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+ PUSH_FAILURE_POINT (p1 + mcnt, d, -2);
+
+ goto fail;
+ }
+ }
+
+ /* Move past the register number and the inner group count. */
+ p += 2;
+ break;
+
+
+ /* \<digit> has been turned into a `duplicate' command which is
+ followed by the numeric value of <digit> as the register number. */
+ case duplicate:
+ {
+ register const CHAR_T *d2, *dend2;
+ int regno = *p++; /* Get which register to match against. */
+ DEBUG_PRINT2 ("EXECUTING duplicate %d.\n", regno);
+
+ /* Can't back reference a group which we've never matched. */
+ if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno]))
+ goto fail;
+
+ /* Where in input to try to start matching. */
+ d2 = regstart[regno];
+
+ /* Where to stop matching; if both the place to start and
+ the place to stop matching are in the same string, then
+ set to the place to stop, otherwise, for now have to use
+ the end of the first string. */
+
+ dend2 = ((FIRST_STRING_P (regstart[regno])
+ == FIRST_STRING_P (regend[regno]))
+ ? regend[regno] : end_match_1);
+ for (;;)
+ {
+ /* If necessary, advance to next segment in register
+ contents. */
+ while (d2 == dend2)
+ {
+ if (dend2 == end_match_2) break;
+ if (dend2 == regend[regno]) break;
+
+ /* End of string1 => advance to string2. */
+ d2 = string2;
+ dend2 = regend[regno];
+ }
+ /* At end of register contents => success */
+ if (d2 == dend2) break;
+
+ /* If necessary, advance to next segment in data. */
+ PREFETCH ();
+
+ /* How many characters left in this segment to match. */
+ mcnt = dend - d;
+
+ /* Want how many consecutive characters we can match in
+ one shot, so, if necessary, adjust the count. */
+ if (mcnt > dend2 - d2)
+ mcnt = dend2 - d2;
+
+ /* Compare that many; failure if mismatch, else move
+ past them. */
+ if (translate
+ ? PREFIX(bcmp_translate) (d, d2, mcnt, translate)
+ : memcmp (d, d2, mcnt*sizeof(UCHAR_T)))
+ goto fail;
+ d += mcnt, d2 += mcnt;
+
+ /* Do this because we've match some characters. */
+ SET_REGS_MATCHED ();
+ }
+ }
+ break;
+
+
+ /* begline matches the empty string at the beginning of the string
+ (unless `not_bol' is set in `bufp'), and, if
+ `newline_anchor' is set, after newlines. */
+ case begline:
+ DEBUG_PRINT1 ("EXECUTING begline.\n");
+
+ if (AT_STRINGS_BEG (d))
+ {
+ if (!bufp->not_bol) break;
+ }
+ else if (d[-1] == '\n' && bufp->newline_anchor)
+ {
+ break;
+ }
+ /* In all other cases, we fail. */
+ goto fail;
+
+
+ /* endline is the dual of begline. */
+ case endline:
+ DEBUG_PRINT1 ("EXECUTING endline.\n");
+
+ if (AT_STRINGS_END (d))
+ {
+ if (!bufp->not_eol) break;
+ }
+
+ /* We have to ``prefetch'' the next character. */
+ else if ((d == end1 ? *string2 : *d) == '\n'
+ && bufp->newline_anchor)
+ {
+ break;
+ }
+ goto fail;
+
+
+ /* Match at the very beginning of the data. */
+ case begbuf:
+ DEBUG_PRINT1 ("EXECUTING begbuf.\n");
+ if (AT_STRINGS_BEG (d))
+ break;
+ goto fail;
+
+
+ /* Match at the very end of the data. */
+ case endbuf:
+ DEBUG_PRINT1 ("EXECUTING endbuf.\n");
+ if (AT_STRINGS_END (d))
+ break;
+ goto fail;
+
+
+ /* on_failure_keep_string_jump is used to optimize `.*\n'. It
+ pushes NULL as the value for the string on the stack. Then
+ `pop_failure_point' will keep the current value for the
+ string, instead of restoring it. To see why, consider
+ matching `foo\nbar' against `.*\n'. The .* matches the foo;
+ then the . fails against the \n. But the next thing we want
+ to do is match the \n against the \n; if we restored the
+ string value, we would be back at the foo.
+
+ Because this is used only in specific cases, we don't need to
+ check all the things that `on_failure_jump' does, to make
+ sure the right things get saved on the stack. Hence we don't
+ share its code. The only reason to push anything on the
+ stack at all is that otherwise we would have to change
+ `anychar's code to do something besides goto fail in this
+ case; that seems worse than this. */
+ case on_failure_keep_string_jump:
+ DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump");
+
+ EXTRACT_NUMBER_AND_INCR (mcnt, p);
+#ifdef _LIBC
+ DEBUG_PRINT3 (" %d (to %p):\n", mcnt, p + mcnt);
+#else
+ DEBUG_PRINT3 (" %d (to 0x%x):\n", mcnt, p + mcnt);
+#endif
+
+ PUSH_FAILURE_POINT (p + mcnt, NULL, -2);
+ break;
+
+
+ /* Uses of on_failure_jump:
+
+ Each alternative starts with an on_failure_jump that points
+ to the beginning of the next alternative. Each alternative
+ except the last ends with a jump that in effect jumps past
+ the rest of the alternatives. (They really jump to the
+ ending jump of the following alternative, because tensioning
+ these jumps is a hassle.)
+
+ Repeats start with an on_failure_jump that points past both
+ the repetition text and either the following jump or
+ pop_failure_jump back to this on_failure_jump. */
+ case on_failure_jump:
+ on_failure:
+ DEBUG_PRINT1 ("EXECUTING on_failure_jump");
+
+ EXTRACT_NUMBER_AND_INCR (mcnt, p);
+#ifdef _LIBC
+ DEBUG_PRINT3 (" %d (to %p)", mcnt, p + mcnt);
+#else
+ DEBUG_PRINT3 (" %d (to 0x%x)", mcnt, p + mcnt);
+#endif
+
+ /* If this on_failure_jump comes right before a group (i.e.,
+ the original * applied to a group), save the information
+ for that group and all inner ones, so that if we fail back
+ to this point, the group's information will be correct.
+ For example, in \(a*\)*\1, we need the preceding group,
+ and in \(zz\(a*\)b*\)\2, we need the inner group. */
+
+ /* We can't use `p' to check ahead because we push
+ a failure point to `p + mcnt' after we do this. */
+ p1 = p;
+
+ /* We need to skip no_op's before we look for the
+ start_memory in case this on_failure_jump is happening as
+ the result of a completed succeed_n, as in \(a\)\{1,3\}b\1
+ against aba. */
+ while (p1 < pend && (re_opcode_t) *p1 == no_op)
+ p1++;
+
+ if (p1 < pend && (re_opcode_t) *p1 == start_memory)
+ {
+ /* We have a new highest active register now. This will
+ get reset at the start_memory we are about to get to,
+ but we will have saved all the registers relevant to
+ this repetition op, as described above. */
+ highest_active_reg = *(p1 + 1) + *(p1 + 2);
+ if (lowest_active_reg == NO_LOWEST_ACTIVE_REG)
+ lowest_active_reg = *(p1 + 1);
+ }
+
+ DEBUG_PRINT1 (":\n");
+ PUSH_FAILURE_POINT (p + mcnt, d, -2);
+ break;
+
+
+ /* A smart repeat ends with `maybe_pop_jump'.
+ We change it to either `pop_failure_jump' or `jump'. */
+ case maybe_pop_jump:
+ EXTRACT_NUMBER_AND_INCR (mcnt, p);
+ DEBUG_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt);
+ {
+ register UCHAR_T *p2 = p;
+
+ /* Compare the beginning of the repeat with what in the
+ pattern follows its end. If we can establish that there
+ is nothing that they would both match, i.e., that we
+ would have to backtrack because of (as in, e.g., `a*a')
+ then we can change to pop_failure_jump, because we'll
+ never have to backtrack.
+
+ This is not true in the case of alternatives: in
+ `(a|ab)*' we do need to backtrack to the `ab' alternative
+ (e.g., if the string was `ab'). But instead of trying to
+ detect that here, the alternative has put on a dummy
+ failure point which is what we will end up popping. */
+
+ /* Skip over open/close-group commands.
+ If what follows this loop is a ...+ construct,
+ look at what begins its body, since we will have to
+ match at least one of that. */
+ while (1)
+ {
+ if (p2 + 2 < pend
+ && ((re_opcode_t) *p2 == stop_memory
+ || (re_opcode_t) *p2 == start_memory))
+ p2 += 3;
+ else if (p2 + 2 + 2 * OFFSET_ADDRESS_SIZE < pend
+ && (re_opcode_t) *p2 == dummy_failure_jump)
+ p2 += 2 + 2 * OFFSET_ADDRESS_SIZE;
+ else
+ break;
+ }
+
+ p1 = p + mcnt;
+ /* p1[0] ... p1[2] are the `on_failure_jump' corresponding
+ to the `maybe_finalize_jump' of this case. Examine what
+ follows. */
+
+ /* If we're at the end of the pattern, we can change. */
+ if (p2 == pend)
+ {
+ /* Consider what happens when matching ":\(.*\)"
+ against ":/". I don't really understand this code
+ yet. */
+ p[-(1+OFFSET_ADDRESS_SIZE)] = (UCHAR_T)
+ pop_failure_jump;
+ DEBUG_PRINT1
+ (" End of pattern: change to `pop_failure_jump'.\n");
+ }
+
+ else if ((re_opcode_t) *p2 == exactn
+#ifdef MBS_SUPPORT
+ || (re_opcode_t) *p2 == exactn_bin
+#endif
+ || (bufp->newline_anchor && (re_opcode_t) *p2 == endline))
+ {
+ register UCHAR_T c
+ = *p2 == (UCHAR_T) endline ? '\n' : p2[2];
+
+ if (((re_opcode_t) p1[1+OFFSET_ADDRESS_SIZE] == exactn
+#ifdef MBS_SUPPORT
+ || (re_opcode_t) p1[1+OFFSET_ADDRESS_SIZE] == exactn_bin
+#endif
+ ) && p1[3+OFFSET_ADDRESS_SIZE] != c)
+ {
+ p[-(1+OFFSET_ADDRESS_SIZE)] = (UCHAR_T)
+ pop_failure_jump;
+#ifdef WCHAR
+ DEBUG_PRINT3 (" %C != %C => pop_failure_jump.\n",
+ (wint_t) c,
+ (wint_t) p1[3+OFFSET_ADDRESS_SIZE]);
+#else
+ DEBUG_PRINT3 (" %c != %c => pop_failure_jump.\n",
+ (char) c,
+ (char) p1[3+OFFSET_ADDRESS_SIZE]);
+#endif
+ }
+
+#ifndef WCHAR
+ else if ((re_opcode_t) p1[3] == charset
+ || (re_opcode_t) p1[3] == charset_not)
+ {
+ int not = (re_opcode_t) p1[3] == charset_not;
+
+ if (c < (unsigned) (p1[4] * BYTEWIDTH)
+ && p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
+ not = !not;
+
+ /* `not' is equal to 1 if c would match, which means
+ that we can't change to pop_failure_jump. */
+ if (!not)
+ {
+ p[-3] = (unsigned char) pop_failure_jump;
+ DEBUG_PRINT1 (" No match => pop_failure_jump.\n");
+ }
+ }
+#endif /* not WCHAR */
+ }
+#ifndef WCHAR
+ else if ((re_opcode_t) *p2 == charset)
+ {
+ /* We win if the first character of the loop is not part
+ of the charset. */
+ if ((re_opcode_t) p1[3] == exactn
+ && ! ((int) p2[1] * BYTEWIDTH > (int) p1[5]
+ && (p2[2 + p1[5] / BYTEWIDTH]
+ & (1 << (p1[5] % BYTEWIDTH)))))
+ {
+ p[-3] = (unsigned char) pop_failure_jump;
+ DEBUG_PRINT1 (" No match => pop_failure_jump.\n");
+ }
+
+ else if ((re_opcode_t) p1[3] == charset_not)
+ {
+ int idx;
+ /* We win if the charset_not inside the loop
+ lists every character listed in the charset after. */
+ for (idx = 0; idx < (int) p2[1]; idx++)
+ if (! (p2[2 + idx] == 0
+ || (idx < (int) p1[4]
+ && ((p2[2 + idx] & ~ p1[5 + idx]) == 0))))
+ break;
+
+ if (idx == p2[1])
+ {
+ p[-3] = (unsigned char) pop_failure_jump;
+ DEBUG_PRINT1 (" No match => pop_failure_jump.\n");
+ }
+ }
+ else if ((re_opcode_t) p1[3] == charset)
+ {
+ int idx;
+ /* We win if the charset inside the loop
+ has no overlap with the one after the loop. */
+ for (idx = 0;
+ idx < (int) p2[1] && idx < (int) p1[4];
+ idx++)
+ if ((p2[2 + idx] & p1[5 + idx]) != 0)
+ break;
+
+ if (idx == p2[1] || idx == p1[4])
+ {
+ p[-3] = (unsigned char) pop_failure_jump;
+ DEBUG_PRINT1 (" No match => pop_failure_jump.\n");
+ }
+ }
+ }
+#endif /* not WCHAR */
+ }
+ p -= OFFSET_ADDRESS_SIZE; /* Point at relative address again. */
+ if ((re_opcode_t) p[-1] != pop_failure_jump)
+ {
+ p[-1] = (UCHAR_T) jump;
+ DEBUG_PRINT1 (" Match => jump.\n");
+ goto unconditional_jump;
+ }
+ /* Note fall through. */
+
+
+ /* The end of a simple repeat has a pop_failure_jump back to
+ its matching on_failure_jump, where the latter will push a
+ failure point. The pop_failure_jump takes off failure
+ points put on by this pop_failure_jump's matching
+ on_failure_jump; we got through the pattern to here from the
+ matching on_failure_jump, so didn't fail. */
+ case pop_failure_jump:
+ {
+ /* We need to pass separate storage for the lowest and
+ highest registers, even though we don't care about the
+ actual values. Otherwise, we will restore only one
+ register from the stack, since lowest will == highest in
+ `pop_failure_point'. */
+ active_reg_t dummy_low_reg, dummy_high_reg;
+ UCHAR_T *pdummy = NULL;
+ const CHAR_T *sdummy = NULL;
+
+ DEBUG_PRINT1 ("EXECUTING pop_failure_jump.\n");
+ POP_FAILURE_POINT (sdummy, pdummy,
+ dummy_low_reg, dummy_high_reg,
+ reg_dummy, reg_dummy, reg_info_dummy);
+ }
+ /* Note fall through. */
+
+ unconditional_jump:
+#ifdef _LIBC
+ DEBUG_PRINT2 ("\n%p: ", p);
+#else
+ DEBUG_PRINT2 ("\n0x%x: ", p);
+#endif
+ /* Note fall through. */
+
+ /* Unconditionally jump (without popping any failure points). */
+ case jump:
+ EXTRACT_NUMBER_AND_INCR (mcnt, p); /* Get the amount to jump. */
+ DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt);
+ p += mcnt; /* Do the jump. */
+#ifdef _LIBC
+ DEBUG_PRINT2 ("(to %p).\n", p);
+#else
+ DEBUG_PRINT2 ("(to 0x%x).\n", p);
+#endif
+ break;
+
+
+ /* We need this opcode so we can detect where alternatives end
+ in `group_match_null_string_p' et al. */
+ case jump_past_alt:
+ DEBUG_PRINT1 ("EXECUTING jump_past_alt.\n");
+ goto unconditional_jump;
+
+
+ /* Normally, the on_failure_jump pushes a failure point, which
+ then gets popped at pop_failure_jump. We will end up at
+ pop_failure_jump, also, and with a pattern of, say, `a+', we
+ are skipping over the on_failure_jump, so we have to push
+ something meaningless for pop_failure_jump to pop. */
+ case dummy_failure_jump:
+ DEBUG_PRINT1 ("EXECUTING dummy_failure_jump.\n");
+ /* It doesn't matter what we push for the string here. What
+ the code at `fail' tests is the value for the pattern. */
+ PUSH_FAILURE_POINT (NULL, NULL, -2);
+ goto unconditional_jump;
+
+
+ /* At the end of an alternative, we need to push a dummy failure
+ point in case we are followed by a `pop_failure_jump', because
+ we don't want the failure point for the alternative to be
+ popped. For example, matching `(a|ab)*' against `aab'
+ requires that we match the `ab' alternative. */
+ case push_dummy_failure:
+ DEBUG_PRINT1 ("EXECUTING push_dummy_failure.\n");
+ /* See comments just above at `dummy_failure_jump' about the
+ two zeroes. */
+ PUSH_FAILURE_POINT (NULL, NULL, -2);
+ break;
+
+ /* Have to succeed matching what follows at least n times.
+ After that, handle like `on_failure_jump'. */
+ case succeed_n:
+ EXTRACT_NUMBER (mcnt, p + OFFSET_ADDRESS_SIZE);
+ DEBUG_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt);
+
+ assert (mcnt >= 0);
+ /* Originally, this is how many times we HAVE to succeed. */
+ if (mcnt > 0)
+ {
+ mcnt--;
+ p += OFFSET_ADDRESS_SIZE;
+ STORE_NUMBER_AND_INCR (p, mcnt);
+#ifdef _LIBC
+ DEBUG_PRINT3 (" Setting %p to %d.\n", p - OFFSET_ADDRESS_SIZE
+ , mcnt);
+#else
+ DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p - OFFSET_ADDRESS_SIZE
+ , mcnt);
+#endif
+ }
+ else if (mcnt == 0)
+ {
+#ifdef _LIBC
+ DEBUG_PRINT2 (" Setting two bytes from %p to no_op.\n",
+ p + OFFSET_ADDRESS_SIZE);
+#else
+ DEBUG_PRINT2 (" Setting two bytes from 0x%x to no_op.\n",
+ p + OFFSET_ADDRESS_SIZE);
+#endif /* _LIBC */
+
+#ifdef WCHAR
+ p[1] = (UCHAR_T) no_op;
+#else
+ p[2] = (UCHAR_T) no_op;
+ p[3] = (UCHAR_T) no_op;
+#endif /* WCHAR */
+ goto on_failure;
+ }
+ break;
+
+ case jump_n:
+ EXTRACT_NUMBER (mcnt, p + OFFSET_ADDRESS_SIZE);
+ DEBUG_PRINT2 ("EXECUTING jump_n %d.\n", mcnt);
+
+ /* Originally, this is how many times we CAN jump. */
+ if (mcnt)
+ {
+ mcnt--;
+ STORE_NUMBER (p + OFFSET_ADDRESS_SIZE, mcnt);
+
+#ifdef _LIBC
+ DEBUG_PRINT3 (" Setting %p to %d.\n", p + OFFSET_ADDRESS_SIZE,
+ mcnt);
+#else
+ DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p + OFFSET_ADDRESS_SIZE,
+ mcnt);
+#endif /* _LIBC */
+ goto unconditional_jump;
+ }
+ /* If don't have to jump any more, skip over the rest of command. */
+ else
+ p += 2 * OFFSET_ADDRESS_SIZE;
+ break;
+
+ case set_number_at:
+ {
+ DEBUG_PRINT1 ("EXECUTING set_number_at.\n");
+
+ EXTRACT_NUMBER_AND_INCR (mcnt, p);
+ p1 = p + mcnt;
+ EXTRACT_NUMBER_AND_INCR (mcnt, p);
+#ifdef _LIBC
+ DEBUG_PRINT3 (" Setting %p to %d.\n", p1, mcnt);
+#else
+ DEBUG_PRINT3 (" Setting 0x%x to %d.\n", p1, mcnt);
+#endif
+ STORE_NUMBER (p1, mcnt);
+ break;
+ }
+
+#if 0
+ /* The DEC Alpha C compiler 3.x generates incorrect code for the
+ test WORDCHAR_P (d - 1) != WORDCHAR_P (d) in the expansion of
+ AT_WORD_BOUNDARY, so this code is disabled. Expanding the
+ macro and introducing temporary variables works around the bug. */
+
+ case wordbound:
+ DEBUG_PRINT1 ("EXECUTING wordbound.\n");
+ if (AT_WORD_BOUNDARY (d))
+ break;
+ goto fail;
+
+ case notwordbound:
+ DEBUG_PRINT1 ("EXECUTING notwordbound.\n");
+ if (AT_WORD_BOUNDARY (d))
+ goto fail;
+ break;
+#else
+ case wordbound:
+ {
+ boolean prevchar, thischar;
+
+ DEBUG_PRINT1 ("EXECUTING wordbound.\n");
+ if (AT_STRINGS_BEG (d) || AT_STRINGS_END (d))
+ break;
+
+ prevchar = WORDCHAR_P (d - 1);
+ thischar = WORDCHAR_P (d);
+ if (prevchar != thischar)
+ break;
+ goto fail;
+ }
+
+ case notwordbound:
+ {
+ boolean prevchar, thischar;
+
+ DEBUG_PRINT1 ("EXECUTING notwordbound.\n");
+ if (AT_STRINGS_BEG (d) || AT_STRINGS_END (d))
+ goto fail;
+
+ prevchar = WORDCHAR_P (d - 1);
+ thischar = WORDCHAR_P (d);
+ if (prevchar != thischar)
+ goto fail;
+ break;
+ }
+#endif
+
+ case wordbeg:
+ DEBUG_PRINT1 ("EXECUTING wordbeg.\n");
+ if (!AT_STRINGS_END (d) && WORDCHAR_P (d)
+ && (AT_STRINGS_BEG (d) || !WORDCHAR_P (d - 1)))
+ break;
+ goto fail;
+
+ case wordend:
+ DEBUG_PRINT1 ("EXECUTING wordend.\n");
+ if (!AT_STRINGS_BEG (d) && WORDCHAR_P (d - 1)
+ && (AT_STRINGS_END (d) || !WORDCHAR_P (d)))
+ break;
+ goto fail;
+
+#ifdef emacs
+ case before_dot:
+ DEBUG_PRINT1 ("EXECUTING before_dot.\n");
+ if (PTR_CHAR_POS ((unsigned char *) d) >= point)
+ goto fail;
+ break;
+
+ case at_dot:
+ DEBUG_PRINT1 ("EXECUTING at_dot.\n");
+ if (PTR_CHAR_POS ((unsigned char *) d) != point)
+ goto fail;
+ break;
+
+ case after_dot:
+ DEBUG_PRINT1 ("EXECUTING after_dot.\n");
+ if (PTR_CHAR_POS ((unsigned char *) d) <= point)
+ goto fail;
+ break;
+
+ case syntaxspec:
+ DEBUG_PRINT2 ("EXECUTING syntaxspec %d.\n", mcnt);
+ mcnt = *p++;
+ goto matchsyntax;
+
+ case wordchar:
+ DEBUG_PRINT1 ("EXECUTING Emacs wordchar.\n");
+ mcnt = (int) Sword;
+ matchsyntax:
+ PREFETCH ();
+ /* Can't use *d++ here; SYNTAX may be an unsafe macro. */
+ d++;
+ if (SYNTAX (d[-1]) != (enum syntaxcode) mcnt)
+ goto fail;
+ SET_REGS_MATCHED ();
+ break;
+
+ case notsyntaxspec:
+ DEBUG_PRINT2 ("EXECUTING notsyntaxspec %d.\n", mcnt);
+ mcnt = *p++;
+ goto matchnotsyntax;
+
+ case notwordchar:
+ DEBUG_PRINT1 ("EXECUTING Emacs notwordchar.\n");
+ mcnt = (int) Sword;
+ matchnotsyntax:
+ PREFETCH ();
+ /* Can't use *d++ here; SYNTAX may be an unsafe macro. */
+ d++;
+ if (SYNTAX (d[-1]) == (enum syntaxcode) mcnt)
+ goto fail;
+ SET_REGS_MATCHED ();
+ break;
+
+#else /* not emacs */
+ case wordchar:
+ DEBUG_PRINT1 ("EXECUTING non-Emacs wordchar.\n");
+ PREFETCH ();
+ if (!WORDCHAR_P (d))
+ goto fail;
+ SET_REGS_MATCHED ();
+ d++;
+ break;
+
+ case notwordchar:
+ DEBUG_PRINT1 ("EXECUTING non-Emacs notwordchar.\n");
+ PREFETCH ();
+ if (WORDCHAR_P (d))
+ goto fail;
+ SET_REGS_MATCHED ();
+ d++;
+ break;
+#endif /* not emacs */
+
+ default:
+ abort ();
+ }
+ continue; /* Successfully executed one pattern command; keep going. */
+
+
+ /* We goto here if a matching operation fails. */
+ fail:
+ if (!FAIL_STACK_EMPTY ())
+ { /* A restart point is known. Restore to that state. */
+ DEBUG_PRINT1 ("\nFAIL:\n");
+ POP_FAILURE_POINT (d, p,
+ lowest_active_reg, highest_active_reg,
+ regstart, regend, reg_info);
+
+ /* If this failure point is a dummy, try the next one. */
+ if (!p)
+ goto fail;
+
+ /* If we failed to the end of the pattern, don't examine *p. */
+ assert (p <= pend);
+ if (p < pend)
+ {
+ boolean is_a_jump_n = false;
+
+ /* If failed to a backwards jump that's part of a repetition
+ loop, need to pop this failure point and use the next one. */
+ switch ((re_opcode_t) *p)
+ {
+ case jump_n:
+ is_a_jump_n = true;
+ case maybe_pop_jump:
+ case pop_failure_jump:
+ case jump:
+ p1 = p + 1;
+ EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+ p1 += mcnt;
+
+ if ((is_a_jump_n && (re_opcode_t) *p1 == succeed_n)
+ || (!is_a_jump_n
+ && (re_opcode_t) *p1 == on_failure_jump))
+ goto fail;
+ break;
+ default:
+ /* do nothing */ ;
+ }
+ }
+
+ if (d >= string1 && d <= end1)
+ dend = end_match_1;
+ }
+ else
+ break; /* Matching at this starting point really fails. */
+ } /* for (;;) */
+
+ if (best_regs_set)
+ goto restore_best_regs;
+
+ FREE_VARIABLES ();
+
+ return -1; /* Failure to match. */
+} /* re_match_2 */
+
+/* Subroutine definitions for re_match_2. */
+
+
+/* We are passed P pointing to a register number after a start_memory.
+
+ Return true if the pattern up to the corresponding stop_memory can
+ match the empty string, and false otherwise.
+
+ If we find the matching stop_memory, sets P to point to one past its number.
+ Otherwise, sets P to an undefined byte less than or equal to END.
+
+ We don't handle duplicates properly (yet). */
+
+static boolean
+PREFIX(group_match_null_string_p) (p, end, reg_info)
+ UCHAR_T **p, *end;
+ PREFIX(register_info_type) *reg_info;
+{
+ int mcnt;
+ /* Point to after the args to the start_memory. */
+ UCHAR_T *p1 = *p + 2;
+
+ while (p1 < end)
+ {
+ /* Skip over opcodes that can match nothing, and return true or
+ false, as appropriate, when we get to one that can't, or to the
+ matching stop_memory. */
+
+ switch ((re_opcode_t) *p1)
+ {
+ /* Could be either a loop or a series of alternatives. */
+ case on_failure_jump:
+ p1++;
+ EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+
+ /* If the next operation is not a jump backwards in the
+ pattern. */
+
+ if (mcnt >= 0)
+ {
+ /* Go through the on_failure_jumps of the alternatives,
+ seeing if any of the alternatives cannot match nothing.
+ The last alternative starts with only a jump,
+ whereas the rest start with on_failure_jump and end
+ with a jump, e.g., here is the pattern for `a|b|c':
+
+ /on_failure_jump/0/6/exactn/1/a/jump_past_alt/0/6
+ /on_failure_jump/0/6/exactn/1/b/jump_past_alt/0/3
+ /exactn/1/c
+
+ So, we have to first go through the first (n-1)
+ alternatives and then deal with the last one separately. */
+
+
+ /* Deal with the first (n-1) alternatives, which start
+ with an on_failure_jump (see above) that jumps to right
+ past a jump_past_alt. */
+
+ while ((re_opcode_t) p1[mcnt-(1+OFFSET_ADDRESS_SIZE)] ==
+ jump_past_alt)
+ {
+ /* `mcnt' holds how many bytes long the alternative
+ is, including the ending `jump_past_alt' and
+ its number. */
+
+ if (!PREFIX(alt_match_null_string_p) (p1, p1 + mcnt -
+ (1 + OFFSET_ADDRESS_SIZE),
+ reg_info))
+ return false;
+
+ /* Move to right after this alternative, including the
+ jump_past_alt. */
+ p1 += mcnt;
+
+ /* Break if it's the beginning of an n-th alternative
+ that doesn't begin with an on_failure_jump. */
+ if ((re_opcode_t) *p1 != on_failure_jump)
+ break;
+
+ /* Still have to check that it's not an n-th
+ alternative that starts with an on_failure_jump. */
+ p1++;
+ EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+ if ((re_opcode_t) p1[mcnt-(1+OFFSET_ADDRESS_SIZE)] !=
+ jump_past_alt)
+ {
+ /* Get to the beginning of the n-th alternative. */
+ p1 -= 1 + OFFSET_ADDRESS_SIZE;
+ break;
+ }
+ }
+
+ /* Deal with the last alternative: go back and get number
+ of the `jump_past_alt' just before it. `mcnt' contains
+ the length of the alternative. */
+ EXTRACT_NUMBER (mcnt, p1 - OFFSET_ADDRESS_SIZE);
+
+ if (!PREFIX(alt_match_null_string_p) (p1, p1 + mcnt, reg_info))
+ return false;
+
+ p1 += mcnt; /* Get past the n-th alternative. */
+ } /* if mcnt > 0 */
+ break;
+
+
+ case stop_memory:
+ assert (p1[1] == **p);
+ *p = p1 + 2;
+ return true;
+
+
+ default:
+ if (!PREFIX(common_op_match_null_string_p) (&p1, end, reg_info))
+ return false;
+ }
+ } /* while p1 < end */
+
+ return false;
+} /* group_match_null_string_p */
+
+
+/* Similar to group_match_null_string_p, but doesn't deal with alternatives:
+ It expects P to be the first byte of a single alternative and END one
+ byte past the last. The alternative can contain groups. */
+
+static boolean
+PREFIX(alt_match_null_string_p) (p, end, reg_info)
+ UCHAR_T *p, *end;
+ PREFIX(register_info_type) *reg_info;
+{
+ int mcnt;
+ UCHAR_T *p1 = p;
+
+ while (p1 < end)
+ {
+ /* Skip over opcodes that can match nothing, and break when we get
+ to one that can't. */
+
+ switch ((re_opcode_t) *p1)
+ {
+ /* It's a loop. */
+ case on_failure_jump:
+ p1++;
+ EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+ p1 += mcnt;
+ break;
+
+ default:
+ if (!PREFIX(common_op_match_null_string_p) (&p1, end, reg_info))
+ return false;
+ }
+ } /* while p1 < end */
+
+ return true;
+} /* alt_match_null_string_p */
+
+
+/* Deals with the ops common to group_match_null_string_p and
+ alt_match_null_string_p.
+
+ Sets P to one after the op and its arguments, if any. */
+
+static boolean
+PREFIX(common_op_match_null_string_p) (p, end, reg_info)
+ UCHAR_T **p, *end;
+ PREFIX(register_info_type) *reg_info;
+{
+ int mcnt;
+ boolean ret;
+ int reg_no;
+ UCHAR_T *p1 = *p;
+
+ switch ((re_opcode_t) *p1++)
+ {
+ case no_op:
+ case begline:
+ case endline:
+ case begbuf:
+ case endbuf:
+ case wordbeg:
+ case wordend:
+ case wordbound:
+ case notwordbound:
+#ifdef emacs
+ case before_dot:
+ case at_dot:
+ case after_dot:
+#endif
+ break;
+
+ case start_memory:
+ reg_no = *p1;
+ assert (reg_no > 0 && reg_no <= MAX_REGNUM);
+ ret = PREFIX(group_match_null_string_p) (&p1, end, reg_info);
+
+ /* Have to set this here in case we're checking a group which
+ contains a group and a back reference to it. */
+
+ if (REG_MATCH_NULL_STRING_P (reg_info[reg_no]) == MATCH_NULL_UNSET_VALUE)
+ REG_MATCH_NULL_STRING_P (reg_info[reg_no]) = ret;
+
+ if (!ret)
+ return false;
+ break;
+
+ /* If this is an optimized succeed_n for zero times, make the jump. */
+ case jump:
+ EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+ if (mcnt >= 0)
+ p1 += mcnt;
+ else
+ return false;
+ break;
+
+ case succeed_n:
+ /* Get to the number of times to succeed. */
+ p1 += OFFSET_ADDRESS_SIZE;
+ EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+
+ if (mcnt == 0)
+ {
+ p1 -= 2 * OFFSET_ADDRESS_SIZE;
+ EXTRACT_NUMBER_AND_INCR (mcnt, p1);
+ p1 += mcnt;
+ }
+ else
+ return false;
+ break;
+
+ case duplicate:
+ if (!REG_MATCH_NULL_STRING_P (reg_info[*p1]))
+ return false;
+ break;
+
+ case set_number_at:
+ p1 += 2 * OFFSET_ADDRESS_SIZE;
+
+ default:
+ /* All other opcodes mean we cannot match the empty string. */
+ return false;
+ }
+
+ *p = p1;
+ return true;
+} /* common_op_match_null_string_p */
+
+
+/* Return zero if TRANSLATE[S1] and TRANSLATE[S2] are identical for LEN
+ bytes; nonzero otherwise. */
+
+static int
+PREFIX(bcmp_translate) (s1, s2, len, translate)
+ const CHAR_T *s1, *s2;
+ register int len;
+ RE_TRANSLATE_TYPE translate;
+{
+ register const UCHAR_T *p1 = (const UCHAR_T *) s1;
+ register const UCHAR_T *p2 = (const UCHAR_T *) s2;
+ while (len)
+ {
+#ifdef WCHAR
+ if (((*p1<=0xff)?translate[*p1++]:*p1++)
+ != ((*p2<=0xff)?translate[*p2++]:*p2++))
+ return 1;
+#else /* BYTE */
+ if (translate[*p1++] != translate[*p2++]) return 1;
+#endif /* WCHAR */
+ len--;
+ }
+ return 0;
+}
+
+
+#else /* not INSIDE_RECURSION */
+
+/* Entry points for GNU code. */
+
+/* re_compile_pattern is the GNU regular expression compiler: it
+ compiles PATTERN (of length SIZE) and puts the result in BUFP.
+ Returns 0 if the pattern was valid, otherwise an error string.
+
+ Assumes the `allocated' (and perhaps `buffer') and `translate' fields
+ are set in BUFP on entry.
+
+ We call regex_compile to do the actual compilation. */
+
+const char *
+re_compile_pattern (pattern, length, bufp)
+ const char *pattern;
+ size_t length;
+ struct re_pattern_buffer *bufp;
+{
+ reg_errcode_t ret;
+
+ /* GNU code is written to assume at least RE_NREGS registers will be set
+ (and at least one extra will be -1). */
+ bufp->regs_allocated = REGS_UNALLOCATED;
+
+ /* And GNU code determines whether or not to get register information
+ by passing null for the REGS argument to re_match, etc., not by
+ setting no_sub. */
+ bufp->no_sub = 0;
+
+ /* Match anchors at newline. */
+ bufp->newline_anchor = 1;
+
+# ifdef MBS_SUPPORT
+ if (MB_CUR_MAX != 1)
+ ret = wcs_regex_compile (pattern, length, re_syntax_options, bufp);
+ else
+# endif
+ ret = byte_regex_compile (pattern, length, re_syntax_options, bufp);
+
+ if (!ret)
+ return NULL;
+ return gettext (re_error_msgid + re_error_msgid_idx[(int) ret]);
+}
+#ifdef _LIBC
+weak_alias (__re_compile_pattern, re_compile_pattern)
+#endif
+
+/* Entry points compatible with 4.2 BSD regex library. We don't define
+ them unless specifically requested. */
+
+#if defined _REGEX_RE_COMP || defined _LIBC
+
+/* BSD has one and only one pattern buffer. */
+static struct re_pattern_buffer re_comp_buf;
+
+char *
+#ifdef _LIBC
+/* Make these definitions weak in libc, so POSIX programs can redefine
+ these names if they don't use our functions, and still use
+ regcomp/regexec below without link errors. */
+weak_function
+#endif
+re_comp (s)
+ const char *s;
+{
+ reg_errcode_t ret;
+
+ if (!s)
+ {
+ if (!re_comp_buf.buffer)
+ return gettext ("No previous regular expression");
+ return 0;
+ }
+
+ if (!re_comp_buf.buffer)
+ {
+ re_comp_buf.buffer = (unsigned char *) malloc (200);
+ if (re_comp_buf.buffer == NULL)
+ return (char *) gettext (re_error_msgid
+ + re_error_msgid_idx[(int) REG_ESPACE]);
+ re_comp_buf.allocated = 200;
+
+ re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH);
+ if (re_comp_buf.fastmap == NULL)
+ return (char *) gettext (re_error_msgid
+ + re_error_msgid_idx[(int) REG_ESPACE]);
+ }
+
+ /* Since `re_exec' always passes NULL for the `regs' argument, we
+ don't need to initialize the pattern buffer fields which affect it. */
+
+ /* Match anchors at newlines. */
+ re_comp_buf.newline_anchor = 1;
+
+# ifdef MBS_SUPPORT
+ if (MB_CUR_MAX != 1)
+ ret = wcs_regex_compile (s, strlen (s), re_syntax_options, &re_comp_buf);
+ else
+# endif
+ ret = byte_regex_compile (s, strlen (s), re_syntax_options, &re_comp_buf);
+
+ if (!ret)
+ return NULL;
+
+ /* Yes, we're discarding `const' here if !HAVE_LIBINTL. */
+ return (char *) gettext (re_error_msgid + re_error_msgid_idx[(int) ret]);
+}
+
+
+int
+#ifdef _LIBC
+weak_function
+#endif
+re_exec (s)
+ const char *s;
+{
+ const int len = strlen (s);
+ return
+ 0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0);
+}
+
+#endif /* _REGEX_RE_COMP */
+
+/* POSIX.2 functions. Don't define these for Emacs. */
+
+#ifndef emacs
+
+/* regcomp takes a regular expression as a string and compiles it.
+
+ PREG is a regex_t *. We do not expect any fields to be initialized,
+ since POSIX says we shouldn't. Thus, we set
+
+ `buffer' to the compiled pattern;
+ `used' to the length of the compiled pattern;
+ `syntax' to RE_SYNTAX_POSIX_EXTENDED if the
+ REG_EXTENDED bit in CFLAGS is set; otherwise, to
+ RE_SYNTAX_POSIX_BASIC;
+ `newline_anchor' to REG_NEWLINE being set in CFLAGS;
+ `fastmap' to an allocated space for the fastmap;
+ `fastmap_accurate' to zero;
+ `re_nsub' to the number of subexpressions in PATTERN.
+
+ PATTERN is the address of the pattern string.
+
+ CFLAGS is a series of bits which affect compilation.
+
+ If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we
+ use POSIX basic syntax.
+
+ If REG_NEWLINE is set, then . and [^...] don't match newline.
+ Also, regexec will try a match beginning after every newline.
+
+ If REG_ICASE is set, then we considers upper- and lowercase
+ versions of letters to be equivalent when matching.
+
+ If REG_NOSUB is set, then when PREG is passed to regexec, that
+ routine will report only success or failure, and nothing about the
+ registers.
+
+ It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for
+ the return codes and their meanings.) */
+
+int
+regcomp (preg, pattern, cflags)
+ regex_t *preg;
+ const char *pattern;
+ int cflags;
+{
+ reg_errcode_t ret;
+ reg_syntax_t syntax
+ = (cflags & REG_EXTENDED) ?
+ RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC;
+
+ /* regex_compile will allocate the space for the compiled pattern. */
+ preg->buffer = 0;
+ preg->allocated = 0;
+ preg->used = 0;
+
+ /* Try to allocate space for the fastmap. */
+ preg->fastmap = (char *) malloc (1 << BYTEWIDTH);
+
+ if (cflags & REG_ICASE)
+ {
+ unsigned i;
+
+ preg->translate
+ = (RE_TRANSLATE_TYPE) malloc (CHAR_SET_SIZE
+ * sizeof (*(RE_TRANSLATE_TYPE)0));
+ if (preg->translate == NULL)
+ return (int) REG_ESPACE;
+
+ /* Map uppercase characters to corresponding lowercase ones. */
+ for (i = 0; i < CHAR_SET_SIZE; i++)
+ preg->translate[i] = ISUPPER (i) ? TOLOWER (i) : i;
+ }
+ else
+ preg->translate = NULL;
+
+ /* If REG_NEWLINE is set, newlines are treated differently. */
+ if (cflags & REG_NEWLINE)
+ { /* REG_NEWLINE implies neither . nor [^...] match newline. */
+ syntax &= ~RE_DOT_NEWLINE;
+ syntax |= RE_HAT_LISTS_NOT_NEWLINE;
+ /* It also changes the matching behavior. */
+ preg->newline_anchor = 1;
+ }
+ else
+ preg->newline_anchor = 0;
+
+ preg->no_sub = !!(cflags & REG_NOSUB);
+
+ /* POSIX says a null character in the pattern terminates it, so we
+ can use strlen here in compiling the pattern. */
+# ifdef MBS_SUPPORT
+ if (MB_CUR_MAX != 1)
+ ret = wcs_regex_compile (pattern, strlen (pattern), syntax, preg);
+ else
+# endif
+ ret = byte_regex_compile (pattern, strlen (pattern), syntax, preg);
+
+ /* POSIX doesn't distinguish between an unmatched open-group and an
+ unmatched close-group: both are REG_EPAREN. */
+ if (ret == REG_ERPAREN) ret = REG_EPAREN;
+
+ if (ret == REG_NOERROR && preg->fastmap)
+ {
+ /* Compute the fastmap now, since regexec cannot modify the pattern
+ buffer. */
+ if (re_compile_fastmap (preg) == -2)
+ {
+ /* Some error occurred while computing the fastmap, just forget
+ about it. */
+ free (preg->fastmap);
+ preg->fastmap = NULL;
+ }
+ }
+
+ return (int) ret;
+}
+#ifdef _LIBC
+weak_alias (__regcomp, regcomp)
+#endif
+
+
+/* regexec searches for a given pattern, specified by PREG, in the
+ string STRING.
+
+ If NMATCH is zero or REG_NOSUB was set in the cflags argument to
+ `regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at
+ least NMATCH elements, and we set them to the offsets of the
+ corresponding matched substrings.
+
+ EFLAGS specifies `execution flags' which affect matching: if
+ REG_NOTBOL is set, then ^ does not match at the beginning of the
+ string; if REG_NOTEOL is set, then $ does not match at the end.
+
+ We return 0 if we find a match and REG_NOMATCH if not. */
+
+int
+regexec (preg, string, nmatch, pmatch, eflags)
+ const regex_t *preg;
+ const char *string;
+ size_t nmatch;
+ regmatch_t pmatch[];
+ int eflags;
+{
+ int ret;
+ struct re_registers regs;
+ regex_t private_preg;
+ int len = strlen (string);
+ boolean want_reg_info = !preg->no_sub && nmatch > 0;
+
+ private_preg = *preg;
+
+ private_preg.not_bol = !!(eflags & REG_NOTBOL);
+ private_preg.not_eol = !!(eflags & REG_NOTEOL);
+
+ /* The user has told us exactly how many registers to return
+ information about, via `nmatch'. We have to pass that on to the
+ matching routines. */
+ private_preg.regs_allocated = REGS_FIXED;
+
+ if (want_reg_info)
+ {
+ regs.num_regs = nmatch;
+ regs.start = TALLOC (nmatch * 2, regoff_t);
+ if (regs.start == NULL)
+ return (int) REG_NOMATCH;
+ regs.end = regs.start + nmatch;
+ }
+
+ /* Perform the searching operation. */
+ ret = re_search (&private_preg, string, len,
+ /* start: */ 0, /* range: */ len,
+ want_reg_info ? &regs : (struct re_registers *) 0);
+
+ /* Copy the register information to the POSIX structure. */
+ if (want_reg_info)
+ {
+ if (ret >= 0)
+ {
+ unsigned r;
+
+ for (r = 0; r < nmatch; r++)
+ {
+ pmatch[r].rm_so = regs.start[r];
+ pmatch[r].rm_eo = regs.end[r];
+ }
+ }
+
+ /* If we needed the temporary register info, free the space now. */
+ free (regs.start);
+ }
+
+ /* We want zero return to mean success, unlike `re_search'. */
+ return ret >= 0 ? (int) REG_NOERROR : (int) REG_NOMATCH;
+}
+#ifdef _LIBC
+weak_alias (__regexec, regexec)
+#endif
+
+
+/* Returns a message corresponding to an error code, ERRCODE, returned
+ from either regcomp or regexec. We don't use PREG here. */
+
+size_t
+regerror (errcode, preg, errbuf, errbuf_size)
+ int errcode;
+ const regex_t *preg;
+ char *errbuf;
+ size_t errbuf_size;
+{
+ const char *msg;
+ size_t msg_size;
+
+ if (errcode < 0
+ || errcode >= (int) (sizeof (re_error_msgid_idx)
+ / sizeof (re_error_msgid_idx[0])))
+ /* Only error codes returned by the rest of the code should be passed
+ to this routine. If we are given anything else, or if other regex
+ code generates an invalid error code, then the program has a bug.
+ Dump core so we can fix it. */
+ abort ();
+
+ msg = gettext (re_error_msgid + re_error_msgid_idx[errcode]);
+
+ msg_size = strlen (msg) + 1; /* Includes the null. */
+
+ if (errbuf_size != 0)
+ {
+ if (msg_size > errbuf_size)
+ {
+#if defined HAVE_MEMPCPY || defined _LIBC
+ *((char *) __mempcpy (errbuf, msg, errbuf_size - 1)) = '\0';
+#else
+ memcpy (errbuf, msg, errbuf_size - 1);
+ errbuf[errbuf_size - 1] = 0;
+#endif
+ }
+ else
+ memcpy (errbuf, msg, msg_size);
+ }
+
+ return msg_size;
+}
+#ifdef _LIBC
+weak_alias (__regerror, regerror)
+#endif
+
+
+/* Free dynamically allocated space used by PREG. */
+
+void
+regfree (preg)
+ regex_t *preg;
+{
+ if (preg->buffer != NULL)
+ free (preg->buffer);
+ preg->buffer = NULL;
+
+ preg->allocated = 0;
+ preg->used = 0;
+
+ if (preg->fastmap != NULL)
+ free (preg->fastmap);
+ preg->fastmap = NULL;
+ preg->fastmap_accurate = 0;
+
+ if (preg->translate != NULL)
+ free (preg->translate);
+ preg->translate = NULL;
+}
+#ifdef _LIBC
+weak_alias (__regfree, regfree)
+#endif
+
+#endif /* not emacs */
+
+#endif /* not INSIDE_RECURSION */
+
+
+#undef STORE_NUMBER
+#undef STORE_NUMBER_AND_INCR
+#undef EXTRACT_NUMBER
+#undef EXTRACT_NUMBER_AND_INCR
+
+#undef DEBUG_PRINT_COMPILED_PATTERN
+#undef DEBUG_PRINT_DOUBLE_STRING
+
+#undef INIT_FAIL_STACK
+#undef RESET_FAIL_STACK
+#undef DOUBLE_FAIL_STACK
+#undef PUSH_PATTERN_OP
+#undef PUSH_FAILURE_POINTER
+#undef PUSH_FAILURE_INT
+#undef PUSH_FAILURE_ELT
+#undef POP_FAILURE_POINTER
+#undef POP_FAILURE_INT
+#undef POP_FAILURE_ELT
+#undef DEBUG_PUSH
+#undef DEBUG_POP
+#undef PUSH_FAILURE_POINT
+#undef POP_FAILURE_POINT
+
+#undef REG_UNSET_VALUE
+#undef REG_UNSET
+
+#undef PATFETCH
+#undef PATFETCH_RAW
+#undef PATUNFETCH
+#undef TRANSLATE
+
+#undef INIT_BUF_SIZE
+#undef GET_BUFFER_SPACE
+#undef BUF_PUSH
+#undef BUF_PUSH_2
+#undef BUF_PUSH_3
+#undef STORE_JUMP
+#undef STORE_JUMP2
+#undef INSERT_JUMP
+#undef INSERT_JUMP2
+#undef EXTEND_BUFFER
+#undef GET_UNSIGNED_NUMBER
+#undef FREE_STACK_RETURN
+
+# undef POINTER_TO_OFFSET
+# undef MATCHING_IN_FRST_STRING
+# undef PREFETCH
+# undef AT_STRINGS_BEG
+# undef AT_STRINGS_END
+# undef WORDCHAR_P
+# undef FREE_VAR
+# undef FREE_VARIABLES
+# undef NO_HIGHEST_ACTIVE_REG
+# undef NO_LOWEST_ACTIVE_REG
+
+# undef CHAR_T
+# undef UCHAR_T
+# undef COMPILED_BUFFER_VAR
+# undef OFFSET_ADDRESS_SIZE
+# undef CHAR_CLASS_SIZE
+# undef PREFIX
+# undef ARG_PREFIX
+# undef PUT_CHAR
+# undef BYTE
+# undef WCHAR
+
+# define DEFINED_ONCE
diff --git a/contrib/binutils/libiberty/rename.c b/contrib/binutils/libiberty/rename.c
index 2e9dec1..0563062 100644
--- a/contrib/binutils/libiberty/rename.c
+++ b/contrib/binutils/libiberty/rename.c
@@ -1,7 +1,16 @@
/* rename -- rename a file
This function is in the public domain. */
-/* Rename a file. */
+/*
+
+@deftypefn Supplemental int rename (const char *@var{old}, const char *@var{new})
+
+Renames a file from @var{old} to @var{new}. If @var{new} already
+exists, it is removed.
+
+@end deftypefn
+
+*/
#ifdef HAVE_CONFIG_H
#include "config.h"
diff --git a/contrib/binutils/libiberty/rindex.c b/contrib/binutils/libiberty/rindex.c
index 061d126..ef9cdc5 100644
--- a/contrib/binutils/libiberty/rindex.c
+++ b/contrib/binutils/libiberty/rindex.c
@@ -1,5 +1,17 @@
/* Stub implementation of (obsolete) rindex(). */
+/*
+
+@deftypefn Supplemental char* rindex (const char *@var{s}, int @var{c})
+
+Returns a pointer to the last occurrence of the character @var{c} in
+the string @var{s}, or @code{NULL} if not found. The use of @code{rindex} is
+deprecated in new programs in favor of @code{strrchr}.
+
+@end deftypefn
+
+*/
+
extern char *strrchr ();
char *
diff --git a/contrib/binutils/libiberty/setenv.c b/contrib/binutils/libiberty/setenv.c
index f025716..8394faf 100644
--- a/contrib/binutils/libiberty/setenv.c
+++ b/contrib/binutils/libiberty/setenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
This file based on setenv.c in the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -16,10 +16,29 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+
+/*
+
+@deftypefn Supplemental int setenv (const char *@var{name}, const char *@var{value}, int @var{overwrite})
+@deftypefnx Supplemental void unsetenv (const char *@var{name})
+
+@code{setenv} adds @var{name} to the environment with value
+@var{value}. If the name was already present in the environment,
+the new value will be stored only if @var{overwrite} is nonzero.
+The companion @code{unsetenv} function removes @var{name} from the
+environment. This implementation is not safe for multithreaded code.
+
+@end deftypefn
+
+*/
+
#if HAVE_CONFIG_H
# include <config.h>
#endif
+#define setenv libiberty_setenv
+#define unsetenv libiberty_unsetenv
+
#include "ansidecl.h"
#include <sys/types.h> /* For `size_t' */
#include <stdio.h> /* For `NULL' */
@@ -45,6 +64,9 @@ extern int errno;
extern char **environ;
#endif
+#undef setenv
+#undef unsetenv
+
/* LOCK and UNLOCK are defined as no-ops. This makes the libiberty
* implementation MT-Unsafe. */
#define LOCK
diff --git a/contrib/binutils/libiberty/sigsetmask.c b/contrib/binutils/libiberty/sigsetmask.c
index db6408d..f705fbb 100644
--- a/contrib/binutils/libiberty/sigsetmask.c
+++ b/contrib/binutils/libiberty/sigsetmask.c
@@ -3,8 +3,17 @@
Contributed by Cygnus Support.
This file is in the public doamin. */
-/* Set the current signal mask to the set provided, and return the
- previous value */
+/*
+
+@deftypefn Supplemental int sigsetmask (int @var{set})
+
+Sets the signal mask to the one provided in @var{set} and returns
+the old mask (which, for libiberty's implementation, will always
+be the value @code{1}).
+
+@end deftypefn
+
+*/
#define _POSIX_SOURCE
#include <ansidecl.h>
diff --git a/contrib/binutils/libiberty/spaces.c b/contrib/binutils/libiberty/spaces.c
index ea92571..bfead7e 100644
--- a/contrib/binutils/libiberty/spaces.c
+++ b/contrib/binutils/libiberty/spaces.c
@@ -19,21 +19,13 @@ Boston, MA 02111-1307, USA. */
/*
-NAME
+@deftypefn Extension char* spaces (int @var{count})
- spaces -- return a pointer to a buffer full of spaces
+Returns a pointer to a memory region filled with the specified
+number of spaces and null terminated. The returned pointer is
+valid until at least the next call.
-SYNOPSIS
-
- char *spaces (int count)
-
-DESCRIPTION
-
- Returns a pointer to a memory region filled with the specified
- number of spaces and null terminated. The returned pointer is
- valid until at least the next call.
-
-BUGS
+@end deftypefn
*/
diff --git a/contrib/binutils/libiberty/splay-tree.c b/contrib/binutils/libiberty/splay-tree.c
index 52b57c0..a712395 100644
--- a/contrib/binutils/libiberty/splay-tree.c
+++ b/contrib/binutils/libiberty/splay-tree.c
@@ -1,5 +1,5 @@
/* A splay-tree datatype.
- Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
Contributed by Mark Mitchell (mark@markmitchell.com).
This file is part of GNU CC.
@@ -368,6 +368,40 @@ splay_tree_lookup (sp, key)
return 0;
}
+/* Return the node in SP with the greatest key. */
+
+splay_tree_node
+splay_tree_max (sp)
+ splay_tree sp;
+{
+ splay_tree_node n = sp->root;
+
+ if (!n)
+ return NULL;
+
+ while (n->right)
+ n = n->right;
+
+ return n;
+}
+
+/* Return the node in SP with the smallest key. */
+
+splay_tree_node
+splay_tree_min (sp)
+ splay_tree sp;
+{
+ splay_tree_node n = sp->root;
+
+ if (!n)
+ return NULL;
+
+ while (n->left)
+ n = n->left;
+
+ return n;
+}
+
/* Return the immediate predecessor KEY, or NULL if there is no
predecessor. KEY need not be present in the tree. */
diff --git a/contrib/binutils/libiberty/strcasecmp.c b/contrib/binutils/libiberty/strcasecmp.c
index 3aa930b..4bfe650 100644
--- a/contrib/binutils/libiberty/strcasecmp.c
+++ b/contrib/binutils/libiberty/strcasecmp.c
@@ -10,6 +10,16 @@
* is provided ``as is'' without express or implied warranty.
*/
+/*
+
+@deftypefn Supplemental int strcasecmp (const char *@var{s1}, const char *@var{s2})
+
+A case-insensitive @code{strcmp}.
+
+@end deftypefn
+
+*/
+
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
#endif /* LIBC_SCCS and not lint */
@@ -27,7 +37,7 @@ static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
* based upon ascii character sequences.
*/
typedef unsigned char uc;
-static unsigned char charmap[] = {
+static const unsigned char charmap[] = {
(uc)'\000',(uc)'\001',(uc)'\002',(uc)'\003',(uc)'\004',(uc)'\005',(uc)'\006',(uc)'\007',
(uc)'\010',(uc)'\011',(uc)'\012',(uc)'\013',(uc)'\014',(uc)'\015',(uc)'\016',(uc)'\017',
(uc)'\020',(uc)'\021',(uc)'\022',(uc)'\023',(uc)'\024',(uc)'\025',(uc)'\026',(uc)'\027',
diff --git a/contrib/binutils/libiberty/strchr.c b/contrib/binutils/libiberty/strchr.c
index 550480f..1f71c51 100644
--- a/contrib/binutils/libiberty/strchr.c
+++ b/contrib/binutils/libiberty/strchr.c
@@ -2,19 +2,15 @@
This function is in the public domain. */
/*
-NAME
- strchr -- return pointer to first occurance of a character
-SYNOPSIS
- char *strchr (const char *s, int c)
+@deftypefn Supplemental char* strchr (const char *@var{s}, int @var{c})
+
+Returns a pointer to the first occurrence of the character @var{c} in
+the string @var{s}, or @code{NULL} if not found. If @var{c} is itself the
+null character, the results are undefined.
+
+@end deftypefn
-DESCRIPTION
- Returns a pointer to the first occurance of character C in
- string S, or a NULL pointer if no occurance is found.
-
-BUGS
- Behavior when character is the null character is implementation
- dependent.
*/
#include <ansidecl.h>
diff --git a/contrib/binutils/libiberty/strdup.c b/contrib/binutils/libiberty/strdup.c
index 1785b34..49233ba 100644
--- a/contrib/binutils/libiberty/strdup.c
+++ b/contrib/binutils/libiberty/strdup.c
@@ -1,3 +1,14 @@
+/*
+
+@deftypefn Supplemental char* strdup (const char *@var{s})
+
+Returns a pointer to a copy of @var{s} in memory obtained from
+@code{malloc}, or @code{NULL} if insufficient memory was available.
+
+@end deftypefn
+
+*/
+
char *
strdup(s)
char *s;
diff --git a/contrib/binutils/libiberty/strerror.c b/contrib/binutils/libiberty/strerror.c
index 0dd2220..18050c2 100644
--- a/contrib/binutils/libiberty/strerror.c
+++ b/contrib/binutils/libiberty/strerror.c
@@ -13,6 +13,7 @@
incompatible with our later declaration, perhaps by using const
attributes. So we hide the declaration in errno.h (if any) using a
macro. */
+#define sys_nerr sys_nerr__
#define sys_errlist sys_errlist__
#endif
@@ -20,6 +21,7 @@
#include <errno.h>
#ifdef HAVE_SYS_ERRLIST
+#undef sys_nerr
#undef sys_errlist
#endif
@@ -56,10 +58,10 @@ static void init_error_tables PARAMS ((void));
struct error_info
{
- int value; /* The numeric value from <errno.h> */
- const char *name; /* The equivalent symbolic value */
+ const int value; /* The numeric value from <errno.h> */
+ const char *const name; /* The equivalent symbolic value */
#ifndef HAVE_SYS_ERRLIST
- const char *msg; /* Short message about this value */
+ const char *const msg; /* Short message about this value */
#endif
};
@@ -560,28 +562,23 @@ init_error_tables ()
/*
-NAME
-
- errno_max -- return the max errno value
-SYNOPSIS
+@deftypefn Extension int errno_max (void)
- int errno_max ();
+Returns the maximum @code{errno} value for which a corresponding
+symbolic name or message is available. Note that in the case where we
+use the @code{sys_errlist} supplied by the system, it is possible for
+there to be more symbolic names than messages, or vice versa. In
+fact, the manual page for @code{perror(3C)} explicitly warns that one
+should check the size of the table (@code{sys_nerr}) before indexing
+it, since new error codes may be added to the system before they are
+added to the table. Thus @code{sys_nerr} might be smaller than value
+implied by the largest @code{errno} value defined in @code{<errno.h>}.
-DESCRIPTION
+We return the maximum value that can be used to obtain a meaningful
+symbolic name or message.
- Returns the maximum errno value for which a corresponding symbolic
- name or message is available. Note that in the case where
- we use the sys_errlist supplied by the system, it is possible for
- there to be more symbolic names than messages, or vice versa.
- In fact, the manual page for perror(3C) explicitly warns that one
- should check the size of the table (sys_nerr) before indexing it,
- since new error codes may be added to the system before they are
- added to the table. Thus sys_nerr might be smaller than value
- implied by the largest errno value defined in <errno.h>.
-
- We return the maximum value that can be used to obtain a meaningful
- symbolic name or message.
+@end deftypefn
*/
@@ -602,31 +599,25 @@ errno_max ()
/*
-NAME
+@deftypefn Supplemental char* strerror (int @var{errnoval})
- strerror -- map an error number to an error message string
+Maps an @code{errno} number to an error message string, the contents
+of which are implementation defined. On systems which have the
+external variables @code{sys_nerr} and @code{sys_errlist}, these
+strings will be the same as the ones used by @code{perror}.
-SYNOPSIS
+If the supplied error number is within the valid range of indices for
+the @code{sys_errlist}, but no message is available for the particular
+error number, then returns the string @samp{Error @var{num}}, where
+@var{num} is the error number.
- char *strerror (int errnoval)
+If the supplied error number is not a valid index into
+@code{sys_errlist}, returns @code{NULL}.
-DESCRIPTION
-
- Maps an errno number to an error message string, the contents of
- which are implementation defined. On systems which have the external
- variables sys_nerr and sys_errlist, these strings will be the same
- as the ones used by perror().
-
- If the supplied error number is within the valid range of indices
- for the sys_errlist, but no message is available for the particular
- error number, then returns the string "Error NUM", where NUM is the
- error number.
+The returned string is only guaranteed to be valid only until the
+next call to @code{strerror}.
- If the supplied error number is not a valid index into sys_errlist,
- returns NULL.
-
- The returned string is only guaranteed to be valid only until the
- next call to strerror.
+@end deftypefn
*/
@@ -634,7 +625,7 @@ char *
strerror (errnoval)
int errnoval;
{
- char *msg;
+ const char *msg;
static char buf[32];
#ifndef HAVE_SYS_ERRLIST
@@ -676,32 +667,24 @@ strerror (errnoval)
/*
-NAME
+@deftypefn Replacement {const char*} strerrno (int @var{errnum})
- strerrno -- map an error number to a symbolic name string
+Given an error number returned from a system call (typically returned
+in @code{errno}), returns a pointer to a string containing the
+symbolic name of that error number, as found in @code{<errno.h>}.
-SYNOPSIS
+If the supplied error number is within the valid range of indices for
+symbolic names, but no name is available for the particular error
+number, then returns the string @samp{Error @var{num}}, where @var{num}
+is the error number.
- const char *strerrno (int errnoval)
+If the supplied error number is not within the range of valid
+indices, then returns @code{NULL}.
-DESCRIPTION
-
- Given an error number returned from a system call (typically
- returned in errno), returns a pointer to a string containing the
- symbolic name of that error number, as found in <errno.h>.
-
- If the supplied error number is within the valid range of indices
- for symbolic names, but no name is available for the particular
- error number, then returns the string "Error NUM", where NUM is
- the error number.
-
- If the supplied error number is not within the range of valid
- indices, then returns NULL.
-
-BUGS
+The contents of the location pointed to are only guaranteed to be
+valid until the next call to @code{strerrno}.
- The contents of the location pointed to are only guaranteed to be
- valid until the next call to strerrno.
+@end deftypefn
*/
@@ -744,18 +727,12 @@ strerrno (errnoval)
/*
-NAME
-
- strtoerrno -- map a symbolic errno name to a numeric value
-
-SYNOPSIS
-
- int strtoerrno (char *name)
+@deftypefn Extension int strtoerrno (const char *@var{name})
-DESCRIPTION
+Given the symbolic name of a error number (e.g., @code{EACCES}), map it
+to an errno value. If no translation is found, returns 0.
- Given the symbolic name of a error number, map it to an errno value.
- If no translation is found, returns 0.
+@end deftypefn
*/
@@ -806,7 +783,7 @@ main ()
int errn;
int errnmax;
const char *name;
- char *msg;
+ const char *msg;
char *strerror ();
errnmax = errno_max ();
diff --git a/contrib/binutils/libiberty/strncasecmp.c b/contrib/binutils/libiberty/strncasecmp.c
index 4485cac..77cb421 100644
--- a/contrib/binutils/libiberty/strncasecmp.c
+++ b/contrib/binutils/libiberty/strncasecmp.c
@@ -10,6 +10,16 @@
* is provided ``as is'' without express or implied warranty.
*/
+/*
+
+@deftypefn Supplemental int strncasecmp (const char *@var{s1}, const char *@var{s2})
+
+A case-insensitive @code{strncmp}.
+
+@end deftypefn
+
+*/
+
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
#endif /* LIBC_SCCS and not lint */
@@ -26,7 +36,7 @@ static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
* together for a case independent comparison. The mappings are
* based upon ascii character sequences.
*/
-static unsigned char charmap[] = {
+static const unsigned char charmap[] = {
'\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
'\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
'\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
diff --git a/contrib/binutils/libiberty/strncmp.c b/contrib/binutils/libiberty/strncmp.c
index b3b9de1..819cea6 100644
--- a/contrib/binutils/libiberty/strncmp.c
+++ b/contrib/binutils/libiberty/strncmp.c
@@ -1,6 +1,17 @@
/* strncmp -- compare two strings, stop after n bytes.
This function is in the public domain. */
+/*
+
+@deftypefn Supplemental int strncmp (const char *@var{s1}, const char *@var{s2}, size_t @var{n})
+
+Compares the first @var{n} bytes of two strings, returning a value as
+@code{strcmp}.
+
+@end deftypefn
+
+*/
+
#include <ansidecl.h>
#ifdef __STDC__
#include <stddef.h>
diff --git a/contrib/binutils/libiberty/strrchr.c b/contrib/binutils/libiberty/strrchr.c
index 8c05bcb..bc380c4 100644
--- a/contrib/binutils/libiberty/strrchr.c
+++ b/contrib/binutils/libiberty/strrchr.c
@@ -2,19 +2,15 @@
This function is in the public domain. */
/*
-NAME
- strrchr -- return pointer to last occurance of a character
-
-SYNOPSIS
- char *strrchr (const char *s, int c)
-
-DESCRIPTION
- Returns a pointer to the last occurance of character C in
- string S, or a NULL pointer if no occurance is found.
-
-BUGS
- Behavior when character is the null character is implementation
- dependent.
+
+@deftypefn Supplemental char* strrchr (const char *@var{s}, int @var{c})
+
+Returns a pointer to the last occurrence of the character @var{c} in
+the string @var{s}, or @code{NULL} if not found. If @var{c} is itself the
+null character, the results are undefined.
+
+@end deftypefn
+
*/
#include <ansidecl.h>
diff --git a/contrib/binutils/libiberty/strsignal.c b/contrib/binutils/libiberty/strsignal.c
index 5625323..86c8aca 100644
--- a/contrib/binutils/libiberty/strsignal.c
+++ b/contrib/binutils/libiberty/strsignal.c
@@ -17,6 +17,7 @@
ignore any declaration in the system header files, and always
declare it ourselves. With luck, this will always work. */
#define sys_siglist no_such_symbol
+#define sys_nsig sys_nsig__no_such_symbol
#include <stdio.h>
#include <signal.h>
@@ -38,6 +39,7 @@ extern PTR memset ();
/* Undefine the macro we used to hide the definition of sys_siglist
found in the system header files. */
#undef sys_siglist
+#undef sys_nsig
#ifndef NULL
# ifdef __STDC__
@@ -65,10 +67,10 @@ static void init_signal_tables PARAMS ((void));
struct signal_info
{
- int value; /* The numeric value from <signal.h> */
- const char *name; /* The equivalent symbolic value */
+ const int value; /* The numeric value from <signal.h> */
+ const char *const name; /* The equivalent symbolic value */
#ifndef HAVE_SYS_SIGLIST
- const char *msg; /* Short message about this value */
+ const char *const msg; /* Short message about this value */
#endif
};
@@ -348,28 +350,22 @@ init_signal_tables ()
/*
-NAME
-
- signo_max -- return the max signo value
-
-SYNOPSIS
+@deftypefn Extension int signo_max (void)
- int signo_max ();
+Returns the maximum signal value for which a corresponding symbolic
+name or message is available. Note that in the case where we use the
+@code{sys_siglist} supplied by the system, it is possible for there to
+be more symbolic names than messages, or vice versa. In fact, the
+manual page for @code{psignal(3b)} explicitly warns that one should
+check the size of the table (@code{NSIG}) before indexing it, since
+new signal codes may be added to the system before they are added to
+the table. Thus @code{NSIG} might be smaller than value implied by
+the largest signo value defined in @code{<signal.h>}.
-DESCRIPTION
-
- Returns the maximum signo value for which a corresponding symbolic
- name or message is available. Note that in the case where
- we use the sys_siglist supplied by the system, it is possible for
- there to be more symbolic names than messages, or vice versa.
- In fact, the manual page for psignal(3b) explicitly warns that one
- should check the size of the table (NSIG) before indexing it,
- since new signal codes may be added to the system before they are
- added to the table. Thus NSIG might be smaller than value
- implied by the largest signo value defined in <signal.h>.
+We return the maximum value that can be used to obtain a meaningful
+symbolic name or message.
- We return the maximum value that can be used to obtain a meaningful
- symbolic name or message.
+@end deftypefn
*/
@@ -389,31 +385,25 @@ signo_max ()
/*
-NAME
-
- strsignal -- map a signal number to a signal message string
+@deftypefn Supplemental {const char *} strsignal (int @var{signo})
-SYNOPSIS
-
- const char *strsignal (int signo)
-
-DESCRIPTION
+Maps an signal number to an signal message string, the contents of
+which are implementation defined. On systems which have the external
+variable @code{sys_siglist}, these strings will be the same as the
+ones used by @code{psignal()}.
- Maps an signal number to an signal message string, the contents of
- which are implementation defined. On systems which have the external
- variable sys_siglist, these strings will be the same as the ones used
- by psignal().
+If the supplied signal number is within the valid range of indices for
+the @code{sys_siglist}, but no message is available for the particular
+signal number, then returns the string @samp{Signal @var{num}}, where
+@var{num} is the signal number.
- If the supplied signal number is within the valid range of indices
- for the sys_siglist, but no message is available for the particular
- signal number, then returns the string "Signal NUM", where NUM is the
- signal number.
+If the supplied signal number is not a valid index into
+@code{sys_siglist}, returns @code{NULL}.
- If the supplied signal number is not a valid index into sys_siglist,
- returns NULL.
+The returned string is only guaranteed to be valid only until the next
+call to @code{strsignal}.
- The returned string is only guaranteed to be valid only until the
- next call to strsignal.
+@end deftypefn
*/
@@ -459,31 +449,23 @@ strsignal (signo)
/*
-NAME
-
- strsigno -- map an signal number to a symbolic name string
+@deftypefn Extension {const char*} strsigno (int @var{signo})
-SYNOPSIS
+Given an signal number, returns a pointer to a string containing the
+symbolic name of that signal number, as found in @code{<signal.h>}.
- const char *strsigno (int signo)
+If the supplied signal number is within the valid range of indices for
+symbolic names, but no name is available for the particular signal
+number, then returns the string @samp{Signal @var{num}}, where
+@var{num} is the signal number.
-DESCRIPTION
+If the supplied signal number is not within the range of valid
+indices, then returns @code{NULL}.
- Given an signal number, returns a pointer to a string containing
- the symbolic name of that signal number, as found in <signal.h>.
+The contents of the location pointed to are only guaranteed to be
+valid until the next call to @code{strsigno}.
- If the supplied signal number is within the valid range of indices
- for symbolic names, but no name is available for the particular
- signal number, then returns the string "Signal NUM", where NUM is
- the signal number.
-
- If the supplied signal number is not within the range of valid
- indices, then returns NULL.
-
-BUGS
-
- The contents of the location pointed to are only guaranteed to be
- valid until the next call to strsigno.
+@end deftypefn
*/
@@ -522,18 +504,12 @@ strsigno (signo)
/*
-NAME
-
- strtosigno -- map a symbolic signal name to a numeric value
+@deftypefn Extension int strtosigno (const char *@var{name})
-SYNOPSIS
+Given the symbolic name of a signal, map it to a signal number. If no
+translation is found, returns 0.
- int strtosigno (char *name)
-
-DESCRIPTION
-
- Given the symbolic name of a signal, map it to a signal number.
- If no translation is found, returns 0.
+@end deftypefn
*/
@@ -568,19 +544,14 @@ strtosigno (name)
/*
-NAME
+@deftypefn Supplemental void psignal (unsigned @var{signo}, char *@var{message})
- psignal -- print message about signal to stderr
+Print @var{message} to the standard error, followed by a colon,
+followed by the description of the signal specified by @var{signo},
+followed by a newline.
-SYNOPSIS
-
- void psignal (unsigned signo, char *message);
-
-DESCRIPTION
+@end deftypefn
- Print to the standard error the message, followed by a colon,
- followed by the description of the signal specified by signo,
- followed by a newline.
*/
#ifndef HAVE_PSIGNAL
diff --git a/contrib/binutils/libiberty/strstr.c b/contrib/binutils/libiberty/strstr.c
index fab36e3..470e04b 100644
--- a/contrib/binutils/libiberty/strstr.c
+++ b/contrib/binutils/libiberty/strstr.c
@@ -3,24 +3,16 @@
/*
-NAME
+@deftypefn Supplemental char* strstr (const char *@var{string}, const char *@var{sub})
- strstr -- locate first occurance of a substring
+This function searches for the substring @var{sub} in the string
+@var{string}, not including the terminating null characters. A pointer
+to the first occurrence of @var{sub} is returned, or @code{NULL} if the
+substring is absent. If @var{sub} points to a string with zero
+length, the function returns @var{string}.
-SYNOPSIS
+@end deftypefn
- #include <string.h>
-
- char *strstr (char *s1, char *s2)
-
-DESCRIPTION
-
- Locates the first occurance in the string pointed to by S1 of
- the string pointed to by S2. Returns a pointer to the substring
- found, or a NULL pointer if not found. If S2 points to a string
- with zero length, the function returns S1.
-
-BUGS
*/
diff --git a/contrib/binutils/libiberty/strtod.c b/contrib/binutils/libiberty/strtod.c
index 90292c2..6b69ccf 100644
--- a/contrib/binutils/libiberty/strtod.c
+++ b/contrib/binutils/libiberty/strtod.c
@@ -22,6 +22,21 @@ the resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why
the executable file might be covered by the GNU General Public License. */
+/*
+
+@deftypefn Supplemental double strtod (const char *@var{string}, char **@var{endptr})
+
+This ISO C function converts the initial portion of @var{string} to a
+@code{double}. If @var{endptr} is not @code{NULL}, a pointer to the
+character after the last character used in the conversion is stored in
+the location referenced by @var{endptr}. If no conversion is
+performed, zero is returned and the value of @var{string} is stored in
+the location referenced by @var{endptr}.
+
+@end deftypefn
+
+*/
+
#include "ansidecl.h"
#include "safe-ctype.h"
diff --git a/contrib/binutils/libiberty/strtol.c b/contrib/binutils/libiberty/strtol.c
index 7095c72..d9f54cc 100644
--- a/contrib/binutils/libiberty/strtol.c
+++ b/contrib/binutils/libiberty/strtol.c
@@ -28,6 +28,25 @@
* SUCH DAMAGE.
*/
+/*
+
+@deftypefn Supplemental {long int} strtol (const char *@var{string}, char **@var{endptr}, int @var{base})
+@deftypefnx Supplemental {unsigned long int} strtoul (const char *@var{string}, char **@var{endptr}, int @var{base})
+
+The @code{strtol} function converts the string in @var{string} to a
+long integer value according to the given @var{base}, which must be
+between 2 and 36 inclusive, or be the special value 0. If @var{base}
+is 0, @code{strtol} will look for the prefixes @code{0} and @code{0x}
+to indicate bases 8 and 16, respectively, else default to base 10.
+When the base is 16 (either explicitly or implicitly), a prefix of
+@code{0x} is allowed. The handling of @var{endptr} is as that of
+@code{strtod} above. The @code{strtoul} function is the same, except
+that the converted value is unsigned.
+
+@end deftypefn
+
+*/
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/contrib/binutils/libiberty/ternary.c b/contrib/binutils/libiberty/ternary.c
new file mode 100644
index 0000000..056d2ce
--- /dev/null
+++ b/contrib/binutils/libiberty/ternary.c
@@ -0,0 +1,166 @@
+/* ternary.c - Ternary Search Trees
+ Copyright (C) 2001 Free Software Foundation, Inc.
+
+ Contributed by Daniel Berlin (dan@cgsoftware.com)
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ USA. */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#include <stdio.h>
+
+#include "libiberty.h"
+#include "ternary.h"
+
+/* Non-recursive so we don't waste stack space/time on large
+ insertions. */
+
+PTR
+ternary_insert (root, s, data, replace)
+ ternary_tree *root;
+ const char *s;
+ PTR data;
+ int replace;
+{
+ int diff;
+ ternary_tree curr, *pcurr;
+
+ /* Start at the root. */
+ pcurr = root;
+ /* Loop until we find the right position */
+ while ((curr = *pcurr))
+ {
+ /* Calculate the difference */
+ diff = *s - curr->splitchar;
+ /* Handle current char equal to node splitchar */
+ if (diff == 0)
+ {
+ /* Handle the case of a string we already have */
+ if (*s++ == 0)
+ {
+ if (replace)
+ curr->eqkid = (ternary_tree) data;
+ return (PTR) curr->eqkid;
+ }
+ pcurr = &(curr->eqkid);
+ }
+ /* Handle current char less than node splitchar */
+ else if (diff < 0)
+ {
+ pcurr = &(curr->lokid);
+ }
+ /* Handle current char greater than node splitchar */
+ else
+ {
+ pcurr = &(curr->hikid);
+ }
+ }
+ /* It's not a duplicate string, and we should insert what's left of
+ the string, into the tree rooted at curr */
+ for (;;)
+ {
+ /* Allocate the memory for the node, and fill it in */
+ *pcurr = (ternary_tree) xmalloc (sizeof (ternary_node));
+ curr = *pcurr;
+ curr->splitchar = *s;
+ curr->lokid = curr->hikid = curr->eqkid = 0;
+
+ /* Place nodes until we hit the end of the string.
+ When we hit it, place the data in the right place, and
+ return.
+ */
+ if (*s++ == 0)
+ {
+ curr->eqkid = (ternary_tree) data;
+ return data;
+ }
+ pcurr = &(curr->eqkid);
+ }
+}
+
+/* Free the ternary search tree rooted at p. */
+void
+ternary_cleanup (p)
+ ternary_tree p;
+{
+ if (p)
+ {
+ ternary_cleanup (p->lokid);
+ if (p->splitchar)
+ ternary_cleanup (p->eqkid);
+ ternary_cleanup (p->hikid);
+ free (p);
+ }
+}
+
+/* Non-recursive find of a string in the ternary tree */
+PTR
+ternary_search (p, s)
+ const ternary_node *p;
+ const char *s;
+{
+ const ternary_node *curr;
+ int diff, spchar;
+ spchar = *s;
+ curr = p;
+ /* Loop while we haven't hit a NULL node or returned */
+ while (curr)
+ {
+ /* Calculate the difference */
+ diff = spchar - curr->splitchar;
+ /* Handle the equal case */
+ if (diff == 0)
+ {
+ if (spchar == 0)
+ return (PTR) curr->eqkid;
+ spchar = *++s;
+ curr = curr->eqkid;
+ }
+ /* Handle the less than case */
+ else if (diff < 0)
+ curr = curr->lokid;
+ /* All that's left is greater than */
+ else
+ curr = curr->hikid;
+ }
+ return NULL;
+}
+
+/* For those who care, the recursive version of the search. Useful if
+ you want a starting point for pmsearch or nearsearch. */
+static PTR
+ternary_recursivesearch (p, s)
+ const ternary_node *p;
+ const char *s;
+{
+ if (!p)
+ return 0;
+ if (*s < p->splitchar)
+ return ternary_recursivesearch (p->lokid, s);
+ else if (*s > p->splitchar)
+ return ternary_recursivesearch (p->hikid, s);
+ else
+ {
+ if (*s == 0)
+ return (PTR) p->eqkid;
+ return ternary_recursivesearch (p->eqkid, ++s);
+ }
+}
diff --git a/contrib/binutils/libiberty/tmpnam.c b/contrib/binutils/libiberty/tmpnam.c
index 8eb77e2..406878c 100644
--- a/contrib/binutils/libiberty/tmpnam.c
+++ b/contrib/binutils/libiberty/tmpnam.c
@@ -1,3 +1,17 @@
+/*
+
+@deftypefn Supplemental char* tmpnam (char *@var{s})
+
+This function attempts to create a name for a temporary file, which
+will be a valid file name yet not exist when @code{tmpnam} checks for
+it. @var{s} must point to a buffer of at least @code{L_tmpnam} bytes,
+or be @code{NULL}. Use of this function creates a security risk, and it must
+not be used in new projects. Use @code{mkstemp} instead.
+
+@end deftypefn
+
+*/
+
#include <stdio.h>
#ifndef L_tmpnam
diff --git a/contrib/binutils/libiberty/vasprintf.c b/contrib/binutils/libiberty/vasprintf.c
index c34585d..d438225 100644
--- a/contrib/binutils/libiberty/vasprintf.c
+++ b/contrib/binutils/libiberty/vasprintf.c
@@ -28,7 +28,9 @@ Boston, MA 02111-1307, USA. */
#include <varargs.h>
#endif
#include <stdio.h>
+#ifdef HAVE_STRING_H
#include <string.h>
+#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#else
@@ -41,6 +43,21 @@ extern PTR malloc ();
int global_total_width;
#endif
+/*
+
+@deftypefn Extension int vasprintf (char **@var{resptr}, const char *@var{format}, va_list @var{args})
+
+Like @code{vsprintf}, but instead of passing a pointer to a buffer,
+you pass a pointer to a pointer. This function will compute the size
+of the buffer needed, allocate memory with @code{malloc}, and store a
+pointer to the allocated memory in @code{*@var{resptr}}. The value
+returned is the same as @code{vsprintf} would return. If memory could
+not be allocated, zero is returned and @code{NULL} is stored in
+@code{*@var{resptr}}.
+
+@end deftypefn
+
+*/
static int int_vasprintf PARAMS ((char **, const char *, va_list *));
@@ -142,29 +159,22 @@ vasprintf (result, format, args)
}
#ifdef TEST
-static void checkit PARAMS ((const char *, ...));
-
-static void
-checkit VPARAMS ((const char* format, ...))
+static void ATTRIBUTE_PRINTF_1
+checkit VPARAMS ((const char *format, ...))
{
- va_list args;
char *result;
-#ifndef ANSI_PROTOTYPES
- const char *format;
-#endif
-
- VA_START (args, format);
-
-#ifndef ANSI_PROTOTYPES
- format = va_arg (args, const char *);
-#endif
-
+ VA_OPEN (args, format);
+ VA_FIXEDARG (args, const char *, format);
vasprintf (&result, format, args);
+ VA_CLOSE (args);
+
if (strlen (result) < (size_t) global_total_width)
printf ("PASS: ");
else
printf ("FAIL: ");
printf ("%d %s\n", global_total_width, result);
+
+ free (result);
}
extern int main PARAMS ((void));
diff --git a/contrib/binutils/libiberty/vfork.c b/contrib/binutils/libiberty/vfork.c
index 5e877210..4aa5c21 100644
--- a/contrib/binutils/libiberty/vfork.c
+++ b/contrib/binutils/libiberty/vfork.c
@@ -1,6 +1,16 @@
/* Emulate vfork using just plain fork, for systems without a real vfork.
This function is in the public domain. */
+/*
+
+@deftypefn Supplemental int vfork (void)
+
+Emulates @code{vfork} by calling @code{fork} and returning its value.
+
+@end deftypefn
+
+*/
+
#include "ansidecl.h"
extern int fork PARAMS ((void));
diff --git a/contrib/binutils/libiberty/vprintf.c b/contrib/binutils/libiberty/vprintf.c
index 65b425a..c57c3e4 100644
--- a/contrib/binutils/libiberty/vprintf.c
+++ b/contrib/binutils/libiberty/vprintf.c
@@ -1,3 +1,20 @@
+/*
+
+@deftypefn Supplemental int vprintf (const char *@var{format}, va_list @var{ap})
+@deftypefnx Supplemental int vfprintf (FILE *@var{stream}, const char *@var{format}, va_list @var{ap})
+@deftypefnx Supplemental int vsprintf (char *@var{str}, const char *@var{format}, va_list @var{ap})
+
+These functions are the same as @code{printf}, @code{fprintf}, and
+@code{sprintf}, respectively, except that they are called with a
+@code{va_list} instead of a variable number of arguments. Note that
+they do not call @code{va_end}; this is the application's
+responsibility. In @libib{} they are implemented in terms of the
+nonstandard but common function @code{_doprnt}.
+
+@end deftypefn
+
+*/
+
#ifdef __STDC__
#include <stdarg.h>
#else
diff --git a/contrib/binutils/libiberty/vsprintf.c b/contrib/binutils/libiberty/vsprintf.c
index bf0760c..b69e9bc 100644
--- a/contrib/binutils/libiberty/vsprintf.c
+++ b/contrib/binutils/libiberty/vsprintf.c
@@ -3,7 +3,7 @@
implementations of stdio; newer ones should already have vsprintf.
Written by Per Bothner of Cygnus Support.
Based on libg++'s "form" (written by Doug Lea; dl@rocky.oswego.edu).
- Copyright (C) 1991, 1995 Free Software Foundation, Inc.
+ Copyright (C) 1991, 1995, 2002 Free Software Foundation, Inc.
This file is part of the libiberty library. This library is free
software; you can redistribute it and/or modify it under the
@@ -31,6 +31,8 @@ the executable file might be covered by the GNU General Public License. */
#include <ansidecl.h>
#undef vsprintf
+#if defined _IOSTRG && defined _IOWRT
+
int
vsprintf (buf, format, ap)
char *buf;
@@ -53,3 +55,5 @@ vsprintf (buf, format, ap)
return ret;
}
+
+#endif
diff --git a/contrib/binutils/libiberty/waitpid.c b/contrib/binutils/libiberty/waitpid.c
index 2848309..703b8a6 100644
--- a/contrib/binutils/libiberty/waitpid.c
+++ b/contrib/binutils/libiberty/waitpid.c
@@ -1,3 +1,15 @@
+/*
+
+@deftypefn Supplemental int waitpid (int @var{pid}, int *@var{status}, int)
+
+This is a wrapper around the @code{wait} function. Any ``special''
+values of @var{pid} depend on your implementation of @code{wait}, as
+does the return value. The third argument is unused in @libib{}.
+
+@end deftypefn
+
+*/
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/contrib/binutils/libiberty/xatexit.c b/contrib/binutils/libiberty/xatexit.c
index 31476c2..728254b 100644
--- a/contrib/binutils/libiberty/xatexit.c
+++ b/contrib/binutils/libiberty/xatexit.c
@@ -5,6 +5,20 @@
* %sccs.include.redist.c%
*/
+
+/*
+
+@deftypefun int xatexit (void (*@var{fn}) (void))
+
+Behaves as the standard @code{atexit} function, but with no limit on
+the number of registered functions. Returns 0 on success, or @minus{}1 on
+failure. If you use @code{xatexit} to register functions, you must use
+@code{xexit} to terminate your program.
+
+@end deftypefun
+
+*/
+
/* Adapted from newlib/libc/stdlib/{,at}exit.[ch].
If you use xatexit, you must call xexit instead of exit. */
diff --git a/contrib/binutils/libiberty/xexit.c b/contrib/binutils/libiberty/xexit.c
index e8b1ed1..a65690f 100644
--- a/contrib/binutils/libiberty/xexit.c
+++ b/contrib/binutils/libiberty/xexit.c
@@ -17,6 +17,18 @@ License along with libiberty; see the file COPYING.LIB. If not, write
to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+/*
+
+@deftypefn Replacement void xexit (int @var{code})
+
+Terminates the program. If any functions have been registered with
+the @code{xatexit} replacement function, they will be called first.
+Termination is handled via the system's normal @code{exit} call.
+
+@end deftypefn
+
+*/
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/contrib/binutils/libiberty/xmalloc.c b/contrib/binutils/libiberty/xmalloc.c
index 3ea2d4a..bf0cf2d 100644
--- a/contrib/binutils/libiberty/xmalloc.c
+++ b/contrib/binutils/libiberty/xmalloc.c
@@ -17,6 +17,49 @@ License along with libiberty; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+/*
+
+@deftypefn Replacement void* xmalloc (size_t)
+
+Allocate memory without fail. If @code{malloc} fails, this will print
+a message to @code{stderr} (using the name set by
+@code{xmalloc_set_program_name},
+if any) and then call @code{xexit}. Note that it is therefore safe for
+a program to contain @code{#define malloc xmalloc} in its source.
+
+@end deftypefn
+
+@deftypefn Replacement void* xrealloc (void *@var{ptr}, size_t @var{size})
+Reallocate memory without fail. This routine functions like @code{realloc},
+but will behave the same as @code{xmalloc} if memory cannot be found.
+
+@end deftypefn
+
+@deftypefn Replacement void* xcalloc (size_t @var{nelem}, size_t @var{elsize})
+
+Allocate memory without fail, and set it to zero. This routine functions
+like @code{calloc}, but will behave the same as @code{xmalloc} if memory
+cannot be found.
+
+@end deftypefn
+
+@deftypefn Replacement void xmalloc_set_program_name (const char *@var{name})
+
+You can use this to set the name of the program used by
+@code{xmalloc_failed} when printing a failure message.
+
+@end deftypefn
+
+@deftypefn Replacement void xmalloc_failed (size_t)
+
+This function is not meant to be called by client code, and is listed
+here for completeness only. If any of the allocation routines fail, this
+function will be called to print an error message and terminate execution.
+
+@end deftypefn
+
+*/
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/contrib/binutils/libiberty/xmemdup.c b/contrib/binutils/libiberty/xmemdup.c
index fdb17a5..9e9d66b 100644
--- a/contrib/binutils/libiberty/xmemdup.c
+++ b/contrib/binutils/libiberty/xmemdup.c
@@ -2,6 +2,19 @@
This trivial function is in the public domain.
Jeff Garzik, September 1999. */
+/*
+
+@deftypefn Replacement void* xmemdup (void *@var{input}, size_t @var{copy_size}, size_t @var{alloc_size})
+
+Duplicates a region of memory without fail. First, @var{alloc_size} bytes
+are allocated, then @var{copy_size} bytes from @var{input} are copied into
+it, and the new memory is returned. If fewer bytes are copied than were
+allocated, the remaining memory is zeroed.
+
+@end deftypefn
+
+*/
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
diff --git a/contrib/binutils/libiberty/xstrdup.c b/contrib/binutils/libiberty/xstrdup.c
index 6f846cf..5aa084a 100644
--- a/contrib/binutils/libiberty/xstrdup.c
+++ b/contrib/binutils/libiberty/xstrdup.c
@@ -2,6 +2,17 @@
This trivial function is in the public domain.
Ian Lance Taylor, Cygnus Support, December 1995. */
+/*
+
+@deftypefn Replacement char* xstrdup (const char *@var{s})
+
+Duplicates a character string without fail, using @code{xmalloc} to
+obtain memory.
+
+@end deftypefn
+
+*/
+
#include <sys/types.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
diff --git a/contrib/binutils/libiberty/xstrerror.c b/contrib/binutils/libiberty/xstrerror.c
index 770b653..9000d17 100644
--- a/contrib/binutils/libiberty/xstrerror.c
+++ b/contrib/binutils/libiberty/xstrerror.c
@@ -2,6 +2,17 @@
Fri Jun 16 18:30:00 1995 Pat Rankin <rankin@eql.caltech.edu>
This code is in the public domain. */
+/*
+
+@deftypefn Replacement char* xstrerror (int @var{errnum})
+
+Behaves exactly like the standard @code{strerror} function, but
+will never return a @code{NULL} pointer.
+
+@end deftypefn
+
+*/
+
#include <stdio.h>
#include "libiberty.h"
OpenPOWER on IntegriCloud