From 19ddc834bc1ebc4e7cb7aa053cb815b3c6cc1115 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 14 Oct 1997 15:10:45 -0400 Subject: [PATCH] cplus-dem.c (demangle_signature): Don't look for return types on constructors. Tue Oct 14 12:01:00 1997 Mark Mitchell * cplus-dem.c (demangle_signature): Don't look for return types on constructors. Handle member template constructors. and update from devo. From-SVN: r15901 --- libiberty/ChangeLog | 62 ++++++++++++++++++++++++++++ libiberty/Makefile.in | 2 +- libiberty/README | 7 ++-- libiberty/argv.c | 57 ++++++++++++++++++++++++++ libiberty/config.table | 2 + libiberty/config/mh-windows | 2 +- libiberty/cplus-dem.c | 81 +++++++++++++++++++++++++++++++++++-- libiberty/functions.def | 1 + libiberty/pexecute.c | 55 +++++++++++++++++++++++-- libiberty/vasprintf.c | 4 ++ 10 files changed, 260 insertions(+), 13 deletions(-) diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index a2c2274c9381..b0dc9dca2bac 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,30 @@ +Tue Oct 14 12:01:00 1997 Mark Mitchell + + * cplus-dem.c (demangle_signature): Don't look for return types on + constructors. Handle member template constructors. + +Fri Oct 3 17:53:30 1997 Ian Lance Taylor + + * README: Fix configuration instructions. + +Mon Sep 29 12:28:41 1997 Ian Lance Taylor + + * pexecute.c: Update to current version from /gd/gnu/lib: + + Mon Sep 29 12:27:59 1997 Ian Lance Taylor + + * pexecute.c: Use spawn if __CYGWIN32__. + + 1997-08-08 Paul Eggert + + * pexecute.c: Include "config.h" first, as per autoconf manual. + + Fri Jun 27 15:20:29 1997 Scott Christley + + * pexecute.c (fix_argv): New function. + (pexecute): Win32 but not Cygwin32 needs its arguments fixed. + Add underscore to cwait function call. + Sun Sep 28 12:00:52 1997 Mark Mitchell * cplus-dem.c (demangle_template): Add new parameter. Handle new @@ -5,6 +32,31 @@ Sun Sep 28 12:00:52 1997 Mark Mitchell (consume_count_with_underscores): New function. (demangle_signature): Handle new name-mangling scheme. +Sun Sep 28 12:00:52 1997 Mark Mitchell + + * cplus-dem.c (demangle_template): Add new parameter. Handle new + template-function mangling. + (consume_count_with_underscores): New function. + (demangle_signature): Handle new name-mangling scheme. + +Wed Sep 24 00:31:59 1997 Felix Lee + + * asprintf.c: stdarg.h when ALMOST_STDC + * config/mh-windows (EXTRA_OFILES): add asprintf.o and + strncasecmp.o. + +Thu Aug 28 14:27:15 1997 Andrew Cagney + + * vasprintf.c (vasprintf): Allow for _BSD_VA_LIST_. + + * config.table: Add case for FreeBSD 2.1 and 2.2, needs mh-fbsd21. + + * config/mh-fbsd21 (EXTRA_OFILES): Force vasprintf.o + +Wed Sep 10 12:43:10 1997 Jason Merrill + + * cplus-dem.c (demangle_fund_type): Change "complex" to "__complex". + Tue Sep 9 19:39:12 1997 Jim Wilson * Makefile.in (install_to_libdir, install_to_tooldir): Add MULTISUBDIR @@ -14,11 +66,21 @@ Fri Sep 5 17:28:50 1997 Jim Wilson * Makefile.in (distclean): Do MULTICLEAN before deleting Makefile. +Fri Sep 5 16:34:42 1997 Andrew Cagney + + * asprintf.c (asprintf): New file. + * Makefile.in (CFILES): Add asprintf.c + * functions.def: Ditto. + Wed Sep 3 14:35:52 1997 Jim Wilson * Makefile.in (stamp-needed, stamp-config): Add MULTISRCTOP to pathname for move-if-change. +Thu Aug 28 18:53:34 1997 Andrew Cagney + + * argv.c (dupargv): New function, duplicate an argument vector. + Tue Aug 19 20:28:45 1997 Geoffrey Noer * config/mh-cygwin32: also build random.o diff --git a/libiberty/Makefile.in b/libiberty/Makefile.in index 64a3defaf0f5..9d0f914d308c 100644 --- a/libiberty/Makefile.in +++ b/libiberty/Makefile.in @@ -146,7 +146,7 @@ HFILES = # NOTE: If you add new files to the library, add them to this list # (alphabetical), and add them to REQUIRED_OFILES or 'functions.def'. -CFILES = alloca.c argv.c atexit.c basename.c bcmp.c bcopy.c bzero.c \ +CFILES = asprintf.c alloca.c argv.c atexit.c basename.c bcmp.c bcopy.c bzero.c \ choose-temp.c clock.c concat.c cplus-dem.c fdmatch.c fnmatch.c \ getcwd.c getopt.c getopt1.c getpagesize.c getruntime.c \ floatformat.c hex.c index.c insque.c \ diff --git a/libiberty/README b/libiberty/README index 5081bbac1968..92dc202929b9 100644 --- a/libiberty/README +++ b/libiberty/README @@ -11,10 +11,9 @@ Current members include: We expect many of the GNU subroutines that are floating around to eventually arrive here. -To build the library, do: - - ./configure HOSTTYPE - make +The library must be configured from the top source directory. Don't +try to run configure in this directory. Follow the configuration +instructions in ../README. Please report bugs and fixes to "bug-gnu-utils@prep.ai.mit.edu". Thank you. diff --git a/libiberty/argv.c b/libiberty/argv.c index 60694f919bb9..824a02988363 100644 --- a/libiberty/argv.c +++ b/libiberty/argv.c @@ -68,6 +68,63 @@ extern char *strdup (); /* Duplicate a string */ #define INITIAL_MAXARGC 8 /* Number of args + NULL in initial argv */ +/* + +NAME + + dupargv -- duplicate an argument vector + +SYNOPSIS + + char **dupargv (vector) + char **vector; + +DESCRIPTION + + Duplicate an argument vector. Simply scans through the + vector, duplicating each argument argument until the + terminating NULL is found. + +RETURNS + + Returns a pointer to the argument vector if + successful. Returns NULL if there is insufficient memory to + complete building the argument vector. + +*/ + +char ** +dupargv (argv) + char **argv; +{ + int argc; + char **copy; + + if (argv == NULL) + return NULL; + + /* the vector */ + for (argc = 0; argv[argc] != NULL; argc++); + copy = (char **) malloc ((argc + 1) * sizeof (char *)); + if (copy == NULL) + return NULL; + + /* the strings */ + for (argc = 0; argv[argc] != NULL; argc++) + { + int len = strlen (argv[argc]); + copy[argc] = malloc (sizeof (char *) * (len + 1)); + if (copy[argc] == NULL) + { + freeargv (copy); + return NULL; + } + strcpy (copy[argc], argv[argc]); + } + copy[argc] = NULL; + return copy; +} + /* NAME diff --git a/libiberty/config.table b/libiberty/config.table index dba783b489f0..484761c51908 100644 --- a/libiberty/config.table +++ b/libiberty/config.table @@ -10,6 +10,8 @@ case "${host}" in *-*-cxux7*) frag=mh-cxux7 ;; *-*-cygwin32) frag=mh-cygwin32 ;; *-*-dgux*) frag=mh-sysv ;; + *-*-freebsd2.1.*) frag=mh-fbsd21 ;; + *-*-freebsd2.2.*) frag=mh-fbsd21 ;; hppa*-hp-bsd*) frag=mh-hpbsd ;; *-*-hpux*) frag=mh-hpux ;; *-*-hiux*) frag=mh-hpux ;; diff --git a/libiberty/config/mh-windows b/libiberty/config/mh-windows index f20c51f21910..3dbd6ef694a2 100644 --- a/libiberty/config/mh-windows +++ b/libiberty/config/mh-windows @@ -1,2 +1,2 @@ HDEFINES=-DNEED_basename -DNEED_sys_siglist -DNEED_strsignal -DNO_SYS_FILE_H -EXTRA_OFILES=strcasecmp.o vasprintf.o +EXTRA_OFILES=asprintf.o strcasecmp.o strncasecmp.o vasprintf.o diff --git a/libiberty/cplus-dem.c b/libiberty/cplus-dem.c index 055ab0818e5d..6f6c390c686e 100644 --- a/libiberty/cplus-dem.c +++ b/libiberty/cplus-dem.c @@ -293,6 +293,9 @@ string_prependn PARAMS ((string *, const char *, int)); static int get_count PARAMS ((const char **, int *)); +static int +consume_count_with_underscores PARAMS ((const char**)); + static int consume_count PARAMS ((const char **)); @@ -342,6 +345,42 @@ consume_count (type) } +/* Like consume_count, but for counts that are preceeded and followed + by '_' if they are greater than 10. Also, -1 is returned for + failure, since 0 can be a valid value. */ + +static int +consume_count_with_underscores (mangled) + const char **mangled; +{ + int idx; + + if (**mangled == '_') + { + (*mangled)++; + if (!isdigit (**mangled)) + return -1; + + idx = consume_count (mangled); + if (**mangled != '_') + /* The trailing underscore was missing. */ + return -1; + + (*mangled)++; + } + else + { + if (**mangled < '0' || **mangled > '9') + return -1; + + idx = **mangled - '0'; + (*mangled)++; + } + + return idx; +} + + /* Like consume_count, but for counts that are preceeded and followed by '_' if they are greater than 10. Also, -1 is returned for failure, since 0 can be a valid value. */ @@ -831,7 +870,8 @@ demangle_signature (work, mangled, declp) { /* A G++ template function. Read the template arguments. */ success = demangle_template (work, mangled, declp, 0, 0); - expect_return_type = 1; + if (!(work->constructor & 1)) + expect_return_type = 1; (*mangled)++; break; } @@ -1534,7 +1574,8 @@ demangle_prefix (work, mangled, declp) } } else if ((scan == *mangled) - && (isdigit (scan[2]) || (scan[2] == 'Q') || (scan[2] == 't'))) + && (isdigit (scan[2]) || (scan[2] == 'Q') || (scan[2] == 't') + || (scan[2] == 'H'))) { /* The ARM says nothing about the mangling of local variables. But cfront mangles local variables by prepending __ @@ -1551,7 +1592,8 @@ demangle_prefix (work, mangled, declp) { /* A GNU style constructor starts with __[0-9Qt]. But cfront uses names like __Q2_3foo3bar for nested type names. So don't accept - this style of constructor for cfront demangling. */ + this style of constructor for cfront demangling. A GNU + style member-template constructor starts with 'H'. */ if (!(LUCID_DEMANGLING || ARM_DEMANGLING)) work -> constructor += 1; *mangled = scan + 2; @@ -2345,6 +2387,37 @@ do_type (work, mangled, result) } break; + case 'X': + case 'Y': + /* A template parm. We substitute the corresponding argument. */ + { + int idx; + int lvl; + + (*mangled)++; + idx = consume_count_with_underscores (mangled); + + if (idx == -1 + || (work->tmpl_argvec && idx >= work->ntmpl_args) + || consume_count_with_underscores (mangled) == -1) + { + success = 0; + break; + } + + if (work->tmpl_argvec) + string_append (result, work->tmpl_argvec[idx]); + else + { + char buf[10]; + sprintf(buf, "T%d", idx); + string_append (result, buf); + } + + success = 1; + } + break; + default: success = demangle_fund_type (work, mangled, result); break; @@ -2423,7 +2496,7 @@ demangle_fund_type (work, mangled, result) case 'J': (*mangled)++; APPEND_BLANK (result); - string_append (result, "complex"); + string_append (result, "__complex"); break; default: done = 1; diff --git a/libiberty/functions.def b/libiberty/functions.def index aeed4c69c3b0..6c14c9bfd51a 100644 --- a/libiberty/functions.def +++ b/libiberty/functions.def @@ -9,6 +9,7 @@ * the corresponding function in libc. */ +DEF(asprintf, int, (), NOTHING) DEF(atexit, int, (f), void (*f)()) DEF(bcmp, int, (s1, s2, length), char *s1 AND char *s2 AND int length ) DEF(bcopy, void, (s1, s2, length), char *s1 AND char *s2 AND int length ) diff --git a/libiberty/pexecute.c b/libiberty/pexecute.c index ab5f392780c2..b8594eb0954e 100644 --- a/libiberty/pexecute.c +++ b/libiberty/pexecute.c @@ -23,11 +23,14 @@ Boston, MA 02111-1307, USA. */ /* This file lives in at least two places: libiberty and gcc. Don't change one without the other. */ +#ifdef IN_GCC +#include "config.h" +#endif + #include #include #ifdef IN_GCC -#include "config.h" #include "gansidecl.h" /* ??? Need to find a suitable header file. */ #define PEXECUTE_FIRST 1 @@ -223,6 +226,51 @@ pwait (pid, status, flags) extern int _spawnv (); extern int _spawnvp (); +#ifdef __CYGWIN32__ + +#define fix_argv(argvec) (argvec) + +#else + +/* This is a kludge to get around the Microsoft C spawn functions' propensity + to remove the outermost set of double quotes from all arguments. */ + +const char * const * +fix_argv (argvec) + char **argvec; +{ + int i; + + for (i = 1; argvec[i] != 0; i++) + { + int len, j; + char *temp, *newtemp; + + temp = argvec[i]; + len = strlen (temp); + for (j = 0; j < len; j++) + { + if (temp[j] == '"') + { + newtemp = xmalloc (len + 2); + strncpy (newtemp, temp, j); + newtemp [j] = '\\'; + strncpy (&newtemp [j+1], &temp [j], len-j); + newtemp [len+1] = 0; + temp = newtemp; + len++; + j++; + } + } + + argvec[i] = temp; + } + + return (const char * const *) argvec; +} + +#endif /* ! defined (__CYGWIN32__) */ + int pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) const char *program; @@ -236,7 +284,8 @@ pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags) if ((flags & PEXECUTE_ONE) != PEXECUTE_ONE) abort (); - pid = (flags & PEXECUTE_SEARCH ? _spawnvp : _spawnv) (_P_NOWAIT, program, argv); + pid = (flags & PEXECUTE_SEARCH ? _spawnvp : _spawnv) + (_P_NOWAIT, program, fix_argv(argv)); if (pid == -1) { *errmsg_fmt = install_error_msg; @@ -254,7 +303,7 @@ pwait (pid, status, flags) { /* ??? Here's an opportunity to canonicalize the values in STATUS. Needed? */ - return cwait (status, pid, WAIT_CHILD); + return _cwait (status, pid, WAIT_CHILD); } #endif /* _WIN32 */ diff --git a/libiberty/vasprintf.c b/libiberty/vasprintf.c index 3794cbd2c4fb..38e846804617 100644 --- a/libiberty/vasprintf.c +++ b/libiberty/vasprintf.c @@ -118,7 +118,11 @@ int vasprintf (result, format, args) char **result; const char *format; +#if defined (_BSD_VA_LIST_) && defined (__FreeBSD__) + _BSD_VA_LIST_ args; +#else va_list args; +#endif { return int_vasprintf (result, format, &args); }