Synced with libiberty in the gcc repository.

This commit is contained in:
H.J. Lu 2000-06-15 20:56:25 +00:00
parent b91280077a
commit eb383413c2
18 changed files with 4421 additions and 283 deletions

View File

@ -1,11 +1,83 @@
2000-06-06 DJ Delorie <dj@cygnus.com>
2000-06-09 Zack Weinberg <zack@wolery.cumb.org>
* Makefile.in: add EXTRA_INCS
* configure.in: if with-newlib, point to it for includes
rather than using the installed includes, for target builds.
If cygwin, override function list only for target builds.
* configure: regenerate
* cp-demangle.c (demangle_operator_name): Add spaces before
names beginning with a letter: delete, delete[], new, new[],
sizeof.
(demangle_special_name): Handle TF <type> and TJ <type>.
Thu Jun 8 18:52:24 2000 Philippe De Muyter <phdm@macqel.be>
* cp-demangle.c (template_arg_list_new): Revert previous PARAMS patch.
Thu Jun 8 09:25:54 2000 Philippe De Muyter <phdm@macqel.be>
* cp-demangle.c (stdio.h): File included unconditionaly.
(template_arg_list_new): Parameter list is PARAMS ((void)), not ().
* dyn-string.c (stdio.h): File included.
* partition.c (partition_print): No `&' needed to take the address of
a function.
2000-06-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* configure.in (ac_libiberty_warn_cflags): Add -pedantic.
* choose-temp.c (try, choose_temp_base, make_temp_file): Constify.
* cp-demangle.c (demangle_char): Change parameter from char to int.
(demangle_expression, demangle_expr_primary): Remove extra
semi-colon in prototype.
* dyn-string.c (dyn_string_append_char): Change parameter from
char to int.
* memcmp.c (memcmp): Constify.
* mkstemps.c (gcc_uint64_t): Mark GNUC `long long' case with
__extension__.
* partition.c (elem_compare): Prototype. Don't cast away
const-ness.
* setenv.c (setenv): Use braces to avoid ambiguous `else'.
2000-06-07 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* Makefile.in (cp-demangle.o): Depend on $(INCDIR)/demangle.h.
* cp-demangle.c: Include demangle.h.
(template_arg_list_new): DeANSIfy.
(cp_demangle): Make static and add prototype.
(operator_code, operators): Constify.
(demangle_operator_name): Likewise for variables `p1', `p2' and `p'.
2000-06-05 Alex Samuel <samuel@codesourcery.com>
* cp-demangle.c (demangle_prefix): Cast argument to isdigit to
unsigned char.
(demangle_unqualified_name): Likewise.
(demangle_number_literally): Likewise.
(demangle_type): Likewise.
(demangle_substitution): Likewise.
(is_mangled_char): Likewise, for isalnum.
2000-06-04 Alex Samuel <samuel@codesourcery.com>
* Makefile.in (CFILES): Add cp-demangle.c and dyn-string.c.
(REQUIRED_OFILES): Add cp-demangle.o and dyn-string.o.
(cp-demangle.o): New dependency.
(dyn-string.o): Likewise.
* dyn-string.c: Move here from gcc/dyn-string.c. Add new functions.
* cplus-dem.c (libiberty_demanglers): Add initializer for new-ABI
demangler.
(cplus_demangle): Call cplus_demangle_new_abi if in new-ABI
demangling mode.
(gnu_new_abi_symbol_characters): New function.
(main): Use gnu_new_abi_symbol_characters. * cp-demangle.c: New
file.
* cp-demangle.c: New file.
Tue May 30 16:45:25 2000 Andrew Cagney <cagney@b1.cygnus.com>
* floatformat.c: Add name to each floatformat field.
@ -16,7 +88,7 @@ Tue May 30 15:07:52 2000 Jeffrey A Law (law@cygnus.com)
2000-05-29 Zack Weinberg <zack@wolery.cumb.org>
* hashtab.c, partition.c, xmemdup.c: Include string.h
* hashtab.c, partition.c, sort.c, xmemdup.c: Include string.h
if HAVE_STRING_H.
* pexecute.c, xexit.c: Include stdlib.h if HAVE_STDLIB_H.
* objalloc.c: Include config.h. Include stdlib.h and don't
@ -26,22 +98,125 @@ Tue May 30 15:07:52 2000 Jeffrey A Law (law@cygnus.com)
HAVE_STRING_H, else declare memset without prototype. Don't
include stddef.h.
* sort.c: Bring over from GCC.
2000-05-23 Mike Stump <mrs@wrs.com>
2000-05-26 Alexandre Oliva <aoliva@cygnus.com>
* Makefile.in (xmalloc.o): Add dependency for config.h, fixes make
-j3.
2000-05-18 J. David Anglin <dave@hiauly1.hia.nrc.ca>
* xmalloc.c: Include config.h for HAVE_SBRK definition.
2000-05-16 Horst von Brand <vonbrand@sleipnir.valparaiso.cl>
* hashtab.c (hash_pointer): Delete low-order bits which are
probably zero, also eliminate a warning on alpha.
2000-05-15 David Edelsohn <edelsohn@gnu.org>
* Makefile.in: Change "pic" to depend on $(PICFLAG), not
on $(enable_shared).
2000-05-10 Jakub Jelinek <jakub@redhat.com>
* config.table: Use mh-sparcpic for sparc*-*-*.
2000-05-08 Nick Clifton <nickc@cygnus.com>
* Makefile.in (CFILES): Add strncmp.c.
(NEEDED): Add strncmp.
2000-05-04 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* cplus-dem.c (cplus_demangle_opname, demangle_function_name):
Cast the arguments to `islower' to `unsigned char'.
(print_demangler_list): Prototype.
Thu May 4 17:14:41 2000 Philippe De Muyter <phdm@macqel.be>
* sort.c (UCHAR_MAX): Provide fallback definition.
2000-04-29 Alexandre Oliva <aoliva@cygnus.com>
* Makefile.in (maintainer-clean-subdir): Fix handling of empty
SUBDIRS.
2000-04-28 Kenneth Block <block@zk3.dec.com>
Jason Merrill <jason@casey.cygnus.com>
* cplus-dem.c (libiberty_demanglers): New table for demangle styles.
(cplus_demangle_set_style): New function for setting style.
(cplus_demangle_name_to_style): New function to translate name.
2000-04-27 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* aclocal.m4: New file with new test libiberty_AC_FUNC_STRNCMP.
* configure.in (AC_CHECK_HEADERS): Add sys/mman.h fcntl.h.
(libiberty_AC_FUNC_STRNCMP): Invoke.
* strncmp.c: New file.
Thu Apr 27 16:58:43 MET DST 2000 Jan Hubicka <jh@suse.cz>
* hashtab.c (htab_expand): Add prototype.
(find_empty_slot_for_expand): Likewise.
2000-04-24 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* hashtab.c (hash_pointer, eq_pointer): Make definition static to
match prototype.
(htab_expand): Cast the return value of xcalloc.
2000-04-24 Mark Mitchell <mark@codesourcery.com>
* hashtab.c (hash_pointer): New function.
(eq_pointer): Likewise.
(htab_hash_pointer): New variable.
(htab_eq_pointer): Likewise.
2000-04-23 Mark Mitchell <mark@codesourcery.com>
* sort.c (sort_pointers): Fix endianness bugs.
* sort.c: New file.
* Makefile.in (CFILES): Add sort.c
(REQUIRED_OFILES): Add sort.o.
(sort.o): New target.
2000-04-21 Michael Sokolov <msokolov@ivan.Harhan.ORG>
* Makefile.in (*-subdir): Revamp slightly to avoid losing on
4.3BSD systems.
Tue Apr 18 16:23:31 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* hashtab.c: Various minor cleanups.
(htab_find_slot_with_hash): INSERT is now enum insert_option.
(htab_find_slot): Likewise.
2000-04-16 Dave Pitts <dpitts@cozx.com>
* cplus-dem.c (cplus_demangle_opname): Changed to use islower.
2000-04-05 Richard Henderson <rth@cygnus.com>
* splay-tree.c (splay_tree_remove): New.
2000-03-30 Mark Mitchell <mark@codesourcery.com>
* hashtab.c (find_empty_slot_for_expand): Use hashval_t for hash
codes.
(htab_find_with_hash): Likewise.
(htab_find_slot_with_hash): Likewise.
2000-03-29 Zack Weinberg <zack@wolery.cumb.org>
* hashtab.c (htab_find_with_hash): Avoid calculating hash2
unless it will be used. Rearrange loop for better
optimization.
(higher_prime_number): Add static prototype.
Thu Mar 16 01:33:58 2000 Jeffrey A Law (law@cygnus.com)
* Makefile.in (partition.o): Depend on config.h

View File

@ -1,6 +1,6 @@
#
# Makefile
# Copyright (C) 1990, 91 - 99, 2000
# Copyright (C) 1990, 91-99, 2000
# Free Software Foundation
#
# This file is part of the libiberty library.
@ -106,10 +106,11 @@ installcheck: installcheck-subdir
INCDIR=$(srcdir)/$(MULTISRCTOP)../include
COMPILE.c = $(CC) -c @DEFS@ $(LIBCFLAGS) -I. -I$(INCDIR) @EXTRA_INCS@ $(HDEFINES) @ac_libiberty_warn_cflags@
COMPILE.c = $(CC) -c @DEFS@ $(LIBCFLAGS) -I. -I$(INCDIR) $(HDEFINES) @ac_libiberty_warn_cflags@
.c.o:
test x"$(enable_shared)" != xyes || \
$(COMPILE.c) $(PICFLAG) $< -o pic/$@
if [ x"$(PICFLAG)" != x ]; then \
$(COMPILE.c) $(PICFLAG) $< -o pic/$@; \
else true; fi
$(COMPILE.c) $<
info: info-subdir
@ -124,23 +125,25 @@ HFILES = alloca-conf.h
# (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 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 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 spaces.c splay-tree.c strcasecmp.c \
strncasecmp.c strchr.c strdup.c strerror.c strrchr.c \
strsignal.c strstr.c strtod.c strtol.c strtoul.c tmpnam.c \
vasprintf.c vfork.c vfprintf.c vprintf.c vsprintf.c waitpid.c \
xatexit.c xexit.c xmalloc.c xmemdup.c xstrdup.c xstrerror.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 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 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 \
fdmatch.o fnmatch.o getopt.o getopt1.o getpwd.o getruntime.o hashtab.o \
hex.o floatformat.o objalloc.o obstack.o partition.o pexecute.o spaces.o \
splay-tree.o strerror.o strsignal.o xatexit.o xexit.o xmalloc.o \
xmemdup.o xstrdup.o xstrerror.o
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 objalloc.o obstack.o \
partition.o pexecute.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)
@ -167,7 +170,7 @@ install_to_tooldir: all
# to include there. Do not add anything LGPL to this list; libstdc++
# can't use anything encumbering.
NEEDED = atexit calloc memchr memcmp memcpy memmove memset rename strchr \
strerror strrchr strstr strtol strtoul tmpnam vfprintf vprintf \
strerror strncmp strrchr strstr strtol strtoul tmpnam vfprintf vprintf \
vfork waitpid bcmp bcopy bzero
needed-list: Makefile
rm -f needed-list; touch needed-list; \
@ -185,7 +188,7 @@ required-list: Makefile
echo $(REQUIRED_OFILES) > required-list
stamp-picdir:
if [ x"$(enable_shared)" = xyes ] && [ ! -d pic ]; then \
if [ x"$(PICFLAG)" != x ] && [ ! -d pic ]; then \
mkdir pic; \
else true; fi
touch stamp-picdir
@ -260,6 +263,8 @@ choose-temp.o: config.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
getcwd.o: config.h
@ -276,13 +281,14 @@ obstack.o: config.h $(INCDIR)/obstack.h
partition.o: config.h $(INCDIR)/partition.h
pexecute.o: config.h $(INCDIR)/libiberty.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
xatexit.o: $(INCDIR)/libiberty.h
xexit.o: $(INCDIR)/libiberty.h
xmalloc.o: $(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

71
libiberty/aclocal.m4 vendored Normal file
View File

@ -0,0 +1,71 @@
dnl See whether strncmp reads past the end of its string parameters.
dnl On some versions of SunOS4 at least, strncmp reads a word at a time
dnl but erroneously reads past the end of strings. This can cause
dnl a SEGV in some cases.
AC_DEFUN(libiberty_AC_FUNC_STRNCMP,
[AC_REQUIRE([AC_FUNC_MMAP])
AC_CACHE_CHECK([for working strncmp], ac_cv_func_strncmp_works,
[AC_TRY_RUN([
/* Test by Jim Wilson and Kaveh Ghazi.
Check whether strncmp reads past the end of its string parameters. */
#include <sys/types.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
#ifndef MAP_ANON
#ifdef MAP_ANONYMOUS
#define MAP_ANON MAP_ANONYMOUS
#else
#define MAP_ANON MAP_FILE
#endif
#endif
#ifndef MAP_FILE
#define MAP_FILE 0
#endif
#ifndef O_RDONLY
#define O_RDONLY 0
#endif
#define MAP_LEN 0x10000
main ()
{
#if defined(HAVE_MMAP) || defined(HAVE_MMAP_ANYWHERE)
char *p;
int dev_zero;
dev_zero = open ("/dev/zero", O_RDONLY);
if (dev_zero < 0)
exit (1);
p = (char *) mmap (0, MAP_LEN, PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, dev_zero, 0);
if (p == (char *)-1)
exit (2);
else
{
char *string = "__si_type_info";
char *q = (char *) p + MAP_LEN - strlen (string) - 2;
char *r = (char *) p + 0xe;
strcpy (q, string);
strcpy (r, string);
strncmp (r, q, 14);
}
#endif /* HAVE_MMAP || HAVE_MMAP_ANYWHERE */
exit (0);
}
], ac_cv_func_strncmp_works=yes, ac_cv_func_strncmp_works=no,
ac_cv_func_strncmp_works=no)
rm -f core core.* *.core])
if test $ac_cv_func_strncmp_works = no ; then
LIBOBJS="$LIBOBJS strncmp.o"
fi
])

View File

@ -79,9 +79,11 @@ extern int mkstemps ();
If success, DIR is returned.
Otherwise NULL is returned. */
static char *
static const char *try PARAMS ((const char *, const char *));
static const char *
try (dir, base)
char *dir, *base;
const char *dir, *base;
{
if (base != 0)
return base;
@ -102,7 +104,7 @@ try (dir, base)
char *
choose_temp_base ()
{
char *base = 0;
const char *base = 0;
char *temp_filename;
int len;
static char tmp[] = { DIR_SEPARATOR, 't', 'm', 'p', 0 };
@ -147,7 +149,7 @@ char *
make_temp_file (suffix)
const char *suffix;
{
char *base = 0;
const char *base = 0;
char *temp_filename;
int base_len, suffix_len;
int fd;

View File

@ -13,6 +13,9 @@
/* 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
/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */
#undef HAVE_SYS_WAIT_H
@ -196,6 +199,9 @@
/* Define if you have the waitpid function. */
#undef HAVE_WAITPID
/* Define if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
@ -208,6 +214,9 @@
/* Define if you have the <sys/file.h> header file. */
#undef HAVE_SYS_FILE_H
/* Define if you have the <sys/mman.h> header file. */
#undef HAVE_SYS_MMAN_H
/* Define if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H

View File

@ -27,6 +27,7 @@ if [ "${shared}" = "yes" ]; then
i[3456]86-*-*) frags="${frags} ../../config/mh-x86pic" ;;
powerpc*-*-aix*) ;;
powerpc*-*-*) frags="${frags} ../../config/mh-ppcpic" ;;
sparc*-*-*) frags="${frags} ../../config/mh-sparcpic" ;;
*-*-*) frags="${frags} ../../config/mh-${host_cpu}pic" ;;
esac
fi

585
libiberty/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -55,7 +55,7 @@ AC_PROG_CC_GNU
if test $ac_cv_prog_gcc = yes; then
GCC=yes
ac_libiberty_warn_cflags='-W -Wall -Wtraditional'
ac_libiberty_warn_cflags='-W -Wall -Wtraditional -pedantic'
dnl Check whether -g works, even if CFLAGS is set, in case the package
dnl plays around with CFLAGS (such as to build both debugging and
dnl normal versions of a library), tasteless as that idea is.
@ -109,7 +109,7 @@ 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 stdlib.h string.h unistd.h strings.h sys/time.h sys/resource.h sys/stat.h)
AC_CHECK_HEADERS(sys/file.h sys/param.h stdlib.h string.h unistd.h strings.h sys/time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h)
AC_HEADER_SYS_WAIT
# This is the list of functions which libiberty will provide if they
@ -216,11 +216,6 @@ if test -n "${with_target_subdir}"; then
setobjs=yes
if test -d ${libiberty_topdir}/newlib
then
EXTRA_INCS="-I${libiberty_topdir}/newlib/libc/include"
fi
fi
else
@ -230,7 +225,6 @@ else
fi
AC_SUBST(EXTRA_INCS)
AC_SUBST(CHECK)
if test -z "${setobjs}"; then
@ -283,15 +277,10 @@ if test -z "${setobjs}"; then
# provides from our shell variables, so that they appear to be
# missing.
# DJ - only if we're *building* cygwin, not just building *with* cygwin
if test -n "${with_target_subdir}"
then
funcs="`echo $funcs | sed -e 's/random//'`"
LIBOBJS="$LIBOBJS random.o"
vars="`echo $vars | sed -e 's/sys_siglist//'`"
checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
fi
funcs="`echo $funcs | sed -e 's/random//'`"
LIBOBJS="$LIBOBJS random.o"
vars="`echo $vars | sed -e 's/sys_siglist//'`"
checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
;;
*-*-mingw32*)
@ -363,6 +352,8 @@ EOF
AC_CHECK_FUNCS($checkfuncs)
fi
libiberty_AC_FUNC_STRNCMP
# Install a library built with a cross compiler in $(tooldir) rather
# than $(libdir).
if test -z "${with_cross_host}"; then

3015
libiberty/cp-demangle.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -252,6 +252,55 @@ typedef enum type_kind_t
tk_real
} type_kind_t;
struct demangler_engine libiberty_demanglers[] =
{
{
AUTO_DEMANGLING_STYLE_STRING,
auto_demangling,
"Automatic selection based on executable"
}
,
{
GNU_DEMANGLING_STYLE_STRING,
gnu_demangling,
"GNU (g++) style demangling"
}
,
{
LUCID_DEMANGLING_STYLE_STRING,
lucid_demangling,
"Lucid (lcc) style demangling"
}
,
{
ARM_DEMANGLING_STYLE_STRING,
arm_demangling,
"ARM style demangling"
}
,
{
HP_DEMANGLING_STYLE_STRING,
hp_demangling,
"HP (aCC) style demangling"
}
,
{
EDG_DEMANGLING_STYLE_STRING,
edg_demangling,
"EDG style demangling"
}
,
{
GNU_NEW_ABI_DEMANGLING_STYLE_STRING,
gnu_new_abi_demangling,
"GNU (g++) new-ABI-style demangling"
}
,
{
NULL, unknown_demangling, NULL
}
};
#define STRING_EMPTY(str) ((str) -> b == (str) -> p)
#define PREPEND_BLANK(str) {if (!STRING_EMPTY(str)) \
string_prepend(str, " ");}
@ -636,8 +685,8 @@ cplus_demangle_opname (opname, result, options)
}
}
else if (opname[0] == '_' && opname[1] == '_'
&& opname[2] >= 'a' && opname[2] <= 'z'
&& opname[3] >= 'a' && opname[3] <= 'z')
&& islower((unsigned char)opname[2])
&& islower((unsigned char)opname[3]))
{
if (opname[4] == '\0')
{
@ -733,6 +782,7 @@ cplus_demangle_opname (opname, result, options)
return ret;
}
/* Takes operator name as e.g. "++" and returns mangled
operator name (e.g. "postincrement_expr"), or NULL if not found.
@ -758,6 +808,40 @@ cplus_mangle_opname (opname, options)
return (0);
}
/* Add a routine to set the demangling style to be sure it is valid and
allow for any demangler initialization that maybe necessary. */
enum demangling_styles
cplus_demangle_set_style (style)
enum demangling_styles style;
{
struct demangler_engine *demangler = libiberty_demanglers;
for (; demangler->demangling_style != unknown_demangling; ++demangler)
if (style == demangler->demangling_style)
{
current_demangling_style = style;
return current_demangling_style;
}
return unknown_demangling;
}
/* Do string name to style translation */
enum demangling_styles
cplus_demangle_name_to_style (name)
const char *name;
{
struct demangler_engine *demangler = libiberty_demanglers;
for (; demangler->demangling_style != unknown_demangling; ++demangler)
if (strcmp (name, demangler->demangling_style_name) == 0)
return demangler->demangling_style;
return unknown_demangling;
}
/* char *cplus_demangle (const char *mangled, int options)
If MANGLED is a mangled function name produced by GNU C++, then
@ -798,6 +882,10 @@ cplus_demangle (mangled, options)
if ((work -> options & DMGL_STYLE_MASK) == 0)
work -> options |= (int) current_demangling_style & DMGL_STYLE_MASK;
/* The new-ABI demangling is implemented elsewhere. */
if (GNU_NEW_ABI_DEMANGLING)
return cplus_demangle_new_abi (mangled);
ret = internal_cplus_demangle (work, mangled);
squangle_mop_up (work);
return (ret);
@ -4188,8 +4276,8 @@ demangle_function_name (work, mangled, declp, scan)
}
}
else if (declp->b[0] == '_' && declp->b[1] == '_'
&& declp->b[2] >= 'a' && declp->b[2] <= 'z'
&& declp->b[3] >= 'a' && declp->b[3] <= 'z')
&& islower((unsigned char)declp->b[2])
&& islower((unsigned char)declp->b[3]))
{
if (declp->b[4] == '\0')
{
@ -4402,6 +4490,7 @@ static int flags = DMGL_PARAMS | DMGL_ANSI;
static void demangle_it PARAMS ((char *));
static void usage PARAMS ((FILE *, int)) ATTRIBUTE_NORETURN;
static void fatal PARAMS ((const char *)) ATTRIBUTE_NORETURN;
static void print_demangler_list PARAMS ((FILE *));
static void
demangle_it (mangled_name)
@ -4421,16 +4510,43 @@ demangle_it (mangled_name)
}
}
static void
print_demangler_list (stream)
FILE *stream;
{
struct demangler_engine *demangler;
fprintf (stream, "{%s", libiberty_demanglers->demangling_style_name);
for (demangler = libiberty_demanglers + 1;
demangler->demangling_style != unknown_demangling;
++demangler)
fprintf (stream, ",%s", demangler->demangling_style_name);
fprintf (stream, "}");
}
static void
usage (stream, status)
FILE *stream;
int status;
{
fprintf (stream, "\
Usage: %s [-_] [-n] [-s {gnu,lucid,arm,hp,edg}] [--strip-underscores]\n\
[--no-strip-underscores] [--format={gnu,lucid,arm,hp,edg}]\n\
[--help] [--version] [arg...]\n",
Usage: %s [-_] [-n] [--strip-underscores] [--no-strip-underscores] \n",
program_name);
fprintf (stream, "\
[-s ");
print_demangler_list (stream);
fprintf (stream, "]\n");
fprintf (stream, "\
[--format ");
print_demangler_list (stream);
fprintf (stream, "]\n");
fprintf (stream, "\
[--help] [--version] [arg...]\n");
exit (status);
}
@ -4468,6 +4584,9 @@ standard_symbol_characters PARAMS ((void));
static const char *
hp_symbol_characters PARAMS ((void));
static const char *
gnu_new_abi_symbol_characters PARAMS ((void));
/* Return the string of non-alnum characters that may occur
as a valid symbol component, in the standard assembler symbol
syntax. */
@ -4516,6 +4635,17 @@ hp_symbol_characters ()
}
/* Return the string of non-alnum characters that may occur
as a valid symbol component in the GNU standard C++ ABI mangling
scheme. */
static const char *
gnu_new_abi_symbol_characters ()
{
return "_";
}
extern int main PARAMS ((int, char **));
int
@ -4553,32 +4683,19 @@ main (argc, argv)
flags |= DMGL_JAVA;
break;
case 's':
if (strcmp (optarg, "gnu") == 0)
{
current_demangling_style = gnu_demangling;
}
else if (strcmp (optarg, "lucid") == 0)
{
current_demangling_style = lucid_demangling;
}
else if (strcmp (optarg, "arm") == 0)
{
current_demangling_style = arm_demangling;
}
else if (strcmp (optarg, "hp") == 0)
{
current_demangling_style = hp_demangling;
}
else if (strcmp (optarg, "edg") == 0)
{
current_demangling_style = edg_demangling;
}
else
{
fprintf (stderr, "%s: unknown demangling style `%s'\n",
program_name, optarg);
return (1);
}
{
enum demangling_styles style;
style = cplus_demangle_name_to_style (optarg);
if (style == unknown_demangling)
{
fprintf (stderr, "%s: unknown demangling style `%s'\n",
program_name, optarg);
return (1);
}
else
cplus_demangle_set_style (style);
}
break;
}
}
@ -4603,6 +4720,9 @@ main (argc, argv)
case hp_demangling:
valid_symbols = hp_symbol_characters ();
break;
case gnu_new_abi_demangling:
valid_symbols = gnu_new_abi_symbol_characters ();
break;
default:
/* Folks should explicitly indicate the appropriate alphabet for
each demangling. Providing a default would allow the

333
libiberty/dyn-string.c Normal file
View File

@ -0,0 +1,333 @@
/* An abstract string datatype.
Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
Contributed by Mark Mitchell (mark@markmitchell.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
#include <stdio.h>
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include "libiberty.h"
#include "dyn-string.h"
/* Performs in-place initialization of a dyn_string struct. This
function can be used with a dyn_string struct on the stack or
embedded in another object. The contents of of the string itself
are still dynamically allocated. The string initially is capable
of holding at least SPACE characeters, including the terminating
NUL. If SPACE is 0, it will silently be increated to 1. */
void
dyn_string_init (ds_struct_ptr, space)
struct dyn_string *ds_struct_ptr;
int space;
{
/* We need at least one byte in which to store the terminating NUL. */
if (space == 0)
space = 1;
ds_struct_ptr->allocated = space;
ds_struct_ptr->s = (char *) xmalloc (space);
ds_struct_ptr->length = 0;
ds_struct_ptr->s[0] = '\0';
}
/* Create a new dynamic string capable of holding at least SPACE characters,
including the terminating NUL. If SPACE is 0, it will be silently
increased to 1. */
dyn_string_t
dyn_string_new (space)
int space;
{
dyn_string_t result = (dyn_string_t) xmalloc (sizeof (struct dyn_string));
dyn_string_init (result, space);
return result;
}
/* Free the memory used by DS. */
void
dyn_string_delete (ds)
dyn_string_t ds;
{
free (ds->s);
free (ds);
}
/* Returns the contents of DS in a buffer allocated with malloc. It
is the caller's responsibility to deallocate the buffer using free.
DS is then set to the empty string. */
char*
dyn_string_release (ds)
dyn_string_t ds;
{
/* Store the old buffer. */
char* result = ds->s;
/* The buffer is no longer owned by DS. */
ds->s = NULL;
/* Reinitialize DS to the empty string. */
dyn_string_init (ds, 0);
/* Return the old buffer. */
return result;
}
/* Increase the capacity of DS so it can hold at least SPACE
characters, plus the terminating NUL. This function will not (at
present) reduce the capacity of DS. */
dyn_string_t
dyn_string_resize (ds, space)
dyn_string_t ds;
int space;
{
int new_allocated = ds->allocated;
/* Increase SPACE to hold the NUL termination. */
++space;
while (space > new_allocated)
new_allocated *= 2;
if (new_allocated != ds->allocated)
{
/* We actually need more space. */
ds->allocated = new_allocated;
ds->s = (char *) xrealloc (ds->s, ds->allocated);
}
return ds;
}
/* Sets the contents of DS to the empty string. */
void
dyn_string_clear (ds)
dyn_string_t ds;
{
/* A dyn_string always has room for at least the NUL terminator. */
ds->s[0] = '\0';
ds->length = 0;
}
/* Makes the contents of DEST the same as the contents of SRC. DEST
and SRC must be distinct. */
void
dyn_string_copy (dest, src)
dyn_string_t dest;
dyn_string_t src;
{
if (dest == src)
abort ();
/* Make room in DEST. */
dyn_string_resize (dest, src->length);
/* Copy DEST into SRC. */
strcpy (dest->s, src->s);
/* Update the size of DEST. */
dest->length = src->length;
}
/* Copies SRC, a NUL-terminated string, into DEST. */
void
dyn_string_copy_cstr (dest, src)
dyn_string_t dest;
const char *src;
{
int length = strlen (src);
/* Make room in DEST. */
dyn_string_resize (dest, length);
/* Copy DEST into SRC. */
strcpy (dest->s, src);
/* Update the size of DEST. */
dest->length = length;
}
/* Inserts SRC at the beginning of DEST. DEST is expanded as
necessary. SRC and DEST must be distinct. */
void
dyn_string_prepend (dest, src)
dyn_string_t dest;
dyn_string_t src;
{
dyn_string_insert (dest, 0, src);
}
/* Inserts SRC, a NUL-terminated string, at the beginning of DEST.
DEST is expanded as necessary. */
void
dyn_string_prepend_cstr (dest, src)
dyn_string_t dest;
const char *src;
{
dyn_string_insert_cstr (dest, 0, src);
}
/* Inserts SRC into DEST starting at position POS. DEST is expanded as
necessary. SRC and DEST must be distinct. */
void
dyn_string_insert (dest, pos, src)
dyn_string_t dest;
int pos;
dyn_string_t src;
{
int i;
if (src == dest)
abort ();
dyn_string_resize (dest, dest->length + src->length);
/* Make room for the insertion. Be sure to copy the NUL. */
for (i = dest->length; i >= pos; --i)
dest->s[i + src->length] = dest->s[i];
/* Splice in the new stuff. */
strncpy (dest->s + pos, src->s, src->length);
/* Compute the new length. */
dest->length += src->length;
}
/* Inserts SRC, a NUL-terminated string, into DEST starting at
position POS. DEST is expanded as necessary. */
void
dyn_string_insert_cstr (dest, pos, src)
dyn_string_t dest;
int pos;
const char *src;
{
int i;
int length = strlen (src);
dyn_string_resize (dest, dest->length + length);
/* Make room for the insertion. Be sure to copy the NUL. */
for (i = dest->length; i >= pos; --i)
dest->s[i + length] = dest->s[i];
/* Splice in the new stuff. */
strncpy (dest->s + pos, src, length);
/* Compute the new length. */
dest->length += length;
}
/* Append S to DS, resizing DS if necessary. Returns DS. */
dyn_string_t
dyn_string_append (ds, s)
dyn_string_t ds;
dyn_string_t s;
{
dyn_string_resize (ds, ds->length + s->length);
strcpy (ds->s + ds->length, s->s);
ds->length += s->length;
return ds;
}
/* Append the NUL-terminated string S to DS, resizing DS if necessary.
Returns DS. */
dyn_string_t
dyn_string_append_cstr (ds, s)
dyn_string_t ds;
const char *s;
{
int len = strlen (s);
/* The new length is the old length plus the size of our string, plus
one for the null at the end. */
dyn_string_resize (ds, ds->length + len);
strcpy (ds->s + ds->length, s);
ds->length += len;
return ds;
}
/* Appends C to the end of DS. */
dyn_string_t
dyn_string_append_char (ds, c)
dyn_string_t ds;
int c;
{
/* Make room for the extra character. */
dyn_string_resize (ds, ds->length + 1);
/* Append the character; it will overwrite the old NUL. */
ds->s[ds->length] = c;
/* Add a new NUL at the end. */
ds->s[ds->length + 1] = '\0';
/* Update the length. */
++(ds->length);
return ds;
}
/* Sets the contents of DEST to the substring of SRC starting at START
and ending before END. START must be less than or equal to END,
and both must be between zero and the length of SRC, inclusive. */
void
dyn_string_substring (dest, src, start, end)
dyn_string_t dest;
dyn_string_t src;
int start;
int end;
{
int i;
int length = end - start;
if (start > end || start > src->length || end > src->length)
abort ();
/* Make room for the substring. */
dyn_string_resize (dest, length);
/* Copy the characters in the substring, */
for (i = length; --i >= 0; )
dest->s[i] = src->s[start + i];
/* NUL-terimate the result. */
dest->s[length] = '\0';
/* Record the length of the substring. */
dest->length = length;
}
/* Returns non-zero if DS1 and DS2 have the same contents. */
int
dyn_string_eq (ds1, ds2)
dyn_string_t ds1;
dyn_string_t ds2;
{
/* If DS1 and DS2 have different lengths, they must not be the same. */
if (ds1->length != ds2->length)
return 0;
else
return !strcmp (ds1->s, ds2->s);
}

View File

@ -1,5 +1,5 @@
/* An expandable hash tables datatype.
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2000 Free Software Foundation, Inc.
Contributed by Vladimir Makarov (vmakarov@cygnus.com).
This file is part of the libiberty library.
@ -59,8 +59,20 @@ Boston, MA 02111-1307, USA. */
#define DELETED_ENTRY ((void *) 1)
static unsigned long higher_prime_number PARAMS ((unsigned long));
static hashval_t hash_pointer PARAMS ((const void *));
static int eq_pointer PARAMS ((const void *, const void *));
static void htab_expand PARAMS ((htab_t));
static void **find_empty_slot_for_expand PARAMS ((htab_t, hashval_t));
/* At some point, we could make these be NULL, and modify the
hash-table routines to handle NULL specially; that would avoid
function-call overhead for the common case of hashing pointers. */
htab_hash htab_hash_pointer = hash_pointer;
htab_eq htab_eq_pointer = eq_pointer;
/* The following function returns the nearest prime number which is
greater than given source number. */
greater than a given source number, N. */
static unsigned long
higher_prime_number (n)
@ -68,24 +80,47 @@ higher_prime_number (n)
{
unsigned long i;
n |= 0x01; /* Force N to be odd. */
/* Ensure we have a larger number and then force to odd. */
n++;
n |= 0x01;
/* All odd numbers < 9 are prime. */
if (n < 9)
return n; /* All odd numbers < 9 are prime. */
return n;
/* Otherwise find the next prime using a sieve. */
next:
n += 2;
i = 3;
do
{
if (n % i == 0)
goto next;
i += 2;
}
while ((i * i) <= n);
for (i = 3; i * i <= n; i += 2)
if (n % i == 0)
{
n += 2;
goto next;
}
return n;
}
/* Returns a hash code for P. */
static hashval_t
hash_pointer (p)
const void *p;
{
return (hashval_t) ((long)p >> 3);
}
/* Returns non-zero if P1 and P2 are equal. */
static int
eq_pointer (p1, p2)
const void *p1;
const void *p2;
{
return p1 == p2;
}
/* This function creates table with length slightly longer than given
source length. Created hash table is initiated as empty (all the
hash table entries are EMPTY_ENTRY). The function returns the
@ -118,13 +153,12 @@ htab_delete (htab)
htab_t htab;
{
int i;
if (htab->del_f)
for (i = htab->size - 1; i >= 0; i--)
{
if (htab->entries[i] != EMPTY_ENTRY
&& htab->entries[i] != DELETED_ENTRY)
(*htab->del_f) (htab->entries[i]);
}
if (htab->entries[i] != EMPTY_ENTRY
&& htab->entries[i] != DELETED_ENTRY)
(*htab->del_f) (htab->entries[i]);
free (htab->entries);
free (htab);
@ -137,13 +171,12 @@ htab_empty (htab)
htab_t htab;
{
int i;
if (htab->del_f)
for (i = htab->size - 1; i >= 0; i--)
{
if (htab->entries[i] != EMPTY_ENTRY
&& htab->entries[i] != DELETED_ENTRY)
(*htab->del_f) (htab->entries[i]);
}
if (htab->entries[i] != EMPTY_ENTRY
&& htab->entries[i] != DELETED_ENTRY)
(*htab->del_f) (htab->entries[i]);
memset (htab->entries, 0, htab->size * sizeof (void *));
}
@ -154,22 +187,23 @@ htab_empty (htab)
hash table.
This function also assumes there are no deleted entries in the table.
HASH is the hash value for the element to be inserted. */
static void **
find_empty_slot_for_expand (htab, hash)
htab_t htab;
unsigned int hash;
hashval_t hash;
{
size_t size = htab->size;
unsigned int hash2 = 1 + hash % (size - 2);
hashval_t hash2 = 1 + hash % (size - 2);
unsigned int index = hash % size;
for (;;)
{
void **slot = htab->entries + index;
if (*slot == EMPTY_ENTRY)
return slot;
if (*slot == DELETED_ENTRY)
else if (*slot == DELETED_ENTRY)
abort ();
index += hash2;
@ -196,7 +230,7 @@ htab_expand (htab)
olimit = oentries + htab->size;
htab->size = higher_prime_number (htab->size * 2);
htab->entries = xcalloc (htab->size, sizeof (void **));
htab->entries = (void **) xcalloc (htab->size, sizeof (void **));
htab->n_elements -= htab->n_deleted;
htab->n_deleted = 0;
@ -205,14 +239,18 @@ htab_expand (htab)
do
{
void *x = *p;
if (x != EMPTY_ENTRY && x != DELETED_ENTRY)
{
void **q = find_empty_slot_for_expand (htab, (*htab->hash_f) (x));
*q = x;
}
p++;
}
while (p < olimit);
free (oentries);
}
@ -223,33 +261,41 @@ void *
htab_find_with_hash (htab, element, hash)
htab_t htab;
const void *element;
unsigned int hash;
hashval_t hash;
{
unsigned int index, hash2;
unsigned int index;
hashval_t hash2;
size_t size;
void *entry;
htab->searches++;
size = htab->size;
hash2 = 1 + hash % (size - 2);
index = hash % size;
entry = htab->entries[index];
if (entry == EMPTY_ENTRY
|| (entry != DELETED_ENTRY && (*htab->eq_f) (entry, element)))
return entry;
hash2 = 1 + hash % (size - 2);
for (;;)
{
void *entry = htab->entries[index];
if (entry == EMPTY_ENTRY)
return NULL;
else if (entry != DELETED_ENTRY && (*htab->eq_f) (entry, element))
return entry;
htab->collisions++;
index += hash2;
if (index >= size)
index -= size;
entry = htab->entries[index];
if (entry == EMPTY_ENTRY
|| (entry != DELETED_ENTRY && (*htab->eq_f) (entry, element)))
return entry;
}
}
/* Like htab_find_slot_with_hash, but compute the hash value from the
element. */
void *
htab_find (htab, element)
htab_t htab;
@ -268,14 +314,15 @@ void **
htab_find_slot_with_hash (htab, element, hash, insert)
htab_t htab;
const void *element;
unsigned int hash;
int insert;
hashval_t hash;
enum insert_option insert;
{
void **first_deleted_slot;
unsigned int index, hash2;
unsigned int index;
hashval_t hash2;
size_t size;
if (insert && htab->size * 3 <= htab->n_elements * 4)
if (insert == INSERT && htab->size * 3 <= htab->n_elements * 4)
htab_expand (htab);
size = htab->size;
@ -290,7 +337,7 @@ htab_find_slot_with_hash (htab, element, hash, insert)
void *entry = htab->entries[index];
if (entry == EMPTY_ENTRY)
{
if (!insert)
if (insert == NO_INSERT)
return NULL;
htab->n_elements++;
@ -309,11 +356,8 @@ htab_find_slot_with_hash (htab, element, hash, insert)
if (!first_deleted_slot)
first_deleted_slot = &htab->entries[index];
}
else
{
if ((*htab->eq_f) (entry, element))
return &htab->entries[index];
}
else if ((*htab->eq_f) (entry, element))
return &htab->entries[index];
htab->collisions++;
index += hash2;
@ -324,11 +368,12 @@ htab_find_slot_with_hash (htab, element, hash, insert)
/* Like htab_find_slot_with_hash, but compute the hash value from the
element. */
void **
htab_find_slot (htab, element, insert)
htab_t htab;
const void *element;
int insert;
enum insert_option insert;
{
return htab_find_slot_with_hash (htab, element, (*htab->hash_f) (element),
insert);
@ -345,7 +390,7 @@ htab_remove_elt (htab, element)
{
void **slot;
slot = htab_find_slot (htab, element, 0);
slot = htab_find_slot (htab, element, NO_INSERT);
if (*slot == EMPTY_ENTRY)
return;
@ -368,8 +413,10 @@ htab_clear_slot (htab, slot)
if (slot < htab->entries || slot >= htab->entries + htab->size
|| *slot == EMPTY_ENTRY || *slot == DELETED_ENTRY)
abort ();
if (htab->del_f)
(*htab->del_f) (*slot);
*slot = DELETED_ENTRY;
htab->n_deleted++;
}
@ -385,12 +432,13 @@ htab_traverse (htab, callback, info)
htab_trav callback;
void *info;
{
void **slot, **limit;
slot = htab->entries;
limit = slot + htab->size;
void **slot = htab->entries;
void **limit = slot + htab->size;
do
{
void *x = *slot;
if (x != EMPTY_ENTRY && x != DELETED_ENTRY)
if (!(*callback) (slot, info))
break;
@ -398,7 +446,7 @@ htab_traverse (htab, callback, info)
while (++slot < limit);
}
/* The following function returns current size of given hash table. */
/* Return the current size of given hash table. */
size_t
htab_size (htab)
@ -407,8 +455,7 @@ htab_size (htab)
return htab->size;
}
/* The following function returns current number of elements in given
hash table. */
/* Return the current number of elements in given hash table. */
size_t
htab_elements (htab)
@ -417,17 +464,15 @@ htab_elements (htab)
return htab->n_elements - htab->n_deleted;
}
/* The following function returns number of percents of fixed
collisions during all work with given hash table. */
/* Return the fraction of fixed collisions during all work with given
hash table. */
double
htab_collisions (htab)
htab_t htab;
{
int searches;
searches = htab->searches;
if (searches == 0)
if (htab->searches == 0)
return 0.0;
return (double)htab->collisions / (double)searches;
return (double) htab->collisions / (double) htab->searches;
}

View File

@ -25,8 +25,8 @@ int
DEFUN(memcmp, (str1, str2, count),
const PTR str1 AND const PTR str2 AND size_t count)
{
register unsigned char *s1 = (unsigned char*)str1;
register unsigned char *s2 = (unsigned char*)str2;
register const unsigned char *s1 = (const unsigned char*)str1;
register const unsigned char *s2 = (const unsigned char*)str2;
while (count-- > 0)
{

View File

@ -39,7 +39,7 @@
/* We need to provide a type for gcc_uint64_t. */
#ifdef __GNUC__
typedef unsigned long long gcc_uint64_t;
__extension__ typedef unsigned long long gcc_uint64_t;
#else
typedef unsigned long gcc_uint64_t;
#endif

View File

@ -34,6 +34,8 @@
#include "libiberty.h"
#include "partition.h"
static int elem_compare PARAMS ((const void *, const void *));
/* Creates a partition of NUM_ELEMENTS elements. Initially each
element is in a class by itself. */
@ -128,8 +130,8 @@ elem_compare (elem1, elem2)
const void *elem1;
const void *elem2;
{
int e1 = * (int *) elem1;
int e2 = * (int *) elem2;
int e1 = * (const int *) elem1;
int e2 = * (const int *) elem2;
if (e1 < e2)
return -1;
else if (e1 > e2)
@ -175,7 +177,7 @@ partition_print (part, fp)
c = elements[c].next - elements;
}
/* Sort them. */
qsort ((void *) class_elements, count, sizeof (int), &elem_compare);
qsort ((void *) class_elements, count, sizeof (int), elem_compare);
/* Print them. */
fputc ('(', fp);
for (i = 0; i < count; ++i)

View File

@ -72,11 +72,13 @@ setenv (name, value, replace)
size = 0;
if (__environ != NULL)
for (ep = __environ; *ep != NULL; ++ep)
if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=')
break;
else
++size;
{
for (ep = __environ; *ep != NULL; ++ep)
if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=')
break;
else
++size;
}
if (__environ == NULL || *ep == NULL)
{

28
libiberty/strncmp.c Normal file
View File

@ -0,0 +1,28 @@
/* strncmp -- compare two strings, stop after n bytes.
This function is in the public domain. */
#include <ansidecl.h>
#ifdef __STDC__
#include <stddef.h>
#else
#define size_t unsigned long
#endif
int
strncmp(s1, s2, n)
const char *s1, *s2;
register size_t n;
{
register unsigned char u1, u2;
while (n-- > 0)
{
u1 = (unsigned char) *s1++;
u2 = (unsigned char) *s2++;
if (u1 != u2)
return u1 - u2;
if (u1 == '\0')
return 0;
}
return 0;
}

View File

@ -17,6 +17,9 @@ 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 "ansidecl.h"
#include "libiberty.h"