OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /or1k/tags/start/gdb-5.0/libiberty
    from Rev 579 to Rev 1765
    Reverse comparison

Rev 579 → Rev 1765

/Makefile.in
0,0 → 1,288
#
# Makefile
# Copyright (C) 1990, 91 - 99, 2000
# 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.
#
 
# This file was written by K. Richard Pixley <rich@cygnus.com>.
 
#
# Makefile for libiberty directory
#
 
srcdir = @srcdir@
VPATH = @srcdir@
 
prefix = @prefix@
 
exec_prefix = @exec_prefix@
bindir = @bindir@
libdir = @libdir@
 
SHELL = @SHELL@
 
# Multilib support variables.
MULTISRCTOP =
MULTIBUILDTOP =
MULTIDIRS =
MULTISUBDIR =
MULTIDO = true
MULTICLEAN = true
 
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
 
AR = @AR@
AR_FLAGS = rc
 
CC = @CC@
CFLAGS = @CFLAGS@
LIBCFLAGS = $(CFLAGS)
RANLIB = @RANLIB@
 
PICFLAG =
 
MAKEOVERRIDES =
 
TARGETLIB = libiberty.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.)
EXTRA_OFILES =
 
# Flags to pass to a recursive make.
FLAGS_TO_PASS = \
"AR=$(AR)" \
"AR_FLAGS=$(AR_FLAGS)" \
"CC=$(CC)" \
"CFLAGS=$(CFLAGS)" \
"LIBCFLAGS=$(LIBCFLAGS)" \
"EXTRA_OFILES=$(EXTRA_OFILES)" \
"HDEFINES=$(HDEFINES)" \
"INSTALL=$(INSTALL)" \
"INSTALL_DATA=$(INSTALL_DATA)" \
"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
"LDFLAGS=$(LDFLAGS)" \
"LOADLIBES=$(LOADLIBES)" \
"RANLIB=$(RANLIB)" \
"SHELL=$(SHELL)" \
"prefix=$(prefix)" \
"exec_prefix=$(exec_prefix)" \
"libdir=$(libdir)" \
"libsubdir=$(libsubdir)" \
"tooldir=$(tooldir)"
 
# Subdirectories to recurse into. We need to override this during cleaning
SUBDIRS = testsuite
 
all: stamp-picdir $(TARGETLIB) needed-list required-list all-subdir
@$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=all
 
.PHONY: check installcheck
check: check-subdir
installcheck: installcheck-subdir
 
@host_makefile_frag@
 
INCDIR=$(srcdir)/$(MULTISRCTOP)../include
 
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/$@
$(COMPILE.c) $<
 
info: info-subdir
install-info: install-info-subdir
clean-info: clean-info-subdir
dvi: dvi-subdir
 
# Include files that are in this directory.
HFILES = alloca-conf.h
 
# 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 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
 
# 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
 
$(TARGETLIB): $(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS) $(ALLOCA)
rm -f $(TARGETLIB)
$(AR) $(AR_FLAGS) $(TARGETLIB) \
$(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS) $(ALLOCA)
$(RANLIB) $(TARGETLIB)
 
INSTALL_DEST = @INSTALL_DEST@
install: install_to_$(INSTALL_DEST) install-subdir
 
install_to_libdir: all
$(INSTALL_DATA) $(TARGETLIB) $(libdir)$(MULTISUBDIR)/$(TARGETLIB)n
( cd $(libdir)$(MULTISUBDIR) ; $(RANLIB) $(TARGETLIB)n )
mv -f $(libdir)$(MULTISUBDIR)/$(TARGETLIB)n $(libdir)$(MULTISUBDIR)/$(TARGETLIB)
@$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
 
install_to_tooldir: all
$(INSTALL_DATA) $(TARGETLIB) $(tooldir)/lib$(MULTISUBDIR)/$(TARGETLIB)n
( cd $(tooldir)/lib$(MULTISUBDIR) ; $(RANLIB) $(TARGETLIB)n )
mv -f $(tooldir)/lib$(MULTISUBDIR)/$(TARGETLIB)n $(tooldir)/lib$(MULTISUBDIR)/$(TARGETLIB)
@$(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
 
# needed-list is used by libstdc++. NEEDED is the list of functions
# 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 \
vfork waitpid bcmp bcopy bzero
needed-list: Makefile
rm -f needed-list; touch needed-list; \
for f in $(NEEDED); do \
for g in $(LIBOBJS) $(EXTRA_OFILES); do \
case "$$g" in \
*$$f*) echo $$g >> needed-list ;; \
esac; \
done; \
done
 
# required-list was used when building a shared bfd/opcodes/libiberty
# library. I don't know if it used by anything currently.
required-list: Makefile
echo $(REQUIRED_OFILES) > required-list
 
stamp-picdir:
if [ x"$(enable_shared)" = xyes ] && [ ! -d pic ]; then \
mkdir pic; \
else true; fi
touch stamp-picdir
 
.PHONY: all etags tags ls clean stage1 stage2
 
etags tags: TAGS etags-subdir
 
TAGS: $(CFILES) $(HFILES)
etags `for i in $(HFILES) $(CFILES); do echo $(srcdir)/$$i ; done`
 
# The standalone demangler (c++filt) has been moved to binutils.
demangle:
@echo "The standalone demangler, now named c++filt, is now"
@echo "a part of binutils."
@false
 
ls:
@echo Makefile $(HFILES) $(CFILES)
 
# Need to deal with profiled libraries, too.
 
# Cleaning has to be done carefully to ensure that we don't clean our SUBDIRS
# multiple times, hence our explicit recursion with an empty SUBDIRS.
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
@$(MULTICLEAN) multi-clean DO=mostlyclean
clean: clean-subdir
$(MAKE) SUBDIRS="" mostlyclean
rm -f *.a required-list tmpmulti.out
@$(MULTICLEAN) multi-clean DO=clean
distclean: distclean-subdir
$(MAKE) SUBDIRS="" clean
@$(MULTICLEAN) multi-clean DO=distclean
rm -f *~ Makefile config.status xhost-mkfrag TAGS multilib.out
rm -f config.log
maintainer-clean realclean: maintainer-clean-subdir
$(MAKE) SUBDIRS="" distclean
 
force:
 
Makefile: $(srcdir)/Makefile.in config.status
CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status
 
config.h: stamp-h ; @true
stamp-h: config.in config.status
CONFIG_FILES= CONFIG_HEADERS=config.h:config.in $(SHELL) ./config.status
 
config.status: $(srcdir)/configure $(srcdir)/config.table
$(SHELL) ./config.status --recheck
 
 
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:
@target=`echo $@ | sed -e 's/-subdir//'`; \
for dir in . $(SUBDIRS) ; do \
test $$dir = . || (cd $$dir && $(MAKE) $$target) || exit 1; \
done
 
$(REQUIRED_OFILES) $(EXTRA_OFILES) $(LIBOBJS) $(ALLOCA): stamp-picdir
 
alloca.o: config.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
clock.o: config.h
concat.o: $(INCDIR)/libiberty.h
cplus-dem.o: config.h $(INCDIR)/demangle.h
fdmatch.o: $(INCDIR)/libiberty.h
fnmatch.o: config.h $(INCDIR)/fnmatch.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
mkstemps.o: config.h
objalloc.o: $(INCDIR)/objalloc.h
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
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
xmemdup.o: config.h $(INCDIR)/libiberty.h
xstrdup.o: config.h $(INCDIR)/libiberty.h
xstrerror.o: config.h $(INCDIR)/libiberty.h
hashtab.o: config.h $(INCDIR)/libiberty.h $(INCDIR)/hashtab.h $(INCDIR)/ansidecl.h
/xexit.c
0,0 → 1,36
/* xexit.c -- Run any exit handlers, then exit.
Copyright (C) 1994, 95, 1997 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. */
 
#include "ansidecl.h"
#include "libiberty.h"
 
#include <stdio.h>
 
/* This variable is set by xatexit if it is called. This way, xmalloc
doesn't drag xatexit into the link. */
void (*_xexit_cleanup) PARAMS ((void));
 
void
xexit (code)
int code;
{
if (_xexit_cleanup != NULL)
(*_xexit_cleanup) ();
exit (code);
}
/strcasecmp.c
0,0 → 1,82
/*
* Copyright (c) 1987 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of California at Berkeley. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific written prior permission. This software
* is provided ``as is'' without express or implied warranty.
*/
 
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87";
#endif /* LIBC_SCCS and not lint */
 
#include <ansidecl.h>
#ifdef __STDC__
#include <stddef.h>
#else
#define size_t unsigned long
#endif
 
/*
* This array is designed for mapping upper and lower case letter
* together for a case independent comparison. The mappings are
* based upon ascii character sequences.
*/
typedef unsigned char uc;
static 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',
(uc)'\030',(uc)'\031',(uc)'\032',(uc)'\033',(uc)'\034',(uc)'\035',(uc)'\036',(uc)'\037',
(uc)'\040',(uc)'\041',(uc)'\042',(uc)'\043',(uc)'\044',(uc)'\045',(uc)'\046',(uc)'\047',
(uc)'\050',(uc)'\051',(uc)'\052',(uc)'\053',(uc)'\054',(uc)'\055',(uc)'\056',(uc)'\057',
(uc)'\060',(uc)'\061',(uc)'\062',(uc)'\063',(uc)'\064',(uc)'\065',(uc)'\066',(uc)'\067',
(uc)'\070',(uc)'\071',(uc)'\072',(uc)'\073',(uc)'\074',(uc)'\075',(uc)'\076',(uc)'\077',
(uc)'\100',(uc)'\141',(uc)'\142',(uc)'\143',(uc)'\144',(uc)'\145',(uc)'\146',(uc)'\147',
(uc)'\150',(uc)'\151',(uc)'\152',(uc)'\153',(uc)'\154',(uc)'\155',(uc)'\156',(uc)'\157',
(uc)'\160',(uc)'\161',(uc)'\162',(uc)'\163',(uc)'\164',(uc)'\165',(uc)'\166',(uc)'\167',
(uc)'\170',(uc)'\171',(uc)'\172',(uc)'\133',(uc)'\134',(uc)'\135',(uc)'\136',(uc)'\137',
(uc)'\140',(uc)'\141',(uc)'\142',(uc)'\143',(uc)'\144',(uc)'\145',(uc)'\146',(uc)'\147',
(uc)'\150',(uc)'\151',(uc)'\152',(uc)'\153',(uc)'\154',(uc)'\155',(uc)'\156',(uc)'\157',
(uc)'\160',(uc)'\161',(uc)'\162',(uc)'\163',(uc)'\164',(uc)'\165',(uc)'\166',(uc)'\167',
(uc)'\170',(uc)'\171',(uc)'\172',(uc)'\173',(uc)'\174',(uc)'\175',(uc)'\176',(uc)'\177',
(uc)'\200',(uc)'\201',(uc)'\202',(uc)'\203',(uc)'\204',(uc)'\205',(uc)'\206',(uc)'\207',
(uc)'\210',(uc)'\211',(uc)'\212',(uc)'\213',(uc)'\214',(uc)'\215',(uc)'\216',(uc)'\217',
(uc)'\220',(uc)'\221',(uc)'\222',(uc)'\223',(uc)'\224',(uc)'\225',(uc)'\226',(uc)'\227',
(uc)'\230',(uc)'\231',(uc)'\232',(uc)'\233',(uc)'\234',(uc)'\235',(uc)'\236',(uc)'\237',
(uc)'\240',(uc)'\241',(uc)'\242',(uc)'\243',(uc)'\244',(uc)'\245',(uc)'\246',(uc)'\247',
(uc)'\250',(uc)'\251',(uc)'\252',(uc)'\253',(uc)'\254',(uc)'\255',(uc)'\256',(uc)'\257',
(uc)'\260',(uc)'\261',(uc)'\262',(uc)'\263',(uc)'\264',(uc)'\265',(uc)'\266',(uc)'\267',
(uc)'\270',(uc)'\271',(uc)'\272',(uc)'\273',(uc)'\274',(uc)'\275',(uc)'\276',(uc)'\277',
(uc)'\300',(uc)'\341',(uc)'\342',(uc)'\343',(uc)'\344',(uc)'\345',(uc)'\346',(uc)'\347',
(uc)'\350',(uc)'\351',(uc)'\352',(uc)'\353',(uc)'\354',(uc)'\355',(uc)'\356',(uc)'\357',
(uc)'\360',(uc)'\361',(uc)'\362',(uc)'\363',(uc)'\364',(uc)'\365',(uc)'\366',(uc)'\367',
(uc)'\370',(uc)'\371',(uc)'\372',(uc)'\333',(uc)'\334',(uc)'\335',(uc)'\336',(uc)'\337',
(uc)'\340',(uc)'\341',(uc)'\342',(uc)'\343',(uc)'\344',(uc)'\345',(uc)'\346',(uc)'\347',
(uc)'\350',(uc)'\351',(uc)'\352',(uc)'\353',(uc)'\354',(uc)'\355',(uc)'\356',(uc)'\357',
(uc)'\360',(uc)'\361',(uc)'\362',(uc)'\363',(uc)'\364',(uc)'\365',(uc)'\366',(uc)'\367',
(uc)'\370',(uc)'\371',(uc)'\372',(uc)'\373',(uc)'\374',(uc)'\375',(uc)'\376',(uc)'\377',
};
 
int
strcasecmp(s1, s2)
const char *s1, *s2;
{
register unsigned char u1, u2;
 
for (;;) {
u1 = (unsigned char) *s1++;
u2 = (unsigned char) *s2++;
if (charmap[u1] != charmap[u2]) {
return charmap[u1] - charmap[u2];
}
if (u1 == '\0') {
return 0;
}
}
}
 
/setenv.c
0,0 → 1,163
/* Copyright (C) 1992, 1995, 1996, 1997 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
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.
 
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
Library General Public License for more details.
 
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
 
#if HAVE_CONFIG_H
# include <config.h>
#endif
 
#include "ansidecl.h"
#include <sys/types.h> /* For `size_t' */
#include <stdio.h> /* For `NULL' */
 
#include <errno.h>
#if !defined(errno) && !defined(HAVE_ERRNO_DECL)
extern int errno;
#endif
#define __set_errno(ev) ((errno) = (ev))
 
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#if HAVE_STRING_H
# include <string.h>
#endif
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
 
#define __environ environ
#ifndef HAVE_ENVIRON_DECL
extern char **environ;
#endif
 
/* LOCK and UNLOCK are defined as no-ops. This makes the libiberty
* implementation MT-Unsafe. */
#define LOCK
#define UNLOCK
 
/* Below this point, it's verbatim code from the glibc-2.0 implementation */
 
/* If this variable is not a null pointer we allocated the current
environment. */
static char **last_environ;
 
 
int
setenv (name, value, replace)
const char *name;
const char *value;
int replace;
{
register char **ep;
register size_t size;
const size_t namelen = strlen (name);
const size_t vallen = strlen (value) + 1;
 
LOCK;
 
size = 0;
if (__environ != NULL)
for (ep = __environ; *ep != NULL; ++ep)
if (!strncmp (*ep, name, namelen) && (*ep)[namelen] == '=')
break;
else
++size;
 
if (__environ == NULL || *ep == NULL)
{
char **new_environ;
if (__environ == last_environ && __environ != NULL)
/* We allocated this space; we can extend it. */
new_environ = (char **) realloc (last_environ,
(size + 2) * sizeof (char *));
else
new_environ = (char **) malloc ((size + 2) * sizeof (char *));
 
if (new_environ == NULL)
{
UNLOCK;
return -1;
}
 
new_environ[size] = malloc (namelen + 1 + vallen);
if (new_environ[size] == NULL)
{
free ((char *) new_environ);
__set_errno (ENOMEM);
UNLOCK;
return -1;
}
 
if (__environ != last_environ)
memcpy ((char *) new_environ, (char *) __environ,
size * sizeof (char *));
 
memcpy (new_environ[size], name, namelen);
new_environ[size][namelen] = '=';
memcpy (&new_environ[size][namelen + 1], value, vallen);
 
new_environ[size + 1] = NULL;
 
last_environ = __environ = new_environ;
}
else if (replace)
{
size_t len = strlen (*ep);
if (len + 1 < namelen + 1 + vallen)
{
/* The existing string is too short; malloc a new one. */
char *new = malloc (namelen + 1 + vallen);
if (new == NULL)
{
UNLOCK;
return -1;
}
*ep = new;
}
memcpy (*ep, name, namelen);
(*ep)[namelen] = '=';
memcpy (&(*ep)[namelen + 1], value, vallen);
}
 
UNLOCK;
 
return 0;
}
 
void
unsetenv (name)
const char *name;
{
const size_t len = strlen (name);
char **ep;
 
LOCK;
 
for (ep = __environ; *ep; ++ep)
if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
{
/* Found it. Remove this pointer by moving later ones back. */
char **dp = ep;
do
dp[0] = dp[1];
while (*dp++);
/* Continue the loop in case NAME appears again. */
}
 
UNLOCK;
}
/memmove.c
0,0 → 1,18
/* Wrapper to implement ANSI C's memmove using BSD's bcopy. */
/* This function is in the public domain. --Per Bothner. */
#include <ansidecl.h>
#ifdef __STDC__
#include <stddef.h>
#else
#define size_t unsigned long
#endif
 
PTR
memmove (s1, s2, n)
PTR s1;
const PTR s2;
size_t n;
{
bcopy (s2, s1, n);
return s1;
}
/strsignal.c
0,0 → 1,644
/* Extended support for using signal values.
Written by Fred Fish. fnf@cygnus.com
This file is in the public domain. */
 
#include "ansidecl.h"
#include "libiberty.h"
 
#include "config.h"
 
/* We need to declare sys_siglist, because even if the system provides
it we can't assume that it is declared in <signal.h> (for example,
SunOS provides sys_siglist, but it does not declare it in any
header file). fHowever, we can't declare sys_siglist portably,
because on some systems it is declared with const and on some
systems it is declared without const. If we were using autoconf,
we could work out the right declaration. Until, then we just
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
 
#include <stdio.h>
#include <signal.h>
 
/* Routines imported from standard C runtime libraries. */
 
#ifdef __STDC__
#include <stddef.h>
extern void *malloc (size_t size); /* 4.10.3.3 */
extern void *memset (void *s, int c, size_t n); /* 4.11.6.1 */
#else /* !__STDC__ */
extern char *malloc (); /* Standard memory allocater */
extern char *memset ();
#endif /* __STDC__ */
 
/* Undefine the macro we used to hide the definition of sys_siglist
found in the system header files. */
#undef sys_siglist
 
#ifndef NULL
# ifdef __STDC__
# define NULL (void *) 0
# else
# define NULL 0
# endif
#endif
 
#ifndef MAX
# define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif
 
static void init_signal_tables PARAMS ((void));
 
/* Translation table for signal values.
 
Note that this table is generally only accessed when it is used at runtime
to initialize signal name and message tables that are indexed by signal
value.
 
Not all of these signals will exist on all systems. This table is the only
thing that should have to be updated as new signal numbers are introduced.
It's sort of ugly, but at least its portable. */
 
struct signal_info
{
int value; /* The numeric value from <signal.h> */
const char *name; /* The equivalent symbolic value */
#ifndef HAVE_SYS_SIGLIST
const char *msg; /* Short message about this value */
#endif
};
 
#ifndef HAVE_SYS_SIGLIST
# define ENTRY(value, name, msg) {value, name, msg}
#else
# define ENTRY(value, name, msg) {value, name}
#endif
 
static const struct signal_info signal_table[] =
{
#if defined (SIGHUP)
ENTRY(SIGHUP, "SIGHUP", "Hangup"),
#endif
#if defined (SIGINT)
ENTRY(SIGINT, "SIGINT", "Interrupt"),
#endif
#if defined (SIGQUIT)
ENTRY(SIGQUIT, "SIGQUIT", "Quit"),
#endif
#if defined (SIGILL)
ENTRY(SIGILL, "SIGILL", "Illegal instruction"),
#endif
#if defined (SIGTRAP)
ENTRY(SIGTRAP, "SIGTRAP", "Trace/breakpoint trap"),
#endif
/* Put SIGIOT before SIGABRT, so that if SIGIOT==SIGABRT then SIGABRT
overrides SIGIOT. SIGABRT is in ANSI and POSIX.1, and SIGIOT isn't. */
#if defined (SIGIOT)
ENTRY(SIGIOT, "SIGIOT", "IOT trap"),
#endif
#if defined (SIGABRT)
ENTRY(SIGABRT, "SIGABRT", "Aborted"),
#endif
#if defined (SIGEMT)
ENTRY(SIGEMT, "SIGEMT", "Emulation trap"),
#endif
#if defined (SIGFPE)
ENTRY(SIGFPE, "SIGFPE", "Arithmetic exception"),
#endif
#if defined (SIGKILL)
ENTRY(SIGKILL, "SIGKILL", "Killed"),
#endif
#if defined (SIGBUS)
ENTRY(SIGBUS, "SIGBUS", "Bus error"),
#endif
#if defined (SIGSEGV)
ENTRY(SIGSEGV, "SIGSEGV", "Segmentation fault"),
#endif
#if defined (SIGSYS)
ENTRY(SIGSYS, "SIGSYS", "Bad system call"),
#endif
#if defined (SIGPIPE)
ENTRY(SIGPIPE, "SIGPIPE", "Broken pipe"),
#endif
#if defined (SIGALRM)
ENTRY(SIGALRM, "SIGALRM", "Alarm clock"),
#endif
#if defined (SIGTERM)
ENTRY(SIGTERM, "SIGTERM", "Terminated"),
#endif
#if defined (SIGUSR1)
ENTRY(SIGUSR1, "SIGUSR1", "User defined signal 1"),
#endif
#if defined (SIGUSR2)
ENTRY(SIGUSR2, "SIGUSR2", "User defined signal 2"),
#endif
/* Put SIGCLD before SIGCHLD, so that if SIGCLD==SIGCHLD then SIGCHLD
overrides SIGCLD. SIGCHLD is in POXIX.1 */
#if defined (SIGCLD)
ENTRY(SIGCLD, "SIGCLD", "Child status changed"),
#endif
#if defined (SIGCHLD)
ENTRY(SIGCHLD, "SIGCHLD", "Child status changed"),
#endif
#if defined (SIGPWR)
ENTRY(SIGPWR, "SIGPWR", "Power fail/restart"),
#endif
#if defined (SIGWINCH)
ENTRY(SIGWINCH, "SIGWINCH", "Window size changed"),
#endif
#if defined (SIGURG)
ENTRY(SIGURG, "SIGURG", "Urgent I/O condition"),
#endif
#if defined (SIGIO)
/* "I/O pending" has also been suggested, but is misleading since the
signal only happens when the process has asked for it, not everytime
I/O is pending. */
ENTRY(SIGIO, "SIGIO", "I/O possible"),
#endif
#if defined (SIGPOLL)
ENTRY(SIGPOLL, "SIGPOLL", "Pollable event occurred"),
#endif
#if defined (SIGSTOP)
ENTRY(SIGSTOP, "SIGSTOP", "Stopped (signal)"),
#endif
#if defined (SIGTSTP)
ENTRY(SIGTSTP, "SIGTSTP", "Stopped (user)"),
#endif
#if defined (SIGCONT)
ENTRY(SIGCONT, "SIGCONT", "Continued"),
#endif
#if defined (SIGTTIN)
ENTRY(SIGTTIN, "SIGTTIN", "Stopped (tty input)"),
#endif
#if defined (SIGTTOU)
ENTRY(SIGTTOU, "SIGTTOU", "Stopped (tty output)"),
#endif
#if defined (SIGVTALRM)
ENTRY(SIGVTALRM, "SIGVTALRM", "Virtual timer expired"),
#endif
#if defined (SIGPROF)
ENTRY(SIGPROF, "SIGPROF", "Profiling timer expired"),
#endif
#if defined (SIGXCPU)
ENTRY(SIGXCPU, "SIGXCPU", "CPU time limit exceeded"),
#endif
#if defined (SIGXFSZ)
ENTRY(SIGXFSZ, "SIGXFSZ", "File size limit exceeded"),
#endif
#if defined (SIGWIND)
ENTRY(SIGWIND, "SIGWIND", "SIGWIND"),
#endif
#if defined (SIGPHONE)
ENTRY(SIGPHONE, "SIGPHONE", "SIGPHONE"),
#endif
#if defined (SIGLOST)
ENTRY(SIGLOST, "SIGLOST", "Resource lost"),
#endif
#if defined (SIGWAITING)
ENTRY(SIGWAITING, "SIGWAITING", "Process's LWPs are blocked"),
#endif
#if defined (SIGLWP)
ENTRY(SIGLWP, "SIGLWP", "Signal LWP"),
#endif
#if defined (SIGDANGER)
ENTRY(SIGDANGER, "SIGDANGER", "Swap space dangerously low"),
#endif
#if defined (SIGGRANT)
ENTRY(SIGGRANT, "SIGGRANT", "Monitor mode granted"),
#endif
#if defined (SIGRETRACT)
ENTRY(SIGRETRACT, "SIGRETRACT", "Need to relinguish monitor mode"),
#endif
#if defined (SIGMSG)
ENTRY(SIGMSG, "SIGMSG", "Monitor mode data available"),
#endif
#if defined (SIGSOUND)
ENTRY(SIGSOUND, "SIGSOUND", "Sound completed"),
#endif
#if defined (SIGSAK)
ENTRY(SIGSAK, "SIGSAK", "Secure attention"),
#endif
ENTRY(0, NULL, NULL)
};
 
/* Translation table allocated and initialized at runtime. Indexed by the
signal value to find the equivalent symbolic value. */
 
static const char **signal_names;
static int num_signal_names = 0;
 
/* Translation table allocated and initialized at runtime, if it does not
already exist in the host environment. Indexed by the signal value to find
the descriptive string.
 
We don't export it for use in other modules because even though it has the
same name, it differs from other implementations in that it is dynamically
initialized rather than statically initialized. */
 
#ifndef HAVE_SYS_SIGLIST
 
static int sys_nsig;
static const char **sys_siglist;
 
#else
 
#ifdef NSIG
static int sys_nsig = NSIG;
#else
#ifdef _NSIG
static int sys_nsig = _NSIG;
#endif
#endif
extern const char * const sys_siglist[];
 
#endif
 
 
/*
 
NAME
 
init_signal_tables -- initialize the name and message tables
 
SYNOPSIS
 
static void init_signal_tables ();
 
DESCRIPTION
 
Using the signal_table, which is initialized at compile time, generate
the signal_names and the sys_siglist (if needed) tables, which are
indexed at runtime by a specific signal value.
 
BUGS
 
The initialization of the tables may fail under low memory conditions,
in which case we don't do anything particularly useful, but we don't
bomb either. Who knows, it might succeed at a later point if we free
some memory in the meantime. In any case, the other routines know
how to deal with lack of a table after trying to initialize it. This
may or may not be considered to be a bug, that we don't specifically
warn about this particular failure mode.
 
*/
 
static void
init_signal_tables ()
{
const struct signal_info *eip;
int nbytes;
 
/* If we haven't already scanned the signal_table once to find the maximum
signal value, then go find it now. */
 
if (num_signal_names == 0)
{
for (eip = signal_table; eip -> name != NULL; eip++)
{
if (eip -> value >= num_signal_names)
{
num_signal_names = eip -> value + 1;
}
}
}
 
/* Now attempt to allocate the signal_names table, zero it out, and then
initialize it from the statically initialized signal_table. */
 
if (signal_names == NULL)
{
nbytes = num_signal_names * sizeof (char *);
if ((signal_names = (const char **) malloc (nbytes)) != NULL)
{
memset (signal_names, 0, nbytes);
for (eip = signal_table; eip -> name != NULL; eip++)
{
signal_names[eip -> value] = eip -> name;
}
}
}
 
#ifndef HAVE_SYS_SIGLIST
 
/* Now attempt to allocate the sys_siglist table, zero it out, and then
initialize it from the statically initialized signal_table. */
 
if (sys_siglist == NULL)
{
nbytes = num_signal_names * sizeof (char *);
if ((sys_siglist = (const char **) malloc (nbytes)) != NULL)
{
memset (sys_siglist, 0, nbytes);
sys_nsig = num_signal_names;
for (eip = signal_table; eip -> name != NULL; eip++)
{
sys_siglist[eip -> value] = eip -> msg;
}
}
}
 
#endif
 
}
 
 
/*
 
NAME
 
signo_max -- return the max signo value
 
SYNOPSIS
 
int signo_max ();
 
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.
 
*/
 
int
signo_max ()
{
int maxsize;
 
if (signal_names == NULL)
{
init_signal_tables ();
}
maxsize = MAX (sys_nsig, num_signal_names);
return (maxsize - 1);
}
 
 
/*
 
NAME
 
strsignal -- map a signal number to a signal message string
 
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 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 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 sys_siglist,
returns NULL.
 
The returned string is only guaranteed to be valid only until the
next call to strsignal.
 
*/
 
#ifndef HAVE_STRSIGNAL
 
const char *
strsignal (signo)
int signo;
{
const char *msg;
static char buf[32];
 
#ifndef HAVE_SYS_SIGLIST
 
if (signal_names == NULL)
{
init_signal_tables ();
}
 
#endif
 
if ((signo < 0) || (signo >= sys_nsig))
{
/* Out of range, just return NULL */
msg = NULL;
}
else if ((sys_siglist == NULL) || (sys_siglist[signo] == NULL))
{
/* In range, but no sys_siglist or no entry at this index. */
sprintf (buf, "Signal %d", signo);
msg = (const char *) buf;
}
else
{
/* In range, and a valid message. Just return the message. */
msg = (const char *) sys_siglist[signo];
}
return (msg);
}
 
#endif /* ! HAVE_STRSIGNAL */
 
/*
 
NAME
 
strsigno -- map an signal number to a symbolic name string
 
SYNOPSIS
 
const char *strsigno (int signo)
 
DESCRIPTION
 
Given an signal number, returns a pointer to a string containing
the symbolic name of that signal number, as found in <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 "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.
 
*/
 
const char *
strsigno (signo)
int signo;
{
const char *name;
static char buf[32];
 
if (signal_names == NULL)
{
init_signal_tables ();
}
 
if ((signo < 0) || (signo >= num_signal_names))
{
/* Out of range, just return NULL */
name = NULL;
}
else if ((signal_names == NULL) || (signal_names[signo] == NULL))
{
/* In range, but no signal_names or no entry at this index. */
sprintf (buf, "Signal %d", signo);
name = (const char *) buf;
}
else
{
/* In range, and a valid name. Just return the name. */
name = signal_names[signo];
}
 
return (name);
}
 
 
/*
 
NAME
 
strtosigno -- map a symbolic signal name to a numeric value
 
SYNOPSIS
 
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.
 
*/
 
int
strtosigno (name)
const char *name;
{
int signo = 0;
 
if (name != NULL)
{
if (signal_names == NULL)
{
init_signal_tables ();
}
for (signo = 0; signo < num_signal_names; signo++)
{
if ((signal_names[signo] != NULL) &&
(strcmp (name, signal_names[signo]) == 0))
{
break;
}
}
if (signo == num_signal_names)
{
signo = 0;
}
}
return (signo);
}
 
 
/*
 
NAME
 
psignal -- print message about signal to stderr
 
SYNOPSIS
 
void psignal (unsigned signo, char *message);
 
DESCRIPTION
 
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
 
void
psignal (signo, message)
unsigned signo;
char *message;
{
if (signal_names == NULL)
{
init_signal_tables ();
}
if ((signo <= 0) || (signo >= sys_nsig))
{
fprintf (stderr, "%s: unknown signal\n", message);
}
else
{
fprintf (stderr, "%s: %s\n", message, sys_siglist[signo]);
}
}
 
#endif /* ! HAVE_PSIGNAL */
 
 
/* A simple little main that does nothing but print all the signal translations
if MAIN is defined and this file is compiled and linked. */
 
#ifdef MAIN
 
#include <stdio.h>
 
int
main ()
{
int signo;
int maxsigno;
const char *name;
const char *msg;
 
maxsigno = signo_max ();
printf ("%d entries in names table.\n", num_signal_names);
printf ("%d entries in messages table.\n", sys_nsig);
printf ("%d is max useful index.\n", maxsigno);
 
/* Keep printing values until we get to the end of *both* tables, not
*either* table. Note that knowing the maximum useful index does *not*
relieve us of the responsibility of testing the return pointer for
NULL. */
 
for (signo = 0; signo <= maxsigno; signo++)
{
name = strsigno (signo);
name = (name == NULL) ? "<NULL>" : name;
msg = strsignal (signo);
msg = (msg == NULL) ? "<NULL>" : msg;
printf ("%-4d%-18s%s\n", signo, name, msg);
}
 
return 0;
}
 
#endif
/getpagesize.c
0,0 → 1,96
/* Emulation of getpagesize() for systems that need it. */
 
/*
 
NAME
 
getpagesize -- return the number of bytes in page of memory
 
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.
 
BUGS
 
Is intended as a reasonable replacement for systems where this
is not provided as a system call. The value of 4096 may or may
not be correct for the systems where it is returned as the default
value.
 
*/
 
#ifndef VMS
 
#include "config.h"
 
#include <sys/types.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
 
#undef GNU_OUR_PAGESIZE
#if defined (HAVE_SYSCONF) && defined (HAVE_UNISTD_H)
#include <unistd.h>
#ifdef _SC_PAGESIZE
#define GNU_OUR_PAGESIZE sysconf(_SC_PAGESIZE)
#endif
#endif
 
#ifndef GNU_OUR_PAGESIZE
# ifdef PAGESIZE
# define GNU_OUR_PAGESIZE PAGESIZE
# else /* no PAGESIZE */
# ifdef EXEC_PAGESIZE
# define GNU_OUR_PAGESIZE EXEC_PAGESIZE
# else /* no EXEC_PAGESIZE */
# ifdef NBPG
# define GNU_OUR_PAGESIZE (NBPG * CLSIZE)
# ifndef CLSIZE
# define CLSIZE 1
# endif /* CLSIZE */
# else /* no NBPG */
# ifdef NBPC
# define GNU_OUR_PAGESIZE NBPC
# else /* no NBPC */
# define GNU_OUR_PAGESIZE 4096 /* Just punt and use reasonable value */
# endif /* NBPC */
# endif /* NBPG */
# endif /* EXEC_PAGESIZE */
# endif /* PAGESIZE */
#endif /* GNU_OUR_PAGESIZE */
 
int
getpagesize ()
{
return (GNU_OUR_PAGESIZE);
}
 
#else /* VMS */
 
#if 0 /* older distributions of gcc-vms are missing <syidef.h> */
#include <syidef.h>
#endif
#ifndef SYI$_PAGE_SIZE /* VMS V5.4 and earlier didn't have this yet */
#define SYI$_PAGE_SIZE 4452
#endif
extern unsigned long lib$getsyi(const unsigned short *,...);
 
int getpagesize ()
{
long pagsiz = 0L;
unsigned short itmcod = SYI$_PAGE_SIZE;
 
(void) lib$getsyi (&itmcod, (void *) &pagsiz);
if (pagsiz == 0L)
pagsiz = 512L; /* VAX default */
return (int) pagsiz;
}
 
#endif /* VMS */
/config.table
0,0 → 1,61
case "${host}" in
rs6000-ibm-aix3.1 | rs6000-ibm-aix)
frag=mh-aix ;;
*-*-cxux7*) frag=mh-cxux7 ;;
*-*-freebsd2.1.*) frag=mh-fbsd21 ;;
*-*-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
 
# If they didn't specify --enable-shared, don't generate shared libs.
case "${enable_shared}" in
yes) shared=yes ;;
no) shared=no ;;
"") shared=no ;;
*) shared=yes ;;
esac
if [ "${shared}" = "yes" ]; then
case "${host}" in
*-*-cygwin*) ;;
alpha*-*-linux*) frags="${frags} ../../config/mh-elfalphapic" ;;
arm*-*-*) frags="${frags} ../../config/mh-armpic" ;;
hppa*-*-*) frags="${frags} ../../config/mh-papic" ;;
i[3456]86-*-*) frags="${frags} ../../config/mh-x86pic" ;;
powerpc*-*-aix*) ;;
powerpc*-*-*) frags="${frags} ../../config/mh-ppcpic" ;;
*-*-*) frags="${frags} ../../config/mh-${host_cpu}pic" ;;
esac
fi
 
echo "# Warning: this fragment is automatically generated" > temp-frag
 
for frag in ${frags}; do
case ${frag} in
../* )
if [ ${srcdir} = . ]; then
[ -n "${with_target_subdir}" ] && frag=../${frag}
[ -n "${with_multisrctop}" ] && frag=${with_multisrctop}${frag}
fi
;;
esac
frag=${srcdir}/${xsrcdir}config/$frag
if [ -f ${frag} ]; then
echo "Appending ${frag} to xhost-mkfrag"
echo "# Following fragment copied from ${frag}" >> temp-frag
cat ${frag} >> temp-frag
fi
done
 
# record if we want to build shared libs.
if [ "${shared}" = "yes" ]; then
echo enable_shared = yes >> temp-frag
else
echo enable_shared = no >> temp-frag
fi
 
frag=xhost-mkfrag
${CONFIG_SHELL-/bin/sh} ${libiberty_topdir}/move-if-change temp-frag xhost-mkfrag
/xstrerror.c
0,0 → 1,56
/* xstrerror.c -- jacket routine for more robust strerror() usage.
Fri Jun 16 18:30:00 1995 Pat Rankin <rankin@eql.caltech.edu>
This code is in the public domain. */
 
#include <stdio.h>
 
#include "libiberty.h"
#include "config.h"
 
#ifdef VMS
#include <errno.h>
#if !defined (__STRICT_ANSI__) && !defined (__HIDE_FORBIDDEN_NAMES)
extern char *strerror PARAMS ((int,...));
#define DONT_DECLARE_STRERROR
#endif
#endif /* VMS */
 
#ifndef DONT_DECLARE_STRERROR
extern char *strerror PARAMS ((int));
#endif
 
/* If strerror returns NULL, we'll format the number into a static buffer. */
 
#define ERRSTR_FMT "undocumented error #%d"
static char xstrerror_buf[sizeof ERRSTR_FMT + 20];
 
/* Like strerror, but result is never a null pointer. */
 
char *
xstrerror (errnum)
int errnum;
{
char *errstr;
#ifdef VMS
char *(*vmslib_strerror) PARAMS ((int,...));
 
/* Override any possibly-conflicting declaration from system header. */
vmslib_strerror = (char *(*) PARAMS ((int,...))) strerror;
/* Second argument matters iff first is EVMSERR, but it's simpler to
pass it unconditionally. `vaxc$errno' is declared in <errno.h>
and maintained by the run-time library in parallel to `errno'.
We assume that `errnum' corresponds to the last value assigned to
errno by the run-time library, hence vaxc$errno will be relevant. */
errstr = (*vmslib_strerror) (errnum, vaxc$errno);
#else
errstr = strerror (errnum);
#endif
 
/* If `errnum' is out of range, result might be NULL. We'll fix that. */
if (!errstr)
{
sprintf (xstrerror_buf, ERRSTR_FMT, errnum);
errstr = xstrerror_buf;
}
return errstr;
}
/memchr.c
0,0 → 1,60
/*
FUNCTION
<<memchr>>---find character in memory
 
INDEX
memchr
 
ANSI_SYNOPSIS
#include <string.h>
void *memchr(const void *<[src]>, int <[c]>, size_t <[length]>);
 
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
 
*/
 
#include <ansidecl.h>
#ifdef __STDC__
#include <stddef.h>
#else
#define size_t unsigned long
#endif
 
PTR
memchr (src_void, c, length)
register const PTR src_void;
int c;
size_t length;
{
const unsigned char *src = (const unsigned char *)src_void;
while (--length >= 0)
{
if (*src == c)
return (PTR)src;
src++;
}
return NULL;
}
/basename.c
0,0 → 1,66
/* Return the basename of a pathname.
This file is in the public domain. */
 
/*
NAME
basename -- return pointer to last component of a pathname
 
SYNOPSIS
char *basename (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).
 
BUGS
Presumes a UNIX or DOS/Windows style path with UNIX or DOS/Windows
style separators.
*/
 
#include "ansidecl.h"
#include "libiberty.h"
#include <ctype.h>
 
#ifndef DIR_SEPARATOR
#define DIR_SEPARATOR '/'
#endif
 
#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
defined (__OS2__)
#define HAVE_DOS_BASED_FILE_SYSTEM
#ifndef DIR_SEPARATOR_2
#define DIR_SEPARATOR_2 '\\'
#endif
#endif
 
/* Define IS_DIR_SEPARATOR. */
#ifndef DIR_SEPARATOR_2
# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
#else /* DIR_SEPARATOR_2 */
# define IS_DIR_SEPARATOR(ch) \
(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
#endif /* DIR_SEPARATOR_2 */
 
char *
basename (name)
const char *name;
{
const char *base;
 
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
/* Skip over the disk name in MSDOS pathnames. */
if (isalpha (name[0]) && name[1] == ':')
name += 2;
#endif
 
for (base = name; *name; name++)
{
if (IS_DIR_SEPARATOR (*name))
{
base = name + 1;
}
}
return (char *) base;
}
 
/bcopy.c
0,0 → 1,35
/* bcopy -- copy memory regions of arbitary length
 
NAME
bcopy -- copy memory regions of arbitrary length
 
SYNOPSIS
void bcopy (char *in, char *out, int length)
 
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.
 
*/
 
void
bcopy (src, dest, len)
register char *src, *dest;
int len;
{
if (dest < src)
while (len--)
*dest++ = *src++;
else
{
char *lasts = src + (len-1);
char *lastd = dest + (len-1);
while (len--)
*(char *)lastd-- = *(char *)lasts--;
}
}
/config.h-vms
0,0 → 1,13
#ifndef NEED_strerror
#define NEED_strerror
#endif
#ifndef NEED_basename
#define NEED_basename
#endif
#ifndef NEED_psignal
#define NEED_psignal
#endif
#ifndef NEED_on_exit
#define NEED_on_exit
#endif
 
/bcmp.c
0,0 → 1,49
/* bcmp
This function is in the public domain. */
 
/*
 
NAME
 
bcmp -- compare two memory regions
 
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
 
*/
 
 
int
bcmp (from, to, count)
char *from, *to;
int count;
{
int rtnval = 0;
 
while (count-- > 0)
{
if (*from++ != *to++)
{
rtnval = 1;
break;
}
}
return (rtnval);
}
 
/pexecute.c
0,0 → 1,778
/* Utilities to execute a program in a subprocess (possibly linked by pipes
with other subprocesses), and wait for it.
Copyright (C) 1996-2000 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. */
 
/* This file exports two functions: pexecute and pwait. */
 
/* This file lives in at least two places: libiberty and gcc.
Don't change one without the other. */
 
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
 
#include <stdio.h>
#include <errno.h>
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#define ISSPACE (x) isspace(x)
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
 
#ifdef vfork /* Autoconf may define this to fork for us. */
# define VFORK_STRING "fork"
#else
# define VFORK_STRING "vfork"
#endif
#ifdef HAVE_VFORK_H
#include <vfork.h>
#endif
#ifdef VMS
#define vfork() (decc$$alloc_vfork_blocks() >= 0 ? \
lib$get_current_invo_context(decc$$get_vfork_jmpbuf()) : -1)
#endif /* VMS */
 
#include "libiberty.h"
 
/* stdin file number. */
#define STDIN_FILE_NO 0
 
/* stdout file number. */
#define STDOUT_FILE_NO 1
 
/* value of `pipe': port index for reading. */
#define READ_PORT 0
 
/* value of `pipe': port index for writing. */
#define WRITE_PORT 1
 
static char *install_error_msg = "installation problem, cannot exec `%s'";
 
/* pexecute: execute a program.
 
PROGRAM and ARGV are the arguments to execv/execvp.
 
THIS_PNAME is name of the calling program (i.e. argv[0]).
 
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.
 
(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.
 
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.
 
The result is the WEXITSTATUS on systems like MSDOS where we spawn and wait
for the child here.
 
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.
 
pwait: cover function for wait.
 
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.
 
The result is the pid of the child reaped,
or -1 for failure (errno says why).
 
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.
 
pfinish: finish generation of script
 
pfinish is necessary for systems like MPW where a script is generated that
runs the requested programs.
*/
 
#ifdef __MSDOS__
 
/* MSDOS doesn't multitask, but for the sake of a consistent interface
the code behaves like it does. pexecute runs the program, tucks the
exit code away, and returns a "pid". pwait must be called to fetch the
exit code. */
 
#include <process.h>
 
/* For communicating information from pexecute to pwait. */
static int last_pid = 0;
static int last_status = 0;
static int last_reaped = 0;
 
int
pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags)
const char *program;
char * const *argv;
const char *this_pname;
const char *temp_base;
char **errmsg_fmt, **errmsg_arg;
int flags;
{
int rc;
 
last_pid++;
if (last_pid < 0)
last_pid = 1;
 
if ((flags & PEXECUTE_ONE) != PEXECUTE_ONE)
abort ();
 
#ifdef __GO32__
/* ??? What are the possible return values from spawnv? */
rc = (flags & PEXECUTE_SEARCH ? spawnvp : spawnv) (1, program, argv);
#else
char *scmd, *rf;
FILE *argfile;
int i, el = flags & PEXECUTE_SEARCH ? 4 : 0;
 
if (temp_base == 0)
temp_base = choose_temp_base ();
scmd = (char *) xmalloc (strlen (program) + strlen (temp_base) + 6 + el);
rf = scmd + strlen(program) + 2 + el;
sprintf (scmd, "%s%s @%s.gp", program,
(flags & PEXECUTE_SEARCH ? ".exe" : ""), temp_base);
argfile = fopen (rf, "w");
if (argfile == 0)
{
int errno_save = errno;
free (scmd);
errno = errno_save;
*errmsg_fmt = "cannot open `%s.gp'";
*errmsg_arg = temp_base;
return -1;
}
 
for (i=1; argv[i]; i++)
{
char *cp;
for (cp = argv[i]; *cp; cp++)
{
if (*cp == '"' || *cp == '\'' || *cp == '\\' || ISSPACE (*cp))
fputc ('\\', argfile);
fputc (*cp, argfile);
}
fputc ('\n', argfile);
}
fclose (argfile);
 
rc = system (scmd);
 
{
int errno_save = errno;
remove (rf);
free (scmd);
errno = errno_save;
}
#endif
 
if (rc == -1)
{
*errmsg_fmt = install_error_msg;
*errmsg_arg = program;
return -1;
}
 
/* Tuck the status away for pwait, and return a "pid". */
last_status = rc << 8;
return last_pid;
}
 
int
pwait (pid, status, flags)
int pid;
int *status;
int flags;
{
/* On MSDOS each pexecute must be followed by it's associated pwait. */
if (pid != last_pid
/* Called twice for the same child? */
|| pid == last_reaped)
{
/* ??? ECHILD would be a better choice. Can we use it here? */
errno = EINVAL;
return -1;
}
/* ??? Here's an opportunity to canonicalize the values in STATUS.
Needed? */
*status = last_status;
last_reaped = last_pid;
return last_pid;
}
 
#endif /* MSDOS */
 
#if defined (_WIN32) && ! defined (_UWIN)
 
#include <process.h>
 
#ifdef __CYGWIN__
 
#define fix_argv(argvec) (argvec)
 
extern int _spawnv ();
extern int _spawnvp ();
 
#else /* ! __CYGWIN__ */
 
/* 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;
}
 
for (i = 0; argvec[i] != 0; i++)
{
if (strpbrk (argvec[i], " \t"))
{
int len, trailing_backslash;
char *temp;
 
len = strlen (argvec[i]);
trailing_backslash = 0;
 
/* There is an added complication when an arg with embedded white
space ends in a backslash (such as in the case of -iprefix arg
passed to cpp). The resulting quoted strings gets misinterpreted
by the command interpreter -- it thinks that the ending quote
is escaped by the trailing backslash and things get confused.
We handle this case by escaping the trailing backslash, provided
it was not escaped in the first place. */
if (len > 1
&& argvec[i][len-1] == '\\'
&& argvec[i][len-2] != '\\')
{
trailing_backslash = 1;
++len; /* to escape the final backslash. */
}
 
len += 2; /* and for the enclosing quotes. */
 
temp = xmalloc (len + 1);
temp[0] = '"';
strcpy (temp + 1, argvec[i]);
if (trailing_backslash)
temp[len-2] = '\\';
temp[len-1] = '"';
temp[len] = '\0';
 
argvec[i] = temp;
}
}
 
return (const char * const *) argvec;
}
#endif /* __CYGWIN__ */
 
#include <io.h>
#include <fcntl.h>
#include <signal.h>
 
/* mingw32 headers may not define the following. */
 
#ifndef _P_WAIT
# define _P_WAIT 0
# define _P_NOWAIT 1
# define _P_OVERLAY 2
# define _P_NOWAITO 3
# define _P_DETACH 4
 
# define WAIT_CHILD 0
# define WAIT_GRANDCHILD 1
#endif
 
/* Win32 supports pipes */
int
pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags)
const char *program;
char * const *argv;
const char *this_pname;
const char *temp_base;
char **errmsg_fmt, **errmsg_arg;
int flags;
{
int pid;
int pdes[2], org_stdin, org_stdout;
int input_desc, output_desc;
int retries, sleep_interval;
 
/* Pipe waiting from last process, to be used as input for the next one.
Value is STDIN_FILE_NO if no pipe is waiting
(i.e. the next command is the first of a group). */
static int last_pipe_input;
 
/* If this is the first process, initialize. */
if (flags & PEXECUTE_FIRST)
last_pipe_input = STDIN_FILE_NO;
 
input_desc = last_pipe_input;
 
/* If this isn't the last process, make a pipe for its output,
and record it as waiting to be the input to the next process. */
if (! (flags & PEXECUTE_LAST))
{
if (_pipe (pdes, 256, O_BINARY) < 0)
{
*errmsg_fmt = "pipe";
*errmsg_arg = NULL;
return -1;
}
output_desc = pdes[WRITE_PORT];
last_pipe_input = pdes[READ_PORT];
}
else
{
/* Last process. */
output_desc = STDOUT_FILE_NO;
last_pipe_input = STDIN_FILE_NO;
}
 
if (input_desc != STDIN_FILE_NO)
{
org_stdin = dup (STDIN_FILE_NO);
dup2 (input_desc, STDIN_FILE_NO);
close (input_desc);
}
 
if (output_desc != STDOUT_FILE_NO)
{
org_stdout = dup (STDOUT_FILE_NO);
dup2 (output_desc, STDOUT_FILE_NO);
close (output_desc);
}
 
pid = (flags & PEXECUTE_SEARCH ? _spawnvp : _spawnv)
(_P_NOWAIT, program, fix_argv(argv));
 
if (input_desc != STDIN_FILE_NO)
{
dup2 (org_stdin, STDIN_FILE_NO);
close (org_stdin);
}
 
if (output_desc != STDOUT_FILE_NO)
{
dup2 (org_stdout, STDOUT_FILE_NO);
close (org_stdout);
}
 
if (pid == -1)
{
*errmsg_fmt = install_error_msg;
*errmsg_arg = program;
return -1;
}
 
return pid;
}
 
/* MS CRTDLL doesn't return enough information in status to decide if the
child exited due to a signal or not, rather it simply returns an
integer with the exit code of the child; eg., if the child exited with
an abort() call and didn't have a handler for SIGABRT, it simply returns
with status = 3. We fix the status code to conform to the usual WIF*
macros. Note that WIFSIGNALED will never be true under CRTDLL. */
 
int
pwait (pid, status, flags)
int pid;
int *status;
int flags;
{
#ifdef __CYGWIN__
return wait (status);
#else
int termstat;
 
pid = _cwait (&termstat, pid, WAIT_CHILD);
 
/* ??? Here's an opportunity to canonicalize the values in STATUS.
Needed? */
 
/* cwait returns the child process exit code in termstat.
A value of 3 indicates that the child caught a signal, but not
which one. Since only SIGABRT, SIGFPE and SIGINT do anything, we
report SIGABRT. */
if (termstat == 3)
*status = SIGABRT;
else
*status = (((termstat) & 0xff) << 8);
 
return pid;
#endif /* __CYGWIN__ */
}
 
#endif /* _WIN32 && ! _UWIN */
 
#ifdef OS2
 
/* ??? Does OS2 have process.h? */
extern int spawnv ();
extern int spawnvp ();
 
int
pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags)
const char *program;
char * const *argv;
const char *this_pname;
const char *temp_base;
char **errmsg_fmt, **errmsg_arg;
int flags;
{
int pid;
 
if ((flags & PEXECUTE_ONE) != PEXECUTE_ONE)
abort ();
/* ??? Presumably 1 == _P_NOWAIT. */
pid = (flags & PEXECUTE_SEARCH ? spawnvp : spawnv) (1, program, argv);
if (pid == -1)
{
*errmsg_fmt = install_error_msg;
*errmsg_arg = program;
return -1;
}
return pid;
}
 
int
pwait (pid, status, flags)
int pid;
int *status;
int flags;
{
/* ??? Here's an opportunity to canonicalize the values in STATUS.
Needed? */
int pid = wait (status);
return pid;
}
 
#endif /* OS2 */
 
#ifdef MPW
 
/* MPW pexecute doesn't actually run anything; instead, it writes out
script commands that, when run, will do the actual executing.
 
For example, in GCC's case, GCC will write out several script commands:
 
cpp ...
cc1 ...
as ...
ld ...
 
and then exit. None of the above programs will have run yet. The task
that called GCC will then execute the script and cause cpp,etc. to run.
The caller must invoke pfinish before calling exit. This adds
the finishing touches to the generated script. */
 
static int first_time = 1;
 
int
pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags)
const char *program;
char * const *argv;
const char *this_pname;
const char *temp_base;
char **errmsg_fmt, **errmsg_arg;
int flags;
{
char tmpprogram[255];
char *cp, *tmpname;
int i;
 
mpwify_filename (program, tmpprogram);
if (first_time)
{
printf ("Set Failed 0\n");
first_time = 0;
}
 
fputs ("If {Failed} == 0\n", stdout);
/* If being verbose, output a copy of the command. It should be
accurate enough and escaped enough to be "clickable". */
if (flags & PEXECUTE_VERBOSE)
{
fputs ("\tEcho ", stdout);
fputc ('\'', stdout);
fputs (tmpprogram, stdout);
fputc ('\'', stdout);
fputc (' ', stdout);
for (i=1; argv[i]; i++)
{
fputc ('\'', stdout);
/* See if we have an argument that needs fixing. */
if (strchr(argv[i], '/'))
{
tmpname = (char *) xmalloc (256);
mpwify_filename (argv[i], tmpname);
argv[i] = tmpname;
}
for (cp = argv[i]; *cp; cp++)
{
/* Write an Option-d escape char in front of special chars. */
if (strchr("'+", *cp))
fputc ('\266', stdout);
fputc (*cp, stdout);
}
fputc ('\'', stdout);
fputc (' ', stdout);
}
fputs ("\n", stdout);
}
fputs ("\t", stdout);
fputs (tmpprogram, stdout);
fputc (' ', stdout);
 
for (i=1; argv[i]; i++)
{
/* See if we have an argument that needs fixing. */
if (strchr(argv[i], '/'))
{
tmpname = (char *) xmalloc (256);
mpwify_filename (argv[i], tmpname);
argv[i] = tmpname;
}
if (strchr (argv[i], ' '))
fputc ('\'', stdout);
for (cp = argv[i]; *cp; cp++)
{
/* Write an Option-d escape char in front of special chars. */
if (strchr("'+", *cp))
fputc ('\266', stdout);
fputc (*cp, stdout);
}
if (strchr (argv[i], ' '))
fputc ('\'', stdout);
fputc (' ', stdout);
}
 
fputs ("\n", stdout);
 
/* Output commands that arrange to clean up and exit if a failure occurs.
We have to be careful to collect the status from the program that was
run, rather than some other script command. Also, we don't exit
immediately, since necessary cleanups are at the end of the script. */
fputs ("\tSet TmpStatus {Status}\n", stdout);
fputs ("\tIf {TmpStatus} != 0\n", stdout);
fputs ("\t\tSet Failed {TmpStatus}\n", stdout);
fputs ("\tEnd\n", stdout);
fputs ("End\n", stdout);
 
/* We're just composing a script, can't fail here. */
return 0;
}
 
int
pwait (pid, status, flags)
int pid;
int *status;
int flags;
{
*status = 0;
return 0;
}
 
/* Write out commands that will exit with the correct error code
if something in the script failed. */
 
void
pfinish ()
{
printf ("\tExit \"{Failed}\"\n");
}
 
#endif /* MPW */
 
/* include for Unix-like environments but not for Dos-like environments */
#if ! defined (__MSDOS__) && ! defined (OS2) && ! defined (MPW) \
&& ! (defined (_WIN32) && ! defined (_UWIN))
 
extern int execv ();
extern int execvp ();
 
int
pexecute (program, argv, this_pname, temp_base, errmsg_fmt, errmsg_arg, flags)
const char *program;
char * const *argv;
const char *this_pname;
const char *temp_base ATTRIBUTE_UNUSED;
char **errmsg_fmt, **errmsg_arg;
int flags;
{
int (*func)() = (flags & PEXECUTE_SEARCH ? execvp : execv);
int pid;
int pdes[2];
int input_desc, output_desc;
int retries, sleep_interval;
/* Pipe waiting from last process, to be used as input for the next one.
Value is STDIN_FILE_NO if no pipe is waiting
(i.e. the next command is the first of a group). */
static int last_pipe_input;
 
/* If this is the first process, initialize. */
if (flags & PEXECUTE_FIRST)
last_pipe_input = STDIN_FILE_NO;
 
input_desc = last_pipe_input;
 
/* If this isn't the last process, make a pipe for its output,
and record it as waiting to be the input to the next process. */
if (! (flags & PEXECUTE_LAST))
{
if (pipe (pdes) < 0)
{
*errmsg_fmt = "pipe";
*errmsg_arg = NULL;
return -1;
}
output_desc = pdes[WRITE_PORT];
last_pipe_input = pdes[READ_PORT];
}
else
{
/* Last process. */
output_desc = STDOUT_FILE_NO;
last_pipe_input = STDIN_FILE_NO;
}
 
/* Fork a subprocess; wait and retry if it fails. */
sleep_interval = 1;
for (retries = 0; retries < 4; retries++)
{
pid = vfork ();
if (pid >= 0)
break;
sleep (sleep_interval);
sleep_interval *= 2;
}
 
switch (pid)
{
case -1:
{
*errmsg_fmt = VFORK_STRING;
*errmsg_arg = NULL;
return -1;
}
 
case 0: /* child */
/* Move the input and output pipes into place, if necessary. */
if (input_desc != STDIN_FILE_NO)
{
close (STDIN_FILE_NO);
dup (input_desc);
close (input_desc);
}
if (output_desc != STDOUT_FILE_NO)
{
close (STDOUT_FILE_NO);
dup (output_desc);
close (output_desc);
}
 
/* Close the parent's descs that aren't wanted here. */
if (last_pipe_input != STDIN_FILE_NO)
close (last_pipe_input);
 
/* Exec the program. */
(*func) (program, argv);
 
/* Note: Calling fprintf and exit here doesn't seem right for vfork. */
fprintf (stderr, "%s: ", this_pname);
fprintf (stderr, install_error_msg, program);
fprintf (stderr, ": %s\n", xstrerror (errno));
exit (-1);
/* NOTREACHED */
return 0;
 
default:
/* In the parent, after forking.
Close the descriptors that we made for this child. */
if (input_desc != STDIN_FILE_NO)
close (input_desc);
if (output_desc != STDOUT_FILE_NO)
close (output_desc);
 
/* Return child's process number. */
return pid;
}
}
 
int
pwait (pid, status, flags)
int pid;
int *status;
int flags ATTRIBUTE_UNUSED;
{
/* ??? Here's an opportunity to canonicalize the values in STATUS.
Needed? */
#ifdef VMS
pid = waitpid (-1, status, 0);
#else
pid = wait (status);
#endif
return pid;
}
 
#endif /* ! __MSDOS__ && ! OS2 && ! MPW && ! (_WIN32 && ! _UWIN) */
/strerror.c
0,0 → 1,831
/* Extended support for using errno values.
Written by Fred Fish. fnf@cygnus.com
This file is in the public domain. --Per Bothner. */
 
#include "ansidecl.h"
#include "libiberty.h"
 
#include "config.h"
 
#ifdef HAVE_SYS_ERRLIST
/* Note that errno.h (not sure what OS) or stdio.h (BSD 4.4, at least)
might declare sys_errlist in a way that the compiler might consider
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_errlist sys_errlist__
#endif
 
#include <stdio.h>
#include <errno.h>
 
#ifdef HAVE_SYS_ERRLIST
#undef sys_errlist
#endif
 
/* Routines imported from standard C runtime libraries. */
 
#ifdef __STDC__
#include <stddef.h>
extern void *malloc (size_t size); /* 4.10.3.3 */
extern void *memset (void *s, int c, size_t n); /* 4.11.6.1 */
#else /* !__STDC__ */
extern char *malloc (); /* Standard memory allocater */
extern char *memset ();
#endif /* __STDC__ */
 
#ifndef MAX
# define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif
 
static void init_error_tables PARAMS ((void));
 
/* Translation table for errno values. See intro(2) in most UNIX systems
Programmers Reference Manuals.
 
Note that this table is generally only accessed when it is used at runtime
to initialize errno name and message tables that are indexed by errno
value.
 
Not all of these errnos will exist on all systems. This table is the only
thing that should have to be updated as new error numbers are introduced.
It's sort of ugly, but at least its portable. */
 
struct error_info
{
int value; /* The numeric value from <errno.h> */
const char *name; /* The equivalent symbolic value */
#ifndef HAVE_SYS_ERRLIST
const char *msg; /* Short message about this value */
#endif
};
 
#ifndef HAVE_SYS_ERRLIST
# define ENTRY(value, name, msg) {value, name, msg}
#else
# define ENTRY(value, name, msg) {value, name}
#endif
 
static const struct error_info error_table[] =
{
#if defined (EPERM)
ENTRY(EPERM, "EPERM", "Not owner"),
#endif
#if defined (ENOENT)
ENTRY(ENOENT, "ENOENT", "No such file or directory"),
#endif
#if defined (ESRCH)
ENTRY(ESRCH, "ESRCH", "No such process"),
#endif
#if defined (EINTR)
ENTRY(EINTR, "EINTR", "Interrupted system call"),
#endif
#if defined (EIO)
ENTRY(EIO, "EIO", "I/O error"),
#endif
#if defined (ENXIO)
ENTRY(ENXIO, "ENXIO", "No such device or address"),
#endif
#if defined (E2BIG)
ENTRY(E2BIG, "E2BIG", "Arg list too long"),
#endif
#if defined (ENOEXEC)
ENTRY(ENOEXEC, "ENOEXEC", "Exec format error"),
#endif
#if defined (EBADF)
ENTRY(EBADF, "EBADF", "Bad file number"),
#endif
#if defined (ECHILD)
ENTRY(ECHILD, "ECHILD", "No child processes"),
#endif
#if defined (EWOULDBLOCK) /* Put before EAGAIN, sometimes aliased */
ENTRY(EWOULDBLOCK, "EWOULDBLOCK", "Operation would block"),
#endif
#if defined (EAGAIN)
ENTRY(EAGAIN, "EAGAIN", "No more processes"),
#endif
#if defined (ENOMEM)
ENTRY(ENOMEM, "ENOMEM", "Not enough space"),
#endif
#if defined (EACCES)
ENTRY(EACCES, "EACCES", "Permission denied"),
#endif
#if defined (EFAULT)
ENTRY(EFAULT, "EFAULT", "Bad address"),
#endif
#if defined (ENOTBLK)
ENTRY(ENOTBLK, "ENOTBLK", "Block device required"),
#endif
#if defined (EBUSY)
ENTRY(EBUSY, "EBUSY", "Device busy"),
#endif
#if defined (EEXIST)
ENTRY(EEXIST, "EEXIST", "File exists"),
#endif
#if defined (EXDEV)
ENTRY(EXDEV, "EXDEV", "Cross-device link"),
#endif
#if defined (ENODEV)
ENTRY(ENODEV, "ENODEV", "No such device"),
#endif
#if defined (ENOTDIR)
ENTRY(ENOTDIR, "ENOTDIR", "Not a directory"),
#endif
#if defined (EISDIR)
ENTRY(EISDIR, "EISDIR", "Is a directory"),
#endif
#if defined (EINVAL)
ENTRY(EINVAL, "EINVAL", "Invalid argument"),
#endif
#if defined (ENFILE)
ENTRY(ENFILE, "ENFILE", "File table overflow"),
#endif
#if defined (EMFILE)
ENTRY(EMFILE, "EMFILE", "Too many open files"),
#endif
#if defined (ENOTTY)
ENTRY(ENOTTY, "ENOTTY", "Not a typewriter"),
#endif
#if defined (ETXTBSY)
ENTRY(ETXTBSY, "ETXTBSY", "Text file busy"),
#endif
#if defined (EFBIG)
ENTRY(EFBIG, "EFBIG", "File too large"),
#endif
#if defined (ENOSPC)
ENTRY(ENOSPC, "ENOSPC", "No space left on device"),
#endif
#if defined (ESPIPE)
ENTRY(ESPIPE, "ESPIPE", "Illegal seek"),
#endif
#if defined (EROFS)
ENTRY(EROFS, "EROFS", "Read-only file system"),
#endif
#if defined (EMLINK)
ENTRY(EMLINK, "EMLINK", "Too many links"),
#endif
#if defined (EPIPE)
ENTRY(EPIPE, "EPIPE", "Broken pipe"),
#endif
#if defined (EDOM)
ENTRY(EDOM, "EDOM", "Math argument out of domain of func"),
#endif
#if defined (ERANGE)
ENTRY(ERANGE, "ERANGE", "Math result not representable"),
#endif
#if defined (ENOMSG)
ENTRY(ENOMSG, "ENOMSG", "No message of desired type"),
#endif
#if defined (EIDRM)
ENTRY(EIDRM, "EIDRM", "Identifier removed"),
#endif
#if defined (ECHRNG)
ENTRY(ECHRNG, "ECHRNG", "Channel number out of range"),
#endif
#if defined (EL2NSYNC)
ENTRY(EL2NSYNC, "EL2NSYNC", "Level 2 not synchronized"),
#endif
#if defined (EL3HLT)
ENTRY(EL3HLT, "EL3HLT", "Level 3 halted"),
#endif
#if defined (EL3RST)
ENTRY(EL3RST, "EL3RST", "Level 3 reset"),
#endif
#if defined (ELNRNG)
ENTRY(ELNRNG, "ELNRNG", "Link number out of range"),
#endif
#if defined (EUNATCH)
ENTRY(EUNATCH, "EUNATCH", "Protocol driver not attached"),
#endif
#if defined (ENOCSI)
ENTRY(ENOCSI, "ENOCSI", "No CSI structure available"),
#endif
#if defined (EL2HLT)
ENTRY(EL2HLT, "EL2HLT", "Level 2 halted"),
#endif
#if defined (EDEADLK)
ENTRY(EDEADLK, "EDEADLK", "Deadlock condition"),
#endif
#if defined (ENOLCK)
ENTRY(ENOLCK, "ENOLCK", "No record locks available"),
#endif
#if defined (EBADE)
ENTRY(EBADE, "EBADE", "Invalid exchange"),
#endif
#if defined (EBADR)
ENTRY(EBADR, "EBADR", "Invalid request descriptor"),
#endif
#if defined (EXFULL)
ENTRY(EXFULL, "EXFULL", "Exchange full"),
#endif
#if defined (ENOANO)
ENTRY(ENOANO, "ENOANO", "No anode"),
#endif
#if defined (EBADRQC)
ENTRY(EBADRQC, "EBADRQC", "Invalid request code"),
#endif
#if defined (EBADSLT)
ENTRY(EBADSLT, "EBADSLT", "Invalid slot"),
#endif
#if defined (EDEADLOCK)
ENTRY(EDEADLOCK, "EDEADLOCK", "File locking deadlock error"),
#endif
#if defined (EBFONT)
ENTRY(EBFONT, "EBFONT", "Bad font file format"),
#endif
#if defined (ENOSTR)
ENTRY(ENOSTR, "ENOSTR", "Device not a stream"),
#endif
#if defined (ENODATA)
ENTRY(ENODATA, "ENODATA", "No data available"),
#endif
#if defined (ETIME)
ENTRY(ETIME, "ETIME", "Timer expired"),
#endif
#if defined (ENOSR)
ENTRY(ENOSR, "ENOSR", "Out of streams resources"),
#endif
#if defined (ENONET)
ENTRY(ENONET, "ENONET", "Machine is not on the network"),
#endif
#if defined (ENOPKG)
ENTRY(ENOPKG, "ENOPKG", "Package not installed"),
#endif
#if defined (EREMOTE)
ENTRY(EREMOTE, "EREMOTE", "Object is remote"),
#endif
#if defined (ENOLINK)
ENTRY(ENOLINK, "ENOLINK", "Link has been severed"),
#endif
#if defined (EADV)
ENTRY(EADV, "EADV", "Advertise error"),
#endif
#if defined (ESRMNT)
ENTRY(ESRMNT, "ESRMNT", "Srmount error"),
#endif
#if defined (ECOMM)
ENTRY(ECOMM, "ECOMM", "Communication error on send"),
#endif
#if defined (EPROTO)
ENTRY(EPROTO, "EPROTO", "Protocol error"),
#endif
#if defined (EMULTIHOP)
ENTRY(EMULTIHOP, "EMULTIHOP", "Multihop attempted"),
#endif
#if defined (EDOTDOT)
ENTRY(EDOTDOT, "EDOTDOT", "RFS specific error"),
#endif
#if defined (EBADMSG)
ENTRY(EBADMSG, "EBADMSG", "Not a data message"),
#endif
#if defined (ENAMETOOLONG)
ENTRY(ENAMETOOLONG, "ENAMETOOLONG", "File name too long"),
#endif
#if defined (EOVERFLOW)
ENTRY(EOVERFLOW, "EOVERFLOW", "Value too large for defined data type"),
#endif
#if defined (ENOTUNIQ)
ENTRY(ENOTUNIQ, "ENOTUNIQ", "Name not unique on network"),
#endif
#if defined (EBADFD)
ENTRY(EBADFD, "EBADFD", "File descriptor in bad state"),
#endif
#if defined (EREMCHG)
ENTRY(EREMCHG, "EREMCHG", "Remote address changed"),
#endif
#if defined (ELIBACC)
ENTRY(ELIBACC, "ELIBACC", "Can not access a needed shared library"),
#endif
#if defined (ELIBBAD)
ENTRY(ELIBBAD, "ELIBBAD", "Accessing a corrupted shared library"),
#endif
#if defined (ELIBSCN)
ENTRY(ELIBSCN, "ELIBSCN", ".lib section in a.out corrupted"),
#endif
#if defined (ELIBMAX)
ENTRY(ELIBMAX, "ELIBMAX", "Attempting to link in too many shared libraries"),
#endif
#if defined (ELIBEXEC)
ENTRY(ELIBEXEC, "ELIBEXEC", "Cannot exec a shared library directly"),
#endif
#if defined (EILSEQ)
ENTRY(EILSEQ, "EILSEQ", "Illegal byte sequence"),
#endif
#if defined (ENOSYS)
ENTRY(ENOSYS, "ENOSYS", "Operation not applicable"),
#endif
#if defined (ELOOP)
ENTRY(ELOOP, "ELOOP", "Too many symbolic links encountered"),
#endif
#if defined (ERESTART)
ENTRY(ERESTART, "ERESTART", "Interrupted system call should be restarted"),
#endif
#if defined (ESTRPIPE)
ENTRY(ESTRPIPE, "ESTRPIPE", "Streams pipe error"),
#endif
#if defined (ENOTEMPTY)
ENTRY(ENOTEMPTY, "ENOTEMPTY", "Directory not empty"),
#endif
#if defined (EUSERS)
ENTRY(EUSERS, "EUSERS", "Too many users"),
#endif
#if defined (ENOTSOCK)
ENTRY(ENOTSOCK, "ENOTSOCK", "Socket operation on non-socket"),
#endif
#if defined (EDESTADDRREQ)
ENTRY(EDESTADDRREQ, "EDESTADDRREQ", "Destination address required"),
#endif
#if defined (EMSGSIZE)
ENTRY(EMSGSIZE, "EMSGSIZE", "Message too long"),
#endif
#if defined (EPROTOTYPE)
ENTRY(EPROTOTYPE, "EPROTOTYPE", "Protocol wrong type for socket"),
#endif
#if defined (ENOPROTOOPT)
ENTRY(ENOPROTOOPT, "ENOPROTOOPT", "Protocol not available"),
#endif
#if defined (EPROTONOSUPPORT)
ENTRY(EPROTONOSUPPORT, "EPROTONOSUPPORT", "Protocol not supported"),
#endif
#if defined (ESOCKTNOSUPPORT)
ENTRY(ESOCKTNOSUPPORT, "ESOCKTNOSUPPORT", "Socket type not supported"),
#endif
#if defined (EOPNOTSUPP)
ENTRY(EOPNOTSUPP, "EOPNOTSUPP", "Operation not supported on transport endpoint"),
#endif
#if defined (EPFNOSUPPORT)
ENTRY(EPFNOSUPPORT, "EPFNOSUPPORT", "Protocol family not supported"),
#endif
#if defined (EAFNOSUPPORT)
ENTRY(EAFNOSUPPORT, "EAFNOSUPPORT", "Address family not supported by protocol"),
#endif
#if defined (EADDRINUSE)
ENTRY(EADDRINUSE, "EADDRINUSE", "Address already in use"),
#endif
#if defined (EADDRNOTAVAIL)
ENTRY(EADDRNOTAVAIL, "EADDRNOTAVAIL","Cannot assign requested address"),
#endif
#if defined (ENETDOWN)
ENTRY(ENETDOWN, "ENETDOWN", "Network is down"),
#endif
#if defined (ENETUNREACH)
ENTRY(ENETUNREACH, "ENETUNREACH", "Network is unreachable"),
#endif
#if defined (ENETRESET)
ENTRY(ENETRESET, "ENETRESET", "Network dropped connection because of reset"),
#endif
#if defined (ECONNABORTED)
ENTRY(ECONNABORTED, "ECONNABORTED", "Software caused connection abort"),
#endif
#if defined (ECONNRESET)
ENTRY(ECONNRESET, "ECONNRESET", "Connection reset by peer"),
#endif
#if defined (ENOBUFS)
ENTRY(ENOBUFS, "ENOBUFS", "No buffer space available"),
#endif
#if defined (EISCONN)
ENTRY(EISCONN, "EISCONN", "Transport endpoint is already connected"),
#endif
#if defined (ENOTCONN)
ENTRY(ENOTCONN, "ENOTCONN", "Transport endpoint is not connected"),
#endif
#if defined (ESHUTDOWN)
ENTRY(ESHUTDOWN, "ESHUTDOWN", "Cannot send after transport endpoint shutdown"),
#endif
#if defined (ETOOMANYREFS)
ENTRY(ETOOMANYREFS, "ETOOMANYREFS", "Too many references: cannot splice"),
#endif
#if defined (ETIMEDOUT)
ENTRY(ETIMEDOUT, "ETIMEDOUT", "Connection timed out"),
#endif
#if defined (ECONNREFUSED)
ENTRY(ECONNREFUSED, "ECONNREFUSED", "Connection refused"),
#endif
#if defined (EHOSTDOWN)
ENTRY(EHOSTDOWN, "EHOSTDOWN", "Host is down"),
#endif
#if defined (EHOSTUNREACH)
ENTRY(EHOSTUNREACH, "EHOSTUNREACH", "No route to host"),
#endif
#if defined (EALREADY)
ENTRY(EALREADY, "EALREADY", "Operation already in progress"),
#endif
#if defined (EINPROGRESS)
ENTRY(EINPROGRESS, "EINPROGRESS", "Operation now in progress"),
#endif
#if defined (ESTALE)
ENTRY(ESTALE, "ESTALE", "Stale NFS file handle"),
#endif
#if defined (EUCLEAN)
ENTRY(EUCLEAN, "EUCLEAN", "Structure needs cleaning"),
#endif
#if defined (ENOTNAM)
ENTRY(ENOTNAM, "ENOTNAM", "Not a XENIX named type file"),
#endif
#if defined (ENAVAIL)
ENTRY(ENAVAIL, "ENAVAIL", "No XENIX semaphores available"),
#endif
#if defined (EISNAM)
ENTRY(EISNAM, "EISNAM", "Is a named type file"),
#endif
#if defined (EREMOTEIO)
ENTRY(EREMOTEIO, "EREMOTEIO", "Remote I/O error"),
#endif
ENTRY(0, NULL, NULL)
};
 
#ifdef EVMSERR
/* This is not in the table, because the numeric value of EVMSERR (32767)
lies outside the range of sys_errlist[]. */
static struct { int value; const char *name, *msg; }
evmserr = { EVMSERR, "EVMSERR", "VMS-specific error" };
#endif
 
/* Translation table allocated and initialized at runtime. Indexed by the
errno value to find the equivalent symbolic value. */
 
static const char **error_names;
static int num_error_names = 0;
 
/* Translation table allocated and initialized at runtime, if it does not
already exist in the host environment. Indexed by the errno value to find
the descriptive string.
 
We don't export it for use in other modules because even though it has the
same name, it differs from other implementations in that it is dynamically
initialized rather than statically initialized. */
 
#ifndef HAVE_SYS_ERRLIST
 
static int sys_nerr;
static const char **sys_errlist;
 
#else
 
extern int sys_nerr;
extern char *sys_errlist[];
 
#endif
 
 
/*
 
NAME
 
init_error_tables -- initialize the name and message tables
 
SYNOPSIS
 
static void init_error_tables ();
 
DESCRIPTION
 
Using the error_table, which is initialized at compile time, generate
the error_names and the sys_errlist (if needed) tables, which are
indexed at runtime by a specific errno value.
 
BUGS
 
The initialization of the tables may fail under low memory conditions,
in which case we don't do anything particularly useful, but we don't
bomb either. Who knows, it might succeed at a later point if we free
some memory in the meantime. In any case, the other routines know
how to deal with lack of a table after trying to initialize it. This
may or may not be considered to be a bug, that we don't specifically
warn about this particular failure mode.
 
*/
 
static void
init_error_tables ()
{
const struct error_info *eip;
int nbytes;
 
/* If we haven't already scanned the error_table once to find the maximum
errno value, then go find it now. */
 
if (num_error_names == 0)
{
for (eip = error_table; eip -> name != NULL; eip++)
{
if (eip -> value >= num_error_names)
{
num_error_names = eip -> value + 1;
}
}
}
 
/* Now attempt to allocate the error_names table, zero it out, and then
initialize it from the statically initialized error_table. */
 
if (error_names == NULL)
{
nbytes = num_error_names * sizeof (char *);
if ((error_names = (const char **) malloc (nbytes)) != NULL)
{
memset (error_names, 0, nbytes);
for (eip = error_table; eip -> name != NULL; eip++)
{
error_names[eip -> value] = eip -> name;
}
}
}
 
#ifndef HAVE_SYS_ERRLIST
 
/* Now attempt to allocate the sys_errlist table, zero it out, and then
initialize it from the statically initialized error_table. */
 
if (sys_errlist == NULL)
{
nbytes = num_error_names * sizeof (char *);
if ((sys_errlist = (const char **) malloc (nbytes)) != NULL)
{
memset (sys_errlist, 0, nbytes);
sys_nerr = num_error_names;
for (eip = error_table; eip -> name != NULL; eip++)
{
sys_errlist[eip -> value] = eip -> msg;
}
}
}
 
#endif
 
}
 
/*
 
NAME
 
errno_max -- return the max errno value
 
SYNOPSIS
 
int errno_max ();
 
DESCRIPTION
 
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.
 
*/
 
int
errno_max ()
{
int maxsize;
 
if (error_names == NULL)
{
init_error_tables ();
}
maxsize = MAX (sys_nerr, num_error_names);
return (maxsize - 1);
}
 
#ifndef HAVE_STRERROR
 
/*
 
NAME
 
strerror -- map an error number to an error message string
 
SYNOPSIS
 
char *strerror (int errnoval)
 
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.
 
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.
 
*/
 
char *
strerror (errnoval)
int errnoval;
{
char *msg;
static char buf[32];
 
#ifndef HAVE_SYS_ERRLIST
 
if (error_names == NULL)
{
init_error_tables ();
}
 
#endif
 
if ((errnoval < 0) || (errnoval >= sys_nerr))
{
#ifdef EVMSERR
if (errnoval == evmserr.value)
msg = evmserr.msg;
else
#endif
/* Out of range, just return NULL */
msg = NULL;
}
else if ((sys_errlist == NULL) || (sys_errlist[errnoval] == NULL))
{
/* In range, but no sys_errlist or no entry at this index. */
sprintf (buf, "Error %d", errnoval);
msg = buf;
}
else
{
/* In range, and a valid message. Just return the message. */
msg = (char *) sys_errlist[errnoval];
}
return (msg);
}
 
#endif /* ! HAVE_STRERROR */
 
 
/*
 
NAME
 
strerrno -- map an error number to a symbolic name string
 
SYNOPSIS
 
const char *strerrno (int errnoval)
 
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 strerrno.
 
*/
 
const char *
strerrno (errnoval)
int errnoval;
{
const char *name;
static char buf[32];
 
if (error_names == NULL)
{
init_error_tables ();
}
 
if ((errnoval < 0) || (errnoval >= num_error_names))
{
#ifdef EVMSERR
if (errnoval == evmserr.value)
name = evmserr.name;
else
#endif
/* Out of range, just return NULL */
name = NULL;
}
else if ((error_names == NULL) || (error_names[errnoval] == NULL))
{
/* In range, but no error_names or no entry at this index. */
sprintf (buf, "Error %d", errnoval);
name = (const char *) buf;
}
else
{
/* In range, and a valid name. Just return the name. */
name = error_names[errnoval];
}
 
return (name);
}
 
/*
 
NAME
 
strtoerrno -- map a symbolic errno name to a numeric value
 
SYNOPSIS
 
int strtoerrno (char *name)
 
DESCRIPTION
 
Given the symbolic name of a error number, map it to an errno value.
If no translation is found, returns 0.
 
*/
 
int
strtoerrno (name)
const char *name;
{
int errnoval = 0;
 
if (name != NULL)
{
if (error_names == NULL)
{
init_error_tables ();
}
for (errnoval = 0; errnoval < num_error_names; errnoval++)
{
if ((error_names[errnoval] != NULL) &&
(strcmp (name, error_names[errnoval]) == 0))
{
break;
}
}
if (errnoval == num_error_names)
{
#ifdef EVMSERR
if (strcmp (name, evmserr.name) == 0)
errnoval = evmserr.value;
else
#endif
errnoval = 0;
}
}
return (errnoval);
}
 
 
/* A simple little main that does nothing but print all the errno translations
if MAIN is defined and this file is compiled and linked. */
 
#ifdef MAIN
 
#include <stdio.h>
 
int
main ()
{
int errn;
int errnmax;
const char *name;
char *msg;
char *strerror ();
 
errnmax = errno_max ();
printf ("%d entries in names table.\n", num_error_names);
printf ("%d entries in messages table.\n", sys_nerr);
printf ("%d is max useful index.\n", errnmax);
 
/* Keep printing values until we get to the end of *both* tables, not
*either* table. Note that knowing the maximum useful index does *not*
relieve us of the responsibility of testing the return pointer for
NULL. */
 
for (errn = 0; errn <= errnmax; errn++)
{
name = strerrno (errn);
name = (name == NULL) ? "<NULL>" : name;
msg = strerror (errn);
msg = (msg == NULL) ? "<NULL>" : msg;
printf ("%-4d%-18s%s\n", errn, name, msg);
}
 
return 0;
}
 
#endif
/getopt1.c
0,0 → 1,190
/* getopt_long and getopt_long_only entry points for GNU getopt.
Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
Free Software Foundation, Inc.
 
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@gnu.org.
 
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
 
#include "getopt.h"
 
#if !defined __STDC__ || !__STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const
#define const
#endif
#endif
 
#include <stdio.h>
 
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
Library, but also included in many other GNU distributions. Compiling
and linking in this code is a waste when using the GNU C library
(especially if it is a shared library). Rather than having every GNU
program understand `configure --with-gnu-libc' and omit the object files,
it is simpler to just do this in the source for each such file. */
 
#define GETOPT_INTERFACE_VERSION 2
#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2
#include <gnu-versions.h>
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
#define ELIDE_CODE
#endif
#endif
 
#ifndef ELIDE_CODE
 
 
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
#ifdef __GNU_LIBRARY__
#include <stdlib.h>
#endif
 
#ifndef NULL
#define NULL 0
#endif
 
int
getopt_long (argc, argv, options, long_options, opt_index)
int argc;
char *const *argv;
const char *options;
const struct option *long_options;
int *opt_index;
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
}
 
/* Like getopt_long, but '-' as well as '--' can indicate a long option.
If an option that starts with '-' (not '--') doesn't match a long option,
but does match a short option, it is parsed as a short option
instead. */
 
int
getopt_long_only (argc, argv, options, long_options, opt_index)
int argc;
char *const *argv;
const char *options;
const struct option *long_options;
int *opt_index;
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
}
 
 
#endif /* Not ELIDE_CODE. */
#ifdef TEST
 
#include <stdio.h>
 
int
main (argc, argv)
int argc;
char **argv;
{
int c;
int digit_optind = 0;
 
while (1)
{
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] =
{
{"add", 1, 0, 0},
{"append", 0, 0, 0},
{"delete", 1, 0, 0},
{"verbose", 0, 0, 0},
{"create", 0, 0, 0},
{"file", 1, 0, 0},
{0, 0, 0, 0}
};
 
c = getopt_long (argc, argv, "abc:d:0123456789",
long_options, &option_index);
if (c == -1)
break;
 
switch (c)
{
case 0:
printf ("option %s", long_options[option_index].name);
if (optarg)
printf (" with arg %s", optarg);
printf ("\n");
break;
 
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
if (digit_optind != 0 && digit_optind != this_option_optind)
printf ("digits occur in two different argv-elements.\n");
digit_optind = this_option_optind;
printf ("option %c\n", c);
break;
 
case 'a':
printf ("option a\n");
break;
 
case 'b':
printf ("option b\n");
break;
 
case 'c':
printf ("option c with value `%s'\n", optarg);
break;
 
case 'd':
printf ("option d with value `%s'\n", optarg);
break;
 
case '?':
break;
 
default:
printf ("?? getopt returned character code 0%o ??\n", c);
}
}
 
if (optind < argc)
{
printf ("non-option ARGV-elements: ");
while (optind < argc)
printf ("%s ", argv[optind++]);
printf ("\n");
}
 
exit (0);
}
 
#endif /* TEST */
/obstack.c
0,0 → 1,593
/* obstack.c - subroutines used implicitly by object stack macros
Copyright (C) 1988,89,90,91,92,93,94,96,97 Free Software Foundation, Inc.
 
 
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@gnu.org.
 
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
 
#include "obstack.h"
 
/* NOTE BEFORE MODIFYING THIS FILE: This version number must be
incremented whenever callers compiled using an old obstack.h can no
longer properly call the functions in this obstack.c. */
#define OBSTACK_INTERFACE_VERSION 1
 
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself, and the installed library
supports the same library interface we do. This code is part of the GNU
C Library, but also included in many other GNU distributions. Compiling
and linking in this code is a waste when using the GNU C library
(especially if it is a shared library). Rather than having every GNU
program understand `configure --with-gnu-libc' and omit the object
files, it is simpler to just do this in the source for each such file. */
 
#include <stdio.h> /* Random thing to get __GNU_LIBRARY__. */
#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1
#include <gnu-versions.h>
#if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION
#define ELIDE_CODE
#endif
#endif
 
 
#ifndef ELIDE_CODE
 
 
#if defined (__STDC__) && __STDC__
#define POINTER void *
#else
#define POINTER char *
#endif
 
/* Determine default alignment. */
struct fooalign {char x; double d;};
#define DEFAULT_ALIGNMENT \
((PTR_INT_TYPE) ((char *) &((struct fooalign *) 0)->d - (char *) 0))
/* If malloc were really smart, it would round addresses to DEFAULT_ALIGNMENT.
But in fact it might be less smart and round addresses to as much as
DEFAULT_ROUNDING. So we prepare for it to do that. */
union fooround {long x; double d;};
#define DEFAULT_ROUNDING (sizeof (union fooround))
 
/* When we copy a long block of data, this is the unit to do it with.
On some machines, copying successive ints does not work;
in such a case, redefine COPYING_UNIT to `long' (if that works)
or `char' as a last resort. */
#ifndef COPYING_UNIT
#define COPYING_UNIT int
#endif
 
 
/* The functions allocating more room by calling `obstack_chunk_alloc'
jump to the handler pointed to by `obstack_alloc_failed_handler'.
This variable by default points to the internal function
`print_and_abort'. */
#if defined (__STDC__) && __STDC__
static void print_and_abort (void);
void (*obstack_alloc_failed_handler) (void) = print_and_abort;
#else
static void print_and_abort ();
void (*obstack_alloc_failed_handler) () = print_and_abort;
#endif
 
/* Exit value used when `print_and_abort' is used. */
#if defined __GNU_LIBRARY__ || defined HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifndef EXIT_FAILURE
#define EXIT_FAILURE 1
#endif
int obstack_exit_failure = EXIT_FAILURE;
 
/* The non-GNU-C macros copy the obstack into this global variable
to avoid multiple evaluation. */
 
struct obstack *_obstack;
 
/* Define a macro that either calls functions with the traditional malloc/free
calling interface, or calls functions with the mmalloc/mfree interface
(that adds an extra first argument), based on the state of use_extra_arg.
For free, do not use ?:, since some compilers, like the MIPS compilers,
do not allow (expr) ? void : void. */
 
#if defined (__STDC__) && __STDC__
#define CALL_CHUNKFUN(h, size) \
(((h) -> use_extra_arg) \
? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
: (*(struct _obstack_chunk *(*) (long)) (h)->chunkfun) ((size)))
 
#define CALL_FREEFUN(h, old_chunk) \
do { \
if ((h) -> use_extra_arg) \
(*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
else \
(*(void (*) (void *)) (h)->freefun) ((old_chunk)); \
} while (0)
#else
#define CALL_CHUNKFUN(h, size) \
(((h) -> use_extra_arg) \
? (*(h)->chunkfun) ((h)->extra_arg, (size)) \
: (*(struct _obstack_chunk *(*) ()) (h)->chunkfun) ((size)))
 
#define CALL_FREEFUN(h, old_chunk) \
do { \
if ((h) -> use_extra_arg) \
(*(h)->freefun) ((h)->extra_arg, (old_chunk)); \
else \
(*(void (*) ()) (h)->freefun) ((old_chunk)); \
} while (0)
#endif
 
/* Initialize an obstack H for use. Specify chunk size SIZE (0 means default).
Objects start on multiples of ALIGNMENT (0 means use default).
CHUNKFUN is the function to use to allocate chunks,
and FREEFUN the function to free them.
 
Return nonzero if successful, zero if out of memory.
To recover from an out of memory error,
free up some memory, then call this again. */
 
int
_obstack_begin (h, size, alignment, chunkfun, freefun)
struct obstack *h;
int size;
int alignment;
#if defined (__STDC__) && __STDC__
POINTER (*chunkfun) (long);
void (*freefun) (void *);
#else
POINTER (*chunkfun) ();
void (*freefun) ();
#endif
{
register struct _obstack_chunk *chunk; /* points to new chunk */
 
if (alignment == 0)
alignment = (int) DEFAULT_ALIGNMENT;
if (size == 0)
/* Default size is what GNU malloc can fit in a 4096-byte block. */
{
/* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc.
Use the values for range checking, because if range checking is off,
the extra bytes won't be missed terribly, but if range checking is on
and we used a larger request, a whole extra 4096 bytes would be
allocated.
 
These number are irrelevant to the new GNU malloc. I suspect it is
less sensitive to the size of the request. */
int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1))
+ 4 + DEFAULT_ROUNDING - 1)
& ~(DEFAULT_ROUNDING - 1));
size = 4096 - extra;
}
 
#if defined (__STDC__) && __STDC__
h->chunkfun = (struct _obstack_chunk * (*)(void *, long)) chunkfun;
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
#else
h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
h->freefun = freefun;
#endif
h->chunk_size = size;
h->alignment_mask = alignment - 1;
h->use_extra_arg = 0;
 
chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
if (!chunk)
(*obstack_alloc_failed_handler) ();
h->next_free = h->object_base = chunk->contents;
h->chunk_limit = chunk->limit
= (char *) chunk + h->chunk_size;
chunk->prev = 0;
/* The initial chunk now contains no empty object. */
h->maybe_empty_object = 0;
h->alloc_failed = 0;
return 1;
}
 
int
_obstack_begin_1 (h, size, alignment, chunkfun, freefun, arg)
struct obstack *h;
int size;
int alignment;
#if defined (__STDC__) && __STDC__
POINTER (*chunkfun) (POINTER, long);
void (*freefun) (POINTER, POINTER);
#else
POINTER (*chunkfun) ();
void (*freefun) ();
#endif
POINTER arg;
{
register struct _obstack_chunk *chunk; /* points to new chunk */
 
if (alignment == 0)
alignment = (int) DEFAULT_ALIGNMENT;
if (size == 0)
/* Default size is what GNU malloc can fit in a 4096-byte block. */
{
/* 12 is sizeof (mhead) and 4 is EXTRA from GNU malloc.
Use the values for range checking, because if range checking is off,
the extra bytes won't be missed terribly, but if range checking is on
and we used a larger request, a whole extra 4096 bytes would be
allocated.
 
These number are irrelevant to the new GNU malloc. I suspect it is
less sensitive to the size of the request. */
int extra = ((((12 + DEFAULT_ROUNDING - 1) & ~(DEFAULT_ROUNDING - 1))
+ 4 + DEFAULT_ROUNDING - 1)
& ~(DEFAULT_ROUNDING - 1));
size = 4096 - extra;
}
 
#if defined(__STDC__) && __STDC__
h->chunkfun = (struct _obstack_chunk * (*)(void *,long)) chunkfun;
h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun;
#else
h->chunkfun = (struct _obstack_chunk * (*)()) chunkfun;
h->freefun = freefun;
#endif
h->chunk_size = size;
h->alignment_mask = alignment - 1;
h->extra_arg = arg;
h->use_extra_arg = 1;
 
chunk = h->chunk = CALL_CHUNKFUN (h, h -> chunk_size);
if (!chunk)
(*obstack_alloc_failed_handler) ();
h->next_free = h->object_base = chunk->contents;
h->chunk_limit = chunk->limit
= (char *) chunk + h->chunk_size;
chunk->prev = 0;
/* The initial chunk now contains no empty object. */
h->maybe_empty_object = 0;
h->alloc_failed = 0;
return 1;
}
 
/* Allocate a new current chunk for the obstack *H
on the assumption that LENGTH bytes need to be added
to the current object, or a new object of length LENGTH allocated.
Copies any partial object from the end of the old chunk
to the beginning of the new one. */
 
void
_obstack_newchunk (h, length)
struct obstack *h;
int length;
{
register struct _obstack_chunk *old_chunk = h->chunk;
register struct _obstack_chunk *new_chunk;
register long new_size;
register long obj_size = h->next_free - h->object_base;
register long i;
long already;
 
/* Compute size for new chunk. */
new_size = (obj_size + length) + (obj_size >> 3) + 100;
if (new_size < h->chunk_size)
new_size = h->chunk_size;
 
/* Allocate and initialize the new chunk. */
new_chunk = CALL_CHUNKFUN (h, new_size);
if (!new_chunk)
(*obstack_alloc_failed_handler) ();
h->chunk = new_chunk;
new_chunk->prev = old_chunk;
new_chunk->limit = h->chunk_limit = (char *) new_chunk + new_size;
 
/* Move the existing object to the new chunk.
Word at a time is fast and is safe if the object
is sufficiently aligned. */
if (h->alignment_mask + 1 >= DEFAULT_ALIGNMENT)
{
for (i = obj_size / sizeof (COPYING_UNIT) - 1;
i >= 0; i--)
((COPYING_UNIT *)new_chunk->contents)[i]
= ((COPYING_UNIT *)h->object_base)[i];
/* We used to copy the odd few remaining bytes as one extra COPYING_UNIT,
but that can cross a page boundary on a machine
which does not do strict alignment for COPYING_UNITS. */
already = obj_size / sizeof (COPYING_UNIT) * sizeof (COPYING_UNIT);
}
else
already = 0;
/* Copy remaining bytes one by one. */
for (i = already; i < obj_size; i++)
new_chunk->contents[i] = h->object_base[i];
 
/* If the object just copied was the only data in OLD_CHUNK,
free that chunk and remove it from the chain.
But not if that chunk might contain an empty object. */
if (h->object_base == old_chunk->contents && ! h->maybe_empty_object)
{
new_chunk->prev = old_chunk->prev;
CALL_FREEFUN (h, old_chunk);
}
 
h->object_base = new_chunk->contents;
h->next_free = h->object_base + obj_size;
/* The new chunk certainly contains no empty object yet. */
h->maybe_empty_object = 0;
}
 
/* Return nonzero if object OBJ has been allocated from obstack H.
This is here for debugging.
If you use it in a program, you are probably losing. */
 
#if defined (__STDC__) && __STDC__
/* Suppress -Wmissing-prototypes warning. We don't want to declare this in
obstack.h because it is just for debugging. */
int _obstack_allocated_p (struct obstack *h, POINTER obj);
#endif
 
int
_obstack_allocated_p (h, obj)
struct obstack *h;
POINTER obj;
{
register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
register struct _obstack_chunk *plp; /* point to previous chunk if any */
 
lp = (h)->chunk;
/* We use >= rather than > since the object cannot be exactly at
the beginning of the chunk but might be an empty object exactly
at the end of an adjacent chunk. */
while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj))
{
plp = lp->prev;
lp = plp;
}
return lp != 0;
}
/* Free objects in obstack H, including OBJ and everything allocate
more recently than OBJ. If OBJ is zero, free everything in H. */
 
#undef obstack_free
 
/* This function has two names with identical definitions.
This is the first one, called from non-ANSI code. */
 
void
_obstack_free (h, obj)
struct obstack *h;
POINTER obj;
{
register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
register struct _obstack_chunk *plp; /* point to previous chunk if any */
 
lp = h->chunk;
/* We use >= because there cannot be an object at the beginning of a chunk.
But there can be an empty object at that address
at the end of another chunk. */
while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj))
{
plp = lp->prev;
CALL_FREEFUN (h, lp);
lp = plp;
/* If we switch chunks, we can't tell whether the new current
chunk contains an empty object, so assume that it may. */
h->maybe_empty_object = 1;
}
if (lp)
{
h->object_base = h->next_free = (char *) (obj);
h->chunk_limit = lp->limit;
h->chunk = lp;
}
else if (obj != 0)
/* obj is not in any of the chunks! */
abort ();
}
 
/* This function is used from ANSI code. */
 
void
obstack_free (h, obj)
struct obstack *h;
POINTER obj;
{
register struct _obstack_chunk *lp; /* below addr of any objects in this chunk */
register struct _obstack_chunk *plp; /* point to previous chunk if any */
 
lp = h->chunk;
/* We use >= because there cannot be an object at the beginning of a chunk.
But there can be an empty object at that address
at the end of another chunk. */
while (lp != 0 && ((POINTER) lp >= obj || (POINTER) (lp)->limit < obj))
{
plp = lp->prev;
CALL_FREEFUN (h, lp);
lp = plp;
/* If we switch chunks, we can't tell whether the new current
chunk contains an empty object, so assume that it may. */
h->maybe_empty_object = 1;
}
if (lp)
{
h->object_base = h->next_free = (char *) (obj);
h->chunk_limit = lp->limit;
h->chunk = lp;
}
else if (obj != 0)
/* obj is not in any of the chunks! */
abort ();
}
int
_obstack_memory_used (h)
struct obstack *h;
{
register struct _obstack_chunk* lp;
register int nbytes = 0;
 
for (lp = h->chunk; lp != 0; lp = lp->prev)
{
nbytes += lp->limit - (char *) lp;
}
return nbytes;
}
/* Define the error handler. */
#ifndef _
# ifdef HAVE_LIBINTL_H
# include <libintl.h>
# ifndef _
# define _(Str) gettext (Str)
# endif
# else
# define _(Str) (Str)
# endif
#endif
 
static void
print_and_abort ()
{
fputs (_("memory exhausted\n"), stderr);
exit (obstack_exit_failure);
}
#if 0
/* These are now turned off because the applications do not use it
and it uses bcopy via obstack_grow, which causes trouble on sysV. */
 
/* Now define the functional versions of the obstack macros.
Define them to simply use the corresponding macros to do the job. */
 
#if defined (__STDC__) && __STDC__
/* These function definitions do not work with non-ANSI preprocessors;
they won't pass through the macro names in parentheses. */
 
/* The function names appear in parentheses in order to prevent
the macro-definitions of the names from being expanded there. */
 
POINTER (obstack_base) (obstack)
struct obstack *obstack;
{
return obstack_base (obstack);
}
 
POINTER (obstack_next_free) (obstack)
struct obstack *obstack;
{
return obstack_next_free (obstack);
}
 
int (obstack_object_size) (obstack)
struct obstack *obstack;
{
return obstack_object_size (obstack);
}
 
int (obstack_room) (obstack)
struct obstack *obstack;
{
return obstack_room (obstack);
}
 
int (obstack_make_room) (obstack, length)
struct obstack *obstack;
int length;
{
return obstack_make_room (obstack, length);
}
 
void (obstack_grow) (obstack, pointer, length)
struct obstack *obstack;
POINTER pointer;
int length;
{
obstack_grow (obstack, pointer, length);
}
 
void (obstack_grow0) (obstack, pointer, length)
struct obstack *obstack;
POINTER pointer;
int length;
{
obstack_grow0 (obstack, pointer, length);
}
 
void (obstack_1grow) (obstack, character)
struct obstack *obstack;
int character;
{
obstack_1grow (obstack, character);
}
 
void (obstack_blank) (obstack, length)
struct obstack *obstack;
int length;
{
obstack_blank (obstack, length);
}
 
void (obstack_1grow_fast) (obstack, character)
struct obstack *obstack;
int character;
{
obstack_1grow_fast (obstack, character);
}
 
void (obstack_blank_fast) (obstack, length)
struct obstack *obstack;
int length;
{
obstack_blank_fast (obstack, length);
}
 
POINTER (obstack_finish) (obstack)
struct obstack *obstack;
{
return obstack_finish (obstack);
}
 
POINTER (obstack_alloc) (obstack, length)
struct obstack *obstack;
int length;
{
return obstack_alloc (obstack, length);
}
 
POINTER (obstack_copy) (obstack, pointer, length)
struct obstack *obstack;
POINTER pointer;
int length;
{
return obstack_copy (obstack, pointer, length);
}
 
POINTER (obstack_copy0) (obstack, pointer, length)
struct obstack *obstack;
POINTER pointer;
int length;
{
return obstack_copy0 (obstack, pointer, length);
}
 
#endif /* __STDC__ */
 
#endif /* 0 */
 
#endif /* !ELIDE_CODE */
/strrchr.c
0,0 → 1,34
/* Portable version of strrchr().
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.
*/
 
#include <ansidecl.h>
 
char *
strrchr (s, c)
register const char *s;
int c;
{
char *rtnval = 0;
 
do {
if (*s == c)
rtnval = (char*) s;
} while (*s++);
return (rtnval);
}
/config.in
0,0 → 1,224
/* config.in. Generated automatically from configure.in by autoheader. */
 
/* Define if using alloca.c. */
#undef C_ALLOCA
 
/* 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 <sys/wait.h> that is POSIX.1 compatible. */
#undef HAVE_SYS_WAIT_H
 
/* Define if you have <vfork.h>. */
#undef HAVE_VFORK_H
 
/* Define to `int' if <sys/types.h> doesn't define. */
#undef pid_t
 
/* 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
 
/* Define vfork as fork if vfork does not work. */
#undef vfork
 
/* Define if you have the sys_errlist variable. */
#undef HAVE_SYS_ERRLIST
 
/* Define if you have the sys_nerr variable. */
#undef HAVE_SYS_NERR
 
/* Define if you have the sys_siglist variable. */
#undef HAVE_SYS_SIGLIST
 
/* Define if you have the strerror function. */
#undef HAVE_STRERROR
 
/* Define if you have the asprintf function. */
#undef HAVE_ASPRINTF
 
/* Define if you have the atexit function. */
#undef HAVE_ATEXIT
 
/* Define if you have the basename function. */
#undef HAVE_BASENAME
 
/* Define if you have the bcmp function. */
#undef HAVE_BCMP
 
/* Define if you have the bcopy function. */
#undef HAVE_BCOPY
 
/* Define if you have the bzero function. */
#undef HAVE_BZERO
 
/* Define if you have the calloc function. */
#undef HAVE_CALLOC
 
/* Define if you have the clock function. */
#undef HAVE_CLOCK
 
/* Define if you have the getcwd function. */
#undef HAVE_GETCWD
 
/* Define if you have the getpagesize function. */
#undef HAVE_GETPAGESIZE
 
/* Define if you have the getrusage function. */
#undef HAVE_GETRUSAGE
 
/* Define if you have the gettimeofday function. */
#undef HAVE_GETTIMEOFDAY
 
/* Define if you have the index function. */
#undef HAVE_INDEX
 
/* Define if you have the insque function. */
#undef HAVE_INSQUE
 
/* Define if you have the memchr function. */
#undef HAVE_MEMCHR
 
/* Define if you have the memcmp function. */
#undef HAVE_MEMCMP
 
/* Define if you have the memcpy function. */
#undef HAVE_MEMCPY
 
/* Define if you have the memmove function. */
#undef HAVE_MEMMOVE
 
/* Define if you have the memset function. */
#undef HAVE_MEMSET
 
/* Define if you have the mkstemps function. */
#undef HAVE_MKSTEMPS
 
/* Define if you have the on_exit function. */
#undef HAVE_ON_EXIT
 
/* Define if you have the psignal function. */
#undef HAVE_PSIGNAL
 
/* Define if you have the putenv function. */
#undef HAVE_PUTENV
 
/* Define if you have the random function. */
#undef HAVE_RANDOM
 
/* Define if you have the rename function. */
#undef HAVE_RENAME
 
/* Define if you have the rindex function. */
#undef HAVE_RINDEX
 
/* Define if you have the sbrk function. */
#undef HAVE_SBRK
 
/* Define if you have the setenv function. */
#undef HAVE_SETENV
 
/* Define if you have the sigsetmask function. */
#undef HAVE_SIGSETMASK
 
/* Define if you have the strcasecmp function. */
#undef HAVE_STRCASECMP
 
/* Define if you have the strchr function. */
#undef HAVE_STRCHR
 
/* Define if you have the strdup function. */
#undef HAVE_STRDUP
 
/* Define if you have the strerror function. */
#undef HAVE_STRERROR
 
/* Define if you have the strncasecmp function. */
#undef HAVE_STRNCASECMP
 
/* Define if you have the strrchr function. */
#undef HAVE_STRRCHR
 
/* Define if you have the strsignal function. */
#undef HAVE_STRSIGNAL
 
/* Define if you have the strstr function. */
#undef HAVE_STRSTR
 
/* Define if you have the strtod function. */
#undef HAVE_STRTOD
 
/* Define if you have the strtol function. */
#undef HAVE_STRTOL
 
/* Define if you have the strtoul function. */
#undef HAVE_STRTOUL
 
/* Define if you have the sysconf function. */
#undef HAVE_SYSCONF
 
/* Define if you have the times function. */
#undef HAVE_TIMES
 
/* Define if you have the tmpnam function. */
#undef HAVE_TMPNAM
 
/* Define if you have the vasprintf function. */
#undef HAVE_VASPRINTF
 
/* Define if you have the vfprintf function. */
#undef HAVE_VFPRINTF
 
/* Define if you have the vprintf function. */
#undef HAVE_VPRINTF
 
/* Define if you have the vsprintf function. */
#undef HAVE_VSPRINTF
 
/* Define if you have the waitpid function. */
#undef HAVE_WAITPID
 
/* Define if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
 
/* Define if you have the <string.h> header file. */
#undef HAVE_STRING_H
 
/* Define if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
 
/* Define if you have the <sys/file.h> header file. */
#undef HAVE_SYS_FILE_H
 
/* Define if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H
 
/* Define if you have the <sys/resource.h> header file. */
#undef HAVE_SYS_RESOURCE_H
 
/* Define if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
 
/* Define if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
 
/* Define if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/vfprintf.c
0,0 → 1,21
/* Provide a version vfprintf in terms of _doprnt.
By Kaveh Ghazi (ghazi@caip.rutgers.edu) 3/29/98
Copyright (C) 1998 Free Software Foundation, Inc.
*/
 
#ifdef __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include <stdio.h>
#undef vfprintf
 
int
vfprintf (stream, format, ap)
FILE * stream;
const char * format;
va_list ap;
{
return _doprnt (format, ap, stream);
}
/makefile.vms
0,0 → 1,33
#
# Makefile for libiberty under openVMS/Alpha
#
# For use with gnu-make for vms
#
# Created by Klaus K"ampf, kkaempf@progis.de
#
#
 
OBJS=bcopy.obj,bcmp.obj,getopt.obj,obstack.obj,xexit.obj,xmalloc.obj,hex.obj,\
getopt1.obj,cplus-dem.obj,strncasecmp.obj,strcasecmp.obj,strdup.obj,\
concat.obj,getruntime.obj,getpagesize.obj,alloca.obj,xstrerror.obj,\
xmemdup.obj,xstrdup.obj,xatexit.obj,choose-temp.obj,fnmatch.obj,objalloc.obj
 
ifeq ($(CC),gcc)
CFLAGS=/include=([],[-.include])
else
# assume dec c
CFLAGS=/noopt/debug/include=([],[-.include])/define=("const=")/warnings=disable=(missingreturn,implicitfunc)
endif
 
libiberty.olb: config.h alloca-conf.h $(OBJS)
purge
lib/create libiberty *.obj
 
config.h: config.h-vms
$(CP) $< $@
 
clean:
$$ purge
$(RM) config.h;
$(RM) *.obj;
$(RM) libiberty.olb;
/configure.in
0,0 → 1,382
dnl Process this file with autoconf to produce a configure script
 
AC_PREREQ(2.13)
AC_INIT(pexecute.c)
 
dnl We use these options to decide which functions to include.
AC_ARG_WITH(target-subdir,
[ --with-target-subdir=SUBDIR Configuring in a subdirectory])
AC_ARG_WITH(cross-host,
[ --with-cross-host=HOST Configuring with a cross compiler])
AC_ARG_WITH(newlib,
[ --with-newlib Configuring with newlib])
 
if test "${srcdir}" = "."; then
if test -z "${with_target_subdir}"; then
libiberty_topdir="${srcdir}/.."
else
if test "${with_target_subdir}" != "."; then
libiberty_topdir="${srcdir}/${with_multisrctop}../.."
else
libiberty_topdir="${srcdir}/${with_multisrctop}.."
fi
fi
else
libiberty_topdir="${srcdir}/.."
fi
AC_CONFIG_AUX_DIR($libiberty_topdir)
 
AC_CANONICAL_HOST
 
dnl When we start using automake:
dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
 
dnl These must be called before AM_PROG_LIBTOOL, because it may want
dnl to call AC_CHECK_PROG.
AC_CHECK_TOOL(AR, ar)
AC_CHECK_TOOL(RANLIB, ranlib, :)
 
# FIXME: We temporarily define our own version of AC_PROG_CC. This is
# copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS. We
# are probably using a cross compiler, which will not be able to fully
# link an executable. This should really be fixed in autoconf
# itself.
 
AC_DEFUN(LIB_AC_PROG_CC,
[AC_BEFORE([$0], [AC_PROG_CPP])dnl
AC_PROVIDE([AC_PROG_CC])
AC_CHECK_PROG(CC, gcc, gcc)
if test -z "$CC"; then
AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
fi
 
AC_PROG_CC_GNU
 
if test $ac_cv_prog_gcc = yes; then
GCC=yes
ac_libiberty_warn_cflags='-W -Wall -Wtraditional'
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.
ac_test_CFLAGS="${CFLAGS+set}"
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
AC_PROG_CC_G
if test "$ac_test_CFLAGS" = set; then
CFLAGS="$ac_save_CFLAGS"
elif test $ac_cv_prog_cc_g = yes; then
CFLAGS="-g -O2"
else
CFLAGS="-O2"
fi
else
GCC=
ac_libiberty_warn_cflags=
test "${CFLAGS+set}" = set || CFLAGS="-g"
fi
])
AC_SUBST(ac_libiberty_warn_cflags)
 
LIB_AC_PROG_CC
 
AC_ISC_POSIX
 
dnl When we start using libtool:
dnl Default to a non shared library. This may be overridden by the
dnl configure option --enable-shared.
dnl AM_DISABLE_SHARED
 
dnl When we start using libtool:
dnl AM_PROG_LIBTOOL
 
dnl When we start using automake:
dnl AM_CONFIG_HEADER(config.h:config.in)
AC_CONFIG_HEADER(config.h:config.in)
 
dnl When we start using automake:
dnl AM_MAINTAINER_MODE
dnl AC_EXEEXT
 
dnl When we start using automake:
dnl AM_PROG_INSTALL
AC_PROG_INSTALL
 
. ${srcdir}/config.table
host_makefile_frag=${frag}
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_HEADER_SYS_WAIT
 
# This is the list of functions which libiberty will provide if they
# are not available on the host.
 
funcs="asprintf"
funcs="$funcs atexit"
funcs="$funcs basename"
funcs="$funcs bcmp"
funcs="$funcs bcopy"
funcs="$funcs bzero"
funcs="$funcs calloc"
funcs="$funcs clock"
funcs="$funcs getcwd"
funcs="$funcs getpagesize"
funcs="$funcs index"
funcs="$funcs insque"
funcs="$funcs memchr"
funcs="$funcs memcmp"
funcs="$funcs memcpy"
funcs="$funcs memmove"
funcs="$funcs memset"
funcs="$funcs mkstemps"
funcs="$funcs putenv"
funcs="$funcs random"
funcs="$funcs rename"
funcs="$funcs rindex"
funcs="$funcs setenv"
funcs="$funcs sigsetmask"
funcs="$funcs strcasecmp"
funcs="$funcs strchr"
funcs="$funcs strdup"
funcs="$funcs strncasecmp"
funcs="$funcs strrchr"
funcs="$funcs strstr"
funcs="$funcs strtod"
funcs="$funcs strtol"
funcs="$funcs strtoul"
funcs="$funcs tmpnam"
funcs="$funcs vasprintf"
funcs="$funcs vfprintf"
funcs="$funcs vprintf"
funcs="$funcs vsprintf"
funcs="$funcs waitpid"
 
# Also in the old function.def file: alloca, vfork, getopt.
 
vars="sys_errlist sys_nerr sys_siglist"
 
checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
 
# These are neither executed nor required, but they help keep
# autoheader happy without adding a bunch of text to acconfig.h.
if test "x" = "y"; then
AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bzero calloc clock getcwd)
AC_CHECK_FUNCS(getpagesize index insque mkstemps memchr memcmp memcpy memmove)
AC_CHECK_FUNCS(memset putenv random rename rindex sigsetmask strcasecmp)
AC_CHECK_FUNCS(setenv strchr strdup strncasecmp strrchr strstr strtod strtol)
AC_CHECK_FUNCS(strtoul tmpnam vasprintf vfprintf vprintf vsprintf waitpid)
AC_DEFINE(HAVE_SYS_ERRLIST)
AC_DEFINE(HAVE_SYS_NERR)
AC_DEFINE(HAVE_SYS_SIGLIST)
AC_CHECK_FUNCS(getrusage on_exit psignal strerror strsignal sysconf times)
AC_CHECK_FUNCS(sbrk gettimeofday)
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
 
setobjs=
CHECK=
if test -n "${with_target_subdir}"; then
 
# We are being configured as a target library. AC_REPLACE_FUNCS
# may not work correctly, because the compiler may not be able to
# link executables. Note that we may still be being configured
# native.
 
# If we are being configured for newlib, we know which functions
# 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
case "$f" in
asprintf | basename | insque | random | strdup | vasprintf)
;;
*)
n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
AC_DEFINE_UNQUOTED($n)
;;
esac
done
 
# newlib doesnt provide any of the variables in $vars, so we
# dont have to check them here.
 
# Of the functions in $checkfuncs, newlib only has strerror.
AC_DEFINE(HAVE_STRERROR)
 
setobjs=yes
 
fi
 
else
 
# Not a target library, so we set things up to run the test suite.
CHECK=check-cplus-dem
 
fi
 
AC_SUBST(CHECK)
 
if test -z "${setobjs}"; then
case "${host}" in
 
*-*-vxworks*)
# Handle VxWorks configuration specially, since on VxWorks the
# libraries are actually on the target board, not in the file
# system.
LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o"
LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o"
for f in $funcs; do
case "$f" in
basename | getpagesize | insque | random | strcasecmp)
;;
strncasecmp | strdup | vfork | waitpid | vasprintf)
;;
*)
n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
AC_DEFINE_UNQUOTED($n)
;;
esac
done
 
# VxWorks doesn't provide any of the variables in $vars, so we
# don't have to check them here.
 
# Of the functions in $checkfuncs, VxWorks only has strerror.
AC_DEFINE(HAVE_STRERROR)
 
setobjs=yes
;;
 
esac
fi
 
if test -z "${setobjs}"; then
 
case "${host}" in
 
*-*-cygwin*)
# The Cygwin library actually uses a couple of files from
# libiberty when it is built. If we are building a native
# Cygwin, and we run the tests, we will appear to have these
# files. However, when we go on to build winsup, we will wind up
# with a library which does not have the files, since they should
# have come from libiberty.
 
# We handle this by removing the functions the winsup library
# provides from our shell variables, so that they appear to be
# missing.
 
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*)
# Under mingw32, sys_nerr and sys_errlist exist, but they are
# macros, so the test below won't find them.
vars="`echo $vars | sed -e 's/sys_nerr//' -e 's/sys_errlist//'`"
AC_DEFINE(HAVE_SYS_NERR)
AC_DEFINE(HAVE_SYS_ERRLIST)
;;
 
*-*-uwin*)
# Under some versions of uwin, vfork is notoriously buggy and the test
# can hang configure; on other versions, vfork exists just as a stub.
# FIXME: This should be removed once vfork in uwin's runtime is fixed.
ac_cv_func_vfork_works=no
# Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are
# macros (actually, these are imported from a DLL, but the end effect
# is the same), so the test below won't find them.
AC_DEFINE(HAVE_SYS_NERR)
AC_DEFINE(HAVE_SYS_ERRLIST)
;;
 
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
 
AC_FUNC_VFORK
if test $ac_cv_func_vfork_works = no; then
LIBOBJS="$LIBOBJS vfork.o"
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;],
[eval "libiberty_cv_var_$v=yes"],
[eval "libiberty_cv_var_$v=no"])])
if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
AC_MSG_RESULT(yes)
n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
AC_DEFINE_UNQUOTED($n)
else
AC_MSG_RESULT(no)
fi
done
AC_CHECK_FUNCS($checkfuncs)
fi
 
# Install a library built with a cross compiler in $(tooldir) rather
# than $(libdir).
if test -z "${with_cross_host}"; then
INSTALL_DEST=libdir
else
INSTALL_DEST=tooldir
fi
AC_SUBST(INSTALL_DEST)
 
# We need multilib support, but only if configuring for the target.
AC_OUTPUT(Makefile testsuite/Makefile,
[test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
if test -n "$CONFIG_FILES"; then
if test -n "${with_target_subdir}"; then
# FIXME: We shouldn't need to set ac_file
ac_file=Makefile
. ${libiberty_topdir}/config-ml.in
fi
fi],
srcdir=${srcdir}
host=${host}
target=${target}
with_target_subdir=${with_target_subdir}
with_multisubdir=${with_multisubdir}
ac_configure_args="--enable-multilib ${ac_configure_args}"
CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
libiberty_topdir=${libiberty_topdir}
)
/ChangeLog
0,0 → 1,3619
2000-04-05 Richard Henderson <rth@cygnus.com>
 
* splay-tree.c (splay_tree_remove): New.
 
Thu Mar 16 01:33:58 2000 Jeffrey A Law (law@cygnus.com)
 
* Makefile.in (partition.o): Depend on config.h
 
2000-03-14 Bernd Schmidt <bernds@cygnus.co.uk>
 
* hashtab.c (find_empty_slot_for_expand): New function.
(htab_expand): Use it instead of htab_find_slot.
(htab_find_with_hash): Renamed from htab_find; now accepts extra
argument HASH.
(htab_find_slot_with_hash): Likewise for htab_find_slot.
(htab_find): New wrapper function.
(htab_find_slot): Likewise.
(htab_traverse): Pass slot, not entry, to called function.
 
2000-03-09 Alex Samuel <samuel@codesourcery.com>
 
* Makefile.in (CFILES): Add partition.c.
(REQUIRED_OFILES): Add partition.o.
(partition.o): New rule.
* partition.c: New file.
2000-03-09 Zack Weinberg <zack@wolery.cumb.org>
 
* hashtab.c (htab_create): Set del_f.
(htab_delete, htab_empty, htab_remove_elt, htab_clear_slot):
Use it.
 
2000-03-08 Zack Weinberg <zack@wolery.cumb.org>
 
* hashtab.c: Remove debugging variables (all_searches,
all_collisions, all_expansions). Delete
all_hash_table_collisions.
(create_hash_table, delete_hash_table, empty_hash_table,
find_hash_table_entry, remove_element_from_hash_table_entry,
clear_hash_table_slot, traverse_hash_table, hash_table_size,
hash_table_elements_number, hash_table_collisions): Rename to:
htab_create, htab_delete, htab_empty, htab_find_slot,
htab_remove_elt, htab_clear_slot, htab_traverse, htab_size,
htab_elements, htab_collisions.
(htab_find): New function, handles common case where you don't
plan to add or delete an entry.
(htab_expand): Don't create a whole new table, just a new
entry vector.
(htab_find_slot): Simplify logic.
 
1999-08-03 Ian Lance Taylor <ian@zembu.com>
 
* floatformat.c: Add casts to avoid signed/unsigned warnings.
* pexecute.c: Add ATTRIBUTE_UNUSED as needed on Unix.
 
* Makefile.in (install_to_libdir): Change $(TARGETLIB).n to
$(TARGETLIB)n so it works on MSDOS.
(install_to_tooldir): Likewise.
 
1999-07-21 Ian Lance Taylor <ian@zembu.com>
 
From Mark Elbrecht:
* makefile.dos: Remove; obsolete.
* configure.bat: Remove; obsolete.
 
1999-07-11 Ian Lance Taylor <ian@zembu.com>
 
* splay-tree.c (splay_tree_insert): Add initialization to avoid
warning.
 
2000-01-04 Mumit Khan <khan@xraylith.wisc.edu>
 
* pexecute.c: Conditionally include string.h.
(fix_argv): Handle embedded whitespace in args for Mingw32.
 
2000-01-04 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* configure.in (ac_libiberty_warn_cflags): Turn on warnings if
we're using gcc.
 
* Makefile.in (COMPILE.c): Add @ac_libiberty_warn_cflags@
 
1999-12-27 Geoff Keating <geoffk@cygnus.com>
 
* vasprintf.c (int_vasprintf): Don't re-read the format character
as this mishandles strings like '%%s'.
 
1999-12-05 Mark Mitchell <mark@codesourcery.com>
 
* splay-tree.c (splay_tree_new): Use struct splay_tree_node_s
rather than struct splay_tree_node.
(splay_tree_insert): Use struct splay_tree_s rather than struct
splay_tree.
 
Sun Nov 28 00:59:39 1999 Philippe De Muyter <phdm@macqel.be>
 
* hashtab.c (sys/types.h): File included.
 
1999-11-22 Jason Merrill <jason@casey.cygnus.com>
 
* strtoul.c, strtol.c, random.c: Remove advertising clause from
BSD license, pursuant with
 
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
 
Wed Nov 10 09:42:39 1999 Jeffrey A Law (law@cygnus.com)
 
* hashtab.c: Include stdio.h.
 
Mon Nov 8 09:23:41 1999 Jeffrey A Law (law@cygnus.com)
 
* hashtab.c (traverse_hash_table): Protect prototype with PARAMS.
 
Tue Nov 2 03:23:13 1999 Philippe De Muyter <phdm@macqel.be>
 
* xstrdup (sys/types.h): Include this file.
 
1999-10-28 Nathan Sidwell <nathan@acm.org>
 
* Makefile.in (SUBDIRS): New macro.
(mostlyclean, clean, distclean, maintainer-clean): Adjust to
avoid multiple subdirectory cleaning.
(*-subdir): Use SUBDIRS.
 
1999-10-25 Jim Kingdon <http://developer.redhat.com/>
 
* cplus-dem.c: Move declarations of standard_symbol_characters and
hp_symbol_characters inside #ifdef MAIN to avoid compiler
warnings.
 
1999-10-23 08:51 -0700 Zack Weinberg <zack@bitmover.com>
 
* hashtab.c (find_hash_table_entry): When returning a
DELETED_ENTRY slot, change it to EMPTY_ENTRY first.
(clear_hash_table_slot): New function which deletes an entry
by its position in the table, not its value.
(traverse_hash_table): New function which calls a hook
function for every live entry in the table.
 
1999-10-19 Mark Mitchell <mark@codesourcery.com>
 
* cplus-dem.c (INTBUF_SIZE): New macro.
(string_append_template_idx): New function.
(demangle_expression): Likewise.
(demangle_integral_value): Use it.
(demangle_real_value): New function, split out from ...
(demangle_template_value_parm): ... here. Use
string_append_template_idx. Use demangle_real_value.
(demangle_template): Use string_append_template_idx.
(demangle_qualified): Use consume_count_with_underscores.
(get_count): Tweak formatting.
(do_type): Use string_append_template_idx.
 
1999-10-18 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* calloc.c: Add a public domain notice.
 
Mon Oct 18 02:30:47 1999 Philippe De Muyter <phdm@macqel.be>
 
* setenv.c (sys/types.h, stdio.h): Include those files unconditionaly.
 
Fri Oct 15 01:47:51 1999 Vladimir Makarov <vmakarov@loony.cygnus.com>
 
* Makefile.in (CFILES): Add hashtab.c
(REQUIRED_OFILES): Add hashtab.o
(hashtab.o): Add dependencies.
* hashtab.c: New file
 
Wed Oct 13 01:16:47 1999 Mumit Khan <khan@xraylith.wisc.edu>
 
* basename.c (DIR_SEPARATOR): New macro.
(DIR_SEPARATOR_2): Likewise.
(HAVE_DOS_BASED_FILESYSTEM): Likewise.
(IS_DIR_SEPARATOR): Likewise.
(main): Handle MSDOS style pathname.
 
1999-10-11 Mark Mitchell <mark@codesourcery.com>
 
* cplus-dem.c (do_type): Handle pointer to member types whose
enclosing classes have namespace scope.
 
Sun Oct 10 01:23:50 1999 Marc Espie <espie@cvs.openbsd.org>
 
* config.table: Provide a backup shell for executing move-if-change.
 
1999-10-02 Mark Mitchell <mark@codesourcery.com>
 
* xmalloc.c (xmalloc): Fix spelling error.
(xcalloc, xrealloc): Likewise.
 
1999-10-02 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* cplus-dem.c (fancy_abort, demangle_integral_value,
demangle_arm_hp_template, recursively_demangle,
standard_symbol_characters, hp_symbol_characters, main): Add prototype.
(program_name, program_version, fatal): Constify a char*.
(usage, fatal): Mark with ATTRIBUTE_NORETURN.
(main): Call return, not exit.
 
1999-09-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* choose-temp.c: Remove obsolete comment about gcc.
(make_temp_file): Constify a char*.
 
Wed Sep 8 20:03:28 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* xmemdup.c: Include sys/types.h.
 
1999-09-07 Jeff Garzik <jgarzik@pobox.com>
 
* xmemdup.c: New xmemdup function.
* Makefile.in, makefile.vms, vmsbuild.com: Use xmemdup.[co].
 
Tue Sep 7 23:32:18 1999 Linas Vepstas <linas@linas.org>
 
* config.table: Add openedition target.
* config/mh-openedition: New file.
 
Thu Sep 2 01:36:12 1999 Marc Espie <espie@cvs.openbsd.org>
 
* pexecute.c (pexecute): Fill in temp_base when needed.
 
1999-08-31 Richard Henderson <rth@cygnus.com>
 
* getpwd.c: Check HAVE_GETCWD before defining it away.
 
1999-08-30 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* Makefile.in (CFILES): Add calloc.c and getpwd.c.
(REQUIRED_OFILES): Add getpwd.o.
(getpwd.o): Add target.
 
* configure.in (AC_PREREQ): Bump to 2.13.
(AC_CHECK_HEADERS): Add check for <sys/stat.h>.
 
* getpwd.c: New file, moved here from gcc.
 
1999-08-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* cplus-dem.c (gnu_special): Cast a `size_t' to `long' when
comparing against a signed quantity.
(arm_special): Likewise.
(demangle_fund_type): Likewise.
(do_hpacc_template_const_value): Mark parameter `work' with
ATTRIBUTE_UNUSED.
(main): Constify variable `valid_symbols'.
 
Tue Aug 24 02:50:45 1999 Philippe De Muyter <phdm@macqel.be>
 
* strtoul.c (strtoul): Add parentheses around && within ||.
 
Fri Aug 6 23:32:29 1999 Daniel Jacobowitz <drow@drow.them.org>
 
* Makefile.in (FLAGS_TO_PASS): Include prefix, exec_prefix,
libdir, libsubdir and tooldir.
 
1999-08-01 Mark Mitchell <mark@codesourcery.com>
 
* splay-tree.c (splay_tree_insert): Return the new node.
 
1999-07-14 Richard Henderson <rth@cygnus.com>
 
* argv.c: Include stdlib.h and string.h instead of
prototyping directly.
* choose-temp.c: Conditionally include string.h.
 
1999-07-12 Jason Merrill <jason@yorick.cygnus.com>
 
* Makefile.in (NEEDED): Add bcmp, bcopy, bzero.
 
1999-07-11 Ian Lance Taylor <ian@zembu.com>
 
* splay-tree.c (splay_tree_insert): Add initialization to avoid
warning.
 
1999-07-07 Jason Merrill <jason@yorick.cygnus.com>
 
* Makefile.in (needed-list): Only include stuff we actually need
for libstdc++.
 
1999-06-21 Andreas Schwab <schwab@issan.cs.uni-dortmund.de>
 
* configure.in (checkfuncs): Add gettimeofday.
* config.in, configure: Regenerated.
 
Mon Jun 21 05:56:01 1999 Mumit Khan <khan@xraylith.wisc.edu>
 
* configure.in (*-*-uwin*): UWIN has sys_{errlist,nerr} even if
the test fails.
* configure: Regenerate.
 
1999-06-10 Mike Stump <mrs@wrs.com>
 
* Makefile.in (setenv.o): Add config.h dep for setenv.o to fix
parallel builds.
 
1999-05-28 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* putenv.c: Include ansidecl.h to define `const'.
* setenv.c: Likewise.
 
Wed May 26 03:58:20 1999 "Melissa O'Neill" <oneill@cs.sfu.ca>
 
* Makefile.in (CFILES): Add putenv.c and setenv.c.
* configure.in (funcs): Add putenv and setenv.
(AC_CHECK_FUNCS): Check for putenv and setenv.
* configure: Rebuilt.
* putenv.c setenv.c: New files.
 
* getcwd.c (getcwd): If pathname is NULL, then obtain SIZE
bytes of space using malloc.
 
Mon May 17 01:42:34 1999 Stu Grossman <grossman@babylon-5.cygnus.com>
 
* cplus-dem.c (demangle_fund_type (near 'I' case)): Don't advance
the *mangled pointer beyond the end of the string. Clean up code to
match prevailing coding style.
 
1999-05-13 Michael Hayes <m.hayes@elec.canterbury.ac.nz>
 
* tmpnam.c (L_tmpnam): Fix typo.
 
Thu May 13 01:14:46 1999 Marc Espie <espie@cvs.openbsd.org>
 
* cplus-dem.c (standard_symbol_characters): Renamed from
standard_symbol_alphabet. No longer modify TABLE.
(hp_symbol_characters): Renamed from hp_symbol_alphabet. No longer
modify TABLE.
(main): Corresponding changes. Use strchr to determine if a
character is valid.
 
1999-05-11 Jim Blandy <jimb@zwingli.cygnus.com>
 
* cplus-dem.c (main): Use table lookup to distinguish identifier
characters from non-identifier characters.
(standard_symbol_alphabet, hp_symbol_alphabet): New functions.
 
Thu May 6 20:34:42 1999 Fred Fish <fnf@be.com>
 
* configure.in (sys/resource.h): Add to AC_CHECK_HEADERS list.
* getruntime.c: Only attempt to include sys/resource.h and
use getrusage if both HAVE_GETRUSAGE and HAVE_SYS_RESOURCE_H
are defined.
 
Mon Apr 26 01:36:06 1999 Donn Terry (donn@interix.com)
 
* configure.in (alloca detection): Handle alloca directly for interix.
* configure: Rebuilt.
 
Sun Apr 25 01:18:21 1999 Mumit Khan <khan@xraylith.wisc.edu>
 
* choose-temp.c (DIR_SEPARATOR): Use '\\' only for native windows32.
 
1999-04-20 Jim Blandy <jimb@zwingli.cygnus.com>
 
Fix from Dale Hawkins:
* cplus-dem.c (mop_up): Set typevec_size to zero, so it'll be
reallocated properly if we use it again.
 
* cplus-dem.c (demangle_fund_type): Check for buffer overrun. Be
stricter about syntax. Always null-terminate string.
 
Thu Apr 15 23:00:55 1999 Mumit Khan <khan@xraylith.wisc.edu>
 
* configure.in (checkfuncs): Check for sbrk.
* config.in: Rebuilt.
* configure: Likewise.
* xmalloc.c: Use HAVE_SBRK instead of the host specific definitions.
 
1999-04-12 Jim Blandy <jimb@zwingli.cygnus.com>
 
Fix from Marcus Daniels:
* cplus-dem.c (demangle_fund_type): Don't run off the end of the
identifier looking for another underscore.
 
Sun Apr 11 23:20:59 1999 Mumit Khan <khan@xraylith.wisc.edu>
 
* pexecute.c: Change all references to __UWIN__ to _UWIN.
* xmalloc.c: Likewise.
(xcalloc): UWIN has sbrk.
(xrealloc): Fix guard macro.
 
1999-04-11 Richard Henderson <rth@cygnus.com>
 
* alloca-conf.h (alloca) [C_ALLOCA]: Don't use Gcc builtin
or <alloca.h>.
* clock.c (GNU_HZ): New definition.
(clock): Use it.
* getruntime.c: Likewise.
 
* config.table: Use mh-beos.
* config/mh-beos: New file.
 
1999-04-11 Mark Mitchell <mark@codesourcery.com>
 
* cplus-dem.c (demangle_template_value_parm): Handle
pointers-to-members.
(do_type): Handle template parameters as qualifiers.
 
1999-04-01 Jim Blandy <jimb@zwingli.cygnus.com>
 
* cplus-dem.c: Attempt to handle overflows in counts with some
semblance of grace.
(consume_count): Detect overflows. Return -1 to indicate errors,
instead of zero.
(demangle_template_value_parm, demangle_template): Handle change
to consume_count's return convention.
 
1999-04-05 Tom Tromey <tromey@cygnus.com>
 
* testsuite/regress-demangle: New file.
* testsuite/demangle-expected: New file.
 
* Makefile.in (all, check, installcheck, info, install-info,
clean-info, dvi, install, etags, tags, mostlyclean, clean,
distclean, maintainer-clean, realclean): Depend on corresponding
`-subdir' target.
(all-subdir check-subdir installcheck-subdir info-subdir
install-info-subdir clean-info-subdir dvi-subdir
install-info-subdir etags-subdir mostlyclean-subdir clean-subdir
distclean-subdir maintainer-clean-subdir): New target.
* testsuite/Makefile.in: New file.
* configure: Rebuilt.
* configure.in: Create testsuite/Makefile.
 
1999-04-02 Mark Mitchell <mark@codesourcery.com>
 
* splay-tree.h (splay_tree_compare_pointers): Define.
 
1999-03-30 Mark Mitchell <mark@codesourcery.com>
 
* splay-tree.c (splay_tree_compare_ints): Define.
 
1999-03-30 Tom Tromey <tromey@cygnus.com>
 
* cplus-dem.c (consume_count): If `count' wraps, return 0 and
don't advance input pointer.
(demangle_class_name): If consume_count didn't find a count, do
nothing. Don't bother with `strlen' sanity check; consume_count
does it for us.
 
1999-03-16 Stan Shebs <shebs@andros.cygnus.com>
 
From Art Haas <ahaas@neosoft.com>:
* cplus-dem.c (demangle_prefix): Don't grab all the '__' strings
when doing arm or hp style.
(demangle_nested_args): Decr forgetting_types field when done.
 
Thu Mar 11 01:22:58 1999 Mumit Khan <khan@xraylith.wisc.edu>
 
* pexecute.c (__CYGWIN32__): Rename to
(__CYGWIN__): this.
* xmalloc.c: Likewise.
 
Changes to support i386-pc-uwin.
* configure.in (*-*-uwin*): Workaround for vfork bug.
* configure: Regenerate.
* pexecute.c (pexecute): Be like standard Unix.
(pwait): Likewise.
* xmalloc.c (first_break): Define.
(xmalloc_set_program_name): Use.
(xmalloc): Use.
 
Thu Mar 11 01:07:55 1999 Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
 
* config.table: Cleanup and add mh-*pic handling for alpha, arm, powerpc
 
Sun Feb 28 22:30:44 1999 Geoffrey Noer <noer@cygnus.com>
 
* config.table: Check cygwin*, not cygwin32*.
 
Tue Feb 9 16:39:01 1999 Dave Brolley <brolley@cygnus.com>
 
* Makefile.in: Change mkstemp -> mkstemps.
 
Tue Feb 9 01:12:27 1999 Marc Espie <Marc.Espie@liafa.jussieu.fr>
 
* Makefile.in (REQUIRED_OFILES): remove mkstemp.o
* configure.in (funcs): Check for and conditionally add mkstemps to
the list of functions libiberty will provide.
* configure: Rebuilt.
 
Wed Feb 3 00:01:15 1999 Mumit Khan <khan@xraylith.wisc.edu>
 
* clock.c (HZ): Define in terms of (ISO C) CLOCKS_PER_SEC on
platforms that don't have HZ.
* getruntime.c (HZ): Likewise.
 
Sat Jan 30 13:28:04 1999 Richard Henderson <rth@cygnus.com>
 
* Makefile.in (xstrdup.o): Depend on config.h.
 
Wed Jan 13 07:26:44 1999 H.J. Lu (hjl@gnu.org)
 
* cplus-dem.c (mop_up): Set work->previous_argument to NULL after
freeing it.
 
Wed Jan 13 14:16:36 1999 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* xstrdup.c (xstrdup): Switch from strcpy to memcpy for speed.
 
Tue Jan 5 15:58:29 1999 Elena Zannoni <ezannoni@kwikemart.cygnus.com>
 
* Makefile.in (CFILES): fix typo, splay-tree.c instead of
splay-tree.o.
 
1999-01-04 Jason Molenda (jsm@bugshack.cygnus.com)
 
* configure.in: Require autoconf 2.12.1 or higher.
 
1998-12-30 Michael Meissner <meissner@cygnus.com>
 
* random.c (NULL): Don't redefine NULL if it is already defined.
 
Tue Dec 22 09:43:35 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* argv.c (buildargv): Cast the result of alloca in assignment.
 
* 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.
(demangle_qualifier): Likewise.
(demangle_signature): Cast the argument of a ctype function to
unsigned char.
(arm_pt): Add parens around assignment used as truth value.
(demangle_arm_hp_template): Constify variable `args'.
(do_hpacc_template_const_value): Cast the argument of a ctype
function to unsigned char.
(do_hpacc_template_literal): Remove unused variable `i'.
(snarf_numeric_literal): Constify parameter `args'.
Cast the argument of a ctype function to unsigned char.
 
* floatformat.c (floatformat_to_double): Add explicit braces to
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.
 
* objalloc.c (free): Add prototype.
 
Sun Dec 20 16:03:46 1998 Hans-Peter Nilsson <hp@axis.se>
 
* Makefile.in (CFILES): Fix typo: splay-tree.c, not splay-tree.o
 
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.
(do_hpacc_template_literal): remove unused variable `i'.
 
Fri Dec 18 16:11:43 EST 1998 Andrew MacLeod <amacleod@cygnus.com>
 
* cplus-dem.c (demangle_fund_type): Process CV and u codes before
bumping the pointer we read from. Also prepend these codes,
as we do in other places.
 
1998-12-18 Nick Clifton <nickc@cygnus.com>
 
* cplus-dem.c (demangle_arm_hp_template): Make variable 'args' be
'const char *' in order to match its usage when calling siblings.
(snarf_numeric_literal): Make first arg 'const char **' in order
to match usage.
 
Mon Dec 14 09:55:50 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* choose-temp.c: Don't check IN_GCC anymore.
 
* floatformat.c (floatformat_from_double): Use `const', not `CONST'.
* memchr.c (memchr): Likewise.
* memcpy.c (memcpy): Likewise.
* memmove.c (memmove): Likewise.
 
* mkstemp.c: Don't check IN_GCC anymore.
* pexecute.c: Likewise.
* splay-tree.c: Likewise.
 
* strchr.c (strchr): Use `const', not `CONST'.
* strrchr.c (strrchr): Likewise.
* strtol.c (strtol): Likewise.
* strtoul.c (strtoul): Likewise.
 
Fri Dec 4 13:51:04 1998 David Taylor <taylor@texas.cygnus.com>
Elena Zannoni <ezannoni@cygnus.com>
Stan Shebs <shebs@cygnus.com>
Edith Epstein <eepstein@cygnus.com>
Andres MacLeod <amacleod@cygnus.com>
Satish Pai <pai@apollo.hp.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.
(work_stuff): add temp_start field; add field for volatile member
function.
(arm_pt): handle ARM_DEMANGLING and EDG_DEMANGLING styles; HP
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_class): new local variable : save_class_name_end Don't
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.
(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.
(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.
(do_hpacc_template_const_value): new function. Handle template's
value param for HP/aCC.
(do_hpacc_template_literal): new function. Handle a template's
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.
 
Sat Nov 28 17:25:22 1998 Christopher Faylor <cgf@cygnus.com>
 
* pexecute.c: Remove obsolete ifdefed cygwin code.
 
Fri Nov 27 13:26:06 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* choose-temp.c: Always include libiberty.h. Avoid redundancies.
* cplus-dem.c: Likewise. Conform to libiberty.h.
* pexecute.c: Likewise.
* splay-tree.c: Likewise.
 
1998-11-25 Mike Stump <mrs@wrs.com>
 
* Makefile.in (splay-tree.o): Add config.h dependency.
 
Mon Nov 23 16:59:49 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* configure.in: Use AC_PREREQ(2.12.1).
 
1998-11-16 Benjamin Kosnik <bkoz@haight.constant.com>
 
* cplus-dem.c (demangle_fund_type): Add demangling for C9x types.
 
Thu Nov 19 22:15:50 1998 Jeffrey A Law (law@cygnus.com)
 
* mpw.c (mpw_access): Add missing parens.
 
Thu Nov 19 12:59:21 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* configure.in: Call AC_HEADER_SYS_WAIT.
 
* pexecute.c: Include sys/wait.h when !IN_GCC.
 
Thu Nov 19 14:38:20 1998 Geoffrey Noer <noer@cygnus.com>
 
* pexecute.c: revert back to checking old Cygwin
preprocessor symbol until some time has passed.
 
Wed Nov 18 08:52:26 1998 Christopher Faylor <cgf@cygnus.com>
 
* pexecute.c: Reorganize WIN32 case to accomodate Cygwin
since it will now support similar constructs.
 
Fri Nov 13 19:18:05 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* configure.in: Check for calloc.
 
* calloc.c: New file.
 
* xmalloc.c (xcalloc): New function.
 
Fri Nov 13 08:51:46 EST 1998 Andrew MacLeod <amacleod@cygnus.com>
 
*cplus-dem.c (demangle_prefix): Use the last "__"
in the mangled name when looking for the signature. This allows
template names to begin with "__".
 
1998-11-08 Mark Mitchell <mark@markmitchell.com>
 
* cplus-dem.c (type_kind_t): Add tk_reference.
(demangle_template_value_parm): Handle it.
(do_type): Use it for references, instead of tk_pointer.
 
* cplus-dem.c (demangle_template_value_parm): Use cplus_demangle,
not internal_cplus_demangle.
 
Sat Nov 7 16:02:10 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* choose-temp.c: Don't include gansidecl.h.
* mkstemp.c: Likewise.
* pexecute.c: Likewise.
 
Mon Nov 2 15:05:33 1998 Geoffrey Noer <noer@cygnus.com>
 
* configure.in: detect cygwin* instead of cygwin32*
* configure: regenerate
 
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.
 
1998-10-26 Mark Mitchell <mark@markmitchell.com>
 
* splay-tree.c: Tweak include directives to make sure declarations of
xmalloc and free are available.
 
1998-10-25 Mark Mitchell <mark@markmitchell.com>
 
* cplus-dem.c (gnu_special): Fix handling of virtual tables in
anonymous namespaces.
 
1998-10-23 Mark Mitchell <mark@markmitchell.com>
 
* cplus-dem.c (work_stuff): Replace const_type and volatile_type
with type_quals.
(TYPE_UNQUALIFIED): New macro.
(TYPE_QUAL_CONST): Likewise.
(TYPE_QUAL_VOLATILE): Likewise.
(TYPE_QUAL_RESTRICT): Likewise.
(code_for_qualifier): New function.
(qualifier_string): Likewise.
(demangle_qualifier): Likewise.
(internal_cplus_demangle): Use them.
(demangle_signature): Likewise.
(demangle_template_value_parm): Likewise.
(do_type): Likewise.
(demangle_fund_type)): Likewise.
 
Thu Oct 22 19:58:43 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* splay-tree.c (splay_tree_foreach_helper): Make definition static
to match prototype.
 
1998-10-21 Mark Mitchell <mark@markmitchell.com>
 
* splay-tree.c: New file.
* Makefile.in (CFILES): Add it.
(REQUIRED_OFILES): Likewise.
(splay-tree.o): Add dependencies.
 
Tue Oct 20 12:29:02 1998 Andreas Schwab <schwab@issan.cs.uni-dortmund.de>
 
* cplus-dem.c (demangle_qualified): Fix off-by-one when checking
range of 'K' index.
 
Thu Oct 15 18:51:12 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* choose-temp.c: Prototype mkstemps() when IN_GCC.
 
* cplus-dem.c (consume_count): Cast argument of ctype macro to
`unsigned char'.
(cplus_demangle_opname): Cast the result of `strlen' to (int) when
comparing against one.
(cplus_mangle_opname): Likewise.
(demangle_integral_value): Cast argument of ctype macro to
`unsigned char'.
(demangle_template_value_parm): Likewise.
(demangle_template): Initialize variable `bindex'. Cast the
result of `strlen' to (int) when comparing against one. Remove
unused variable `start_of_value_parm'.
(demangle_class_name): Cast the result of `strlen' to (int) when
comparing against one.
(demangle_prefix): Cast argument of ctype macro to `unsigned char'.
(gnu_special): Likewise. Cast the result of `strlen' to (int)
when comparing against one.
(demangle_qualified): Cast argument of ctype macro to `unsigned char'.
(get_count): Likewise.
(do_type): Likewise. Cast the result of `strlen' to (int) when
comparing against one.
(demangle_fund_type): Cast argument of ctype macro to `unsigned char'.
(demangle_function_name): Cast the result of `strlen' to (int)
when comparing against one.
 
* mkstemp.c (mkstemps): Cast variable `len' to (int) when
comparing against one.
 
Tue Oct 13 23:51:51 1998 Jeffrey A Law (law@cygnus.com)
 
* mkstemp.c: Check HAVE_SYS_TIME_H before including sys/time.h
* configure.in (AC_CHECK_HEADERS): Check for sys/time.h too.
* config.in, configure: Rebuilt.
 
* getopt.c: Check HAVE_STRINGS_H before including strings.h.
* configure.in (AC_CHECK_HEADERS): Check for strings.h too.
* config.in, configure: Rebuilt.
 
Mon Oct 12 19:15:59 1998 Geoffrey Noer <noer@cygnus.com>
 
* configure.in: in comment, call AC_EXEEXT instead of AM_EXEEXT
 
Sun Oct 11 17:36:06 1998 Michael Tiemann <tiemann@holodeck.cygnus.com>
 
* Makefile.in (cplus-dem.o, obstack.o): Depend upon config.h.
 
Thu Oct 8 23:42:08 1998 Jeffrey A Law (law@cygnus.com)
 
* Merge egcs & devo libiberty.
 
 
 
* cplus-dem.c (demangle_arm_pt): Demangle anonymous namespaces.
 
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.
 
* vasprintf.c: Include stdarg.h/varargs.h first.
 
* vprintf.c: Likewise.
 
Sat Sep 5 03:24:49 1998 Jeffrey A Law (law@cygnus.com)
 
* pexecute.c: Updates from gcc. Copy in gcc has been removed. This
is the canonical copy. Define ISSPACE if !IN_GCC.
* alloca.c, vfprintf.c, choose-temp.c, mkstemp.c, getopt.c: Similarly.
* getopt1.c, obstack.c: Similarly.
* Makefile.in: Build mkstemp.o
 
Tue Sep 1 23:12:47 1998 Christopher Faylor <cgf@cygnus.com>
 
* configure.in: Include asprintf in list of functions known not
to be in newlib.
* configure: Rebuild.
 
Wed Aug 19 14:05:01 1998 Mumit Khan <khan@xraylith.wisc.edu>
 
* cplus-dem.c (work_stuff): Add dllimported.
(demangled_prefix): Mark symbols imported from PE DLL.
(internal_cplus_demangled): Handle.
 
1998-08-17 Jason Merrill <jason@yorick.cygnus.com>
 
* cplus-dem.c (do_type): Fix simple array handling. If we fail,
stay failed.
 
Mon Aug 17 10:40:34 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* cplus-dem.c: Include config.h if it exists. Also, only
prototype malloc/realloc if we can't get stdlib.h.
 
Sat Aug 15 16:15:01 1998 Ian Lance Taylor <ian@cygnus.com>
 
* configure.in: Switch back to checking --with-target-subdir when
deciding whether to check for newlib, undoing part of July 15
change.
* configure: Rebuild.
 
Thu Aug 13 16:47:38 1998 Mark Mitchell <mark@markmitchell.com>
 
* cplus-dem.c (type_kind_t): New type.
(demangle_template_value_parm): Add type_kind_t parameter. Rely
on this paramter, rather than demangling the type again.
(demangle_integral_value): Pass tk_integral.
(demangle_template_: Pass the value returned from do_type.
(do_type): Return a type_kind_t. Pass tk_integral to
demangle_template_value_parm for array bounds.
(demangle_fund_type): Likewise.
 
Also incorporate from GCC version:
 
Tue Jul 21 13:28:19 1998 Jason Merrill <jason@yorick.cygnus.com>
 
* cplus-dem.c (do_type): Use demangle_template_value_parm for arrays.
 
Thu Aug 13 16:47:38 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* cplus-dem.c (demangle_nested_args): Make function definition
static to match the prototype.
 
Tue Jul 28 11:33:09 1998 Mark Mitchell <mark@markmitchell.com>
 
* cplus-dem.c (type_kind_t): New type.
(demangle_template_value_parm): Add type_kind_t parameter. Rely
on this paramter, rather than demangling the type again.
(demangle_integral_value): Pass tk_integral.
(demangle_template_: Pass the value returned from do_type.
(do_type): Return a type_kind_t. Pass tk_integral to
demangle_template_value_parm for array bounds.
(demangle_fund_type): Likewise.
 
Also incorporate from GCC version:
 
Tue Jul 21 13:28:19 1998 Jason Merrill <jason@yorick.cygnus.com>
 
* cplus-dem.c (do_type): Use demangle_template_value_parm for arrays.
 
Mon Jul 27 12:16:08 1998 Ian Lance Taylor <ian@cygnus.com>
 
* Makefile.in (ALLOCA): New variable.
($(TARGETLIB)): Add $(ALLOCA) to library.
(needed-list): Add $(ALLOCA).
($(ALLOCA)): Depend upon stamp-picdir.
 
Sun Jul 19 08:23:17 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* cplus-dem.c (demangle_nested_args): Make function definition
static to match the prototype.
 
Wed Jul 15 00:12:58 1998 Ian Lance Taylor <ian@cygnus.com>
 
* configure.in: Check --with-cross-host rather than
--with-target-subdir when deciding whether build uses a cross
compiler, and when deciding where to install the library.
* configure: Rebuild.
 
Sun Jul 12 01:27:05 1998 Jason Merrill <jason@yorick.cygnus.com>
 
* cplus-dem.c (demangle_nested_args): Return a value.
 
Sat Jul 11 16:19:48 1998 Mark Mitchell <mark@markmitchell.com>
 
* cplus-dem.c (string): Move definition before work_stuff.
(work_stuff): Add volatile_type, forgetting_types,
previous_argument, and nrepeats fields.
(SCOPE_STRING): New macro.
(demangle_template): Add `remember' parameter. Add comment.
Register the `B' code type here, if remembering. Tidy. Fix crash
on NULL tmpl_argvec. Be consistent with use of tname/trawname.
(demangle_nested_args): New function.
(internal_cplus_demangle): Handle volatile-qualified member
functions.
(mop_up): Delete the previous_argument string if present.
(demangle_signature): Tidy. Handle volatile-qualified member
functions. Handle back-references using the `B' code. Use extra
parameter to demangle_template and SCOPE_STRING where appropriate.
(demangle_template_value_parm): Fix thinko; 'B' is not an integral
code.
(demangle_class): Use SCOPE_STRING.
(gnu_special): Pass additional argument to demangle_template.
Use SCOPE_STRING.
(demangle_qualified): Save qualified types for later
back-references. Handle constructors and destructors for template
types correctly.
(do_type): Tidy. Use SCOPE_STRING. Pass extra argument to
demangle_template. Use demangled_nested_args. Don't remember
qualified types here; that's now done in demangle_qualified.
Similarly for templates.
(do_arg): Improve commment. Handle 'n' repeat code.
(remember_type): Check forgetting_types.
(demangle_args): Deal with 'n' repeat codes. Tidy.
 
Thu Jul 2 16:26:24 1998 Ian Lance Taylor <ian@cygnus.com>
 
* config.table: Only use mh-fbsd21 on *-*-freebsd2.2.[012], not on
*-*-freebsd2.2.*. From Dmitrij Tejblum <tejblum@arc.hq.cti.ru>.
 
Mon Jun 15 16:29:01 1998 Ian Lance Taylor <ian@cygnus.com>
 
* configure.in (setobjs): Correct quoting error in cygwin32 case.
From Chris Faylor <cgf@cygnus.com>.
 
Mon Jun 1 13:47:55 1998 Jason Molenda (crash@bugshack.cygnus.com)
 
* obstack.c: Update to latest FSF version.
 
Mon Jun 1 14:17:36 1998 Mike Stump <mrs@wrs.com>
 
* Makefile.in: Add a dependency on stamp-picdir for the
objects, so that we can do a parallel build.
 
Sat May 30 22:17:13 1998 Mumit Khan <khan@xraylith.wisc.edu>
 
* configure.in (checkfuncs): Add missing "'".
 
Fri May 29 12:40:41 1998 Jason Molenda (crash@bugshack.cygnus.com)
 
* obstack.c (_obstack_memory_used): Elide this function if we're
on a system with GNU libc.
 
Tue May 26 18:28:43 1998 Ian Lance Taylor <ian@cygnus.com>
 
* Makefile.in (distclean): Remove config.log.
 
Tue May 26 15:01:52 1998 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
 
* Makefile.in (distclean): Don't remove alloca-conf.h.
 
Fri May 22 01:38:07 1998 Hans-Peter Nilsson <hp@axis.se>
 
* cplus-dem.c (MBUF_SIZE): Bumped from 512 to 32767.
 
1998-05-21 Mark Mitchell <mmitchell@usa.net>
 
* cplus-dem.c (do_type): Handle volatile qualification.
 
1998-05-21 Manfred Hollstein <manfred@s-direktnet.de>
 
* configure.in: Check for unistd.h as well.
* configure: Rebuild.
* config.in: Rebuild.
* getpagesize.c (GNU_OUR_PAGESIZE): Use sysconf only if _SC_PAGESIZE
is defined in unistd.h. Reformat conditional block for easier reading.
 
* config.table (shared): Default to no if ${enable_shared}
is unset or empty; this logic is used by the toplevel
configure scripts, too.
 
Sat May 16 14:01:26 1998 Jeffrey A Law (law@cygnus.com)
 
* config.table: Add line to set enable_shared in the Makefile
as needed.
 
Wed May 13 14:24:38 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
 
* cplus-dem.c (squangle_mop_up): Change return type to void.
(internal_cplus_demangle): Remove unused parameter `options'.
All callers changed.
(cplus_demangle_opname): Remove function wide variable `int i' and
replace with `size_t i' at each location where it is used.
(cplus_mangle_opname): change type of `i' from int to size_t.
 
Wed May 13 13:39:38 1998 Ian Lance Taylor <ian@cygnus.com>
 
* alloca-conf.h: Include config.h. Check HAVE_ALLOCA_H rather
than sparc or sun.
* Makefile.in (argv.o): Depend upon config.h and alloca-conf.h.
 
Fri May 8 00:23:51 1998 Ian Lance Taylor <ian@cygnus.com>
 
* configure.in: Set libiberty_topdir correctly when srcdir is
"." and with_target_subdir is not set.
* configure: Rebuild.
 
Thu May 7 13:01:44 1998 Ian Lance Taylor <ian@cygnus.com>
 
* configure.in: Add *-*-mingw32* case.
* configure: Rebuild.
 
Wed May 6 11:33:51 1998 Ian Lance Taylor <ian@cygnus.com>
 
* config.table: Never use a PIC file for *-*-cygwin32*.
 
* Makefile.in (config.status): Depend upon config.table.
 
* configure.in: On a cygwin32 host, always compile random, and
don't test for sys_siglist, strsignal, or psignal.
* configure: Rebuild.
 
* clock.c: Check HAVE_SYS_PARAM_H rather than NO_SYS_PARAM_H.
* getcwd.c: Likewise.
* getpagesize.c: Likewise.
* getruntime.c: Likewise.
 
Tue May 5 18:08:32 1998 Ian Lance Taylor <ian@cygnus.com>
 
Use autoconf tests rather than the old dummy.c test:
* configure.in: Add AC_ARG_WITH calls for --with-target-subdir and
--with-newlib. Add AC_CONFIG_HEADER. Use AC_REPLACE_FUNCS for
most functions. Add special cases to handle newlib and VxWorks.
Remove target_makefile_frag. Create stamp-h in AC_OUTPUT if
CONFIG_HEADERS is set. Only call config-ml.in in AC_OUTPUT if
CONFIG_FILES is set; set ac_file before calling it.
* config.table (arm-*-riscix*, *-*-cygwin32): Remove.
(*-*-hpux*, *-*-hiux*, *-*-irix4*, *-*-solaris2*): Remove.
(*-*-sysv4*, *-*-go32, *-*-vxworks5*, *-*-vxworks): Remove
(i[3456]-*-mingw32*): Remove.
* Makefile.in (ERRORS_CC, CONFIG_H, NEEDED_LIST): Remove.
(LIBOBJS): New variable.
(HOST_OFILES, DO_ALSO, STAGESTUFF): Remove.
(all): Depend upon needed-list. Don't check RULE1.
(@target_makefile_frag@): Remove.
(COMPILE.c): Include @DEFS@.
(HFILES): Add alloca-conf.h.
(REQUIRED_OFILES): Remove basename.o.
($(TARGETLIB)): New target.
(stamp-needed, lneeded-list, needed.awk, stamp-config): Remove.
(lconfig.h, needed2.awk, dummy.o, errors): Remove.
(needed-list, config.h): Rewrite.
(RULE1, $(RULE1), RULE2, $(RULE2)): Remove.
(.always.): Remove.
(Makefile): Set CONFIG_FILES and CONFIG_HEADERS.
(stamp-h): New target.
(atexit.o, clock.o, getcwd.o, getpagesize.o): New targets.
(basename.o): Don't depend upon config.h.
(getruntime.o): Depend upon config.h.
* atexit.c: Include config.h. Check HAVE_ON_EXIT rather than
NEED_on_exit.
* basename.c: Don't include config.h. Don't check NEED_basename.
* clock.c: Include config.h.
* getcwd.c: Likewise.
* getpagesize.c: Likewise.
* getruntime.c: Likewise. Fix checks which set HAVE_GETRUSAGE and
HAVE_TIMES.
* strerror.c: Change uses of NEED_sys_errlist to
HAVE_SYS_ERRLIST. Likewise for NEED_strerror and HAVE_STRERROR.
* strsignal.c: Likewise for NEED_sys_siglist and HAVE_SYS_SIGLIST,
and for NEED_strsignal and HAVE_STRSIGNAL and for NEED_psignal and
HAVE_PSIGNAL.
* acconfig.h: New file.
* dummy.c: Remove.
* functions.def: Remove.
* config/mh-cxux7 (HDEFINES): Remove -DHAVE_SYSCONF.
* config/mh-windows (HDEFINES): Remove.
* config/mh-cygwin32: Remove.
* config/mh-go32: Remove.
* config/mh-irix4: Remove.
* config/mh-riscix: Remove.
* config/mh-sysv4: Remove.
* config/mt-mingw32: Remove.
* config/mt-vxworks5: Remove.
* config.in: New file, generated using autoheader.
* configure: Rebuild.
 
Mon May 4 13:00:28 1998 Ian Lance Taylor <ian@cygnus.com>
 
* configure.in: Rewrite to use autoconf.
* configure: Generate using autoconf.
* config/mh-a68bsd: Remove.
* config/mh-apollo68: Remove.
* config/mh-hpbsd: Remove.
* config/mh-ncr3000: Remove.
* config/mh-sysv: Remove.
* config/mh-aix (RANLIB, INSTALL): Don't define.
* config/mh-cxux7 (RANLIB, INSTALL): Don't define.
* config/mh-irix4 (CC, RANLIB, INSTALL): Don't define.
* 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.
(i[3456]86-ncr-sysv4*, *-*-dgux*, hppa*-hp-bsd*): Remove.
(*-*-irix*, *-*-m88kbcs*, *-*-sysv*): Remove.
* Makefile.in (srcdir): Set to @srcdir@.
(VPATH): Likewise.
(prefix, exec_prefix, bindir, libdir): Set to autoconf variables.
(SHELL, INSTALL, INSTALL_PROGRAM, INSTALL_DATA): Likewise.
(CC, CFLAGS, RANLIB)): Likewise.
(datadir, man*dir, infodir, includedir, MAKEINFO): Remove.
(target_makefile_frag, host_makefile_frag): Add substitutions.
(INSTALL_DEST): Set to @INSTALL_DEST@.
(Makefile): Depend upon config.status. Don't depend upon
$(host_makefile_frag) or $(target_makefile_frag).
(config.status): New target.
 
Sun May 3 17:58:49 1998 Ian Lance Taylor <ian@cygnus.com>
 
* config/mt-sunos4: Remove. Should be handled by --with-headers
and --with-libraries options at top level.
* config.table: Never use mt-sunos4.
 
* alloca-conf.h: New file, combining alloca-norm.h and
alloca-botch.h.
* alloca-norm.h: Remove.
* alloca-botch.h: Remove.
* configure.in: Set shell variables files and links to empty.
* config.table: Don't set shell variable files.
* configure.bat: Don't create alloca-conf.h.
* makefile.vms: Likewise.
* mpw-config.in: Likewise.
* vmsbuild.com: Likewise.
 
Fri May 1 11:41:42 1998 Ian Lance Taylor <ian@cygnus.com>
 
* Makefile.in ($(HOST_OFILES) $(REQUIRED_OFILES)): Remove old
target depending upon config.h.
(alloca.o): Add target depending upon config.h
(basename.o, choose-temp.o, fnmatch.o): Likewise.
(getopt.o, getopt1.o, pexecute.o, strerror.o): Likewise.
(strsignal.o, xstrerror.o): Likewise.
 
Fri May 1 04:26:25 1998 Peter Schauer <pes@regent.e-technik.tu-muenchen.de>
 
* cplus-dem.c (cplus_demangle_opname): Initialize work.
 
Mon Apr 27 15:53:30 EDT 1998 Andrew MacLeod <amacleod@cygnus.com>
 
* cplus-dem.c (demangle_qualified): Replace missing else.
 
Sun Apr 26 15:38:50 1998 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
 
* cplus-dem.c (gnu_special): Fix off-by-one bug when checking the
length in the name of a virtual table.
 
Wed Apr 22 10:53:49 EDT 1998 Andrew MacLeod <amacleod@cygnus.com>
 
* cplus-dem.c (struct work stuff): Add field for B and K mangle codes.
(cplus_demangle_opname): Call mop_up_squangle.
(cplus_demangle): Initialize squangle info, then call
internal_cplus_demangle. (Most code moved there as well)
(internal_cplus_demangle): New function, performs most of what use
to be done in cplus_demangle, but is only called with this file.
(squangle_mop_up): New function to clean up B and K code data.
(mop_up): set pointers to NULL after freeing.
(demangle_signature, demangle_template, demangle_class): Add
switch elements to handle K and B codes.
(demangle_prefix, gnu_special, demangle_qualified): Add
code to handle K and B codes.
(do_type, demangle_fund_type): Handle B and K codes.
(remember_Ktype): New function to store K info.
(register_Btype, remember_Btype): New functions for B codes.
(forget_B_and_K_types): New function to destroy B and K info.
 
Fri Apr 10 01:49:10 1998 Jeffrey A Law (law@cygnus.com)
 
* COPYING.LIB, choose-temp.c, cplus-dem.c: Sync with egcs & gcc.
 
Thu Mar 5 09:23:28 1998 Manfred Hollstein <manfred@s-direktnet.de>
 
* config.table: Make locating frag files failsafe even for the
special case if configuring and building in srcdir.
 
Mon Feb 23 14:33:15 1998 Ian Lance Taylor <ian@cygnus.com>
 
* choose-temp.c: Fix handling of sys/file.h to work in libiberty.
 
Sun Feb 22 18:03:23 1998 Jeffrey A Law (law@cygnus.com)
 
* choose-temp.c: Sync with copy in gcc.
 
Thu Feb 12 16:29:49 1998 Ian Lance Taylor <ian@cygnus.com>
 
* getopt.c: Update to latest FSF version.
* getopt1.c: Likewise.
 
Tue Feb 10 16:58:33 1998 Stan Shebs <shebs@andros.cygnus.com>
 
* cplus-dem.c (gnu_special): Don't get confused by .<digits>
strings that are not actually lengths.
 
Fri Feb 6 01:35:17 1998 Manfred Hollstein <manfred@s-direktnet.de>
 
* Makefile.in (FLAGS_TO_PASS): Don't pass PICFLAG.
(.c.o): Check value of enable_shared, not PICFLAG.
(stamp-picdir): Dito.
 
Thu Feb 5 18:48:56 1998 Geoffrey Noer <noer@cygnus.com>
 
* config/mh-cygwin32: remove vasprintf.o from EXTRA_OFILES
since it gets built automatically
 
Sun Feb 1 02:52:32 1998 Mike Stump <mrs@wrs.com>
 
* config.table (vxworks configs): Default to VxWorks 5.x, as that is
the currently shipping OS.
 
Tue Jan 27 16:08:20 1998 Pat Rankin <rankin@eql.caltech.edu>
 
* vmsbuild.com [REQUIRE_OFILES]: Synchronized with Makefile.in:
Add fnmatch.o and objalloc.o; remove vasprintf.o.
[config.h]: Define NEED_strsignal.
 
Mon Jan 19 12:20:01 1998 Ian Lance Taylor <ian@cygnus.com>
 
* functions.def: Correct argument types for strerror and
strsignal. Reported by Alex Gutman <agutman@emc.com>.
 
Sun Jan 18 15:57:28 1998 Michael Snyder <msnyder@cleaver.cygnus.com>
 
* vasprintf.c (int_vasprintf): Increase buffer size for float/double
values.
 
Sat Jan 17 22:28:38 1998 Mumit Khan <khan@xraylith.wisc.edu>
J.J. VanderHeijden <J.J.vanderHeijden@student.utwente.nl>
 
Add mingw32 support.
* pexecute.c (pexecute): New function for mingw32. Supports pipes.
(pwait): New function for mingw32.
 
* config.table (i[3456]86-*-mingw32*): Support for i386-mingw32.
* config/mt-mingw32: New file.
* xmalloc.c (first_break): Not used for mingw32.
(xmalloc_set_program_name): Don't use sbrk on mingw32.
(xmalloc): Likewise.
(xrealloc): Likewise.
 
Sat Jan 17 22:28:05 1998 Jeffrey A Law (law@cygnus.com)
 
* choose-temp.c: Sync with gcc version.
 
Tue Jan 13 18:34:39 1998 Jim Wilson <wilson@cygnus.com>
 
* Makefile.in (install_to_libdir, install_to_tooldir): Add MULTISUBDIR
to all filenames in libdir and tooldir.
(distclean): Do MULTICLEAN before deleting Makefile.
(stamp-needed, stamp-config): Add MULTISRCTOP to
pathname for move-if-change.
 
Thu Dec 4 17:25:19 1997 Jeffrey A Law (law@cygnus.com)
 
* strsignal.c (sys_nsig): Try NSIG and _NSIG.
 
Wed Nov 19 13:37:06 1997 Michael Meissner <meissner@cygnus.com>
 
* alloca-norm.h (alloca, GCC case): Don't redefine alloca if it
was already defined previously.
 
Mon Nov 10 12:48:03 1997 Philippe De Muyter <phdm@macqel.be>
 
* Makefile.in (INSTALL): Use ../install-sh, not install.
 
Tue Oct 28 23:41:15 1997 Judy Goldberg <jodyg@idt.net>
 
* Makefile.in (CFILES): Add pexecute.c.
 
Wed Oct 15 19:13:48 1997 Ian Lance Taylor <ian@cygnus.com>
 
* asprintf.c: Consistently use either stdarg or varargs.
 
Tue Oct 14 12:01:00 1997 Mark Mitchell <mmitchell@usa.net>
 
* cplus-dem.c (demangle_signature): Don't look for return types on
constructors. Handle member template constructors.
 
Fri Oct 3 17:53:30 1997 Ian Lance Taylor <ian@cygnus.com>
 
* README: Fix configuration instructions.
 
Mon Sep 29 12:28:41 1997 Ian Lance Taylor <ian@cygnus.com>
 
* pexecute.c: Update to current version from /gd/gnu/lib:
 
Mon Sep 29 12:27:59 1997 Ian Lance Taylor <ian@cygnus.com>
 
* pexecute.c: Use spawn if __CYGWIN32__.
 
1997-08-08 Paul Eggert <eggert@twinsun.com>
 
* pexecute.c: Include "config.h" first, as per autoconf manual.
 
Fri Jun 27 15:20:29 1997 Scott Christley <scottc@net-community.com>
 
* pexecute.c (fix_argv): New function.
(pexecute): Win32 but not Cygwin32 needs its arguments fixed.
Add underscore to cwait function call.
 
Sun Sep 28 12:00:52 1997 Mark Mitchell <mmitchell@usa.net>
 
* cplus-dem.c (demangle_template): Add new parameter. Handle new
template-function mangling.
(consume_count_with_underscores): New function.
(demangle_signature): Handle new name-mangling scheme.
 
Wed Sep 24 00:31:59 1997 Felix Lee <flee@yin.cygnus.com>
 
* asprintf.c: stdarg.h when ALMOST_STDC
* config/mh-windows (EXTRA_OFILES): add asprintf.o and
strncasecmp.o.
 
Thu Aug 28 14:27:15 1997 Andrew Cagney <cagney@b1.cygnus.com>
 
* vasprintf.c (vasprintf): Allow for _BSD_VA_LIST_.
 
* config.table: Add case for FreeBSD 2.1 and 2.2, needs mh-fbsd21.
 
* config/mh-fbsd21 (EXTRA_OFILES): Force vasprintf.o
 
Wed Sep 10 12:43:10 1997 Jason Merrill <jason@yorick.cygnus.com>
 
* cplus-dem.c (demangle_fund_type): Change "complex" to "__complex".
 
Fri Sep 5 16:34:42 1997 Andrew Cagney <cagney@b1.cygnus.com>
 
* asprintf.c (asprintf): New file.
* Makefile.in (CFILES): Add asprintf.c
* functions.def: Ditto.
 
Thu Aug 28 18:53:34 1997 Andrew Cagney <cagney@b1.cygnus.com>
 
* argv.c (dupargv): New function, duplicate an argument vector.
 
Tue Aug 19 20:28:45 1997 Geoffrey Noer <noer@cygnus.com>
 
* config/mh-cygwin32: also build random.o
 
Tue Aug 19 17:10:56 1997 Jason Merrill <jason@yorick.cygnus.com>
 
* cplus-dem.c: Add 'extern' to prepends_underscore.
 
Wed Jul 30 11:42:19 1997 Per Bothner <bothner@cygnus.com>
 
* cplus-dem.c: Various changes to produce Java output when passed
DMGL_JAVA. Thus "::" becomes "." and "JArray<Foo>" becomes "Foo[]".
(main): Support --java and -j flags to set DMGL_JAVA.
 
Tue Jul 22 19:05:23 1997 Robert Hoehne <robert.hoehne@Mathematik.TU-Chemnitz.DE>
 
* config/mh-go32 (CC, AR, RANLIB): Don't define.
 
Tue Jul 22 17:49:54 1997 Ian Lance Taylor <ian@cygnus.com>
 
* Makefile.in (REQUIRED_OFILES): Add pexecute.o.
(pexecute.o): New target.
 
* Makefile.in (stamp-needed): New target, replacing needed-list.
(needed-list): Just depend upon stamp-needed.
(stamp-config): New target, replacing config.h.
(config.h): Just depend upon stamp-config.
(mostlyclean): Remove stamp-*.
 
Thu Jun 12 11:00:18 1997 Angela Marie Thomas (angela@cygnus.com)
 
* Makefile.in (FLAGS_TO_PASS): pass INSTALL, INSTALL_PROGRAM and
INSTALL_DATA for multilibbed installs
 
Tue Jun 3 13:21:05 1997 Doug Evans <dje@canuck.cygnus.com>
 
Tue Dec 10 09:44:57 1996 Paul Eggert <eggert@twinsun.com>
 
* choose-temp.c (choose_temp_base): Don't dump core if TMPDIR is empty.
 
* choose-temp.c (try): Insist that temp dir be searchable.
 
Wed Oct 23 17:36:39 1996 Doug Rupp (rupp@gnat.com)
 
* choose-temp.c (choose_temp_base): On VMS, use proper syntax
for current directory.
 
Sat Feb 15 19:03:48 1997 Geoffrey Noer (noer@cygnus.com)
 
* pexecute.c: Remove special cases for cygwin32.
(pwait): Remove local definition of `pid'.
 
Tue Nov 12 18:26:15 1996 Doug Rupp (rupp@gnat.com)
 
* pexecute.c (vfork): Supply new definition for VMS.
(pwait): Use waitpid instead of wait for VMS.
 
Tue May 20 14:02:20 1997 Brendan Kehoe <brendan@lisa.cygnus.com>
 
* cplus-dem.c (do_type): Handle `J'.
(demangle_fund_type): Print "complex" for it.
 
Wed Apr 30 12:15:45 1997 Jason Merrill <jason@yorick.cygnus.com>
 
* configure.in: Don't turn on multilib here.
 
Mon Apr 28 19:04:31 1997 Michael Snyder <msnyder@cleaver.cygnus.com>
 
* obstack.c: move _obstack_memory_used outside of ifdef. Cannot be
elided; needed by gdb and not present in libc.
 
Thu Apr 24 19:33:47 1997 Ian Lance Taylor <ian@cygnus.com>
 
* Makefile.in (clean): Remove tmpmulti.out.
 
Tue Apr 22 10:25:15 1997 Fred Fish <fnf@cygnus.com>
 
* floatformat.c (floatformat_ieee_double_littlebyte_bigword):
Add new floatformat, mainly for ARM doubles.
 
Mon Apr 14 12:11:16 1997 Ian Lance Taylor <ian@cygnus.com>
 
* config.table: Use ${config_shell} with ${moveifchange}. From
Thomas Graichen <graichen@rzpd.de>.
 
Fri Apr 4 03:09:24 1997 Ulrich Drepper <drepper@cygnus.com>
 
* configure.in: Enable multilibing by default.
Update multilib template to read config-ml.in.
 
Tue Apr 1 16:26:39 1997 Klaus Kaempf <kkaempf@progis.de>
 
* makefile.vms: Add objalloc.
 
Mon Mar 31 23:57:51 1997 H.J. Lu <hjl@gnu.ai.mit.edu>
 
* cplus-dem.c (demangle_it): Add prototype declaration.
(usage, fatal): Likewise.
 
* xexit.c (_xexit_cleanup): Add prototype.
 
* strerror.c (init_error_tables): Declare.
 
Fri Mar 28 11:43:20 1997 H.J. Lu <hjl@lucon.org>
 
* functions.def: Add DEF of vasprintf, and DEFFUNC of strsignal.
* strsignal.c: Only define strsignal if NEED_strsignal.
* Makefile.in (REQUIRED_OFILES): Remove vasprintf.o.
* configure.in: Add NEED_strsignal to xconfig.h. Add vasprintf.o
to xneeded-list.
* config/mh-cygwin32 (HDEFINES): Add -DNEED_strsignal.
(EXTRA_OFILES): Define to vasprintf.o.
* config/mh-windows (HDEFINES): Add -DNEED_strsignal.
(EXTRA_OFILES): Add vasprintf.o.
* config/mt-vxworks5 (vxconfig.h): Define NEED_strsignal.
(vxneeded-list): Add vasprintf.o.
 
Thu Mar 20 17:02:09 1997 Ian Lance Taylor <ian@cygnus.com>
 
* objalloc.c: Include <stdio.h>.
 
Mon Mar 17 19:23:11 1997 Ian Lance Taylor <ian@cygnus.com>
 
* objalloc.c: New file.
* Makefile.in (CFILES): Add objalloc.c
(REQUIRED_OFILES): Add objalloc.o.
(objalloc.o): New target.
 
Sat Mar 15 18:49:41 1997 Ian Lance Taylor <ian@cygnus.com>
 
* obstack.c: Update to current FSF version.
 
Fri Mar 14 14:18:47 1997 Ian Lance Taylor <ian@cygnus.com>
 
* cplus-dem.c: Add prototypes for all static functions.
(mystrstr): Make static. Make arguments and result const.
(cplus_match): Remove; not used.
 
Tue Mar 11 14:20:31 1997 Brendan Kehoe <brendan@lisa.cygnus.com>
 
* cplus-dem.c (gnu_special): Call demangled_fund_type for other
__t* symbols.
 
Tue Mar 11 15:41:21 1997 H.J. Lu <hjl@lucon.org>
 
* spaces.c: Declare malloc and free properly.
* strsignal.c (init_signal_tables): Add prototype.
* xatexit.c (_xexit_cleanup): Add parameter declarations.
 
Wed Feb 19 15:43:24 1997 Brendan Kehoe <brendan@lisa.cygnus.com>
 
* Makefile.in (lneeded-list): If alloca.o is needed, xexit.o is
also required because of xmalloc.o.
 
Fri Feb 14 13:43:38 1997 Ian Lance Taylor <ian@cygnus.com>
 
* strsignal.c: Unconditionally redefine sys_siglist around the
inclusion of the system header files.
 
Thu Feb 13 22:01:04 1997 Klaus Kaempf <kkaempf@progis.de>
 
* makefile.vms: Remove 8 bit characters. Update to latest
gcc release.
 
Tue Feb 4 11:52:19 1997 Ian Lance Taylor <ian@cygnus.com>
 
* strsignal.c: Use NEED_sys_siglist instead of
LOSING_SYS_SIGLIST.
* config.table: Don't use mh-lynxos.
* config/mh-lynxos: Remove.
 
Thu Jan 16 14:51:03 1997 Bob Manson <manson@charmed.cygnus.com>
 
* cplus-dem.c: Fix indenting; make identical to the copy
in GCC.
(do_type, case 'M'): Check for a template as well as a class.
 
Thu Dec 19 13:51:33 1996 Brendan Kehoe <brendan@lisa.cygnus.com>
 
* config/mt-vxworks5 (vxneeded-list): Remove sigsetmask.o, since
vxworks 5.[0-3] all have sigsetmask in them; the one provided by
libiberty is incorrect, as well.
 
Mon Dec 2 15:03:42 1996 Michael Meissner <meissner@tiktok.cygnus.com>
 
* alloca.c (alloca): When compiled with an ANSI/ISO compiler,
alloca takes a size_t argument, not just unsigned.
 
Mon Nov 18 15:42:08 1996 Jason Merrill <jason@yorick.cygnus.com>
 
* cplus-dem.c: Note that this file also lives in GCC.
 
Mon Nov 18 15:19:00 1996 Dawn Perchik <dawn@critters.cygnus.com>
 
* alloca.c: Remove include of libiberty.h for hpux.
* argv.c: Replace defs from libiberty.h.
* spaces.c: Put back externs from removed from libiberty.h.
* vasprintf.c: Remove include of libiberty.h for hpux.
 
Mon Nov 18 14:08:00 1996 Dawn Perchik <dawn@critters.cygnus.com>
 
* cplus-dem.c: Checking in again; last checkin filed due to sticky tag.
 
Wed Nov 13 08:22:00 1996 Dawn Perchik <dawn@critters.cygnus.com>
 
* cplus-dem.c: Revert last two commits due to conflicts with
hpux system headers.
 
Wed Nov 13 08:22:00 1996 Dawn Perchik <dawn@critters.cygnus.com>
 
* alloca.c, argv.c, spaces.c, strcasecmp.c, vasprintf.c, vprintf.c:
Revert last commit due to conflicts with hpux system headers.
 
Wed Nov 13 10:36:50 1996 Michael Meissner <meissner@tiktok.cygnus.com>
 
* cplus-dem.c (x{m,re}alloc): Make declarations compatibile with
libiberty.h when compiled with a standard compiler.
 
Tue Nov 12 16:31:00 1996 Dawn Perchik <dawn@critters.cygnus.com>
 
* alloca.c: Include libiberty.h for definition of xmalloc.
Don't redefine NULL.
* argv.c: Move prototypes to libiberty.h.
* cplus-dem.c: Include libiberty.h for definition of xmalloc.
Don't redefine NULL.
Use casts to eliminate compiler warnings.
* spaces.c: Remove prototypes for malloc and free which are
already in libibrty.h.
* strcasecmp.c: Use casts to eliminate compiler warnings.
* vasprintf.c: Include libiberty.h for definition of malloc.
Don't redefine NULL.
* vprintf.c: Include stdarg.h if __STDC__.
 
Fri Oct 11 15:42:12 1996 Stu Grossman (grossman@critters.cygnus.com)
 
* config/mh-windows: Add strcasecmp.o to EXTRA_OFILES.
 
Fri Oct 11 11:16:31 1996 Stan Shebs <shebs@andros.cygnus.com>
 
* mpw.c (mpwify_filename): Rewrite to simplify, and to handle
upward components correctly.
 
Tue Oct 8 08:55:34 1996 Stu Grossman (grossman@critters.cygnus.com)
 
* config.table, config/mh-windows: Add support for building under
MSVC (the Microsoft build environment).
 
Mon Oct 7 10:50:27 1996 Ian Lance Taylor <ian@cygnus.com>
 
* fnmatch.c: Undef const if not __STDC__.
 
Thu Oct 3 13:46:39 1996 Ian Lance Taylor <ian@cygnus.com>
 
* fnmatch.c: New file.
* Makefile.in (CFILES): Add fnmatch.c.
(REQUIRED_OFILES): Add fnmatch.o.
(fnmatch.o): New target.
 
Wed Sep 18 14:49:13 1996 Jason Merrill <jason@yorick.cygnus.com>
 
* cplus-dem.c (demangle_template): Fix handling of address args.
(gnu_special): Handle type_info stuff.
 
Fri Sep 13 17:52:55 1996 Stan Shebs <shebs@andros.cygnus.com>
 
* mpw.c (DebugPI): Make settable from the env var DEBUG_PATHNAMES.
(mpwify_filename): Handle "::/" case.
 
Thu Sep 12 13:30:40 1996 Geoffrey Noer <noer@cygnus.com>
 
* config/mh-cygwin32: new file (need -DNEED_basename and
-DNEED_sys_siglist for native NT rebuilding)
* config.table (*-*-cygwin32): new entry
* choose-temp.c: bring in sync with gcc (revert Aug 17 change)
 
Thu Aug 29 16:48:45 1996 Michael Meissner <meissner@tiktok.cygnus.com>
 
* config.table (i[345]86-*-*): Recognize i686 for pentium pro.
 
Tue Aug 27 13:47:58 1996 Stan Shebs <shebs@andros.cygnus.com>
 
* pexecute.c (pexecute) [MPW]: Remove old bogus code that
messed with arguments that included a '/', add escape chars
to double quotes, remove const decl from arg that Mac
compilers don't seem to like.
 
Sat Aug 17 04:44:27 1996 Geoffrey Noer <noer@cygnus.com>
 
* pexecute.c: Update test for win32 (&& ! cygwin32).
* choose-temp.c: fix WIN32 preprocessor defines
 
Thu Aug 15 12:26:48 1996 Stan Shebs <shebs@andros.cygnus.com>
 
* mpw-make.sed: Add @DASH_C_FLAG@ and @SEGMENT_FLAG({Default})@
to editing of default makefile rule.
 
Sun Aug 11 21:03:27 1996 Stu Grossman (grossman@critters.cygnus.com)
 
* alloca-norm.h: Include <malloc.h> if _WIN32.
* argv.c: Include non-prototyped decls for malloc and string
functions if ! _WIN32 or if __GNUC__.
 
Thu Aug 8 12:42:40 1996 Klaus Kaempf <kkaempf@progis.de>
 
* config.h-vms: New file.
* makefile.vms: Use it.
 
Wed Aug 7 17:16:12 1996 Stu Grossman (grossman@critters.cygnus.com)
 
* getopt.c (_getopt_internal): If argc is 0, just return (before
we reference *argv and segfault).
 
Mon Aug 5 01:29:08 1996 Jason Merrill <jason@yorick.cygnus.com>
 
* Makefile.in (distclean): Add multilib.out.
 
Thu Jul 18 17:40:55 1996 Ian Lance Taylor <ian@cygnus.com>
 
* alloca-norm.h: Change #ifdef sparc to #if defined (sparc) &&
defined (sun). From Andrew Gierth <ANDREWG@microlise.co.uk>.
 
Mon Jul 1 13:40:44 1996 Ken Raeburn <raeburn@cygnus.com>
 
Tue May 28 15:29:03 1996 Pat Rankin <rankin@eql.caltech.edu>
 
* vmsbuild.com (REQUIRD_OFILES): Add choose-temp.o and xstrdup.o.
 
Thu Jan 25 18:20:04 1996 Pat Rankin <rankin@eql.caltech.edu>
 
* vmsbuild.com: Changes to handle DEFFUNC(on_exit).
(do_ofiles): Allow nonexistent source file in pass 3.
(chk_deffunc): New routine.
 
Tue Jun 25 19:24:43 1996 Doug Evans <dje@canuck.cygnus.com>
 
* pexecute.c (PEXECUTE_VERBOSE): Define.
(MPW pexecute): Check flags & PEXECUTE_VERBOSE instead of verbose_flag.
 
Tue Jun 25 23:11:48 1996 Jason Molenda (crash@godzilla.cygnus.co.jp)
 
* Makefile.in (docdir): Removed.
 
Tue Jun 25 23:01:07 1996 Jason Molenda (crash@godzilla.cygnus.co.jp)
 
* Makefile.in (oldincludedir): Removed.
 
Tue Jun 25 22:50:07 1996 Jason Molenda (crash@godzilla.cygnus.co.jp)
 
* Makefile.in (datadir): Set to $(prefix)/share.
 
Thu Jun 20 21:17:52 1996 Ian Lance Taylor <ian@cygnus.com>
 
* cplus-dem.c (demangle_arm_pt): Reindent. Avoid endless loop by
checking for errors from do_type.
 
Tue Jun 18 14:36:19 1996 Klaus Kaempf <kkaempf@progis.de>
 
* makefile.vms: New file.
* xmalloc.c: If VMS, include <stdlib.h> and <unixlib.h> rather
than declaring malloc, realloc, and sbrk.
 
Mon Jun 10 13:17:17 1996 Doug Evans <dje@canuck.cygnus.com>
 
* pexecute.c: New file.
 
Wed Jun 5 16:57:45 1996 Richard Henderson <rth@tamu.edu>
 
* xmalloc.c: Declare sbrk.
 
Sat May 4 05:08:45 1996 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
 
* alloca-norm.h: Add SPARCworks cc compatible __builtin_alloca
declaration.
 
Mon Apr 22 18:41:49 1996 Ian Lance Taylor <ian@cygnus.com>
 
* xstrerror.c: Include <stdio.h>.
 
Sun Apr 21 11:55:12 1996 Doug Evans <dje@canuck.cygnus.com>
 
* Makefile.in (CFILES): Add atexit.c.
 
Sun Apr 21 09:50:09 1996 Stephen L Moshier (moshier@world.std.com)
 
* choose-temp.c: Include sys/types.h before sys/file.h for sco3.2v5.
 
Wed Apr 17 11:17:55 1996 Doug Evans <dje@canuck.cygnus.com>
 
* choose-temp.c: Don't #include sys/file.h ifdef NO_SYS_FILE_H.
#include <stdio.h>
* config/mt-vxworks5 (HDEFINES): Define NO_SYS_FILE_H.
 
Tue Apr 16 11:27:16 1996 Jeffrey A Law (law@cygnus.com)
 
* Makefile.in (lneeded-list): If alloca.o is needed, so is xmalloc.o.
Reverts Feb 8, 1995 change.
 
Mon Apr 15 12:53:26 1996 Doug Evans <dje@canuck.cygnus.com>
 
* choose-temp.c: New file.
* Makefile.in (CFILES): Add choose-temp.c.
(REQUIRED_OFILES): Add choose-temp.o.
 
Sat Apr 13 14:19:30 1996 Stu Grossman (grossman@critters.cygnus.com)
 
* floatformat.c (floatformat_to_double): Don't bias exponent when
handling zero's, denorms or NaNs.
 
Thu Apr 11 13:36:56 1996 Stu Grossman (grossman@critters.cygnus.com)
 
* floatformat.c (floatformat_to_double): Fix bugs with handling
numbers with fractions < 32 bits.
 
Mon Apr 8 14:48:34 1996 Ian Lance Taylor <ian@cygnus.com>
 
* config.table: Permit --enable-shared to specify a list of
directories.
 
Tue Mar 19 22:02:07 1996 Jason Merrill <jason@yorick.cygnus.com>
 
* cplus-dem.c (demangle_template): Fix for non-mangled pointer
arguments.
 
Fri Mar 8 17:24:18 1996 Ian Lance Taylor <ian@cygnus.com>
 
* configure.in: If srcdir is `.' and with_target_subdir is not
`.', then set MULTISRCTOP before calling config-ml.in.
 
Thu Mar 7 13:37:10 1996 Stan Shebs <shebs@andros.cygnus.com>
 
* mpw.c (mpw_open): Add debugging output option.
 
Wed Mar 6 17:36:03 1996 Jason Merrill <jason@yorick.cygnus.com>
 
* cplus-dem.c (demangle_template): Fix for address-of-extern arguments.
 
Tue Feb 27 12:00:50 1996 Raymond Jou <rjou@mexican.cygnus.com>
 
* mpw.c (mpwify_filename): Change 6 to 5 in
strncmp (unixname, "/tmp/", 5).
 
Tue Feb 20 10:55:53 1996 Ian Lance Taylor <ian@cygnus.com>
 
* cplus-dem.c (demangle_template): Initialize is_bool. Correctly
handle 0 as a pointer value parameter.
 
Mon Feb 5 16:41:44 1996 Ian Lance Taylor <ian@cygnus.com>
 
* Makefile.in (all): Depend upon required-list.
(required-list): New target.
(clean): Remove required-list.
 
Wed Jan 31 10:19:41 1996 Steve Chamberlain <sac@slash.cygnus.com>
 
* win32.c: Deleted.
* config.table (i386-*-win32): Deleted.
* config/mh-i386win32: Deleted.
 
Thu Jan 18 11:34:17 1996 Ian Lance Taylor <ian@cygnus.com>
 
* cplus-dem.c (cplus_demangle_opname): Change opname parameter to
const char *.
(cplus_mangle_opname): Change return type and opname parameter to
const char *. Don't cast return value.
 
Tue Jan 16 12:13:11 1996 Stan Shebs <shebs@andros.cygnus.com>
 
* mpw.c: Include Timer.h, in order to get m68k Microseconds trap
definition.
 
Wed Jan 3 13:15:04 1996 Fred Fish <fnf@cygnus.com>
 
* obstack.c: Update copyright to 1996.
(_obstack_memory_used): Define new function. Called via
obstack_memory_used macro.
 
Thu Dec 28 11:39:40 1995 Ian Lance Taylor <ian@cygnus.com>
 
* xstrdup.c: New file.
* Makefile.in (CFILES): Add xstrdup.c.
(REQUIRED_OFILES): Add xstrdup.o.
(xstrdup.o): New target.
 
Mon Dec 11 18:18:52 1995 Mike Stump <mrs@cygnus.com>
 
* atexit.c: New stub to provide atexit on systems that have
on_exit, like SunOS 4.1.x systems.
* functions.def (on_exit, atexit): Ditto.
 
Mon Dec 11 15:42:14 1995 Stan Shebs <shebs@andros.cygnus.com>
 
* mpw.c (mpw_abort): Remove decl.
(mpw_access): Move debugging printf.
 
Sat Dec 2 01:25:23 1995 Ian Lance Taylor <ian@cygnus.com>
 
* config.table: Consistently use ${host} rather than ${xhost} or
${target}.
* configure.in: Don't bother to set ${xhost} before calling
config.table.
 
Tue Nov 28 14:16:57 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
 
* Makefile.in (.c.o): Use test instead of the left bracket, to
avoid problems with some versions of make.
 
Tue Nov 28 11:45:17 1995 Stan Shebs <shebs@andros.cygnus.com>
 
* mpw-make.sed: Fix INCDIR edit to work with Nov 14 change.
 
Tue Nov 21 11:26:34 1995 Fred Fish <fnf@rtl.cygnus.com>
 
* config/mh-hpux: Remove. It was only used to define EXTRA_OFILES,
which was set to just alloca.o, which is now automatically marked
as needed by the autoconfiguration process.
 
Tue Nov 21 14:15:06 1995 Ian Lance Taylor <ian@cygnus.com>
 
* config.table: Check ${with_cross_host} rather than comparing
${host} and ${target}.
 
Thu Nov 16 14:34:42 1995 Ian Lance Taylor <ian@cygnus.com>
 
* configure.in: If with_target_subdir is empty, set xhost to
${host} rather than ${target} before calling config.table.
 
Tue Nov 14 01:38:30 1995 Doug Evans <dje@canuck.cygnus.com>
 
* Makefile.in (MULTITOP): Deleted.
(MULTISRCTOP, MULTIBUILDTOP): New.
(FLAGS_TO_PASS): Delete INCDIR.
(INCDIR): Add $(MULTISRCTOP).
(install_to_libdir): Add $(MULTISUBDIR). Call $(MULTIDO).
* configure.in: Delete call to cfg-ml-com.in. Call config-ml.in
instead of cfg-ml-pos.in.
(cross-compile check): Change to test for with_target_subdir.
(EXTRA_LINKS): Delete.
 
Sun Nov 12 12:13:04 1995 Stan Shebs <shebs@andros.cygnus.com>
 
* mpw-make.sed: Add getpagesize.c.o to needed-list.
* mpw.c [USE_MW_HEADERS]: Conditionalize compiling of
functions that are supplied by Metrowerks libraries.
(fstat): Clean up descriptor->pointer conversion code.
(InstallConsole, etc): Empty definitions, for when linking
with SIOUX.
 
Sun Nov 5 19:25:27 1995 Per Bothner <bothner@kalessin.cygnus.com>
 
* Makefile.in (FLAGS_TO_PASS): Also pass PICFLAGS.
(.c.o): Stylistic change.
 
Thu Nov 2 12:06:29 1995 Ian Lance Taylor <ian@cygnus.com>
 
* strtol.c, strtoul.c: Don't include <stdlib.h>. From
phdm@info.ucl.ac.be (Philippe De Muyter).
 
Wed Nov 1 11:59:36 1995 Ian Lance Taylor <ian@cygnus.com>
 
* configure.in: Correct sed call.
 
Mon Oct 30 13:03:45 1995 Per Bothner <bothner@kalessin.cygnus.com>
 
* configure.in: Clean up / simplify for native.
 
* configure.in: Merge in stuff from ../xiberty/configure.in.
* Makefile.in (CC): Add definition (so it can be overrridden
by ../configure).
 
Tue Oct 24 17:57:27 1995 Stan Shebs <shebs@andros.cygnus.com>
 
* mpw-make.sed: Leave strerror.c.o in standard list of functions.
* mpw.c (R_OK, ENOENT, EACCESS, ENOSYS): Remove.
(link): Remove useless definition with error return.
(last_microseconds, warn_if_spin_delay, record_for_spin_delay):
Use UnsignedWide type for microsecond counts.
 
Thu Oct 19 10:52:07 1995 Michael Meissner <meissner@wogglebug.tiac.net>
 
* memcmp.c (memcmp): Argument types are const void *, not void
*const.
 
* strncasecmp.c (strncasecmp): Include ansidecl.h/stdarg.h, not
sys/types.h.
* strcasecmp.c (strcasecmp): Ditto.
 
Tue Oct 10 11:03:24 1995 Fred Fish <fnf@cygnus.com>
 
* Makefile.in (BISON): Remove macro.
 
Tue Sep 26 15:06:46 1995 Stan Shebs <shebs@andros.cygnus.com>
 
* Makefile.in (HFILES): Add default empty definition.
* mpw-config.in (config.h): Only update if changed.
* mpw-make.in: Remove.
* mpw-make.sed: New file, edits Makefile.in into MPW makefile.
* mpw.c: Remove semi-clone of strerror code.
(sys_nerr, sys_errlist): Define here.
(Microseconds): Only define as A-line trap if m68k Mac.
 
Wed Sep 20 12:53:32 1995 Ian Lance Taylor <ian@cygnus.com>
 
* Makefile.in (maintainer-clean): New synonym for distclean.
 
Mon Aug 28 19:47:52 1995 Per Bothner <bothner@kalessin.cygnus.com>
 
* config.table: For host, generalize rs6000-ibm-aix*
to *-ibm-aix* so we also include powerpc.
 
Tue Aug 22 03:18:05 1995 Ken Raeburn <raeburn@kr-laptop.cygnus.com>
 
Fri Jun 16 18:35:40 1995 Pat Rankin (rankin@eql.caltech.edu)
 
* xstrerror.c: New file.
* Makefile.in, vmsbuild.com: Compile it.
 
Mon Jul 31 12:16:32 1995 steve chamberlain <sac@slash.cygnus.com>
 
* config.table (i386-*-win32): New.
 
Fri Jul 21 11:35:52 1995 Doug Evans <dje@canuck.cygnus.com>
 
* Makefile.in (MULTITOP): New variable.
(MULTIDIRS, MULTISUBDIR, MULTIDO, MULTICLEAN): Likewise.
(all): Add multilib support.
(install_to_tooldir, *clean): Likewise.
 
Mon Jul 10 11:47:27 1995 Ken Raeburn <raeburn@cygnus.com>
 
* makefile.dos (OBJS): Add hex.o. From DJ Delorie.
 
Fri Jun 30 17:28:59 1995 Pat Rankin (rankin@eql.caltech.edu)
 
* vmsbuild.com: create "new-lib.olb", build libiberty under that
name, and then make it become "liberty.olb" when done, so that an
incomplete build attempt never leaves behind something which looks
like a complete library.
 
Thu Jun 29 00:22:02 1995 Steve Chamberlain <sac@slash.cygnus.com>
 
* config/mh-i386pe: New file for PE hosts.
* config.table: Understand PE hosts.
 
Wed Jun 28 19:13:23 1995 Jason Merrill <jason@phydeaux.cygnus.com>
 
* cplus-dem.c: Update from gcc.
 
* argv.c, dummy.c: If __STDC__, #include "alloca-conf.h" after
<stddef.h>.
* alloca-norm.h: If __STDC__, declare alloca with its parameter.
 
Thu Jun 22 18:57:47 1995 Stan Shebs <shebs@andros.cygnus.com>
 
* mpw-make.in (ALL_CFLAGS): Define NEED_basename.
* mpw.c: Only test DebugPI once whenever printing debug info.
(mpwify_filename): If filename is /tmp/foo, change it into :_foo,
also fix to not write on input filename buffer.
(mpw_access): Use stat() instead of open(), works for directories
as well as files.
 
Mon Jun 19 00:33:22 1995 Jason Merrill <jason@phydeaux.cygnus.com>
 
* Makefile.in: Massage broken shells that require 'else true'.
 
Sat Jun 17 23:21:58 1995 Fred Fish <fnf@cygnus.com>
 
* alloca-norm.h: Declare alloca as type "PTR" to match functions.def.
Declare __builtin_alloca in the sparc case, as argv.c did.
* argv.c: Replace inline version of alloca-norm.h at start of file with
a #include of alloca-conf.h. Precede it with an include of ansidecl.h
because alloca-norm.h needs to declare alloca as "PTR".
 
Mon Jun 12 14:24:26 1995 Steve Chamberlain <sac@slash.cygnus.com>
 
* win32.c: New file.
 
Fri Jun 9 15:16:14 1995 Jason Merrill <jason@phydeaux.cygnus.com>
 
* dummy.c: #include "alloca-conf.h".
 
Wed Jun 7 11:46:23 1995 Jason Merrill <jason@phydeaux.cygnus.com>
 
* Makefile.in (mostlyclean): Remove stamp-picdir.
(clean): Don't.
 
Mon Jun 5 18:46:06 1995 Jason Merrill <jason@phydeaux.cygnus.com>
 
* config.table (frags): Use toplevel pic frags.
 
* Makefile.in (PICFLAG): New macro.
(all): Depend on stamp-picdir.
(needed-list): Ditto.
(.c.o): Also build pic object.
(stamp-picdir): New rule.
(mostlyclean): Remove pic.
(clean): Remove stamp-picdir.
 
Fri Mar 24 16:55:48 1995 Pat Rankin (rankin@eql.caltech.edu)
 
* vmsbuild.com (config.h): Add `#define NEED_basename'.
 
Tue May 23 10:12:46 1995 Per Bothner <bothner@kalessin.cygnus.com>
 
* clock.c, getopt.c, strtod.c, vsprintf.c: Change from using LGPL
to libio-style copyright.
* getpagesize.c: Remove FSF copyright.
 
Sat May 20 12:30:23 1995 Ken Raeburn <raeburn@kr-laptop.cygnus.com>
 
Added improved VMS support from Pat Rankin:
 
Fri Mar 17 18:40:36 1995 Pat Rankin (rankin@eql.caltech.edu)
 
* vmsbuild.com: new file.
 
* getpagesize.c (getpagesize): implement for VMS;
* strerror.c (strerror, strerrno, strtoerrno): add rudimentary
support for EVMSERR.
 
Thu May 18 17:01:42 1995 Ken Raeburn <raeburn@kr-laptop.cygnus.com>
 
Wed May 10 14:28:16 1995 Richard Earnshaw (rearnsha@armltd.co.uk)
 
* floatformat.c (floatformat_arm_ext): Define.
 
Tue May 16 13:30:59 1995 Per Bothner <bothner@kalessin.cygnus.com>
 
* basename.c, bcmp.c, getcwd.c, insque.c, rename.c, sigsetmask.c,
strerror.c, strsignal.c: Remove FSF copyright.
* sigsetmask.c: #include <sys/types.h> - seems to be needed by ISC.
 
Mon May 15 19:53:17 1995 Per Bothner <bothner@kalessin.cygnus.com>
 
* bcopy.c, bzero.c, memcmp.c, memcpy.c, memset.c, strchr.c,
strrchr.c, strstr.c, vfork.c: Remove FSF Copyright, because this
might contaminate libstdc++ with the LGPL. (OK'd by RMS 11 Oct 94.)
* strchr.c, strrchr.c: Add cast to suppress const warning.
 
Thu May 4 14:36:42 1995 Jason Merrill <jason@phydeaux.cygnus.com>
 
* cplus-dem.c: Use const instead of CONST. Don't include
ansidecl.h directly.
 
Wed Apr 19 01:30:27 1995 Jason Merrill <jason@phydeaux.cygnus.com>
 
* cplus-dem.c: Don't include libiberty.h. Do declare xmalloc and
xrealloc.
(-DMAIN): Don't rely on an externally-defined version number;
instead, require the version number to be defined as a
preprocessor macro. Handle the RS/6000 leading dot. Define
xmalloc, xrealloc and fatal. Don't strip a leading underscore
if we couldn't demangle the word.
 
Tue Apr 4 13:03:51 1995 Stan Shebs <shebs@andros.cygnus.com>
 
(Old mpw.c change descriptions retained for informational value.)
* mpw.c (warning_threshold): Default to .4 sec.
(overflow_count, current_progress): New globals.
(warn_if_spin_delay): Include current progress type,
such as program name, in message.
(mpw_start_progress): Set current_progress variable from arg.
(mpw_end_progress): Report spin delays by power-of-two-size
buckets instead of constant-size buckets.
 
* mpw.c: Clean up formatting, types, returns, etc.
(ENOSYS): Define.
(mpw_fread, mpw_fwrite): Define.
(sleep): Define correctly.
 
* mpw.c: New code to implement cursor spinning support.
(umask): New function.
(mpw_fopen, mpw_fseek, stat, fstat): Call PROGRESS.
 
* mpw.c (mpw_basename, mpw_mixed_basename): New functions, find
basenames for MPW and MPW/Unix filenames.
(mpw_special_init): New function, calls Macsbug if desired.
 
* mpw.c: Add GPL notice.
(mpwify_filename): Add more transformations.
(mpw_fopen): Call mpwify_filename on file names.
(rename): Remove.
(chdir, getcwd): Add simple definitions.
 
* mpw.c: Random cleanups, remove unused code bits.
Added copy of strerror.c for gcc's use.
(stat, fstat, _stat): New versions based on Guido van Rossum code.
 
* mpw.c (mpw_fseek): Make it work correctly when doing SEEK_CUR.
 
* mpw.c (stat): Remove hack definition, get from sys/stat.h.
(fork, vfork, etc): Print error messages if called.
(getrusage, sbrk, environ, isatty, link, utime, mkdir, rmdir,
rename, chown): Define.
 
* mpw-config.in: New file, MPW version of configure.in.
* mpw-make.in: New file, MPW version of Makefile.in.
* mpw.c: New file, MPW compatibility routines.
 
Fri Mar 24 14:10:30 1995 Jim Kingdon (kingdon@lioth.cygnus.com)
 
* basename.c: Include config.h before checking for NEED_basename.
 
Thu Mar 23 19:09:54 1995 Jason Merrill <jason@phydeaux.cygnus.com>
 
* functions.def: Add DEFFUNC for basename.
 
* basename.c: Only define basename if NEED_basename.
 
Thu Mar 16 13:36:05 1995 Jason Merrill <jason@phydeaux.cygnus.com>
 
* config.table: Fix --enable-shared logic for native builds.
 
Mon Mar 13 11:05:11 1995 Jason Merrill <jason@phydeaux.cygnus.com>
 
* cplus-dem.c (demangle_template): Demangle bool literals properly.
 
Mon Mar 6 23:57:28 1995 Stu Grossman (grossman@cygnus.com)
 
* strtol.c strtoul.c: Replace these with less buggy versions from
NetBSD. (strtoul in particular couldn't handle base 16.)
 
Wed Mar 1 15:59:01 1995 Ian Lance Taylor <ian@cygnus.com>
 
* config/mt-vxworks5 (HDEFINES): Define NO_SYS_PARAM_H.
 
* clock.c: If NO_SYS_PARAM_H is defined, don't include
<sys/param.h>.
* getcwd.c, getpagesize.c, getruntime.c: Likewise.
 
Fri Feb 17 15:40:55 1995 Ian Lance Taylor <ian@cygnus.com>
 
* getruntime.c (get_run_time): Don't assume that CLOCKS_PER_SEC is
a number; ANSI appears to permit any expression, including a
function call.
 
* config.table (*-*-vxworks5*): Use mt-vxworks5 when configuring
xiberty.
* config/mt-vxworks5: New file.
 
Thu Feb 9 14:19:45 1995 Ian Lance Taylor <ian@cygnus.com>
 
* basename.c (basename): Change argument to be const.
 
Wed Feb 8 18:06:52 1995 Jason Merrill <jason@phydeaux.cygnus.com>
 
* Makefile.in (lneeded-list): Don't worry about xmalloc.
 
Sun Jan 15 00:40:36 1995 Jeff Law (law@snake.cs.utah.edu)
 
* Makefile.in (distclean): Delete xhost-mkfrag.
 
Thu Jan 12 16:54:18 1995 Jason Merrill <jason@phydeaux.cygnus.com>
 
* Makefile.in (lneeded-list): If alloca.o is needed, so is xmalloc.o.
 
Wed Jan 11 22:39:56 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
 
* hex.c: New file.
* Makefile.in (REQUIRED_OFILES, CFILES): List it.
(hex.o): Add dependencies.
 
* cplus-dem.c (demangle_prefix): For GNU style constructor and
destructor names, try demangling the remainder of the string.
 
Wed Dec 28 00:49:15 1994 Ian Lance Taylor <ian@tweedledumb.cygnus.com>
 
* vasprintf.c (int_vasprintf): New static function.
(vasprintf): Use int_vasprintf. Removes assumption that va_list
is assignment compatible.
 
Sat Nov 5 19:29:12 1994 Jason Merrill (jason@phydeaux.cygnus.com)
 
* Makefile.in (LIBCFLAGS): New variable.
(FLAGS_TO_PASS): Pass it.
(.c.o): Use it.
 
Thu Nov 3 19:09:47 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
 
* getopt.c, getopt1.c: Do compile these functions under Linux,
since many native versions are based on glibc but are buggy.
 
Mon Oct 24 15:16:46 1994 Per Bothner <bothner@kalessin.cygnus.com>
 
* vasprintf.c: Make 'format' arg be const, to avoid a mismatch
with prototype in GNU libc. Support stdarg.h as well as varargs.h.
 
Tue Oct 11 17:48:27 1994 Jason Merrill (jason@phydeaux.cygnus.com)
 
* Makefile.in (REQUIRED_OFILES): Add vasprintf.o.
* functions.def: Remove vasprintf.
 
Wed Sep 14 17:04:55 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
 
* xmalloc.c (first_break): New static variable.
(xmalloc_set_program_name): Record sbrk (0) in first_break.
(xmalloc): If memory allocation fails, try to report how much
memory was allocated by the program up to this point.
(xrealloc): Likewise.
 
Sun Sep 04 17:58:10 1994 Richard Earnshaw (rwe@pegasus.esprit.ec.org)
 
* Makefile.in (ERRORS_CC): New variable, defaulted to $(CC). Use it
when linking dummy.
* config.table: Add host RISCiX Makefile frag.
* config/mh-riscix: New file.
 
Thu Aug 25 17:29:44 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
 
* Makefile.in (FLAGS_TO_PASS): Define.
($(RULE1)): Use $(FLAGS_TO_PASS).
 
Wed Aug 24 17:08:47 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
 
* vasprintf.c: Include <string.h>.
(vasprintf): Add casts to void for va_arg to avoid gcc warnings.
* xatexit.c: Declare malloc.
 
Fri Aug 19 15:29:12 1994 Kung Hsu (kung@mexican.cygnus.com)
 
* cplus-dem.c (demangle_args): Fix a bug in previous patch (the
one below).
 
Thu Aug 18 14:37:14 1994 Kung Hsu (kung@mexican.cygnus.com)
 
* cplus-dem.c (demangle args): Handle ARM repeat encoding where
the type index is greater than 9.
 
Wed Aug 17 16:13:49 1994 Kung Hsu (kung@mexican.cygnus.com)
 
* cplus-dem.c (demangle_qualified): accept optional '_' between
qualified name. This is baecause the template name may end with
numeric and can mixed up with the length of next qualified name.
 
Wed Aug 3 05:52:14 1994 D. V. Henkel-Wallace (gumby@cygnus.com)
 
* config/mt-sunos4: Use our standard location for cross-includes
and cross-libs when the target is also a "host" environment (ie no
newlib; includes and such don't belong to us). This is specific
to the Cygnus Support environment.
 
Tue Aug 2 15:25:12 1994 Kung Hsu (kung@mexican.cygnus.com)
 
* cplus-dem.c (demangle_template): demangle as xxx<'Q'> not
xxx<ch=81>.
 
Mon Aug 1 17:02:48 1994 Kung Hsu (kung@mexican.cygnus.com)
 
* cplus-dem.c (main): flush stdout to make pipe work.
 
Sat Jul 16 12:56:32 1994 Stan Shebs (shebs@andros.cygnus.com)
 
* config.table (*-*-cxux7*): Recognize.
* floatformat.c (floatformat_m88110_ext) [HARRIS_FLOAT_FORMAT]:
Harris-specific float format.
* config/mh-cxux7: New file.
 
Wed Jun 29 00:26:17 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
 
* cplus-dem.c (demangle_template): Make sure that the result of
consume_count doesn't index beyond the end of the string.
 
Mon Jun 20 23:54:37 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
 
* cplus-dem.c (gnu_special): Handle vtable mangling of gcc-2.4.5 and
earlier. Improve test for new vtable mangling. Change output back
to `virtual table'.
 
Mon Jun 20 11:37:30 1994 Ian Lance Taylor (ian@sanguine.cygnus.com)
 
* obstack.c: Always compile this code, even if using the GNU
library. Avoids problems with relatively recent binary
incompatibility.
 
Thu Jun 16 17:54:01 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
 
* cplus-dem.c: Include libiberty.h.
(xmalloc, xrealloc, free): Don't declare.
(strstr): Don't declare parameters.
(xmalloc, xrealloc): Don't define.
(long_options): Add no-strip-underscores.
(main): Call xmalloc_set_program_name. Pass n in short options to
getopt_long. Handle option 'n' to not strip underscores.
(usage): Mention -n and --no-strip-underscores.
 
Sun Jun 12 01:37:09 1994 Jason Merrill (jason@deneb.cygnus.com)
 
* cplus-dem.c (demangle_template): Separate consecutive >'s with a
space.
(gnu_special): Demangle template and qualified names in a vtable name.
 
Fri May 27 12:27:52 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
 
From gas-2.3 and binutils-2.4 net releases:
 
Wed May 11 22:32:00 1994 DJ Delorie (dj@ctron.com)
 
* makefile.dos: [new] Makefile for dos/go32
* configure.bat: update for latest files
* msdos.c: remove some functions now in libc.a
 
Fri May 20 18:53:32 1994 Per Bothner (bothner@kalessin.cygnus.com)
 
* cplus-dem.c (gnu_special): Recognize thunks, as well as
the new naming style for vtables (when -fvtable-thunks).
 
Wed May 18 13:34:06 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
 
* Makefile.in (XTRAFLAGS): Don't define.
(.c.o, dummy.o): Don't use XTRAFLAGS.
($(RULE1)): Don't pass XTRAFLAGS down in recursive call.
 
Fri May 13 16:02:12 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
 
* vasprintf.c: New file.
* Makefile.in, functions.def: Add it.
 
Fri May 13 16:20:28 1994 Jason Merrill (jason@deneb.cygnus.com)
 
* cplus-dem.c (demangle_fund_type): Grok bool.
 
Fri May 6 14:44:21 1994 Steve Chamberlain (sac@cygnus.com)
 
* config.table: Add go32
* config/mh-go32: New template.
 
Fri May 6 11:01:59 1994 D. V. Henkel-Wallace (gumby@rtl.cygnus.com)
 
* config.table, config/mt-sunos4: config for when sun4 is cross target.
 
Mon Apr 11 00:54:33 1994 Richard Stallman (rms@mole.gnu.ai.mit.edu)
 
* getopt.c [not __GNU_LIBRARY__] [__GCC__] [not __STDC__]:
Declare strlen to return int. Don't include stddef.h.
 
Fri Apr 1 00:38:17 1994 Jim Wilson (wilson@mole.gnu.ai.mit.edu)
 
* getopt.c: Delete use of IN_GCC to control whether
stddef.h or gstddef.h is included.
 
Thu Apr 14 14:00:56 1994 Kung Hsu (kung@mexican.cygnus.com)
 
* cplus-dem.c (demangle_signature): Fix a bug in template function
type numbering.
 
Wed Apr 13 17:23:03 1994 Kung Hsu (kung@mexican.cygnus.com)
 
* cplus-dem.c (demangle_signature): Fix template function with arm
style argument type number, Tn.
 
Wed Apr 13 17:11:15 1994 Jason Merrill (jason@deneb.cygnus.com)
 
* cplus-dem.c (optable): Add new[] and delete[].
 
Fri Apr 8 11:21:42 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
 
* argv.c (buildargv): Don't produce empty argument just because
there is trailing whitespace.
 
Wed Apr 6 11:42:14 1994 Kung Hsu (kung@mexican.cygnus.com)
 
* cplus-dem.c (demangle_template): fix 'Q' qualified name bug.
Handle 'p' same as 'P'.
* cplus-dem.c (do_type): Handle 'p' same as 'P'.
 
Sat Mar 26 12:00:13 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
 
* floatformat.c (get_field, put_field): Fix off by one error in
little endian case.
 
Thu Mar 24 10:40:19 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
 
* floatformat.c (floatformat_from_double): Pass unsigned char *,
not char *, to put_field.
 
Fri Mar 18 12:34:33 1994 Per Bothner (bothner@kalessin.cygnus.com)
 
* memmove.c: Re-wrote; placed in public domain.
 
Wed Mar 16 10:33:07 1994 Jim Kingdon (kingdon@lioth.cygnus.com)
 
* cplus-dem.c (demangle_prefix): If ARM demangling, don't treat
__Q* as a constructor.
 
Mon Mar 14 12:26:02 1994 Ian Lance Taylor (ian@cygnus.com)
 
* ieee-float.c: Removed; no longer used.
* Makefile.in: Changed accordingly.
 
Mon Mar 7 12:28:17 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
 
* floatformat.c (get_field): Removed unused local variable i.
(put_field): Removed unused local variable i.
 
Sun Feb 27 21:50:11 1994 Jim Kingdon (kingdon@deneb.cygnus.com)
 
* floatformat.c: New file, intended to replace ieee-float.c.
* Makefile.in: Change accordingly.
 
Thu Feb 24 11:51:12 1994 David J. Mackenzie (djm@rtl.cygnus.com)
 
* getopt.c: Remove #ifdef GETOPT_COMPAT and #if 0 code.
(_getopt_initialize): New function, broken out of _getopt_internal.
(_getopt_internal):
If long_only and the ARGV-element has the form "-f", where f is
a valid short option, don't consider it an abbreviated form of
a long option that starts with f. Otherwise there would be no
way to give the -f short option.
 
Thu Feb 10 14:44:16 1994 Richard Stallman (rms@mole.gnu.ai.mit.edu)
 
* getopt.c [not __GNU_LIBRARY__] [__GNUC__] [not IN_GCC]:
Test just __STDC__, not emacs.
 
Wed Feb 9 00:14:00 1994 Richard Stallman (rms@mole.gnu.ai.mit.edu)
 
* getopt.c [not __GNU_LIBRARY__] [__GNUC__] [not IN_GCC]
[emacs] [not __STDC__]: Don't include stddef.h. Don't declare strlen.
 
Fri Dec 24 19:43:00 1993 Noah Friedman (friedman@nutrimat.gnu.ai.mit.edu)
 
* getopt.c (_NO_PROTO): Define before config.h is included.
 
Mon Sep 20 15:59:03 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu)
 
* getopt.c, getopt1.c [emacs || CONFIG_BROKETS]: Include
<config.h> only under these, else "config.h".
 
Thu Aug 12 18:16:49 1993 Roland McGrath (roland@churchy.gnu.ai.mit.edu)
 
* getopt.c, getopt1.c [HAVE_CONFIG_H]: Include
<config.h> instead of "config.h".
 
Sun Feb 20 17:17:01 1994 Ian Lance Taylor (ian@lisa.cygnus.com)
 
* concat.c: Check ANSI_PROTOTYPES rather than __STDC__ to decide
whether to use prototypes or not.
* strerror.c (const): Never undefine; let ansidecl.h handle it.
* strsignal.c (const): Likewise.
 
Thu Feb 17 13:27:35 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
 
* xatexit.c (_xexit_cleanup): Declare as extern; don't initialize.
Merging common and initialized variables need not be supported by
ANSI C compilers.
(xatexit): Initialize _xexit_cleanup if not already set.
* xexit.c: Comment fix.
 
Wed Feb 16 01:15:36 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
 
* xmalloc.c: Don't declare xexit; it's declared in libiberty.h.
(xrealloc): If oldmem is NULL, allocate with malloc, rather than
assuming that realloc works correctly.
 
Tue Feb 15 09:26:16 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
 
* concat.c, ieee-float.c: Replace inclusion of <string.h>
with explicit function declarations, as recommended by Ian Taylor.
 
Sat Feb 12 10:31:11 1994 David J. Mackenzie (djm@rtl.cygnus.com)
 
* xmalloc.c (xmalloc, xrealloc): Use PTR and size_t throughout.
(malloc, realloc): Declare.
 
Thu Feb 10 17:08:19 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
 
* argv.c, basename.c: Include ansidecl.h and libiberty.h.
* concat.c, fdmatch.c, getruntime.c, spaces.c: Likewise.
* strerror.c, strsignal.c, xatexit.c, xexit.c: Likewise.
* xmalloc.c: Likewise.
* concat.c: Don't declare xmalloc. If __STDC__, use <stdarg.h>
macros, not <varargs.h> macros.
* spaces.c (spaces): Make return type const. Don't crash if
malloc returns NULL.
* strerror.c (struct error_info): Make name and msg fields const.
(error_names): Make const.
(strerrno): Make const.
(strtoerrno): Make argument const.
* strsignal.c (struct signal_info): Make name and msg fields
const.
(signal_names, sys_siglist): Make const.
(strsignal, strsigno): Make const.
(strtosigno): Make argument const.
* xatexit.c: Declare parameter types.
* xmalloc.c (name): Make const.
(xmalloc_set_program_name): Make argument const.
* Makefile.in (INCDIR): Define.
(.c.o): Use $(INCDIR).
(dummy.o): Likewise.
(argv.o, basename.o): New targets; depend on libiberty.h.
(concat.o, fdmatch.o, getruntime.o, spaces.o): Likewise.
(strerror.o, strsignal.o, xatexit.o, xexit.o): Likewise.
(xmalloc.o): Likewise.
(cplus-dem.o): New target; depend on demangle.h.
(getopt.o, getopt1.o): New targets; depend on getopt.h.
(ieee-float.o): New target; depend on ieee-float.h.
(obstack.o): New target; depend on obstack.h.
 
Tue Feb 8 05:29:08 1994 David J. Mackenzie (djm@thepub.cygnus.com)
 
Handle obstack_chunk_alloc returning NULL. This allows
obstacks to be used by libraries, without forcing them
to call exit or longjmp.
* obstack.c (_obstack_begin, _obstack_begin_1, _obstack_newchunk):
If CALL_CHUNKFUN returns NULL, set alloc_failed, else clear it.
(_obstack_begin, _obstack_begin_1): Return 1 if successful, 0 if not.
 
Tue Feb 8 00:32:28 1994 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
 
* concat.c, ieee-float.c: Include <string.h>.
 
Sun Feb 6 21:28:46 1994 David J. Mackenzie (djm@thepub.cygnus.com)
 
* xmalloc.c (xmalloc_set_program_name): New function.
(xmalloc, xrealloc): Include the name in the error message, if set.
 
* Replace atexit.c with xatexit.c.
* Makefile.in (CFILES), functions.def: Change references.
 
Sat Feb 5 14:02:32 1994 Stan Shebs (shebs@andros.cygnus.com)
 
* getruntime.c (get_run_time): Use getrusage or times if
HAVE_GETRUSAGE or HAVE_TIMES are defined.
 
Fri Feb 4 15:49:38 1994 David J. Mackenzie (djm@thepub.cygnus.com)
 
* atexit.c: New file.
* Makefile.in (CFILES), functions.def: Add it.
* xexit.c: New file.
* Makefile.in (CFILES, REQUIRED_OFILES): Add it.
* xmalloc.c (xmalloc, xrealloc): Call xexit instead of exit.
Change request for 0 bytes into request for 1 byte.
 
Wed Feb 2 11:36:49 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
 
* xmalloc.c (xmalloc, xrealloc): Print size using %lu, and cast to
unsigned long, to avoid warnings.
 
Fri Jan 28 17:49:06 1994 Ken Raeburn (raeburn@cujo.cygnus.com)
 
* dummy.c: Don't include time.h ever; always define clock_t as
"unsigned long". Until gcc/fixincludes ensures that clock_t
exists, __STDC__ isn't a sufficient test. And if clock() doesn't
exist, clock_t probably doesn't either.
 
Mon Jan 24 11:52:31 1994 Stan Shebs (shebs@andros.cygnus.com)
 
* clock.c, getruntime.c: New files.
* Makefile.in: Add to file lists.
* functions.def (clock): Add to list.
* dummy.c (time.h): Add if __STDC__.
(clock_t): #define as "unsigned long" if not __STDC__.
 
Tue Jan 11 11:27:44 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
 
* strtod.c: Declare atof. From edler@jan.ultra.nyu.edu (Jan
Edler).
 
Tue Dec 28 14:17:30 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
 
* Makefile.in (errors): Use CFLAGS as well as LDFLAGS when
linking.
 
Fri Dec 17 12:26:07 1993 Kung Hsu (kung@cirdan.cygnus.com)
 
* cplus-dem.c (demangle_arm_pt): New function. Common code
for ARM template demangling.
* cplus-dem.c (demangle_class_name): Use demangle_arm_pt.
* cplus-dem.c (demangle_prefix): Likewise.
 
Tue Nov 30 15:47:48 1993 Jason Merrill (jason@deneb.cygnus.com)
 
* cplus-dem.c (cplus_demangle_opname): Add CONST to please gcc.
 
Sat Nov 27 11:05:50 1993 Fred Fish (fnf@cygnus.com)
 
Merge changes from tom@basil.icce.rug.nl (Tom R.Hageman)
* strerror.c, strsignal.c: As a small space optimization, don't
include messages when they aren't actually used.
 
Merge changes from takefive.co.at!joe (Josef Leherbauer)
* cplus-dem.c (demangle_prefix, demangle_function_name,
cplus_demangle_opname): Fixes for systems where cplus_marker
is something other than '$'.
 
Fri Nov 26 13:51:11 1993 Per Bothner (bothner@kalessin.cygnus.com)
 
* waitpid.c: Simple-minded approcimation to waitpid
using vanilla wait.
* functions.def, Makefile.in: Update accordingly,
 
Thu Nov 18 18:01:15 1993 Kung Hsu (kung@cirdan.cygnus.com)
 
* cplus-dem.c(demangle_template): fix bug template instantiation
with value of user defined type.
 
Wed Nov 17 18:30:21 1993 Kung Hsu (kung@cirdan.cygnus.com)
 
* cplus-dem.c(cplus_demangle_opname): add the subject new function
to support unified search of operator in class.
 
Wed Nov 10 09:47:22 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
 
gcc -Wall lint:
* strtoul.c (strtoul): use "(digit = *s) != '\0'" not just
"digit = *s" as condition in while loop.
 
Tue Nov 9 15:52:22 1993 Mark Eichin (eichin@cygnus.com)
 
* Makefile.in: pass SHELL to recursive make
 
Thu Nov 4 12:09:26 1993 Per Bothner (bothner@kalessin.cygnus.com)
 
* vfprintf.c, vprintf.c, vsprintf.c: Make format arg
be (const char*), for ANSI (and gcc w/fixproto) consistency.
 
Thu Nov 4 08:29:04 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
 
* config.table: Make *-*-hiux* use mh-hpux.
 
Fri Oct 22 07:53:15 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
 
* config.table: Add * to end of all OS names.
 
Tue Oct 19 17:12:01 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
 
* Makefile.in (lneeded-list): ensure that object file names are
not duplicated, as multiple instances of the same object file in
a library causes problems on some machines
 
Mon Oct 18 21:59:28 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
 
* strcasecmp.c, strncasecmp.c: Change u_char to unsigned char.
 
Fri Oct 15 22:17:11 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
 
* strncasecmp.c: new file, implements strncasecmp
* strcasecmp.c: new file, implement strcasecmp
 
* Makefile.in (CFILES): list these two new source files
 
* functions.def: add strcasecmp and strncasecmp entries
 
Fri Oct 15 14:53:05 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
 
* strtoul.c (strtoul), strtol.c (strtol): Handle overflow
according to ANSI C.
 
Thu Oct 14 16:34:19 1993 Kung Hsu (kung@cirdan.cygnus.com)
 
* cplus-dem.c: add support of ARM global constructor/destructor,
and 'G' for passing record or union in parameter.
 
Wed Oct 13 13:36:19 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
 
* Makefile.in: Fix comment to clarify that stuff in REQUIRED_OFILES
should not be in functions.def.
 
Wed Oct 13 13:13:38 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
 
* functions.def: Removed xmalloc. Stuff in REQUIRED_OFILES should
not be in functions.def.
 
Mon Oct 4 18:26:39 1993 Kung Hsu (kung@cirdan.cygnus.com)
 
* cplus-dem.c: change globl constructor/destructor to proper name
 
Tue Sep 28 18:11:07 1993 Kung Hsu (kung@cirdan.cygnus.com)
 
* cplus-dem.c: fix bug in constructor/destructor
 
Tue Sep 28 16:20:49 1993 Kung Hsu (kung@cirdan.cygnus.com)
 
* cplus-dem.c: support both old and new _vt$... vtbl mangled names
 
Fri Sep 24 19:07:16 1993 Jason Merrill (jason@deneb.cygnus.com)
 
* cplus-dem.c: Fix demangle_template prototype
 
Fri Sep 24 17:32:55 1993 Kung Hsu (kung@cirdan.cygnus.com)
 
* cplus-dem.c: fix template demangling
* cplus-dem.c: fix const type demangling
* cplus-dem.c: fix constructor/destructor, virtual table,
qualifier, global constructor/destructor demangling
 
Wed Sep 1 23:13:11 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
 
* strsignal.c, strerror.c: Use fully-bracketed initializer to
keep gcc -Wall happy.
 
Fri Aug 27 10:30:09 1993 Jason Merrill (jason@deneb.cygnus.com)
 
* cplus-dem.c (do_type): Add CONSTS to make gcc happy with last
patch.
 
Fri Aug 27 11:24:54 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
 
Patch from Paul Flinders:
* cplus-dem.c (do_type): Deal with arrays.
 
Tue Aug 24 14:23:50 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
 
* cplus-dem.c (demangle_qualified: Deal with GNU format for more
than 9 classes.
 
Wed Aug 18 19:50:29 1993 Jason Merrill (jason@deneb.cygnus.com)
 
* Makefile.in (dummy.o): Redirect to /dev/null to avoid "variable
not initialized" warnings under HP/UX
 
Sun Aug 15 20:42:40 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
 
* strerror.c: Move include of stdio.h after sys_errlist #define.
Also remove NULL definition (stdio.h always defines NULL, so it
never did anything but clutter up the code).
 
Sat Aug 14 14:21:49 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
 
* Makefile.in, functions.def: handle xmalloc.c
 
* xmalloc.c: provide xmalloc and xrealloc functions
 
Thu Aug 12 17:38:57 1993 David J. Mackenzie (djm@thepub.cygnus.com)
 
* cplus-dem.c: Fix a comment.
 
Sat Aug 7 13:56:35 1993 David J. Mackenzie (djm@thepub.cygnus.com)
 
* getopt1.c: Declare const the way getopt.c does.
 
Fri Aug 6 17:03:13 1993 David J. Mackenzie (djm@thepub.cygnus.com)
 
* obstack.c, alloca.c: Update from FSF.
* getopt.c, getopt1.c: Update to current FSF version, which
doesn't use alloca.
 
Tue Jul 27 14:03:57 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
 
* Makefile.in (demangle): Add the target with a message saying
where demangle went.
 
Mon Jul 26 15:49:54 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
 
* Makefile.in: Remove obsolete `demangle' target.
 
Thu Jul 22 08:31:01 1993 Fred Fish (fnf@deneb.cygnus.com)
 
* cplus-dem.c (arm_special): Apply patch from arg@lucid.com to
avoid infinite loop on vtbl symbols with disambiguating "junk"
tacked on the end.
 
Mon Jul 19 14:10:37 1993 david d `zoo' zuhn (zoo@rtl.cygnus.com)
 
* strsignal.c: work around some systems losing definitions of
sys_siglist
 
* config/mh-lynxos: this system has a losing definition of
sys_siglist
 
* config.table: use mh-lynxos for *-*-lynxos
 
Mon Jul 19 17:08:52 1993 Ken Raeburn (raeburn@rtl.cygnus.com)
 
* config.table: Add support for HPPA BSD hosts.
 
* config/mh-hpbsd: New file.
 
Mon Jul 12 18:00:40 1993 K. Richard Pixley (rich@cygnus.com)
 
* Makefile.in (TAGS): make work when srcdir != objdir.
 
Sun Jun 27 15:35:31 1993 David J. Mackenzie (djm@thepub.cygnus.com)
 
* cplus-dem.c (main): Add long options, including --help and
--version.
(usage): New function from code in main.
 
Tue Jun 22 11:37:38 1993 Per Bothner (bothner@deneb.cygnus.com)
 
* config.table: New shell scipt, sourced by both ./configure,in
and ../xiberty/configure.in, to avoid maintainance lossages.
* configure.in and ../xiberty/configure.in: Use config.table.
 
* configure.in: Don't use mh-aix for AIX 3.2, only for 3.1.
* configure.in: Map *-*-irix* (except irix4) to mh-sysv.
* ../xiberty/configure.in: Update from ./configure.in.
 
Tue Jun 15 17:05:31 1993 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
 
* Makefile.in: remove parentdir support
 
Wed May 26 12:59:09 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
 
* cplus-dem.c (xrealloc): Match definition with prototype.
 
Tue May 25 14:27:51 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
 
* cplus-dem.c (demangle_prefix): Demangle cfront
local variables as an extension to ARM demangling.
 
Fri May 21 09:53:57 1993 Jim Kingdon (kingdon@lioth.cygnus.com)
 
* ieee-float.c: Don't require pointers to double to be aligned.
 
Tue May 18 17:12:10 1993 Fred Fish (fnf@cygnus.com)
 
(merge changes from dlong@cse.ucsc.edu)
* cplus-dem.c (consume_count): Simplify.
* cplus-dem.c (arm_pt, demangle_class_name): New functions.
* cplus-dem.c (various): Calls to arm_pt, demangle_class_name.
 
* cplus-dem.c (xmalloc, xrealloc, strstr): Make extern decls into
full prototypes.
* cplus-dem.c (free): Add prototype.
* cplus-dem.c (optable): Fully bracketize initializer.
 
Fri May 14 17:13:05 1993 Per Bothner (bothner@cygnus.com)
 
* cplus-dem.c: Whether initial underscores are stripped
depends on the external variable prepends_underscore
(which is generated by the binutils Makefile).
 
Fri May 14 07:32:20 1993 Ken Raeburn (raeburn@deneb.cygnus.com)
 
* cplus-dem.c (mop_up, arm_special): Remove some unused variables.
 
Tue May 4 20:31:59 1993 Fred Fish (fnf@cygnus.com)
 
* cplus-dem.c (consume_count): Return zero if arg does not
start with digit, and don't consume any input.
 
Tue May 4 08:10:28 1993 Jim Kingdon (kingdon@cygnus.com)
 
* Makefile.in (demangle): Use ${srcdir} not $^.
 
* strtod.c: New file, needed at least for BSD 4.3.
 
Sun May 2 11:30:42 1993 Fred Fish (fnf@cygnus.com)
 
* strsignal.c (sys_siglist): For ANSI compilations, type is
"const char *const". Also remove conditionalization on __STDC__
since const is defined away for non-ANSI.
 
Wed Apr 28 19:29:55 1993 Ken Raeburn (raeburn@deneb.cygnus.com)
 
* configure.in: Recognize *-*-hpux.
* config/mh-hpux: New file.
 
Tue Apr 27 15:22:19 1993 Per Bothner (bothner@cygnus.com)
 
* tmpnam.c: Added ANSI tmpnam() function.
* functions.def, Makefile.in: Update accordingly.
 
Tue Apr 27 13:38:38 1993 Peter Schauer (pes@regent.e-technik.tu-muenchen.de)
 
* cplus-dem.c (demangle_function_name): Get the demangling of
stop__1A right.
 
Fri Apr 16 23:48:24 1993 Jim Kingdon (kingdon at calvin)
 
* cplus-dem.c: Declare strstr return type.
 
Fri Mar 26 12:01:26 1993 Jim Kingdon (kingdon@cygnus.com)
 
* strsignal.c: Add some AIX signals.
 
Thu Mar 25 15:17:23 1993 Ian Lance Taylor (ian@cygnus.com)
 
* Makefile.in (MAKEOVERRIDES): Define to be empty.
 
Wed Mar 24 01:59:25 1993 david d `zoo' zuhn (zoo at poseidon.cygnus.com)
 
* Makefile.in: add installcheck & dvi targets
 
Thu Mar 18 14:05:44 1993 Per Bothner (bothner@rtl.cygnus.com)
 
* ieee-float.c: New file, moved from ../gdb (since it is
needed by ../opcode/m68k-dis.c).
 
Tue Mar 2 17:47:31 1993 Fred Fish (fnf@cygnus.com)
 
* cplus-dem.c: Replace all references to cfront with ARM.
 
Fri Feb 26 00:17:07 1993 Per Bothner (bothner@rtl.cygnus.com)
 
* cplus-dem.c: Fix main program (when compiled with -DMAIN)
to be more useful as a filter.
 
Sat Feb 20 21:41:39 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
 
* Makefile.in (install_to_libdir, install_to_tooldir): Go into the
destination directory before running $(RANLIB), in case that
program tries to create a file in the current directory as part of
its work.
 
Thu Feb 18 23:00:19 1993 John Gilmore (gnu@cygnus.com)
 
* strsignal.c (sys_siglist): Remove yet another *%^&%&$# "const"
because BSD 4.4 lacks one. Isn't this fun?
 
Thu Feb 18 11:24:25 1993 Fred Fish (fnf@cygnus.com)
 
* cplus-dem.c (demangle_signature): Set func_done after
demangling a template.
* cplus-dem.c (demangle_template): Fix several small bugs
in demangling GNU style templates.
* cplus-dem.c (demangle_prefix): Fix for templates in GNU
style constructors.
* cplus-dem.c (gnu_special): Fix for templates in GNU style
static data members.
 
Tue Feb 16 17:28:35 1993 Fred Fish (fnf@cygnus.com)
 
* cplus-dem.c (demangle_signature): Modify to include type
modifiers like static and const in remembered types.
 
Thu Feb 11 22:20:47 1993 Fred Fish (fnf@cygnus.com)
 
* cplus-dem.c (demangled_qualified): Add new parameter that tells
whether to prepend or append the qualifiers.
* cplus-dem.c (string_prepends): Used now, remove #if 0.
* cplus-dem.c (demangle_signature): Call demangle_qualified
with prepending.
* cplus_dem.c (gnu_special): Recognize static data members that
use qualified names.
* cplus-dem.c (demangle_qualified): Accumulate qualifiers in a
temporary buffer and the prepend or append them to the result,
as specified by the new "append" flag.
* cplus-dem.c (do_type): Call demangled_qualified with
appending.
 
Mon Dec 28 10:47:19 1992 Ken Raeburn (raeburn@cygnus.com)
 
* strsignal.c (signal_table): Now const.
(init_signal_tables): Variable eip now points to const.
 
* strerror.c (error_table): Now const.
(init_error_tables): Variable eip now points to const.
 
Tue Dec 15 15:36:50 1992 Per Bothner (bothner@cygnus.com)
 
* memchr.c (memchr): New (ANSI standard) function.
* Makefile.in, functions.def: Added memchr.
* Makefile.in (AR_FLAGS): Use rc instad of non-standard cq.
 
Wed Dec 2 22:49:10 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
 
* getopt.c: remove use of USG around <alloca.h>, which never meant
anything anyway
 
* config/mh-{aix,apollo68,ncr3000,sysv,sysv4}: removed definitions
of USG and USGr4
 
Thu Nov 19 03:09:33 1992 Brendan Kehoe (brendan@lisa.cygnus.com)
 
* cplus-dem.c (demangle_fund_type): Recognize `w', a wide character;
it's now a type according to the ANSI X3J16 working paper; output
"wchar_t" for it.
(demangle_template): Accept `w' as an integral type.
(xmalloc, xrealloc): Use `char *', not `PTR'. Cast calls to their
counterparts malloc and realloc to `char *'.
(main): Exit with a 0 status.
* Makefile.in (demangle): Don't expect the user to define
DEMANGLE, instead force to be cplus-dem.c. Look in $(srcdir)/../include
for demangle.h. Pass it any HDEFINES or XTRAFLAGS.
 
Wed Nov 18 18:56:20 1992 John Gilmore (gnu@cygnus.com)
 
* Makefile.in (AR_FLAGS): Avoid verbosity.
* config/mh-sysv4: Remove AR_FLAGS override, use INSTALL=cp,
replace USGr4 with HAVE_SYSCONF.
* config/mh-solaris: Remove; mh-sysv4 works now.
* getpagesize.c: Replace USGr4 with HAVE_SYSCONF.
* configure.in: Simplify host matching table, remove separate
solaris config file.
 
Sun Nov 15 09:35:16 1992 Fred Fish (fnf@cygnus.com)
 
* configure.in (i[34]86-*-solaris2*): Add, use mh-sysv4.
 
Tue Nov 3 21:27:03 1992 Brendan Kehoe (brendan@cygnus.com)
 
* cplus-dem.c (xmalloc, xrealloc): Add decls.
(remember_type): Don't cast xmalloc.
(string_need): Likewise; don't cast xrealloc either.
 
Fri Oct 23 08:52:01 1992 Ian Lance Taylor (ian@cygnus.com)
 
* Makefile.in, functions.defs, rename.c: added simple
implementation of rename, since some binutils programs use it.
 
Thu Oct 15 15:18:22 1992 Per Bothner (bothner@cygnus.com)
 
* strsignal.c: Add appropriate 'const' to sys_siglist
extern declaration (if __STDC__). (Needed for Linux.)
* strsignal.c (strsignal): Add cast to remove const-ness.
 
Fri Oct 9 03:22:55 1992 John Gilmore (gnu@cygnus.com)
 
* Makefile.in (needed.awk, needed2.awk): Remove erroneous \'s
before "'s, diagnosed by BSD 4.4 awk.
 
Thu Oct 8 15:25:12 1992 Ian Lance Taylor (ian@cygnus.com)
 
* Makefile.in: create config.h and needed-list through $(CONFIG_H)
and $(NEEDED_LIST), to give some hooks for xiberty.
 
Thu Oct 1 23:31:42 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
 
* configure.in: use cpu-vendor-triple instead of nested cases
 
Wed Sep 30 11:26:59 1992 Per Bothner (bothner@rtl.cygnus.com)
 
* Makefile.in, argv.c, basename.c, bcmp.c, bcopy.c, bzero.c,
concat.c, cplus-dem.c, fdmatch.c, getcwd.c, getopt.c, getopt1.c,
getpagesize.c, insque.c, memcmp.c, memcpy.c, memmove.c, memset.c,
obstack.c, sigsetmask.c, spaces.c, strchr.c, strerror.c,
strrchr.c, strsignal.c, strstr.c, vfork.c, vsprintf.c:
Convert from using GPL to LGPL.
 
Sat Sep 26 04:01:30 1992 John Gilmore (gnu@cygnus.com)
 
* Makefile.in (errors): Leave dummy.o and dummy around so that
we can see how the needed list was generated (it's sometimes wrong).
(mostlyclean): Remove them.
 
Mon Sep 21 14:50:42 1992 Ian Lance Taylor (ian@cygnus.com)
 
* getcwd.c: supply a default if MAXPATHLEN is not defined.
 
* config/mh-irix4: set EXTRA_OFILES to alloca.o, from WRS.
 
Wed Sep 9 12:41:48 1992 Ian Lance Taylor (ian@cygnus.com)
 
* Makefile.in: Use XTRAFLAGS when compiling, so that xiberty works
when cross-compiling.
 
Thu Sep 3 13:29:39 1992 K. Richard Pixley (rich@sendai.cygnus.com)
 
* cplus-dem.c: (demangle_prefix): reduction in strength of strstr
as a time optimization.
 
* cplus-dem.c (cplus_demangle): remove strpbrk test. Appears to
be more expensive than simply demangling.
 
* cplus-dem.c (cplus_match): new function.
 
Tue Sep 1 15:24:04 1992 Per Bothner (bothner@rtl.cygnus.com)
 
* cplus-dem.c: #include <stdio.h>, to define NULL.
Define current_demangling_style.
 
Sun Aug 30 17:58:19 1992 Per Bothner (bothner@rtl.cygnus.com)
 
* cplus-dem.c: New file, moved from ../gdb.
* cplus-dem.c (set_cplus_marker_for_demangling): New exported
function, to avoid compiling in target-dependency for CPLUS_MARKER.
* cplus-dem.c (cplus_demangle): Allow demangling style option
to be passed as a parameter, but using the global variable
current_demangling_style as a default.
* Makefile.in: Update for cplus-dem.c
 
Sat Aug 29 10:44:09 1992 Fred Fish (fnf@cygnus.com)
 
* obstack.c: Merge in comment changes from FSF version. Now
matches the FSF version exactly.
 
Fri Aug 28 18:39:08 1992 John Gilmore (gnu@cygnus.com)
 
* obstack.c (CALL_FREEFUN): Can't use ?: with void values (at
least on losing DECstations!); use if-then-else instead.
 
Wed Aug 19 14:40:34 1992 Ian Lance Taylor (ian@cygnus.com)
 
* Makefile.in: always create installation directories.
 
Mon Aug 10 17:33:40 1992 david d `zoo' zuhn (zoo at cirdan.cygnus.com)
 
* Makefile.in: clean up definition of CFILES, more comments
 
Sat Aug 8 23:10:59 1992 Fred Fish (fnf@cygnus.com)
 
* getopt.c (my_index): Make first arg const to match strchr,
which it sometimes is remapped to.
 
Sat Aug 1 13:48:50 1992 Fred Fish (fnf@cygnus.com)
 
* obstack.c (DEFAULT_ALIGNMENT): Update to match FSF version.
* obstack.c (_obstack_begin): Initialize use_extra_arg.
* obstack.c (_obstack_begin_1): New, from FSF version.
 
Mon Jul 20 21:07:58 1992 Fred Fish (fnf@cygnus.com)
 
* obstack.c (CALL_CHECKFUN, CALL_FREEFUN): Use use_extra_arg and
extra_arg.
* obstack.c (_obstack_begin): Remove area_id and flags arguments
(previously added for mmalloc support, interface has changed).
Also convert flags usage to use use_extra_arg and maybe_empty_object.
 
Fri Jul 10 00:41:53 1992 Fred Fish (fnf@cygnus.com)
 
* argv.c: Move expandargv inline and eliminate static variables.
Rewrite to always allocate in powers of two. Fix to return an
argv with a single null string arg if passed a null string.
 
Fri Jul 3 20:27:29 1992 Fred Fish (fnf@cygnus.com)
 
* random.c, sigsetmask.c, strerror.c, strsignal.c: Remove
"(void)" casts from function calls where the return value is
ignored, in accordance with GNU coding standards.
 
Mon Jun 29 10:54:19 1992 Fred Fish (fnf at cygnus.com)
 
* bcopy.c, strerror.c, strsignal.c: Lint.
 
Thu Jun 25 09:18:41 1992 K. Richard Pixley (rich@rtl.cygnus.com)
 
* getopt.c: merge changes from make.
 
Thu Jun 25 04:43:22 1992 John Gilmore (gnu at cygnus.com)
 
* alloca.c: Incorporate fixes from gdb/alloca.c.
FIXME: Eventually move gdb's alloca configuration files here,
and remove gdb/alloca.c and its Makefile.in support.
 
Tue Jun 23 21:56:30 1992 Fred Fish (fnf@cygnus.com)
 
* dummy.c: Define NOTHING to /*nothing*/, change return type
of main to int and return zero.
* functions.def: Supply NOTHING as the fourth arg to macros
that don't have an explicit arg, to satisfy picky preprocessors.
 
Wed Jun 17 18:13:58 1992 Per Bothner (bothner@rtl.cygnus.com)
 
* Makefile.in: Clean up *clean rules, as per standards.texi.
 
Tue Jun 16 16:11:59 1992 K. Richard Pixley (rich@rtl.cygnus.com)
 
* getopt.c, getopt1.c: merged largely gratuitous, mostly
whitespace diffs from other prep distributions.
 
Mon Jun 15 12:25:46 1992 Fred Fish (fnf@cygnus.com)
 
* config/mh-ncr3000 (INSTALL): Don't use /usr/ucb/install,
it is broken on ncr 3000's.
 
Mon Jun 15 01:03:26 1992 John Gilmore (gnu at cygnus.com)
 
* sigsetmask.c: Rewrite. Old one was very confused about its
arguments and result. New one can't do much, but at least knows
what it can't do, and it's good enough for GDB's use.
 
Sun Jun 14 15:17:40 1992 Stu Grossman (grossman at cygnus.com)
 
* functions.def: Use proper prototype for strtoul.
 
Fri Jun 12 19:22:40 1992 John Gilmore (gnu at cygnus.com)
 
* Makefile.in: Add random.c.
* config/mh-*: Use "true" rather than "echo >/dev/null" for ranlib.
* configure.in: update solaris2 config.
 
Wed Jun 10 16:31:29 1992 Fred Fish (fnf@cygnus.com)
 
* random.c: Add for random() and srandom().
* functions.def: Add random
 
Tue Jun 9 17:27:18 1992 Fred Fish (fnf@cygnus.com)
 
* config/{mh-ncr3000, mh-sysv4}: Add definition for INSTALL
using /usr/ucb/install.
 
Mon Jun 1 13:20:17 1992 Per Bothner (bothner@rtl.cygnus.com)
 
* strerror.c: Kludge to guard against a conflict with
possible declaration of sys_errlist in errno.h.
 
Sun May 31 15:07:47 1992 Mark Eichin (eichin at cygnus.com)
 
* configure.in, config/mh-solaris: add solaris2 config support.
 
Fri May 29 17:23:23 1992 Per Bothner (bothner@rtl.cygnus.com)
 
* sigsetmask.c: #ifdef out sigsetmask if SIG_SETMASK
is not defined (should be defined in signal.h, says Posix.).
 
Mon May 18 17:35:04 1992 K. Richard Pixley (rich@cygnus.com)
 
* getopt.c: merged changes from make-3.62.11.
 
Fri May 8 14:53:07 1992 K. Richard Pixley (rich@cygnus.com)
 
* getopt.c: merged changes from bison-1.18.
 
Tue May 5 11:51:40 1992 Per Bothner (bothner@rtl.cygnus.com)
 
* Makefile.in: Don't have $(EXTRA_OFILES) depend on config.h,
since that introduces a circular dependency.
($(EXTRA_OFILES) are used to build config.h.)
 
* strtoul.c: Fixes to handle non-decimal bases better.
 
Wed Apr 22 09:27:51 1992 Fred Fish (fnf@cygnus.com)
 
* config/mh-ncr3000: Replace MINUS_G with CFLAGS.
* Makefile.dos: Finish MINUS_G eradication.
* Makefile.in (CFILES): Add strsignal.c.
* Makefile.in (REQUIRED_OFILES): Add strerror.o strsignal.o
* Makefile.in (needed-list): Split creation of errors file to
separate make target.
* Makefile.in (config.h, needed2.awk, errors): New targets.
* Makefile.in (clean): Split to multiple lines, add needed2.awk
and config.h.
* dummy.c (DEFFUNC, DEFVAR): Add defines and undefs.
* functions.def (strerror): Remove from optional list.
* functions.def (sys_nerr, sys_errlist, sys_siglist): DEFVAR's
* functions.def (strerror, psignal): DEFFUNC's
* strerror.c: Rewrite from scratch to use sys_errlist only if
available, add errno_max(), add strerrno(), add strtoerrno(),
add test driver.
* strsignal.c: New file, signal equivalent to strerror.c.
Uses sys_siglist if available, defines signo_max(), strsignal(),
strsigno(), strtosigno(), psignal(), and test driver.
 
Mon Apr 20 20:49:32 1992 K. Richard Pixley (rich@cygnus.com)
 
* Makefile.in: do not print recursion line.
 
* Makefile.in: allow CFLAGS to be passed in from command line.
Removed MINUS_G. Default CFLAGS to -g.
 
Mon Apr 20 12:57:46 1992 Per Bothner (bothner@rtl.cygnus.com)
 
* config/mh-aix: New. EXTRA_OFILES lists copysign.o,
so libg++ users don't have to be inconvenienced by a
libc.a bug (libc.a needs copysign, but doesn't define it!).
* configure.in: Use config/mh-aix.
* strtoul.c: Handle '-' as required by ANSI.
Clean up radix handling.
* strstr.c: Fix buggy algorithm.
* Makefile.in: Change so that ${EXTRA_OFILES} is
appended to needed-list (which is used by libg++).
 
Fri Apr 10 22:51:41 1992 Fred Fish (fnf@cygnus.com)
 
* configure.in: Recognize new ncr3000 config.
* config/mh-ncr3000: New config file.
 
Wed Apr 1 23:31:43 1992 John Gilmore (gnu at cygnus.com)
 
* argv.c, dummy.c: Lint.
 
Tue Mar 31 18:46:44 1992 Fred Fish (fnf@cygnus.com)
 
* config/mh-sysv4: New config file.
* configure.in (host_makefile_frag): Set to config/mh-sysv4 for
host_os == sysv4.
* getpagesize.c: For SVR4, use sysconf(_SC_PAGESIZE) to get
pagesize.
 
Sun Mar 29 12:26:42 1992 John Gilmore (gnu at cygnus.com)
 
* getopt.c: Lint.
 
Fri Mar 27 08:32:55 1992 Fred Fish (fnf@cygnus.com)
 
* functions.def (alloca): Fix return type and args to avoid
type clash with gcc's builtin alloca.
 
Tue Mar 24 23:33:42 1992 K. Richard Pixley (rich@cygnus.com)
 
* configure.in, config/mh-irix4: irix4 support.
 
* Makefile.in, functions.def, alloca.c: added alloca.
 
Tue Mar 24 17:34:46 1992 Stu Grossman (grossman at cygnus.com)
 
* obstack.c (CALL_FREEFUN): Make it compile on DECstations.
 
Thu Mar 19 13:57:42 1992 Fred Fish (fnf@cygnus.com)
 
* argv.c: Fix various external function definitions to be
correct in an ANSI compilation environment.
 
Sat Mar 14 17:28:17 1992 Fred Fish (fnf@cygnus.com)
 
* obstack.c: Changes to support calling mmalloc functions,
which take an additional argument over malloc functions.
 
Fri Mar 6 22:01:10 1992 K. Richard Pixley (rich@cygnus.com)
 
* added check target.
 
Thu Feb 27 22:19:39 1992 Per Bothner (bothner@cygnus.com)
 
* argv.c: #include alloca-conf.h (needed by AIX).
 
Wed Feb 26 18:04:40 1992 K. Richard Pixley (rich@cygnus.com)
 
* Makefile.in, configure.in: removed traces of namesubdir,
-subdirs, $(subdir), $(unsubdir), some rcs triggers. Forced
copyrights to '92, changed some from Cygnus to FSF.
 
Sat Feb 22 01:09:21 1992 Stu Grossman (grossman at cygnus.com)
 
* argv.c: Check in Fred's version which fixes problems with
alloca().
 
Fri Feb 7 21:46:08 1992 Stu Grossman (grossman at cygnus.com)
 
* makefile.dos: Remove NUL to keep patch from failing.
 
Thu Jan 30 22:48:41 1992 Stu Grossman (grossman at cygnus.com)
 
* getopt.c (_getopt_internal): Fix usage of enum has_arg.
 
Mon Jan 20 18:53:23 1992 Stu Grossman (grossman at cygnus.com)
 
* getopt.c, getopt1.c, ../include/getopt.h: Get latest versions.
 
Sat Jan 18 16:53:01 1992 Fred Fish (fnf at cygnus.com)
 
* argv.c: New file to build and destroy standard argument
vectors from a command string.
 
* Makefile.in: Add argv.c and argv.o to appropriate macros.
 
Fri Dec 20 12:12:57 1991 Fred Fish (fnf at cygnus.com)
 
* configure.in: Change svr4 references to sysv4.
 
* rindex.c: Declare return type of externally used function
strrchr().
 
Thu Dec 19 18:35:03 1991 John Gilmore (gnu at cygnus.com)
 
* Makefile.in: Remove "***" in normal output, since Make produces
this on errors, and it's convenient to search for.
 
Tue Dec 17 23:21:30 1991 Per Bothner (bothner at cygnus.com)
 
* memcmp.c, memcpy.c, memmove.c, memset.c, strchr.c, strrchr.c:
New ANSI functions. The old non-ANSI functions (such as bcopy)
should be avoided.
* bcopy.c: Fix to correctly handle overlapping regions.
* index.c, rindex.c: Re-write in terms of strchr() and strrchr().
* functions.def: Add the new functions.
* functions.def: Add 4th parameter to DEF macro,
an ansidecl.h-style prototype.
* dummy.c: Use expanded DEF macro to create a dummy function
call, with correct parameter types. (This avoids some
complaints from gcc about predefined builtins.)
 
Move the functionality of config/mh-default into Makefile.in.
This avoid duplication, and simplifies things slightly.
* Makefile.in: Tweak so we don't need config/mh-default.
* README: Update.
* configure.in: No longer need config/mh-default.
* config/mh-default: Deleted.
* config/mh-sysv: Remove lines copied from old mh-default.
 
Tue Dec 17 05:46:46 1991 John Gilmore (gnu at cygnus.com)
 
* fdmatch.c (fdmatch): Don't compare st_rdev, which is for
'mknod' device numbers.
 
Mon Dec 16 12:25:34 1991 Fred Fish (fnf at cygnus.com)
 
* fdmatch.c, Makefile.in: Add new function that takes two
open file descriptors and returns nonzero if they refer to
the same file, zero otherwise. (used in gdb)
 
Wed Dec 11 17:40:39 1991 Steve Chamberlain (sac at rtl.cygnus.com)
From DJ:
* msdos.c: stub functions for dos.
* makefile.dos, configdj.bat: new.
* getopt.c: Don't include alloca-conf.h in a GO32 world.
 
 
Tue Dec 10 04:14:49 1991 K. Richard Pixley (rich at rtl.cygnus.com)
 
* Makefile.in: infodir belongs in datadir.
 
Fri Dec 6 23:26:45 1991 K. Richard Pixley (rich at rtl.cygnus.com)
 
* Makefile.in: remove spaces following hyphens because bsd make
can't cope. added standards.text support. install using
INSTALL_DATA.
 
* configure.in: remove commontargets as it is no longer a
recognized hook.
 
Thu Dec 5 22:46:46 1991 K. Richard Pixley (rich at rtl.cygnus.com)
 
* Makefile.in: idestdir and ddestdir go away. Added copyrights
and shift gpl to v2. Added ChangeLog if it didn't exist. docdir
and mandir now keyed off datadir by default.
 
Fri Nov 22 19:15:29 1991 John Gilmore (gnu at cygnus.com)
 
* Makefile.in: find-needed.awk does not fit in 14 chars.
 
* Makefile.in: Suppress error checking when compiling the test
program, because Ultrix make/sh aborts there due to a bug.
 
Fri Nov 22 12:23:17 1991 Per Bothner (bothner at cygnus.com)
 
* Makefile.in: Re-did how EXTRA_OFILES is used to be more useful.
* README: Explained how the auto-configuration works,
and how to add new files and/or configurations.
 
Fri Nov 22 09:45:23 1991 John Gilmore (gnu at cygnus.com)
 
* strtoul.c: Avoid defining ULONG_MAX if already defined;
cast a const char * to char * for pedants.
 
* getopt.c: Only define "const" after local include files get to,
and only if they haven't defined it.
 
Thu Nov 21 16:58:53 1991 John Gilmore (gnu at cygnus.com)
 
* getcwd.c (remove getwd.c): GNU code should call getcwd(). We
emulate it with getwd() if available. This avoids callers having
to find a MAXPATHLEN or PATH_MAX value from somewhere.
* Makefile.in, functions.def: getwd->getcwd.
* configure.in: Use generic case for every system.
* config/mh-{delta88,mach,rs6000,svr4}: Remove.
* config/mh-sysv: Use default handling, just add -DUSG.
 
Thu Nov 14 10:58:05 1991 Per Bothner (bothner at cygnus.com)
 
* Makefile.in, config/mh-default: Re-do make magic
so that for the default ("automatic") mode we only
compile the files we actually need. Do this using
a recursive make: The top-level generates the list
of needed files (loosely, the ones missing in libc),
and then passes that list to the recursive make.
* config/mh-mach: Remove obsolete STRERROR-{C,O} macros.
 
Tue Nov 12 19:10:57 1991 John Gilmore (gnu at cygnus.com)
 
RS/6000 host support (grumble).
 
* configure.in: Build alloca-conf.h file from alloca-norm.h
(everything else) or alloca-botch.h (rs/6000).
* Makefile.in: Include . on the include path.
* getopt.c: Use alloca-conf.h.
* alloca-norm.h: How to declare alloca on reasonable machines.
* alloca-botch.h: How to declare alloca on braindead machines.
 
Tue Nov 12 09:21:48 1991 Fred Fish (fnf at cygnus.com)
 
* concat.c : New file, like concat() in gdb but can take a
variable number of arguments rather than fixed at 3 args. For
now, client applications must supply an xmalloc(), which is a
front end function to malloc() that deals with out-of-memory
conditions.
 
* Makefile.in: Add concat.c and concat.o to appropriate macros.
 
Sat Nov 9 13:29:59 1991 Fred Fish (fnf at cygnus.com)
 
* config/mh-svr4: Add sigsetmask to list of required functions.
 
Sun Nov 3 11:57:56 1991 Per Bothner (bothner at cygnus.com)
 
* vsprintf.c: New file.
* functions.def, Makefile.in: Add vsprintf.
 
Sun Oct 27 16:31:22 1991 John Gilmore (gnu at cygnus.com)
 
* configure.in, config/mh-rs6000: Add rs/6000 host support.
* Makefile.in: Compile with debug info.
 
Fri Oct 25 17:01:12 1991 Per Bothner (bothner at cygnus.com)
 
* Makefile.in, configure.in, and new files: dummy.c, functions.def,
config/mf-default: Added a default configuration mode,
which includes into libiberty.a functions that are "missing" in libc.
* strdup.c, vprintf.c, vfprintf.c: New files.
 
Thu Oct 24 02:29:26 1991 Fred Fish (fnf at cygnus.com)
 
* config/hmake-svr4: New file.
 
* config/hmake-sysv: Add HOST_CFILES and HOST_OFILES.
 
* basename.c, bcmp.c, bcopy.c, bzero.c, getpagesize.c getwd.c,
index.c, insque.c, rindex.c, spaces.c, strstr.c, vfork.c: New
files containing either portable C versions or emulations using
native library calls.
 
* strerror.c: Add copyright, internal documentation, etc.
 
* strtol.c: Replace hardwired hex constants with some more
portable macros. Remove illegal (according to gcc) cast.
 
* strtoul.c: Replace hardwired hex constant with more portable
macro.
 
* Makefile.in: Move TARGETLIB and CFLAGS where makefile fragments
can override them. Add new source and object file names to CFILES
and OFILES respectively.
 
* configure.in: Add support for SVR4 makefile fragments.
 
Tue Oct 22 19:00:23 1991 Steve Chamberlain (steve at cygnus.com)
 
* Makefile.in: Move RANLIB, AR and AR_FLAGS to where they can be
over-ridden by config/hmake-*
* configure.in: added m88kcvs to sysv list
 
Fri Oct 4 01:29:08 1991 John Gilmore (gnu at cygnus.com)
 
* Makefile.in: Most hosts need strerror, but one or two don't,
and they override these definitions in the host-dependent makefile
fragment.
* config/hmake-mach: The odd man out on strerror -- it's supplied.
* strerror.c: New file.
 
* strtol.c, strtoul.c: Add strtol to libiberty, since Mach lacks
it and bfd uses it.
* configure.in, Makefile.in, config/hmake-mach: Only configure
strtol & strotoul in on Mach.
 
Tue Sep 3 06:36:23 1991 John Gilmore (gnu at cygint.cygnus.com)
 
* obstack.c: Merge with latest FSF version.
 
Local Variables:
version-control: never
End:
/fdmatch.c
0,0 → 1,73
/* Compare two open file descriptors to see if they refer to the same file.
Copyright (C) 1991 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. */
 
 
/*
 
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.
 
BUGS
 
(FIXME: does this work for networks?)
It works for NFS, which assigns a device number to each mount.
 
*/
 
#include "ansidecl.h"
#include "libiberty.h"
#include <sys/types.h>
#include <sys/stat.h>
 
int fdmatch (fd1, fd2)
int fd1;
int fd2;
{
struct stat sbuf1;
struct stat sbuf2;
 
if ((fstat (fd1, &sbuf1) == 0) &&
(fstat (fd2, &sbuf2) == 0) &&
(sbuf1.st_dev == sbuf2.st_dev) &&
(sbuf1.st_ino == sbuf2.st_ino))
{
return (1);
}
else
{
return (0);
}
}
/rename.c
0,0 → 1,22
/* rename -- rename a file
This function is in the public domain. */
 
/* Rename a file. */
 
#include <errno.h>
 
int
rename (zfrom, zto)
char *zfrom;
char *zto;
{
if (link (zfrom, zto) < 0)
{
if (errno != EEXIST)
return -1;
if (unlink (zto) < 0
|| link (zfrom, zto) < 0)
return -1;
}
return unlink (zfrom);
}
/testsuite/Makefile.in
0,0 → 1,75
#
# Makefile
# Copyright (C) 1999
# 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.
#
 
# This file was written by Tom Tromey <tromey@cygnus.com>.
 
#
# Makefile for libiberty/testsuite directory
#
 
srcdir = @srcdir@
VPATH = @srcdir@
 
SHELL = @SHELL@
 
CC = @CC@
CFLAGS = @CFLAGS@
LIBCFLAGS = $(CFLAGS)
 
# Multilib support variables.
MULTISRCTOP =
 
INCDIR=$(srcdir)/../$(MULTISRCTOP)../include
 
all:
 
check: @CHECK@
 
# Run some tests of the demangler.
check-cplus-dem: test-filter $(srcdir)/demangle-expected
$(SHELL) $(srcdir)/regress-demangle $(srcdir)/demangle-expected
 
# Note that we just hard-code prepends_underscore to 0. This doesn't
# matter since any particular test can override the default if need
# be.
TEST_COMPILE = $(CC) @DEFS@ $(LIBCFLAGS) -I.. -I$(INCDIR) $(HDEFINES)
test-filter: $(srcdir)/../cplus-dem.c
echo 'int prepends_underscore = 0;' > test-us.c
$(TEST_COMPILE) -o test-filter -DMAIN -DVERSION='"none"' @DEFS@ \
$(srcdir)/../cplus-dem.c test-us.c -L.. -liberty
 
 
# Standard (either GNU or Cygnus) rules we don't use.
info install-info clean-info dvi install etags tags installcheck:
 
# The standard clean rules.
mostlyclean:
rm -f test-us.c test-filter
clean: mostlyclean
distclean: clean
rm -f Makefile
maintainer-clean realclean: distclean
 
 
Makefile: $(srcdir)/Makefile.in ../config.status
CONFIG_FILES=testsuite/Makefile CONFIG_HEADERS= \
cd .. && $(SHELL) ./config.status
/testsuite/regress-demangle
0,0 → 1,28
#! /bin/sh
 
# Run a regression test for the demangler.
# Usage: regress-demangle TEST-FILE
 
failures=0
count=0
sed -e '/^#/ d' "$1" | (
while read type; do
read mangled
read demangled
 
x="`echo $mangled | ./test-filter $type`"
count=`expr $count + 1`
if test "x$x" != "x$demangled"; then
failures=`expr $failures + 1`
echo "FAIL: $type $mangled"
fi
done
 
if test $failures -eq 0; then
echo "All $count tests passed"
else
echo "$failures of $count tests failed"
fi
 
test $failures -eq 0
)
testsuite/regress-demangle Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: testsuite/demangle-expected =================================================================== --- testsuite/demangle-expected (nonexistent) +++ testsuite/demangle-expected (revision 1765) @@ -0,0 +1,2488 @@ +# This file holds test cases for the demangler. +# Each test consists of three lines in succession. +# The first line is arguments to pass to the test filter program. +# The second line is the mangled string. +# The third line is the expected output. +# A line starting with `#' is ignore. +# However blank lines in this file are NOT ignored. +# +--format=gnu +AddAlignment__9ivTSolverUiP12ivInteractorP7ivTGlue +ivTSolver::AddAlignment(unsigned int, ivInteractor *, ivTGlue *) +# +--format=gnu +ArrowheadIntersects__9ArrowLineP9ArrowheadR6BoxObjP7Graphic +ArrowLine::ArrowheadIntersects(Arrowhead *, BoxObj &, Graphic *) +# +--format=gnu +AtEnd__13ivRubberGroup +ivRubberGroup::AtEnd(void) +# +--format=gnu +BgFilter__9ivTSolverP12ivInteractor +ivTSolver::BgFilter(ivInteractor *) +# +--format=gnu +Check__6UArrayi +UArray::Check(int) +# +--format=gnu +CoreConstDecls__8TextCodeR7ostream +TextCode::CoreConstDecls(ostream &) +# +--format=gnu +Detach__8StateVarP12StateVarView +StateVar::Detach(StateVarView *) +# +--format=gnu +Done__9ComponentG8Iterator +Component::Done(Iterator) +# +--format=gnu +Effect__11RelateManipR7ivEvent +RelateManip::Effect(ivEvent &) +# +--format=gnu +FindFixed__FRP4CNetP4CNet +FindFixed(CNet *&, CNet *) +# +--format=gnu +Fix48_abort__FR8twolongs +Fix48_abort(twolongs &) +# +--format=gnu +GetBarInfo__15iv2_6_VScrollerP13ivPerspectiveRiT2 +iv2_6_VScroller::GetBarInfo(ivPerspective *, int &, int &) +# +--format=gnu +GetBgColor__C9ivPainter +ivPainter::GetBgColor(void) const +# +--format=gnu +InsertBody__15H_PullrightMenuii +H_PullrightMenu::InsertBody(int, int) +# +--format=gnu +InsertCharacter__9TextManipc +TextManip::InsertCharacter(char) +# +--format=gnu +InsertToplevel__7ivWorldP12ivInteractorT1 +ivWorld::InsertToplevel(ivInteractor *, ivInteractor *) +# +--format=gnu +InsertToplevel__7ivWorldP12ivInteractorT1iiUi +ivWorld::InsertToplevel(ivInteractor *, ivInteractor *, int, int, unsigned int) +# +--format=gnu +IsAGroup__FP11GraphicViewP11GraphicComp +IsAGroup(GraphicView *, GraphicComp *) +# +--format=gnu +IsA__10ButtonCodeUl +ButtonCode::IsA(unsigned long) +# +--format=gnu +ReadName__FR7istreamPc +ReadName(istream &, char *) +# +--format=gnu +Redraw__13StringBrowseriiii +StringBrowser::Redraw(int, int, int, int) +# +--format=gnu +Rotate__13ivTransformerf +ivTransformer::Rotate(float) +# +--format=gnu +Rotated__C13ivTransformerf +ivTransformer::Rotated(float) const +# +--format=gnu +Round__Ff +Round(float) +# +--format=gnu +SetExport__16MemberSharedNameUi +MemberSharedName::SetExport(unsigned int) +# +--format=gnu +Set__14ivControlState13ControlStatusUi +ivControlState::Set(ControlStatus, unsigned int) +# +--format=gnu +Set__5DFacePcii +DFace::Set(char *, int, int) +# +--format=gnu +VConvert__9ivTSolverP12ivInteractorRP8TElementT2 +ivTSolver::VConvert(ivInteractor *, TElement *&, TElement *&) +# +--format=gnu +VConvert__9ivTSolverP7ivTGlueRP8TElement +ivTSolver::VConvert(ivTGlue *, TElement *&) +# +--format=gnu +VOrder__9ivTSolverUiRP12ivInteractorT2 +ivTSolver::VOrder(unsigned int, ivInteractor *&, ivInteractor *&) +# +--format=gnu +_10PageButton\$__both +PageButton::__both +# +--format=gnu +_3RNG\$singleMantissa +RNG::singleMantissa +# +--format=gnu +_5IComp\$_release +IComp::_release +# +--format=gnu +_\$_10BitmapComp +BitmapComp::~BitmapComp(void) +# +--format=gnu +_\$_9__io_defs +__io_defs::~__io_defs(void) +# +--format=gnu +_\$_Q23foo3bar +foo::bar::~bar(void) +# +--format=gnu +_\$_Q33foo3bar4bell +foo::bar::bell::~bell(void) +# +--format=gnu +__10ivTelltaleiP7ivGlyph +ivTelltale::ivTelltale(int, ivGlyph *) +# +--format=gnu +__10ivViewportiP12ivInteractorUi +ivViewport::ivViewport(int, ivInteractor *, unsigned int) +# +--format=gnu +__10ostrstream +ostrstream::ostrstream(void) +# +--format=gnu +__10ostrstreamPcii +ostrstream::ostrstream(char *, int, int) +# +--format=gnu +__11BitmapTablei +BitmapTable::BitmapTable(int) +# +--format=gnu +__12ViewportCodeP12ViewportComp +ViewportCode::ViewportCode(ViewportComp *) +# +--format=gnu +__12iv2_6_Borderii +iv2_6_Border::iv2_6_Border(int, int) +# +--format=gnu +__12ivBreak_Listl +ivBreak_List::ivBreak_List(long) +# +--format=gnu +__14iv2_6_MenuItemiP12ivInteractor +iv2_6_MenuItem::iv2_6_MenuItem(int, ivInteractor *) +# +--format=gnu +__20DisplayList_IteratorR11DisplayList +DisplayList_Iterator::DisplayList_Iterator(DisplayList &) +# +--format=gnu +__3fooRT0 +foo::foo(foo &) +# +--format=gnu +__3fooiN31 +foo::foo(int, int, int, int) +# +--format=gnu +__3fooiRT0iT2iT2 +foo::foo(int, foo &, int, foo &, int, foo &) +# +--format=gnu +__6KeyMapPT0 +KeyMap::KeyMap(KeyMap *) +# +--format=gnu +__8ArrowCmdP6EditorUiUi +ArrowCmd::ArrowCmd(Editor *, unsigned int, unsigned int) +# +--format=gnu +__9F_EllipseiiiiP7Graphic +F_Ellipse::F_Ellipse(int, int, int, int, Graphic *) +# +--format=gnu +__9FrameDataP9FrameCompi +FrameData::FrameData(FrameComp *, int) +# +--format=gnu +__9HVGraphicP9CanvasVarP7Graphic +HVGraphic::HVGraphic(CanvasVar *, Graphic *) +# +--format=gnu +__Q23foo3bar +foo::bar::bar(void) +# +--format=gnu +__Q33foo3bar4bell +foo::bar::bell::bell(void) +# +--format=gnu +__aa__3fooRT0 +foo::operator&&(foo &) +# +--format=gnu +__aad__3fooRT0 +foo::operator&=(foo &) +# +--format=gnu +__ad__3fooRT0 +foo::operator&(foo &) +# +--format=gnu +__adv__3fooRT0 +foo::operator/=(foo &) +# +--format=gnu +__aer__3fooRT0 +foo::operator^=(foo &) +# +--format=gnu +__als__3fooRT0 +foo::operator<<=(foo &) +# +--format=gnu +__amd__3fooRT0 +foo::operator%=(foo &) +# +--format=gnu +__ami__3fooRT0 +foo::operator-=(foo &) +# +--format=gnu +__aml__3FixRT0 +Fix::operator*=(Fix &) +# +--format=gnu +__aml__5Fix16i +Fix16::operator*=(int) +# +--format=gnu +__aml__5Fix32RT0 +Fix32::operator*=(Fix32 &) +# +--format=gnu +__aor__3fooRT0 +foo::operator|=(foo &) +# +--format=gnu +__apl__3fooRT0 +foo::operator+=(foo &) +# +--format=gnu +__ars__3fooRT0 +foo::operator>>=(foo &) +# +--format=gnu +__as__3fooRT0 +foo::operator=(foo &) +# +--format=gnu +__cl__3fooRT0 +foo::operator()(foo &) +# +--format=gnu +__cl__6Normal +Normal::operator()(void) +# +--format=gnu +__cl__6Stringii +String::operator()(int, int) +# +--format=gnu +__cm__3fooRT0 +foo::operator, (foo &) +# +--format=gnu +__co__3foo +foo::operator~(void) +# +--format=gnu +__dl__3fooPv +foo::operator delete(void *) +# +--format=gnu +__dv__3fooRT0 +foo::operator/(foo &) +# +--format=gnu +__eq__3fooRT0 +foo::operator==(foo &) +# +--format=gnu +__er__3fooRT0 +foo::operator^(foo &) +# +--format=gnu +__ge__3fooRT0 +foo::operator>=(foo &) +# +--format=gnu +__gt__3fooRT0 +foo::operator>(foo &) +# +--format=gnu +__le__3fooRT0 +foo::operator<=(foo &) +# +--format=gnu +__ls__3fooRT0 +foo::operator<<(foo &) +# +--format=gnu +__ls__FR7ostreamPFR3ios_R3ios +operator<<(ostream &, ios &(*)(ios &)) +# +--format=gnu +__ls__FR7ostreamR3Fix +operator<<(ostream &, Fix &) +# +--format=gnu +__lt__3fooRT0 +foo::operator<(foo &) +# +--format=gnu +__md__3fooRT0 +foo::operator%(foo &) +# +--format=gnu +__mi__3fooRT0 +foo::operator-(foo &) +# +--format=gnu +__ml__3fooRT0 +foo::operator*(foo &) +# +--format=gnu +__mm__3fooi +foo::operator--(int) +# +--format=gnu +__ne__3fooRT0 +foo::operator!=(foo &) +# +--format=gnu +__nt__3foo +foo::operator!(void) +# +--format=gnu +__nw__3fooi +foo::operator new(int) +# +--format=gnu +__oo__3fooRT0 +foo::operator||(foo &) +# +--format=gnu +__opPc__3foo +foo::operator char *(void) +# +--format=gnu +__opi__3foo +foo::operator int(void) +# +--format=gnu +__or__3fooRT0 +foo::operator|(foo &) +# +--format=gnu +__pl__3fooRT0 +foo::operator+(foo &) +# +--format=gnu +__pp__3fooi +foo::operator++(int) +# +--format=gnu +__rf__3foo +foo::operator->(void) +# +--format=gnu +__rm__3fooRT0 +foo::operator->*(foo &) +# +--format=gnu +__rs__3fooRT0 +foo::operator>>(foo &) +# +--format=gnu +_new_Fix__FUs +_new_Fix(unsigned short) +# +--format=gnu +_vt.foo +foo virtual table +# +--format=gnu +_vt.foo.bar +foo::bar virtual table +# +--format=gnu +_vt\$foo +foo virtual table +# +--format=gnu +_vt\$foo\$bar +foo::bar virtual table +# +--format=gnu +append__7ivGlyphPT0 +ivGlyph::append(ivGlyph *) +# +--format=gnu +clearok__FP7_win_sti +clearok(_win_st *, int) +# +--format=gnu +complexfunc2__FPFPc_i +complexfunc2(int (*)(char *)) +# +--format=gnu +complexfunc3__FPFPFPl_s_i +complexfunc3(int (*)(short (*)(long *))) +# +--format=gnu +complexfunc4__FPFPFPc_s_i +complexfunc4(int (*)(short (*)(char *))) +# +--format=gnu +complexfunc5__FPFPc_PFl_i +complexfunc5(int (*(*)(char *))(long)) +# +--format=gnu +complexfunc6__FPFPi_PFl_i +complexfunc6(int (*(*)(int *))(long)) +# +--format=gnu +complexfunc7__FPFPFPc_i_PFl_i +complexfunc7(int (*(*)(int (*)(char *)))(long)) +# +--format=gnu +foo__FiN30 +foo(int, int, int, int) +# +--format=gnu +foo__FiR3fooiT1iT1 +foo(int, foo &, int, foo &, int, foo &) +# +--format=gnu +foo___3barl +bar::foo_(long) +# +--format=gnu +insert__15ivClippingStacklRP8_XRegion +ivClippingStack::insert(long, _XRegion *&) +# +--format=gnu +insert__16ChooserInfo_ListlR11ChooserInfo +ChooserInfo_List::insert(long, ChooserInfo &) +# +--format=gnu +insert__17FontFamilyRepListlRP15ivFontFamilyRep +FontFamilyRepList::insert(long, ivFontFamilyRep *&) +# +--format=gnu +leaveok__FP7_win_stc +leaveok(_win_st *, char) +# +--format=gnu +left_mover__C7ivMFKitP12ivAdjustableP7ivStyle +ivMFKit::left_mover(ivAdjustable *, ivStyle *) const +# +--format=gnu +overload1arg__FSc +overload1arg(signed char) +# +--format=gnu +overload1arg__FUc +overload1arg(unsigned char) +# +--format=gnu +overload1arg__FUi +overload1arg(unsigned int) +# +--format=gnu +overload1arg__FUl +overload1arg(unsigned long) +# +--format=gnu +overload1arg__FUs +overload1arg(unsigned short) +# +--format=gnu +overload1arg__Fc +overload1arg(char) +# +--format=gnu +overload1arg__Fd +overload1arg(double) +# +--format=gnu +overload1arg__Ff +overload1arg(float) +# +--format=gnu +overload1arg__Fi +overload1arg(int) +# +--format=gnu +overload1arg__Fl +overload1arg(long) +# +--format=gnu +overload1arg__Fs +overload1arg(short) +# +--format=gnu +overload1arg__Fv +overload1arg(void) +# +--format=gnu +overloadargs__Fi +overloadargs(int) +# +--format=gnu +overloadargs__Fii +overloadargs(int, int) +# +--format=gnu +overloadargs__Fiii +overloadargs(int, int, int) +# +--format=gnu +overloadargs__Fiiii +overloadargs(int, int, int, int) +# +--format=gnu +overloadargs__Fiiiii +overloadargs(int, int, int, int, int) +# +--format=gnu +overloadargs__Fiiiiii +overloadargs(int, int, int, int, int, int) +# +--format=gnu +overloadargs__Fiiiiiii +overloadargs(int, int, int, int, int, int, int) +# +--format=gnu +overloadargs__Fiiiiiiii +overloadargs(int, int, int, int, int, int, int, int) +# +--format=gnu +overloadargs__Fiiiiiiiii +overloadargs(int, int, int, int, int, int, int, int, int) +# +--format=gnu +overloadargs__Fiiiiiiiiii +overloadargs(int, int, int, int, int, int, int, int, int, int) +# +--format=gnu +overloadargs__Fiiiiiiiiiii +overloadargs(int, int, int, int, int, int, int, int, int, int, int) +# +--format=gnu +poke__8ivRasterUlUlffff +ivRaster::poke(unsigned long, unsigned long, float, float, float, float) +# +--format=gnu +polar__Fdd +polar(double, double) +# +--format=gnu +scale__13ivTransformerff +ivTransformer::scale(float, float) +# +--format=gnu +sgetn__7filebufPci +filebuf::sgetn(char *, int) +# +--format=gnu +shift__FP5_FrepiT0 +shift(_Frep *, int, _Frep *) +# +--format=gnu +test__C6BitSeti +BitSet::test(int) const +# +--format=gnu +test__C6BitSetii +BitSet::test(int, int) const +# +--format=gnu +text_source__8Documentl +Document::text_source(long) +# +--format=gnu +variance__6Erlangd +Erlang::variance(double) +# +--format=gnu +view__14DocumentViewerP8ItemViewP11TabularItem +DocumentViewer::view(ItemView *, TabularItem *) +# +--format=gnu +xy_extents__11ivExtensionffff +ivExtension::xy_extents(float, float, float, float) +# +--format=gnu +zero__8osMemoryPvUi +osMemory::zero(void *, unsigned int) +# +--format=gnu +_2T4\$N +T4::N +# +--format=gnu +_Q22T42t1\$N +T4::t1::N +# +--format=gnu +get__2T1 +T1::get(void) +# +--format=gnu +get__Q22T11a +T1::a::get(void) +# +--format=gnu +get__Q32T11a1b +T1::a::b::get(void) +# +--format=gnu +get__Q42T11a1b1c +T1::a::b::c::get(void) +# +--format=gnu +get__Q52T11a1b1c1d +T1::a::b::c::d::get(void) +# +--format=gnu +put__2T1i +T1::put(int) +# +--format=gnu +put__Q22T11ai +T1::a::put(int) +# +--format=gnu +put__Q32T11a1bi +T1::a::b::put(int) +# +--format=gnu +put__Q42T11a1b1ci +T1::a::b::c::put(int) +# +--format=gnu +put__Q52T11a1b1c1di +T1::a::b::c::d::put(int) +# +--format=gnu +bar__3fooPv +foo::bar(void *) +# +--format=gnu +bar__C3fooPv +foo::bar(void *) const +# +--format=gnu +__eq__3fooRT0 +foo::operator==(foo &) +# +--format=gnu +__eq__C3fooR3foo +foo::operator==(foo &) const +# +--format=gnu +elem__t6vector1Zdi +vector::elem(int) +# +--format=gnu +elem__t6vector1Zii +vector::elem(int) +# +--format=gnu +__t6vector1Zdi +vector::vector(int) +# +--format=gnu +__t6vector1Zii +vector::vector(int) +# +--format=gnu +_\$_t6vector1Zdi +vector::~vector(int) +# +--format=gnu +_\$_t6vector1Zii +vector::~vector(int) +# +--format=gnu +__nw__t2T11ZcUi +T1::operator new(unsigned int) +# +--format=gnu +__nw__t2T11Z1tUi +T1::operator new(unsigned int) +# +--format=gnu +__dl__t2T11ZcPv +T1::operator delete(void *) +# +--format=gnu +__dl__t2T11Z1tPv +T1::operator delete(void *) +# +--format=gnu +__t2T11Zci +T1::T1(int) +# +--format=gnu +__t2T11Zc +T1::T1(void) +# +--format=gnu +__t2T11Z1ti +T1::T1(int) +# +--format=gnu +__t2T11Z1t +T1::T1(void) +# +--format=gnu +__Q2t4List1Z10VHDLEntity3Pix +List::Pix::Pix(void) +# +--format=gnu +__Q2t4List1Z10VHDLEntity3PixPQ2t4List1Z10VHDLEntity7element +List::Pix::Pix(List::element *) +# +--format=gnu +__Q2t4List1Z10VHDLEntity3PixRCQ2t4List1Z10VHDLEntity3Pix +List::Pix::Pix(List::Pix const &) +# +--format=gnu +__Q2t4List1Z10VHDLEntity7elementRC10VHDLEntityPT0 +List::element::element(VHDLEntity const &, List::element *) +# +--format=gnu +__Q2t4List1Z10VHDLEntity7elementRCQ2t4List1Z10VHDLEntity7element +List::element::element(List::element const &) +# +--format=gnu +__cl__C11VHDLLibraryGt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity +VHDLLibrary::operator()(PixX >) const +# +--format=gnu +__cl__Ct4List1Z10VHDLEntityRCQ2t4List1Z10VHDLEntity3Pix +List::operator()(List::Pix const &) const +# +--format=gnu +__ne__FPvRCQ2t4List1Z10VHDLEntity3Pix +operator!=(void *, List::Pix const &) +# +--format=gnu +__ne__FPvRCt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity +operator!=(void *, PixX > const &) +# +--format=gnu +__t4List1Z10VHDLEntityRCt4List1Z10VHDLEntity +List::List(List const &) +# +--format=gnu +__t4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity +PixX >::PixX(void) +# +--format=gnu +__t4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntityP14VHDLLibraryRepGQ2t4List1Z10VHDLEntity3Pix +PixX >::PixX(VHDLLibraryRep *, List::Pix) +# +--format=gnu +__t4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntityRCt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity +PixX >::PixX(PixX > const &) +# +--format=gnu +nextE__C11VHDLLibraryRt4PixX3Z11VHDLLibraryZ14VHDLLibraryRepZt4List1Z10VHDLEntity +VHDLLibrary::nextE(PixX > &) const +# +--format=gnu +next__Ct4List1Z10VHDLEntityRQ2t4List1Z10VHDLEntity3Pix +List::next(List::Pix &) const +# +--format=gnu +_GLOBAL_\$D\$set +global destructors keyed to set +# +--format=gnu +_GLOBAL_\$I\$set +global constructors keyed to set +# +--format=gnu +__as__t5ListS1ZUiRCt5ListS1ZUi +ListS::operator=(ListS const &) +# +--format=gnu +__cl__Ct5ListS1ZUiRCQ2t5ListS1ZUi3Vix +ListS::operator()(ListS::Vix const &) const +# +--format=gnu +__cl__Ct5SetLS1ZUiRCQ2t5SetLS1ZUi3Vix +SetLS::operator()(SetLS::Vix const &) const +# +--format=gnu +__t10ListS_link1ZUiRCUiPT0 +ListS_link::ListS_link(unsigned int const &, ListS_link *) +# +--format=gnu +__t10ListS_link1ZUiRCt10ListS_link1ZUi +ListS_link::ListS_link(ListS_link const &) +# +--format=gnu +__t5ListS1ZUiRCt5ListS1ZUi +ListS::ListS(ListS const &) +# +--format=gnu +next__Ct5ListS1ZUiRQ2t5ListS1ZUi3Vix +ListS::next(ListS::Vix &) const +# +--format=gnu +__ne__FPvRCQ2t5SetLS1ZUi3Vix +operator!=(void *, SetLS::Vix const &) +# +--format=gnu +__t8ListElem1Z5LabelRt4List1Z5Label +ListElem
configure Property changes : Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Index: waitpid.c =================================================================== --- waitpid.c (nonexistent) +++ waitpid.c (revision 1765) @@ -0,0 +1,11 @@ +int +waitpid (pid, stat_loc, options) + int pid, *stat_loc, options; +{ + for (;;) + { + int wpid = wait(stat_loc); + if (wpid == pid || wpid == -1) + return wpid; + } +} Index: getopt.c =================================================================== --- getopt.c (nonexistent) +++ getopt.c (revision 1765) @@ -0,0 +1,1056 @@ +/* Getopt for GNU. + NOTE: getopt is now part of the C library, so if you don't know what + "Keep this file name-space clean" means, talk to drepper@gnu.org + before changing it! + + Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98 + Free Software Foundation, Inc. + + NOTE: The canonical source of this file is maintained with the GNU C Library. + Bugs can be reported to bug-glibc@gnu.org. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + USA. */ + +/* This tells Alpha OSF/1 not to define a getopt prototype in . + Ditto for AIX 3.2 and . */ +#ifndef _NO_PROTO +# define _NO_PROTO +#endif + +#ifdef HAVE_CONFIG_H +# include +#endif + +#if !defined __STDC__ || !__STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +# ifndef const +# define const +# endif +#endif + +#include + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself. This code is part of the GNU C + Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object files, + it is simpler to just do this in the source for each such file. */ + +#define GETOPT_INTERFACE_VERSION 2 +#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 +# include +# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION +# define ELIDE_CODE +# endif +#endif + +#ifndef ELIDE_CODE + + +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#ifdef __GNU_LIBRARY__ +/* Don't include stdlib.h for non-GNU C libraries because some of them + contain conflicting prototypes for getopt. */ +# include +# include +#endif /* GNU C library. */ + +#ifdef VMS +# include +# if HAVE_STRING_H - 0 +# include +# endif +#endif + +#ifndef _ +/* This is for other GNU distributions with internationalized messages. + When compiling libc, the _ macro is predefined. */ +# ifdef HAVE_LIBINTL_H +# include +# define _(msgid) gettext (msgid) +# else +# define _(msgid) (msgid) +# endif +#endif + +/* This version of `getopt' appears to the caller like standard Unix `getopt' + but it behaves differently for the user, since it allows the user + to intersperse the options with the other arguments. + + As `getopt' works, it permutes the elements of ARGV so that, + when it is done, all the options precede everything else. Thus + all application programs are extended to handle flexible argument order. + + Setting the environment variable POSIXLY_CORRECT disables permutation. + Then the behavior is completely standard. + + GNU application programs can use a third alternative mode in which + they can distinguish the relative order of options and other arguments. */ + +#include "getopt.h" + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +char *optarg = NULL; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +/* 1003.2 says this must be 1 before any call. */ +int optind = 1; + +/* Formerly, initialization of getopt depended on optind==0, which + causes problems with re-calling getopt as programs generally don't + know that. */ + +int __getopt_initialized = 0; + +/* The next char to be scanned in the option-element + in which the last option character we returned was found. + This allows us to pick up the scan where we left off. + + If this is zero, or a null string, it means resume the scan + by advancing to the next ARGV-element. */ + +static char *nextchar; + +/* Callers store zero here to inhibit the error message + for unrecognized options. */ + +int opterr = 1; + +/* Set to an option character which was unrecognized. + This must be initialized on some systems to avoid linking in the + system's own getopt implementation. */ + +int optopt = '?'; + +/* Describe how to deal with options that follow non-option ARGV-elements. + + If the caller did not specify anything, + the default is REQUIRE_ORDER if the environment variable + POSIXLY_CORRECT is defined, PERMUTE otherwise. + + REQUIRE_ORDER means don't recognize them as options; + stop option processing when the first non-option is seen. + This is what Unix does. + This mode of operation is selected by either setting the environment + variable POSIXLY_CORRECT, or using `+' as the first character + of the list of option characters. + + PERMUTE is the default. We permute the contents of ARGV as we scan, + so that eventually all the non-options are at the end. This allows options + to be given in any order, even with programs that were not written to + expect this. + + RETURN_IN_ORDER is an option available to programs that were written + to expect options and other ARGV-elements in any order and that care about + the ordering of the two. We describe each non-option ARGV-element + as if it were the argument of an option with character code 1. + Using `-' as the first character of the list of option characters + selects this mode of operation. + + The special argument `--' forces an end of option-scanning regardless + of the value of `ordering'. In the case of RETURN_IN_ORDER, only + `--' can cause `getopt' to return -1 with `optind' != ARGC. */ + +static enum +{ + REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER +} ordering; + +/* Value of POSIXLY_CORRECT environment variable. */ +static char *posixly_correct; + +#ifdef __GNU_LIBRARY__ +/* We want to avoid inclusion of string.h with non-GNU libraries + because there are many ways it can cause trouble. + On some systems, it contains special magic macros that don't work + in GCC. */ +# include +# define my_index strchr +#else + +# if HAVE_STRING_H +# include +# else +# if HAVE_STRINGS_H +# include +# endif +# endif + +/* Avoid depending on library functions or files + whose names are inconsistent. */ + +#ifndef getenv +extern char *getenv (); +#endif + +static char * +my_index (str, chr) + const char *str; + int chr; +{ + while (*str) + { + if (*str == chr) + return (char *) str; + str++; + } + return 0; +} + +/* If using GCC, we can safely declare strlen this way. + If not using GCC, it is ok not to declare it. */ +#ifdef __GNUC__ +/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. + That was relevant to code that was here before. */ +# if (!defined __STDC__ || !__STDC__) && !defined strlen +/* gcc with -traditional declares the built-in strlen to return int, + and has done so at least since version 2.4.5. -- rms. */ +extern int strlen (const char *); +# endif /* not __STDC__ */ +#endif /* __GNUC__ */ + +#endif /* not __GNU_LIBRARY__ */ + +/* Handle permutation of arguments. */ + +/* Describe the part of ARGV that contains non-options that have + been skipped. `first_nonopt' is the index in ARGV of the first of them; + `last_nonopt' is the index after the last of them. */ + +static int first_nonopt; +static int last_nonopt; + +#ifdef _LIBC +/* Bash 2.0 gives us an environment variable containing flags + indicating ARGV elements that should not be considered arguments. */ + +/* Defined in getopt_init.c */ +extern char *__getopt_nonoption_flags; + +static int nonoption_flags_max_len; +static int nonoption_flags_len; + +static int original_argc; +static char *const *original_argv; + +/* Make sure the environment variable bash 2.0 puts in the environment + is valid for the getopt call we must make sure that the ARGV passed + to getopt is that one passed to the process. */ +static void +__attribute__ ((unused)) +store_args_and_env (int argc, char *const *argv) +{ + /* XXX This is no good solution. We should rather copy the args so + that we can compare them later. But we must not use malloc(3). */ + original_argc = argc; + original_argv = argv; +} +# ifdef text_set_element +text_set_element (__libc_subinit, store_args_and_env); +# endif /* text_set_element */ + +# define SWAP_FLAGS(ch1, ch2) \ + if (nonoption_flags_len > 0) \ + { \ + char __tmp = __getopt_nonoption_flags[ch1]; \ + __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ + __getopt_nonoption_flags[ch2] = __tmp; \ + } +#else /* !_LIBC */ +# define SWAP_FLAGS(ch1, ch2) +#endif /* _LIBC */ + +/* Exchange two adjacent subsequences of ARGV. + One subsequence is elements [first_nonopt,last_nonopt) + which contains all the non-options that have been skipped so far. + The other is elements [last_nonopt,optind), which contains all + the options processed since those non-options were skipped. + + `first_nonopt' and `last_nonopt' are relocated so that they describe + the new indices of the non-options in ARGV after they are moved. */ + +#if defined __STDC__ && __STDC__ +static void exchange (char **); +#endif + +static void +exchange (argv) + char **argv; +{ + int bottom = first_nonopt; + int middle = last_nonopt; + int top = optind; + char *tem; + + /* Exchange the shorter segment with the far end of the longer segment. + That puts the shorter segment into the right place. + It leaves the longer segment in the right place overall, + but it consists of two parts that need to be swapped next. */ + +#ifdef _LIBC + /* First make sure the handling of the `__getopt_nonoption_flags' + string can work normally. Our top argument must be in the range + of the string. */ + if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) + { + /* We must extend the array. The user plays games with us and + presents new arguments. */ + char *new_str = malloc (top + 1); + if (new_str == NULL) + nonoption_flags_len = nonoption_flags_max_len = 0; + else + { + memset (__mempcpy (new_str, __getopt_nonoption_flags, + nonoption_flags_max_len), + '\0', top + 1 - nonoption_flags_max_len); + nonoption_flags_max_len = top + 1; + __getopt_nonoption_flags = new_str; + } + } +#endif + + while (top > middle && middle > bottom) + { + if (top - middle > middle - bottom) + { + /* Bottom segment is the short one. */ + int len = middle - bottom; + register int i; + + /* Swap it with the top part of the top segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[top - (middle - bottom) + i]; + argv[top - (middle - bottom) + i] = tem; + SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); + } + /* Exclude the moved bottom segment from further swapping. */ + top -= len; + } + else + { + /* Top segment is the short one. */ + int len = top - middle; + register int i; + + /* Swap it with the bottom part of the bottom segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[middle + i]; + argv[middle + i] = tem; + SWAP_FLAGS (bottom + i, middle + i); + } + /* Exclude the moved top segment from further swapping. */ + bottom += len; + } + } + + /* Update records for the slots the non-options now occupy. */ + + first_nonopt += (optind - last_nonopt); + last_nonopt = optind; +} + +/* Initialize the internal data when the first call is made. */ + +#if defined __STDC__ && __STDC__ +static const char *_getopt_initialize (int, char *const *, const char *); +#endif +static const char * +_getopt_initialize (argc, argv, optstring) + int argc; + char *const *argv; + const char *optstring; +{ + /* Start processing options with ARGV-element 1 (since ARGV-element 0 + is the program name); the sequence of previously skipped + non-option ARGV-elements is empty. */ + + first_nonopt = last_nonopt = optind; + + nextchar = NULL; + + posixly_correct = getenv ("POSIXLY_CORRECT"); + + /* Determine how to handle the ordering of options and nonoptions. */ + + if (optstring[0] == '-') + { + ordering = RETURN_IN_ORDER; + ++optstring; + } + else if (optstring[0] == '+') + { + ordering = REQUIRE_ORDER; + ++optstring; + } + else if (posixly_correct != NULL) + ordering = REQUIRE_ORDER; + else + ordering = PERMUTE; + +#ifdef _LIBC + if (posixly_correct == NULL + && argc == original_argc && argv == original_argv) + { + if (nonoption_flags_max_len == 0) + { + if (__getopt_nonoption_flags == NULL + || __getopt_nonoption_flags[0] == '\0') + nonoption_flags_max_len = -1; + else + { + const char *orig_str = __getopt_nonoption_flags; + int len = nonoption_flags_max_len = strlen (orig_str); + if (nonoption_flags_max_len < argc) + nonoption_flags_max_len = argc; + __getopt_nonoption_flags = + (char *) malloc (nonoption_flags_max_len); + if (__getopt_nonoption_flags == NULL) + nonoption_flags_max_len = -1; + else + memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), + '\0', nonoption_flags_max_len - len); + } + } + nonoption_flags_len = nonoption_flags_max_len; + } + else + nonoption_flags_len = 0; +#endif + + return optstring; +} + +/* Scan elements of ARGV (whose length is ARGC) for option characters + given in OPTSTRING. + + If an element of ARGV starts with '-', and is not exactly "-" or "--", + then it is an option element. The characters of this element + (aside from the initial '-') are option characters. If `getopt' + is called repeatedly, it returns successively each of the option characters + from each of the option elements. + + If `getopt' finds another option character, it returns that character, + updating `optind' and `nextchar' so that the next call to `getopt' can + resume the scan with the following option character or ARGV-element. + + If there are no more option characters, `getopt' returns -1. + Then `optind' is the index in ARGV of the first ARGV-element + that is not an option. (The ARGV-elements have been permuted + so that those that are not options now come last.) + + OPTSTRING is a string containing the legitimate option characters. + If an option character is seen that is not listed in OPTSTRING, + return '?' after printing an error message. If you set `opterr' to + zero, the error message is suppressed but we still return '?'. + + If a char in OPTSTRING is followed by a colon, that means it wants an arg, + so the following text in the same ARGV-element, or the text of the following + ARGV-element, is returned in `optarg'. Two colons mean an option that + wants an optional arg; if there is text in the current ARGV-element, + it is returned in `optarg', otherwise `optarg' is set to zero. + + If OPTSTRING starts with `-' or `+', it requests different methods of + handling the non-option ARGV-elements. + See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. + + Long-named options begin with `--' instead of `-'. + Their names may be abbreviated as long as the abbreviation is unique + or is an exact match for some defined option. If they have an + argument, it follows the option name in the same ARGV-element, separated + from the option name by a `=', or else the in next ARGV-element. + When `getopt' finds a long-named option, it returns 0 if that option's + `flag' field is nonzero, the value of the option's `val' field + if the `flag' field is zero. + + The elements of ARGV aren't really const, because we permute them. + But we pretend they're const in the prototype to be compatible + with other systems. + + LONGOPTS is a vector of `struct option' terminated by an + element containing a name which is zero. + + LONGIND returns the index in LONGOPT of the long-named option found. + It is only valid when a long-named option has been found by the most + recent call. + + If LONG_ONLY is nonzero, '-' as well as '--' can introduce + long-named options. */ + +int +_getopt_internal (argc, argv, optstring, longopts, longind, long_only) + int argc; + char *const *argv; + const char *optstring; + const struct option *longopts; + int *longind; + int long_only; +{ + optarg = NULL; + + if (optind == 0 || !__getopt_initialized) + { + if (optind == 0) + optind = 1; /* Don't scan ARGV[0], the program name. */ + optstring = _getopt_initialize (argc, argv, optstring); + __getopt_initialized = 1; + } + + /* Test whether ARGV[optind] points to a non-option argument. + Either it does not have option syntax, or there is an environment flag + from the shell indicating it is not an option. The later information + is only used when the used in the GNU libc. */ +#ifdef _LIBC +# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ + || (optind < nonoption_flags_len \ + && __getopt_nonoption_flags[optind] == '1')) +#else +# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') +#endif + + if (nextchar == NULL || *nextchar == '\0') + { + /* Advance to the next ARGV-element. */ + + /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been + moved back by the user (who may also have changed the arguments). */ + if (last_nonopt > optind) + last_nonopt = optind; + if (first_nonopt > optind) + first_nonopt = optind; + + if (ordering == PERMUTE) + { + /* If we have just processed some options following some non-options, + exchange them so that the options come first. */ + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (last_nonopt != optind) + first_nonopt = optind; + + /* Skip any additional non-options + and extend the range of non-options previously skipped. */ + + while (optind < argc && NONOPTION_P) + optind++; + last_nonopt = optind; + } + + /* The special ARGV-element `--' means premature end of options. + Skip it like a null option, + then exchange with previous non-options as if it were an option, + then skip everything else like a non-option. */ + + if (optind != argc && !strcmp (argv[optind], "--")) + { + optind++; + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (first_nonopt == last_nonopt) + first_nonopt = optind; + last_nonopt = argc; + + optind = argc; + } + + /* If we have done all the ARGV-elements, stop the scan + and back over any non-options that we skipped and permuted. */ + + if (optind == argc) + { + /* Set the next-arg-index to point at the non-options + that we previously skipped, so the caller will digest them. */ + if (first_nonopt != last_nonopt) + optind = first_nonopt; + return -1; + } + + /* If we have come to a non-option and did not permute it, + either stop the scan or describe it to the caller and pass it by. */ + + if (NONOPTION_P) + { + if (ordering == REQUIRE_ORDER) + return -1; + optarg = argv[optind++]; + return 1; + } + + /* We have found another option-ARGV-element. + Skip the initial punctuation. */ + + nextchar = (argv[optind] + 1 + + (longopts != NULL && argv[optind][1] == '-')); + } + + /* Decode the current option-ARGV-element. */ + + /* Check whether the ARGV-element is a long option. + + If long_only and the ARGV-element has the form "-f", where f is + a valid short option, don't consider it an abbreviated form of + a long option that starts with f. Otherwise there would be no + way to give the -f short option. + + On the other hand, if there's a long option "fubar" and + the ARGV-element is "-fu", do consider that an abbreviation of + the long option, just like "--fu", and not "-f" with arg "u". + + This distinction seems to be the most useful approach. */ + + if (longopts != NULL + && (argv[optind][1] == '-' + || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) + { + char *nameend; + const struct option *p; + const struct option *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = -1; + int option_index; + + for (nameend = nextchar; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; + + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, nextchar, nameend - nextchar)) + { + if ((unsigned int) (nameend - nextchar) + == (unsigned int) strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else + /* Second or later nonexact match found. */ + ambig = 1; + } + + if (ambig && !exact) + { + if (opterr) + fprintf (stderr, _("%s: option `%s' is ambiguous\n"), + argv[0], argv[optind]); + nextchar += strlen (nextchar); + optind++; + optopt = 0; + return '?'; + } + + if (pfound != NULL) + { + option_index = indfound; + optind++; + if (*nameend) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + optarg = nameend + 1; + else + { + if (opterr) + { + if (argv[optind - 1][1] == '-') + /* --option */ + fprintf (stderr, + _("%s: option `--%s' doesn't allow an argument\n"), + argv[0], pfound->name); + else + /* +option or -option */ + fprintf (stderr, + _("%s: option `%c%s' doesn't allow an argument\n"), + argv[0], argv[optind - 1][0], pfound->name); + + nextchar += strlen (nextchar); + + optopt = pfound->val; + return '?'; + } + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + if (opterr) + fprintf (stderr, + _("%s: option `%s' requires an argument\n"), + argv[0], argv[optind - 1]); + nextchar += strlen (nextchar); + optopt = pfound->val; + return optstring[0] == ':' ? ':' : '?'; + } + } + nextchar += strlen (nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + + /* Can't find it as a long option. If this is not getopt_long_only, + or the option starts with '--' or is not a valid short + option, then it's an error. + Otherwise interpret it as a short option. */ + if (!long_only || argv[optind][1] == '-' + || my_index (optstring, *nextchar) == NULL) + { + if (opterr) + { + if (argv[optind][1] == '-') + /* --option */ + fprintf (stderr, _("%s: unrecognized option `--%s'\n"), + argv[0], nextchar); + else + /* +option or -option */ + fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), + argv[0], argv[optind][0], nextchar); + } + nextchar = (char *) ""; + optind++; + optopt = 0; + return '?'; + } + } + + /* Look at and handle the next short option-character. */ + + { + char c = *nextchar++; + char *temp = my_index (optstring, c); + + /* Increment `optind' when we start to process its last character. */ + if (*nextchar == '\0') + ++optind; + + if (temp == NULL || c == ':') + { + if (opterr) + { + if (posixly_correct) + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, _("%s: illegal option -- %c\n"), + argv[0], c); + else + fprintf (stderr, _("%s: invalid option -- %c\n"), + argv[0], c); + } + optopt = c; + return '?'; + } + /* Convenience. Treat POSIX -W foo same as long option --foo */ + if (temp[0] == 'W' && temp[1] == ';') + { + char *nameend; + const struct option *p; + const struct option *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = 0; + int option_index; + + /* This is an option that requires an argument. */ + if (*nextchar != '\0') + { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } + else if (optind == argc) + { + if (opterr) + { + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, _("%s: option requires an argument -- %c\n"), + argv[0], c); + } + optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + return c; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; + + /* optarg is now the argument, see if it's in the + table of longopts. */ + + for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; + + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, nextchar, nameend - nextchar)) + { + if ((unsigned int) (nameend - nextchar) == strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else + /* Second or later nonexact match found. */ + ambig = 1; + } + if (ambig && !exact) + { + if (opterr) + fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), + argv[0], argv[optind]); + nextchar += strlen (nextchar); + optind++; + return '?'; + } + if (pfound != NULL) + { + option_index = indfound; + if (*nameend) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + optarg = nameend + 1; + else + { + if (opterr) + fprintf (stderr, _("\ +%s: option `-W %s' doesn't allow an argument\n"), + argv[0], pfound->name); + + nextchar += strlen (nextchar); + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + if (opterr) + fprintf (stderr, + _("%s: option `%s' requires an argument\n"), + argv[0], argv[optind - 1]); + nextchar += strlen (nextchar); + return optstring[0] == ':' ? ':' : '?'; + } + } + nextchar += strlen (nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + nextchar = NULL; + return 'W'; /* Let the application handle it. */ + } + if (temp[1] == ':') + { + if (temp[2] == ':') + { + /* This is an option that accepts an argument optionally. */ + if (*nextchar != '\0') + { + optarg = nextchar; + optind++; + } + else + optarg = NULL; + nextchar = NULL; + } + else + { + /* This is an option that requires an argument. */ + if (*nextchar != '\0') + { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } + else if (optind == argc) + { + if (opterr) + { + /* 1003.2 specifies the format of this message. */ + fprintf (stderr, + _("%s: option requires an argument -- %c\n"), + argv[0], c); + } + optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; + nextchar = NULL; + } + } + return c; + } +} + +int +getopt (argc, argv, optstring) + int argc; + char *const *argv; + const char *optstring; +{ + return _getopt_internal (argc, argv, optstring, + (const struct option *) 0, + (int *) 0, + 0); +} + +#endif /* Not ELIDE_CODE. */ + +#ifdef TEST + +/* Compile with -DTEST to make an executable for use in testing + the above definition of `getopt'. */ + +int +main (argc, argv) + int argc; + char **argv; +{ + int c; + int digit_optind = 0; + + while (1) + { + int this_option_optind = optind ? optind : 1; + + c = getopt (argc, argv, "abc:d:0123456789"); + if (c == -1) + break; + + switch (c) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value `%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ Index: insque.c =================================================================== --- insque.c (nonexistent) +++ insque.c (revision 1765) @@ -0,0 +1,50 @@ +/* insque(3C) routines + 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[]; + }; + + void insque (struct qelem *elem, struct qelem *pred) + + void remque (struct qelem *elem) + +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. +*/ + + +struct qelem { + struct qelem *q_forw; + struct qelem *q_back; +}; + + +void +insque (elem, pred) + struct qelem *elem; + struct qelem *pred; +{ + elem -> q_forw = pred -> q_forw; + pred -> q_forw -> q_back = elem; + elem -> q_back = pred; + pred -> q_forw = elem; +} + + +void +remque (elem) + struct qelem *elem; +{ + elem -> q_forw -> q_back = elem -> q_back; + elem -> q_back -> q_forw = elem -> q_forw; +} Index: strchr.c =================================================================== --- strchr.c (nonexistent) +++ strchr.c (revision 1765) @@ -0,0 +1,34 @@ +/* Portable version of strchr() + 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) + +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 + +char * +strchr (s, c) + register const char *s; + int c; +{ + do { + if (*s == c) + { + return (char*)s; + } + } while (*s++); + return (0); +} Index: index.c =================================================================== --- index.c (nonexistent) +++ index.c (revision 1765) @@ -0,0 +1,11 @@ +/* Stub implementation of (obsolete) index(). */ + +extern char * strchr(); + +char * +index (s, c) + char *s; + int c; +{ + return strchr (s, c); +} Index: concat.c =================================================================== --- concat.c (nonexistent) +++ concat.c (revision 1765) @@ -0,0 +1,167 @@ +/* Concatenate variable number of strings. + Copyright (C) 1991, 1994 Free Software Foundation, Inc. + Written by Fred Fish @ Cygnus Support + +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. */ + + +/* + +NAME + + concat -- concatenate a variable number of strings + +SYNOPSIS + + #include + + 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. + +NOTES + + This function uses xmalloc() which is expected to be a front end + function to malloc() that deals with low memory situations. In + typical use, if malloc() returns NULL then xmalloc() diverts to an + error handler routine which never returns, and thus xmalloc will + never return a NULL pointer. If the client application wishes to + deal with low memory situations itself, it should supply an xmalloc + that just directly invokes malloc and blindly returns whatever + malloc returns. +*/ + + +#include "ansidecl.h" +#include "libiberty.h" + +#ifdef ANSI_PROTOTYPES +#include +#else +#include +#endif + +#ifdef __STDC__ +#include +extern size_t strlen (const char *s); +#else +extern int strlen (); +#endif + +#define NULLP (char *)0 + +/* VARARGS */ +#ifdef ANSI_PROTOTYPES +char * +concat (const char *first, ...) +#else +char * +concat (va_alist) + va_dcl +#endif +{ + register int length; + register char *newstr; + register char *end; + register const char *arg; + va_list args; +#ifndef ANSI_PROTOTYPES + const char *first; +#endif + + /* First compute the size of the result and get sufficient memory. */ + +#ifdef ANSI_PROTOTYPES + va_start (args, first); +#else + va_start (args); + first = va_arg (args, const char *); +#endif + + 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); + + /* Now copy the individual pieces to the result string. */ + + 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); +} + +#ifdef MAIN + +/* Simple little test driver. */ + +#include + +int +main () +{ + printf ("\"\" = \"%s\"\n", concat (NULLP)); + printf ("\"a\" = \"%s\"\n", concat ("a", NULLP)); + printf ("\"ab\" = \"%s\"\n", concat ("a", "b", NULLP)); + printf ("\"abc\" = \"%s\"\n", concat ("a", "b", "c", NULLP)); + printf ("\"abcd\" = \"%s\"\n", concat ("ab", "cd", NULLP)); + printf ("\"abcde\" = \"%s\"\n", concat ("ab", "c", "de", NULLP)); + printf ("\"abcdef\" = \"%s\"\n", concat ("", "a", "", "bcd", "ef", NULLP)); + return 0; +} + +#endif Index: strtoul.c =================================================================== --- strtoul.c (nonexistent) +++ strtoul.c (revision 1765) @@ -0,0 +1,107 @@ +/* + * Copyright (c) 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. [rescinded 22 July 1999] + * 4. 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. + * + * 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. + */ + +#include +#include +#include +#if 0 +#include +#endif +#include "ansidecl.h" + +#ifndef ULONG_MAX +#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF */ +#endif + +/* + * Convert a string to an unsigned long integer. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +unsigned long +strtoul(nptr, endptr, base) + const char *nptr; + char **endptr; + register int base; +{ + register const char *s = nptr; + register unsigned long acc; + register int c; + register unsigned long cutoff; + register int neg = 0, any, cutlim; + + /* + * See strtol for comments as to the logic used. + */ + do { + c = *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else if (c == '+') + c = *s++; + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; + cutlim = (unsigned long)ULONG_MAX % (unsigned long)base; + for (acc = 0, any = 0;; c = *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) + any = -1; + else { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) { + acc = ULONG_MAX; + errno = ERANGE; + } else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = (char *) (any ? s - 1 : nptr); + return (acc); +} Index: getcwd.c =================================================================== --- getcwd.c (nonexistent) +++ getcwd.c (revision 1765) @@ -0,0 +1,64 @@ +/* Emulate getcwd using getwd. + This function is in the public domain. */ + +/* +NAME + getcwd -- get absolute pathname for current working directory + +SYNOPSIS + char *getcwd (char pathname[len], 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. + + 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(). + +*/ + +#include "config.h" + +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#include + +extern char *getwd (); +extern int errno; + +#ifndef MAXPATHLEN +#define MAXPATHLEN 1024 +#endif + +char * +getcwd (buf, len) + char *buf; + int len; +{ + char ourbuf[MAXPATHLEN]; + char *result; + + result = getwd (ourbuf); + if (result) { + if (strlen (ourbuf) >= len) { + errno = ERANGE; + return 0; + } + if (!buf) { + buf = (char*)malloc(len); + if (!buf) { + errno = ENOMEM; + return 0; + } + } + strcpy (buf, ourbuf); + } + return buf; +} Index: strncasecmp.c =================================================================== --- strncasecmp.c (nonexistent) +++ strncasecmp.c (revision 1765) @@ -0,0 +1,82 @@ +/* + * Copyright (c) 1987 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of California at Berkeley. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific written prior permission. This software + * is provided ``as is'' without express or implied warranty. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87"; +#endif /* LIBC_SCCS and not lint */ + +#include +#ifdef __STDC__ +#include +#else +#define size_t unsigned long +#endif + +/* + * This array is designed for mapping upper and lower case letter + * together for a case independent comparison. The mappings are + * based upon ascii character sequences. + */ +static 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', + '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', + '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', + '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', + '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', + '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', + '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', + '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', + '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', + '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', + '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', + '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', + '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', + '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', + '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', + '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', + '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', + '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', + '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', + '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', + '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', + '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', + '\300', '\341', '\342', '\343', '\344', '\345', '\346', '\347', + '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', + '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', + '\370', '\371', '\372', '\333', '\334', '\335', '\336', '\337', + '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', + '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', + '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', + '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', +}; + +int +strncasecmp(s1, s2, n) + const char *s1, *s2; + register size_t n; +{ + register unsigned char u1, u2; + + for (; n != 0; --n) { + u1 = (unsigned char) *s1++; + u2 = (unsigned char) *s2++; + if (charmap[u1] != charmap[u2]) { + return charmap[u1] - charmap[u2]; + } + if (u1 == '\0') { + return 0; + } + } + return 0; +} Index: choose-temp.c =================================================================== --- choose-temp.c (nonexistent) +++ choose-temp.c (revision 1765) @@ -0,0 +1,203 @@ +/* Utility to pick a temporary filename prefix. + Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. + +This file is part of the libiberty library. +Libiberty is free software; you can redistribute it and/or +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. */ + +/* This file exports two functions: choose_temp_base and make_temp_file. */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include /* May get P_tmpdir. */ +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_STRING_H +#include +#endif +#ifdef HAVE_SYS_FILE_H +#include /* 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 + +/* Name of temporary file. + mktemp requires 6 trailing X's. */ +#define TEMP_FILE "ccXXXXXX" + +/* 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 char * +try (dir, base) + 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 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. It use + is not recommended. */ + +char * +choose_temp_base () +{ + char *base = 0; + 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); + 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); + if (strlen (temp_filename) == 0) + 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; +{ + 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; +} Index: objalloc.c =================================================================== --- objalloc.c (nonexistent) +++ objalloc.c (revision 1765) @@ -0,0 +1,291 @@ +/* objalloc.c -- routines to allocate memory for objects + Copyright 1997 Free Software Foundation, Inc. + Written by Ian Lance Taylor, Cygnus Solutions. + +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 "ansidecl.h" +#include "objalloc.h" + +/* Get a definition for NULL. */ +#include + +#if VMS +#include +#include +#else + +#ifdef ANSI_PROTOTYPES +/* Get a definition for size_t. */ +#include +#endif + +/* For systems with larger pointers than ints, this must be declared. */ +extern PTR malloc PARAMS ((size_t)); +extern void free PARAMS ((PTR)); +#endif + +/* These routines allocate space for an object. Freeing allocated + space may or may not free all more recently allocated space. + + We handle large and small allocation requests differently. If we + don't have enough space in the current block, and the allocation + request is for more than 512 bytes, we simply pass it through to + malloc. */ + +/* The objalloc structure is defined in objalloc.h. */ + +/* This structure appears at the start of each chunk. */ + +struct objalloc_chunk +{ + /* Next chunk. */ + struct objalloc_chunk *next; + /* If this chunk contains large objects, this is the value of + current_ptr when this chunk was allocated. If this chunk + contains small objects, this is NULL. */ + char *current_ptr; +}; + +/* The aligned size of objalloc_chunk. */ + +#define CHUNK_HEADER_SIZE \ + ((sizeof (struct objalloc_chunk) + OBJALLOC_ALIGN - 1) \ + &~ (OBJALLOC_ALIGN - 1)) + +/* We ask for this much memory each time we create a chunk which is to + hold small objects. */ + +#define CHUNK_SIZE (4096 - 32) + +/* A request for this amount or more is just passed through to malloc. */ + +#define BIG_REQUEST (512) + +/* Create an objalloc structure. */ + +struct objalloc * +objalloc_create () +{ + struct objalloc *ret; + struct objalloc_chunk *chunk; + + ret = (struct objalloc *) malloc (sizeof *ret); + if (ret == NULL) + return NULL; + + ret->chunks = (PTR) malloc (CHUNK_SIZE); + if (ret->chunks == NULL) + { + free (ret); + return NULL; + } + + chunk = (struct objalloc_chunk *) ret->chunks; + chunk->next = NULL; + chunk->current_ptr = NULL; + + ret->current_ptr = (char *) chunk + CHUNK_HEADER_SIZE; + ret->current_space = CHUNK_SIZE - CHUNK_HEADER_SIZE; + + return ret; +} + +/* Allocate space from an objalloc structure. */ + +PTR +_objalloc_alloc (o, len) + struct objalloc *o; + unsigned long len; +{ + /* We avoid confusion from zero sized objects by always allocating + at least 1 byte. */ + if (len == 0) + len = 1; + + len = (len + OBJALLOC_ALIGN - 1) &~ (OBJALLOC_ALIGN - 1); + + if (len <= o->current_space) + { + o->current_ptr += len; + o->current_space -= len; + return (PTR) (o->current_ptr - len); + } + + if (len >= BIG_REQUEST) + { + char *ret; + struct objalloc_chunk *chunk; + + ret = (char *) malloc (CHUNK_HEADER_SIZE + len); + if (ret == NULL) + return NULL; + + chunk = (struct objalloc_chunk *) ret; + chunk->next = (struct objalloc_chunk *) o->chunks; + chunk->current_ptr = o->current_ptr; + + o->chunks = (PTR) chunk; + + return (PTR) (ret + CHUNK_HEADER_SIZE); + } + else + { + struct objalloc_chunk *chunk; + + chunk = (struct objalloc_chunk *) malloc (CHUNK_SIZE); + if (chunk == NULL) + return NULL; + chunk->next = (struct objalloc_chunk *) o->chunks; + chunk->current_ptr = NULL; + + o->current_ptr = (char *) chunk + CHUNK_HEADER_SIZE; + o->current_space = CHUNK_SIZE - CHUNK_HEADER_SIZE; + + o->chunks = (PTR) chunk; + + return objalloc_alloc (o, len); + } +} + +/* Free an entire objalloc structure. */ + +void +objalloc_free (o) + struct objalloc *o; +{ + struct objalloc_chunk *l; + + l = (struct objalloc_chunk *) o->chunks; + while (l != NULL) + { + struct objalloc_chunk *next; + + next = l->next; + free (l); + l = next; + } + + free (o); +} + +/* Free a block from an objalloc structure. This also frees all more + recently allocated blocks. */ + +void +objalloc_free_block (o, block) + struct objalloc *o; + PTR block; +{ + struct objalloc_chunk *p, *small; + char *b = (char *) block; + + /* First set P to the chunk which contains the block we are freeing, + and set Q to the last small object chunk we see before P. */ + small = NULL; + for (p = (struct objalloc_chunk *) o->chunks; p != NULL; p = p->next) + { + if (p->current_ptr == NULL) + { + if (b > (char *) p && b < (char *) p + CHUNK_SIZE) + break; + small = p; + } + else + { + if (b == (char *) p + CHUNK_HEADER_SIZE) + break; + } + } + + /* If we can't find the chunk, the caller has made a mistake. */ + if (p == NULL) + abort (); + + if (p->current_ptr == NULL) + { + struct objalloc_chunk *q; + struct objalloc_chunk *first; + + /* The block is in a chunk containing small objects. We can + free every chunk through SMALL, because they have certainly + been allocated more recently. After SMALL, we will not see + any chunks containing small objects; we can free any big + chunk if the current_ptr is greater than or equal to B. We + can then reset the new current_ptr to B. */ + + first = NULL; + q = (struct objalloc_chunk *) o->chunks; + while (q != p) + { + struct objalloc_chunk *next; + + next = q->next; + if (small != NULL) + { + if (small == q) + small = NULL; + free (q); + } + else if (q->current_ptr > b) + free (q); + else if (first == NULL) + first = q; + + q = next; + } + + if (first == NULL) + first = p; + o->chunks = (PTR) first; + + /* Now start allocating from this small block again. */ + o->current_ptr = b; + o->current_space = ((char *) p + CHUNK_SIZE) - b; + } + else + { + struct objalloc_chunk *q; + char *current_ptr; + + /* This block is in a large chunk by itself. We can free + everything on the list up to and including this block. We + then start allocating from the next chunk containing small + objects, setting current_ptr from the value stored with the + large chunk we are freeing. */ + + current_ptr = p->current_ptr; + p = p->next; + + q = (struct objalloc_chunk *) o->chunks; + while (q != p) + { + struct objalloc_chunk *next; + + next = q->next; + free (q); + q = next; + } + + o->chunks = (PTR) p; + + while (p->current_ptr != NULL) + p = p->next; + + o->current_ptr = current_ptr; + o->current_space = ((char *) p + CHUNK_SIZE) - current_ptr; + } +} Index: memcpy.c =================================================================== --- memcpy.c (nonexistent) +++ memcpy.c (revision 1765) @@ -0,0 +1,28 @@ +/* memcpy (the standard C function) + 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); + +DESCRIPTION + Copy LENGTH bytes from memory region pointed to by IN to memory + region pointed to by OUT. +*/ + +#include +#ifdef __STDC__ +#include +#else +#define size_t unsigned long +#endif + +PTR +DEFUN(memcpy, (out, in, length), PTR out AND const PTR in AND size_t length) +{ + bcopy(in, out, length); + return out; +} Index: getpwd.c =================================================================== --- getpwd.c (nonexistent) +++ getpwd.c (revision 1765) @@ -0,0 +1,115 @@ +/* getpwd.c - get the working directory */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +#include +#ifndef errno +extern int errno; +#endif + +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#if HAVE_SYS_STAT_H +#include +#endif + +/* Prototype these in case the system headers don't provide them. */ +extern char *getpwd (); +extern char *getwd (); + +#include "libiberty.h" + +/* Virtually every UN*X system now in common use (except for pre-4.3-tahoe + BSD systems) now provides getcwd as called for by POSIX. Allow for + the few exceptions to the general rule here. */ + +#if !defined(HAVE_GETCWD) && defined(HAVE_GETWD) +#define getcwd(buf,len) getwd(buf) +#endif + +#ifdef MAXPATHLEN +#define GUESSPATHLEN (MAXPATHLEN + 1) +#else +#define GUESSPATHLEN 100 +#endif + +#if !(defined (VMS) || (defined(_WIN32) && !defined(__CYGWIN__))) + +/* Get the working directory. Use the PWD environment variable if it's + set correctly, since this is faster and gives more uniform answers + to the user. Yield the working directory if successful; otherwise, + yield 0 and set errno. */ + +char * +getpwd () +{ + static char *pwd; + static int failure_errno; + + char *p = pwd; + size_t s; + struct stat dotstat, pwdstat; + + if (!p && !(errno = failure_errno)) + { + if (! ((p = getenv ("PWD")) != 0 + && *p == '/' + && stat (p, &pwdstat) == 0 + && stat (".", &dotstat) == 0 + && dotstat.st_ino == pwdstat.st_ino + && dotstat.st_dev == pwdstat.st_dev)) + + /* The shortcut didn't work. Try the slow, ``sure'' way. */ + for (s = GUESSPATHLEN; ! getcwd (p = xmalloc (s), s); s *= 2) + { + int e = errno; + free (p); +#ifdef ERANGE + if (e != ERANGE) +#endif + { + errno = failure_errno = e; + p = 0; + break; + } + } + + /* Cache the result. This assumes that the program does + not invoke chdir between calls to getpwd. */ + pwd = p; + } + return p; +} + +#else /* VMS || _WIN32 && !__CYGWIN__ */ + +#ifndef MAXPATHLEN +#define MAXPATHLEN 255 +#endif + +char * +getpwd () +{ + static char *pwd = 0; + + if (!pwd) + pwd = getcwd (xmalloc (MAXPATHLEN + 1), MAXPATHLEN + 1 +#ifdef VMS + , 0 +#endif + ); + return pwd; +} + +#endif /* VMS || _WIN32 && !__CYGWIN__ */ Index: copysign.c =================================================================== --- copysign.c (nonexistent) +++ copysign.c (revision 1765) @@ -0,0 +1,140 @@ +#include + +#ifdef __IEEE_BIG_ENDIAN + +typedef union +{ + double value; + struct + { + unsigned int sign : 1; + unsigned int exponent: 11; + unsigned int fraction0:4; + unsigned int fraction1:16; + unsigned int fraction2:16; + unsigned int fraction3:16; + + } number; + struct + { + unsigned int sign : 1; + unsigned int exponent: 11; + unsigned int quiet:1; + unsigned int function0:3; + unsigned int function1:16; + unsigned int function2:16; + unsigned int function3:16; + } nan; + struct + { + unsigned long msw; + unsigned long lsw; + } parts; + long aslong[2]; +} __ieee_double_shape_type; + +#endif + +#ifdef __IEEE_LITTLE_ENDIAN + +typedef union +{ + double value; + struct + { +#ifdef __SMALL_BITFIELDS + unsigned int fraction3:16; + unsigned int fraction2:16; + unsigned int fraction1:16; + unsigned int fraction0: 4; +#else + unsigned int fraction1:32; + unsigned int fraction0:20; +#endif + unsigned int exponent :11; + unsigned int sign : 1; + } number; + struct + { +#ifdef __SMALL_BITFIELDS + unsigned int function3:16; + unsigned int function2:16; + unsigned int function1:16; + unsigned int function0:3; +#else + unsigned int function1:32; + unsigned int function0:19; +#endif + unsigned int quiet:1; + unsigned int exponent: 11; + unsigned int sign : 1; + } nan; + struct + { + unsigned long lsw; + unsigned long msw; + } parts; + + long aslong[2]; + +} __ieee_double_shape_type; + +#endif + +#ifdef __IEEE_BIG_ENDIAN +typedef union +{ + float value; + struct + { + unsigned int sign : 1; + unsigned int exponent: 8; + unsigned int fraction0: 7; + unsigned int fraction1: 16; + } number; + struct + { + unsigned int sign:1; + unsigned int exponent:8; + unsigned int quiet:1; + unsigned int function0:6; + unsigned int function1:16; + } nan; + long p1; + +} __ieee_float_shape_type; +#endif + +#ifdef __IEEE_LITTLE_ENDIAN +typedef union +{ + float value; + struct + { + unsigned int fraction0: 7; + unsigned int fraction1: 16; + unsigned int exponent: 8; + unsigned int sign : 1; + } number; + struct + { + unsigned int function1:16; + unsigned int function0:6; + unsigned int quiet:1; + unsigned int exponent:8; + unsigned int sign:1; + } nan; + long p1; + +} __ieee_float_shape_type; +#endif + + +double DEFUN(copysign, (x, y), double x AND double y) +{ + __ieee_double_shape_type a,b; + b.value = y; + a.value = x; + a.number.sign =b.number.sign; + return a.value; +} Index: strstr.c =================================================================== --- strstr.c (nonexistent) +++ strstr.c (revision 1765) @@ -0,0 +1,51 @@ +/* Simple implementation of strstr for systems without it. + This function is in the public domain. */ + +/* + +NAME + + strstr -- locate first occurance of a substring + +SYNOPSIS + + #include + + 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 + +*/ + + +/* FIXME: The above description is ANSI compiliant. This routine has not + been validated to comply with it. -fnf */ + +char * +strstr (s1, s2) + char *s1, *s2; +{ + register char *p = s1; + extern char *strchr (); + extern int strncmp (); +#if __GNUC__==2 + extern __SIZE_TYPE__ strlen (); +#endif + register int len = strlen (s2); + + for (; (p = strchr (p, *s2)) != 0; p++) + { + if (strncmp (p, s2, len) == 0) + { + return (p); + } + } + return (0); +} Index: mpw.c =================================================================== --- mpw.c (nonexistent) +++ mpw.c (revision 1765) @@ -0,0 +1,1010 @@ +/* MPW-Unix compatibility library. + Copyright (C) 1993, 1994, 1995, 1996 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. */ + +/* This should only be compiled and linked under MPW. */ + +#include "mpw.h" + +#include + +#ifndef USE_MW_HEADERS +#include +#include +#endif + +#include +#include + +#include + +/* Initialize to 0 at first, then set to errno_max() later. */ + +int sys_nerr = 0; + +/* Debug flag for pathname hacking. Set this to one and rebuild. */ + +int DebugPI = -1; + +void +mpwify_filename(char *unixname, char *macname) +{ + int i, j; + + /* (should truncate 255 chars from end of name, not beginning) */ + if (strlen (unixname) > 255) + { + fprintf (stderr, "Pathname \"%s\" is too long for Macs, truncating\n", + unixname); + } + j = 0; + /* If you're going to end up with one or more colons in the middle of a + path after an all-Unix relative path is translated, you must add a + colon on the front, so that the first component is not thought to be + a disk name. */ + if (unixname[0] != '/' && ! strchr (unixname, ':') && strchr (unixname, '/')) + { + macname[j++] = ':'; + } + for (i = 0; unixname[i] != '\0' && i < 255; ++i) + { + if (i == 0 && unixname[i] == '/') + { + if (strncmp (unixname, "/tmp/", 5) == 0) + { + /* A temporary name, make a more Mac-flavored tmpname. */ + /* A better choice would be {Boot}Trash:foo, but + that would require being able to identify the + boot disk's and trashcan's name. Another option + would be to have an env var, so user can point it + at a ramdisk. */ + macname[j++] = ':'; + macname[j++] = 't'; + macname[j++] = 'm'; + macname[j++] = 'p'; + macname[j++] = '_'; + i += 4; + } + else + { + /* Don't copy the leading slash. */ + } + } + else if (unixname[i] == ':' && unixname[i+1] == '/') + { + macname[j++] = ':'; + i += 1; + } + else if (unixname[i] == '.' && unixname[i+1] == '/') + { + macname[j++] = ':'; + i += 1; + } + else if (unixname[i] == '.' && unixname[i+1] == '.' && unixname[i+2] == '/') + { + macname[j++] = ':'; + macname[j++] = ':'; + i += 2; + } + else if (unixname[i] == '/') + { + macname[j++] = ':'; + } + else + { + macname[j++] = unixname[i]; + } + } + macname[j] = '\0'; + /* Allow for getting the debug flag from an env var; quite useful. */ + if (DebugPI < 0) + DebugPI = (*(getenv ("DEBUG_PATHNAMES")) == '1' ? 1 : 0); + if (DebugPI) + { + fprintf (stderr, "# Made \"%s\"\n", unixname); + fprintf (stderr, "# into \"%s\"\n", macname); + } +} + +/* MPW-flavored basename finder. */ + +char * +mpw_basename (name) + char *name; +{ + char *base = name; + + while (*name) + { + if (*name++ == ':') + { + base = name; + } + } + return base; +} + +/* Mixed MPW/Unix basename finder. This can be led astray by + filenames with slashes in them and come up with a basename that + either corresponds to no file or (worse) to some other file, so + should only be tried if other methods of finding a file via a + basename have failed. */ + +char * +mpw_mixed_basename (name) + char *name; +{ + char *base = name; + + while (*name) + { + if (*name == '/' || *name == ':') + { + base = name + 1; + } + ++name; + } + return base; +} + +/* This function is fopen() modified to create files that are type TEXT + or 'BIN ', and always of type 'MPS '. */ + +FILE * +mpw_fopen (char *name, char *mode) +{ +#undef fopen + int errnum; + FILE *fp; + char tmpname[256]; + + mpwify_filename (name, tmpname); + PROGRESS (1); + fp = fopen (tmpname, mode); + errnum = errno; + + /* If writing, need to set type and creator usefully. */ + if (strchr (mode, 'w')) + { + char *pname = (char *) malloc (strlen (tmpname) + 2); + OSErr e; + struct FInfo fi; + + pname[0] = strlen (tmpname); + strcpy (pname+1, tmpname); + + e = GetFInfo ((ConstStr255Param) pname, 0, &fi); + /* should do spiffier error handling */ + if (e != 0) + fprintf(stderr, "GetFInfo returns %d\n", e); + if (strchr (mode, 'b')) + { + fi.fdType = (OSType) 'BIN '; + } + else + { + fi.fdType = (OSType) 'TEXT'; + } + fi.fdCreator = (OSType) 'MPS '; + e = SetFInfo ((ConstStr255Param) pname, 0, &fi); + if (e != 0) + fprintf(stderr, "SetFInfo returns %d\n", e); + free (pname); + } + if (fp == NULL) + errno = errnum; + return fp; +} + +/* This is a version of fseek() modified to fill the file with zeros + if seeking past the end of it. */ + +#define ZEROBLKSIZE 4096 + +char zeros[ZEROBLKSIZE]; + +int +mpw_fseek (FILE *fp, int offset, int whence) +{ +#undef fseek + int cursize, numleft; + + PROGRESS (1); + if (whence == SEEK_SET) + { + fseek (fp, 0, SEEK_END); + cursize = ftell (fp); + if (offset > cursize) + { + numleft = offset - cursize; + while (numleft > ZEROBLKSIZE) + { + /* This might fail, should check for that. */ + PROGRESS (1); + fwrite (zeros, 1, ZEROBLKSIZE, fp); + numleft -= ZEROBLKSIZE; + } + PROGRESS (1); + fwrite (zeros, 1, numleft, fp); + fflush (fp); + } + } + return fseek (fp, offset, whence); +} + +int +mpw_fread (char *ptr, int size, int nitems, FILE *stream) +{ +#undef fread + int rslt; + + PROGRESS (1); + rslt = fread (ptr, size, nitems, stream); + PROGRESS (1); + return rslt; +} + +int +mpw_fwrite (char *ptr, int size, int nitems, FILE *stream) +{ +#undef fwrite + int rslt; + + PROGRESS (1); + rslt = fwrite (ptr, size, nitems, stream); + PROGRESS (1); + return rslt; +} + +int +link () +{ + fprintf (stderr, "link not available!\n"); + mpw_abort (); +} + +int +fork () +{ + fprintf (stderr, "fork not available!\n"); + mpw_abort (); +} + +int +vfork () +{ + fprintf (stderr, "vfork not available!\n"); + mpw_abort (); + return (-1); +} + +int +pipe (int *fd) +{ + fprintf (stderr, "pipe not available!\n"); + mpw_abort (); + return (-1); +} + +#ifndef USE_MW_HEADERS +int +execvp (char *file, char **argv) +{ + fprintf (stderr, "execvp not available!\n"); + mpw_abort (); + return (-1); +} + +int +execv (char *path, char **argv) +{ + fprintf (stderr, "execv not available!\n"); + mpw_abort (); + return (-1); +} +#endif + +int +kill (int pid, int sig) +{ + fprintf (stderr, "kill not available!\n"); + mpw_abort (); + return (-1); +} + +int +wait (int *status) +{ + *status = 0; + return 0; +} + +#ifndef USE_MW_HEADERS +int +sleep (int seconds) +{ + unsigned long start_time, now; + + time (&start_time); + + while (1) + { + PROGRESS (1); + time (&now); + if (now > start_time + seconds) + return 0; + } +} +#endif + +void +putenv (char *str) +{ + /* The GCC driver calls this to do things for collect2, but we + don't care about collect2. */ +} + +int +chmod (char *path, int mode) +{ + /* Pretend it was all OK. */ + return 0; +} + +#ifndef USE_MW_HEADERS +int +getuid () +{ + /* One value is as good as another... */ + return 0; +} + +int +getgid () +{ + /* One value is as good as another... */ + return 0; +} +#endif + +/* Instead of coredumping, which is not a normal Mac facility, we + drop into Macsbug. If we then "g" from Macsbug, the program will + exit cleanly. */ + +void +mpw_abort () +{ + /* Make sure no output still buffered up, then zap into MacsBug. */ + fflush(stdout); + fflush(stderr); + printf("## Abort! ##\n"); +#ifdef MPW_SADE + SysError(8005); +#else + Debugger(); +#endif + /* "g" in MacsBug will then cause a regular error exit. */ + exit (1); +} + +/* Imitation getrusage based on the ANSI clock() function. */ + +int +getrusage (int who, struct rusage *rusage) +{ + int clk = clock (); + +#if 0 + rusage->ru_utime.tv_sec = clk / CLOCKS_PER_SEC; + rusage->ru_utime.tv_usec = ((clk * 1000) / CLOCKS_PER_SEC) * 1000; + rusage->ru_stime.tv_sec = 0; + rusage->ru_stime.tv_usec = 0; +#endif +} + +int +sbrk () +{ + return 0; +} + +#ifndef USE_MW_HEADERS +int +isatty (int fd) +{ + return 0; +} + +/* This is inherited from Timothy Murray's Posix library. */ + +#include "utime.h" + +int +utime (char *filename, struct utimbuf *times) +{ + CInfoPBRec cipbr; + HFileInfo *fpb = (HFileInfo *) &cipbr; + DirInfo *dpb = (DirInfo *) &cipbr; + unsigned char pname[256]; + short err; + + strcpy ((char *) pname, filename); + c2pstr (pname); + + dpb->ioDrDirID = 0L; + fpb->ioNamePtr = pname; + fpb->ioVRefNum = 0; + fpb->ioFDirIndex = 0; + fpb->ioFVersNum = 0; + err = PBGetCatInfo (&cipbr, 0); + if (err != noErr) { + errno = ENOENT; + return -1; + } + dpb->ioDrDirID = 0L; + fpb->ioFlMdDat = times->modtime; + fpb->ioFlCrDat = times->actime; + err = PBSetCatInfo (&cipbr, 0); + if (err != noErr) { + errno = EACCES; + return -1; + } + return 0; +} + +int +mkdir (char *path, int mode) +{ + errno = ENOSYS; + return -1; +} + +int +rmdir () +{ + errno = ENOSYS; + return -1; +} +#endif + +chown () +{ + errno = ENOSYS; + return -1; +} + +char *myenviron[] = {NULL}; + +char **environ = myenviron; + +#ifndef USE_MW_HEADERS + +/* Minimal 'stat' emulation: tells directories from files and + gives length and mtime. + + Derived from code written by Guido van Rossum, CWI, Amsterdam + and placed by him in the public domain. */ + +extern int __uid, __gid; + +int __uid = 0; +int __gid = 0; + +/* Bits in ioFlAttrib: */ +#define LOCKBIT (1<<0) /* File locked */ +#define DIRBIT (1<<4) /* It's a directory */ + +/* Macified "stat" in which filename is given relative to a directory, + specified by long DirID. */ + +static int +_stat (char *name, long dirid, struct stat *buf) +{ + CInfoPBRec cipbr; + HFileInfo *fpb = (HFileInfo*) &cipbr; + DirInfo *dpb = (DirInfo*) &cipbr; + Str255 pname; + short err; + + /* Make a temp copy of the name and pascalize. */ + strcpy ((char *) pname, name); + c2pstr (pname); + + cipbr.dirInfo.ioDrDirID = dirid; + cipbr.hFileInfo.ioNamePtr = pname; + cipbr.hFileInfo.ioVRefNum = 0; + cipbr.hFileInfo.ioFDirIndex = 0; + cipbr.hFileInfo.ioFVersNum = 0; + err = PBGetCatInfo (&cipbr, 0); + if (err != noErr) + { + errno = ENOENT; + return -1; + } + /* Mac files are readable if they can be accessed at all. */ + buf->st_mode = 0444; + /* Mark unlocked files as writeable. */ + if (!(fpb->ioFlAttrib & LOCKBIT)) + buf->st_mode |= 0222; + if (fpb->ioFlAttrib & DIRBIT) + { + /* Mark directories as "executable". */ + buf->st_mode |= 0111 | S_IFDIR; + buf->st_size = dpb->ioDrNmFls; + buf->st_rsize = 0; + } + else + { + buf->st_mode |= S_IFREG; + /* Mark apps as "executable". */ + if (fpb->ioFlFndrInfo.fdType == 'APPL') + buf->st_mode |= 0111; + /* Fill in the sizes of data and resource forks. */ + buf->st_size = fpb->ioFlLgLen; + buf->st_rsize = fpb->ioFlRLgLen; + } + /* Fill in various times. */ + buf->st_atime = fpb->ioFlCrDat; + buf->st_mtime = fpb->ioFlMdDat; + buf->st_ctime = fpb->ioFlCrDat; + /* Set up an imitation inode number. */ + buf->st_ino = (unsigned short) fpb->ioDirID; + /* Set up an imitation device. */ + GetVRefNum (buf->st_ino, &buf->st_dev); + buf->st_uid = __uid; + buf->st_gid = __gid; +/* buf->st_FlFndrInfo = fpb->ioFlFndrInfo; */ + return 0; +} + +/* stat() sets up an empty dirid. */ + +int +stat (char *path, struct stat *buf) +{ + long rslt, errnum; + char tmpname[256]; + + mpwify_filename (path, tmpname); + if (DebugPI) + fprintf (stderr, "# stat (%s, %x)", tmpname, buf); + PROGRESS (1); + rslt = _stat (tmpname, 0L, buf); + errnum = errno; + if (DebugPI) + { + fprintf (stderr, " -> %d", rslt); + if (rslt != 0) + fprintf (stderr, " (errno is %d)", errnum); + fprintf (stderr, "\n"); + fflush (stderr); + } + if (rslt != 0) + errno = errnum; + return rslt; +} + +int +fstat (int fd, struct stat *buf) +{ + FCBPBRec fcb; + FILE *fp; + Str255 pathname; + long dirid = 0L, temp; + long rslt, errnum; + short err; + + if (DebugPI < 0) + DebugPI = (*(getenv ("DEBUG_PATHNAMES")) == '1' ? 1 : 0); + if (DebugPI) + fprintf (stderr, "# fstat (%d, %x)", fd, buf); + PROGRESS (1); + pathname[0] = 0; +#ifdef FIOFNAME + /* Use an MPW-specific ioctl to get the pathname associated with + the file descriptor. */ + ioctl (fd, FIOFNAME, (long *) pathname); +#else + you lose +#endif + if (DebugPI) + fprintf (stderr, " (name is %s)", pathname); + dirid = 0L /* fcb.ioFCBParID */ ; + rslt = _stat ((char *) pathname, dirid, buf); + errnum = errno; + if (DebugPI) + { + fprintf (stderr, " -> %d", rslt); + if (rslt != 0) + fprintf (stderr, " (errno is %d)", errnum); + fprintf (stderr, "\n"); + fflush (stderr); + } + if (rslt != 0) + errno = errnum; + return rslt; +} + +#endif /* n USE_MW_HEADERS */ + +chdir () +{ + errno = ENOSYS; + return (-1); +} + +char * +getcwd (char *buf, int size) +{ + if (buf == NULL) + buf = (char *) malloc (size); + strcpy(buf, ":"); + return buf; +} + +/* This should probably be more elaborate for MPW. */ + +char * +getpwd () +{ + return ":"; +} + +int +mpw_open (char *filename, int arg2, int arg3) +{ +#undef open + int fd, errnum = 0; + char tmpname[256]; + + mpwify_filename (filename, tmpname); + fd = open (tmpname, arg2); + errnum = errno; + + if (DebugPI) + { + fprintf (stderr, "# open (%s, %d, %d)", tmpname, arg2, arg3); + fprintf (stderr, " -> %d", fd); + if (fd == -1) + fprintf (stderr, " (errno is %d)", errnum); + fprintf (stderr, "\n"); + } + if (fd == -1) + errno = errnum; + return fd; +} + +int +mpw_access (char *filename, unsigned int cmd) +{ +#undef access + + int rslt, errnum = 0; + struct stat st; + char tmpname[256]; + + mpwify_filename (filename, tmpname); + if (cmd & R_OK || cmd & X_OK) + { + rslt = stat (tmpname, &st); + errnum = errno; + if (rslt >= 0) + { + if ((((st.st_mode & 004) == 0) && (cmd & R_OK)) + || (((st.st_mode & 002) == 0) && (cmd & W_OK)) + || (((st.st_mode & 001) == 0) && (cmd & X_OK))) + { + rslt = -1; + errnum = EACCES; + } + } + } + if (DebugPI) + { + fprintf (stderr, "# mpw_access (%s, %d)", tmpname, cmd); + fprintf (stderr, " -> %d", rslt); + if (rslt != 0) + fprintf (stderr, " (errno is %d)", errnum); + fprintf (stderr, "\n"); + } + if (rslt != 0) + errno = errnum; + return rslt; +} + +/* The MPW library creat() has no mode argument. */ + +int +mpw_creat (char *path, /* mode_t */ int mode) +{ +#undef creat + +#ifdef USE_MW_HEADERS + return creat (path, mode); +#else + return creat (path); +#endif +} + +/* This is a hack to get control in an MPW tool before it crashes the + machine. */ + +mpw_special_init (name) + char *name; +{ + if (strstr (name, "DEBUG")) + DebugStr("\pat beginning of program"); +} + +static int current_umask; + +int +umask(int mask) +{ + int oldmask = current_umask; + + current_umask = mask; + return oldmask; +} + +/* Cursor-spinning stuff that includes metering of spin rate and delays. */ + +/* Nonzero when cursor spinning has been set up properly. */ + +int cursor_inited; + +/* Nonzero if spin should be measured and excessive delays reported. */ + +int measure_spin; + +/* Nonzero if spin histogram and rate data should be written out. */ + +int dump_spin_data; + +long warning_threshold = 400000; + +long bucket_size = 1024; + +long bucket_power = 10; + +long numbuckets = 300; + +int *delay_counts; + +int overflow_count; + +char *current_progress; + +static UnsignedWide last_microseconds; + +static char *last_spin_file = ""; + +static int last_spin_line; + +void +warn_if_spin_delay (char *file, int line) +{ + long diff, ix; + UnsignedWide now; + + Microseconds(&now); + + diff = now.lo - last_microseconds.lo; + + if (diff > warning_threshold) + fprintf (stderr, "# %s: %ld.%06ld sec delay getting from %s:%d to %s:%d\n", + (current_progress ? current_progress : ""), + diff / 1000000, diff % 1000000, + last_spin_file, last_spin_line, file, line); + if (dump_spin_data) + { + if (diff >= 0) + { + ix = diff >> bucket_power; + if (ix >= 0 && ix < numbuckets && delay_counts != NULL) + ++delay_counts[ix]; + else + ++overflow_count; + } + else + fprintf (stderr, "raw diff is %ld (?)\n", diff); + } +} + +void +record_for_spin_delay (char *file, int line) +{ + Microseconds (&last_microseconds); + last_spin_file = file; + last_spin_line = line; +} + +void +mpw_start_progress (char *str, int n, char *file, int line) +{ + int i; + char *measure, *threshold; + + if (!cursor_inited) + { + InitCursorCtl (nil); + cursor_inited = 1; + record_for_spin_delay (file, line); + measure = getenv ("MEASURE_SPIN"); + if (measure != NULL && measure[0] != '\0') + { + measure_spin = 1; + if (strcmp (measure, "all") == 0) + dump_spin_data = 1; + } + threshold = getenv ("SPIN_WARN_THRESHOLD"); + if (threshold != NULL && threshold[0] != '\0') + warning_threshold = atol (threshold); + if (dump_spin_data) + { + if (delay_counts == NULL) + delay_counts = (int *) malloc (numbuckets * sizeof (int)); + for (i = 0; i < numbuckets; ++i) + delay_counts[i] = 0; + overflow_count = 0; + } + } + current_progress = str; + + sys_nerr = errno_max (); + + mpw_special_init (str); +} + +void +mpw_progress (int n) +{ + SpinCursor (32); +} + +void +mpw_progress_measured (int n, char *file, int line) +{ + if (measure_spin) + warn_if_spin_delay (file, line); + SpinCursor (32); + if (measure_spin) + record_for_spin_delay (file, line); +} + +void +mpw_end_progress (char *str, char *file, int line) +{ + long i, delay, count = 0, sum = 0, avgdelay, spinrate; + long curpower = 0, curgroup = 0; + + /* Warn if it's been a while since the last spin. */ + if (measure_spin) + warn_if_spin_delay (file, line); + + /* Dump all the nonzero delay counts and an approximation of the delay. */ + if (dump_spin_data && delay_counts != NULL) + { + for (i = 0; i < numbuckets; ++i) + { + delay = (i + 1) * bucket_size; + sum += delay_counts[i] * (i + 1); + count += delay_counts[i]; + if (delay <= (1 << curpower)) + { + curgroup += delay_counts[i]; + } + else + { + if (curgroup > 0) + fprintf (stderr, + "# %s: %d delays between %ld.%06ld and %ld.%06ld sec\n", + (str ? str : ""), + curgroup, + (1 << curpower) / 1000000, + (1 << curpower) % 1000000, + (1 << (curpower + 1)) / 1000000, + (1 << (curpower + 1)) % 1000000); + ++curpower; + curgroup = 0; + } + } + if (count > 0) + { + avgdelay = (sum * bucket_size) / count; + spinrate = 1000000 / avgdelay; + fprintf (stderr, "# %s: Average spin rate is %d times/sec\n", + (str ? str : ""), spinrate); + } + } +} + +#ifdef PROGRESS_TEST + +/* Test program. */ + +main () +{ + int i, j; + double x = 1.0, y = 2.4; + long start = Microseconds (), tm; FIXME + + START_PROGRESS ("hi", 0); + + for (i = 0; i < 1000; ++i) + { + PROGRESS (1); + + for (j = 0; j < (i * 100); ++j) + { + x += (x * y) / j; + } + } + + END_PROGRESS ("hi"); + + tm = Microseconds () - start; + + printf ("Total time is %d.%d secs\n", tm / 1000000, tm % 1000000); +} + +#endif + +#ifdef USE_MW_HEADERS +/* Empty definitions for Metrowerks' SIOUX console library. */ + +#ifndef __CONSOLE__ +#include +#endif + +short +InstallConsole(short fd) +{ +#pragma unused (fd) + return 0; +} + +void +RemoveConsole(void) +{ +} + +long +WriteCharsToConsole(char *buf, long n) +{ +#pragma unused (buf, n) + return 0; +} + +long ReadCharsFromConsole(char *buf, long n) +{ +#pragma unused (buf, n) + return 0; +} + +extern char * +__ttyname(long fd) +{ + static char *__devicename = "null device"; + + if (fd >= 0 && fd <= 2) + return (__devicename); + return NULL; +} + +#endif Index: mkstemps.c =================================================================== --- mkstemps.c (nonexistent) +++ mkstemps.c (revision 1765) @@ -0,0 +1,128 @@ +/* Copyright (C) 1991, 1992, 1996, 1998 Free Software Foundation, Inc. + This file is derived from mkstemp.c from 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 Library General Public License as + published by the Free Software Foundation; either version 2 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; 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 + +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_STRING_H +#include +#endif +#include +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_SYS_TIME_H +#include +#endif +#include "ansidecl.h" + +/* We need to provide a type for gcc_uint64_t. */ +#ifdef __GNUC__ +typedef unsigned long long gcc_uint64_t; +#else +typedef unsigned long gcc_uint64_t; +#endif + +#ifndef TMP_MAX +#define TMP_MAX 16384 +#endif + +/* Generate a unique temporary file name from TEMPLATE. + + TEMPLATE has the form: + + /ccXXXXXX + + SUFFIX_LEN tells us how long is (it can be zero length). + + The last six characters of TEMPLATE before must be "XXXXXX"; + they are replaced with a string that makes the filename unique. + + Returns a file descriptor open on the file for reading and writing. */ +int +mkstemps (template, suffix_len) + char *template; + int suffix_len; +{ + static const char letters[] + = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + static gcc_uint64_t value; +#ifdef HAVE_GETTIMEOFDAY + struct timeval tv; +#endif + char *XXXXXX; + size_t len; + int count; + + len = strlen (template); + + if ((int) len < 6 + suffix_len + || strncmp (&template[len - 6 - suffix_len], "XXXXXX", 6)) + { + return -1; + } + + XXXXXX = &template[len - 6 - suffix_len]; + +#ifdef HAVE_GETTIMEOFDAY + /* Get some more or less random data. */ + gettimeofday (&tv, NULL); + value += ((gcc_uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid (); +#else + value += getpid (); +#endif + + for (count = 0; count < TMP_MAX; ++count) + { + gcc_uint64_t v = value; + int fd; + + /* Fill in the random bits. */ + XXXXXX[0] = letters[v % 62]; + v /= 62; + XXXXXX[1] = letters[v % 62]; + v /= 62; + XXXXXX[2] = letters[v % 62]; + v /= 62; + XXXXXX[3] = letters[v % 62]; + v /= 62; + XXXXXX[4] = letters[v % 62]; + v /= 62; + XXXXXX[5] = letters[v % 62]; + + fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600); + if (fd >= 0) + /* The file does not exist. */ + return fd; + + /* This is a random value. It is only necessary that the next + TMP_MAX values generated by adding 7777 to VALUE are different + with (module 2^32). */ + value += 7777; + } + + /* We return the null string if we can't find a unique file name. */ + template[0] = '\0'; + return -1; +} Index: mpw-make.sed =================================================================== --- mpw-make.sed (nonexistent) +++ mpw-make.sed (revision 1765) @@ -0,0 +1,51 @@ +# Sed commands to finish translating libiberty's Unix makefile to MPW syntax. + +# Comment out a useless thing. +/^\.always\./s/^/#/ + +# Replace the auto-generated list with the list of what we know we need. +s/`cat needed-list`/"{o}"alloca.c.o "{o}"bcopy.c.o "{o}"getpagesize.c.o "{o}"insque.c.o "{o}"mpw.c.o "{o}"strcasecmp.c.o "{o}"strdup.c.o "{o}"strncasecmp.c.o/ + +# Paste in some desirable definitions. +# The default rule here completely replaces the tricky stuff in the Unix +# Makefile.in. +/^###$/a\ +\ +HDEFINES = -d NEED_sys_siglist -d NEED_sys_errlist -d NEED_basename -d NEED_strcasecmp -d NEED_strncasecmp\ +INCLUDES = -i : -i {INCDIR}: -i {INCDIR}:mpw: -i ::extra-include: -i "{s}"\ +\ +.c.o \\Option-f .c\ + {CC} @DASH_C_FLAG@ {DepDir}{Default}.c {LIBCFLAGS} {INCLUDES} {HDEFINES} @SEGMENT_FLAG({Default})@ -o {TargDir}{Default}.c.o\ + +# Remove dependency on needed-list, which we don't use. +/DO_ALSO =/s/needed-list// + +/INCDIR=/s/"{srcdir}"{MULTISRCTOP}::/"{topsrcdir}"/ + +# Whack out the COMPILE.c trickiness. +/^COMPILE.c /,/^$/d + +# Remove the multido trickiness from the "all" target. +/^all \\Option-f/,/^$/c\ +all \\Option-f {TARGETLIB}\ + + +# Remove the RULE1/RULE2 crud. +/if \[/,/fi/d +/^RULE1 =/,/RULE2 =/d +/RULE2/s/RULE2/TARGETLIB/ + +# Don't want fdmatch ever. +s/ "{o}"fdmatch.c.o// + +# Fix paths to generated files. +/config.h/s/"{s}"config.h/"{o}"config.h/ + +# Whack out config rebuild rules. +/^"{o}"config.h \\Option-f/,/^$/d + + + + + + Index: README =================================================================== --- README (nonexistent) +++ README (revision 1765) @@ -0,0 +1,65 @@ +This directory contains the -liberty library of free software. +It is a collection of subroutines used by various GNU programs. +Current members include: + + getopt -- get options from command line + obstack -- stacks of arbitrarily-sized objects + strerror -- error message strings corresponding to errno + strtol -- string-to-long conversion + strtoul -- string-to-unsigned-long conversion + +We expect many of the GNU subroutines that are floating around to +eventually arrive here. + +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. + +ADDING A NEW FILE +================= + +There are two sets of files: Those that are "required" will be +included in the library for all configurations, while those +that are "optional" will be included in the library only if "needed." + +To add a new required file, edit Makefile to add the source file +name to CFILES and the object file to REQUIRED_OFILES. + +To add a new optional file, it must provide a single function, and the +name of the function must be the same as the name of the file. + + * Add the source file name to CFILES. + + * Add the function to name to the funcs shell variable in + configure.in. + + * Add the function to the AC_CHECK_FUNCS lists just after the + setting of the funcs shell variable. These AC_CHECK_FUNCS calls + are never executed; they are there to make autoheader work + better. + + * Consider the special cases of building libiberty; as of this + writing, the special cases are newlib and VxWorks. If a + particular special case provides the function, you do not need + to do anything. If it does not provide the function, add the + object file to LIBOBJS, and add the function name to the case + controlling whether to define HAVE_func. + +The optional file you've added (e.g. getcwd.c) should compile and work +on all hosts where it is needed. It does not have to work or even +compile on hosts where it is not needed. + +ADDING A NEW CONFIGURATION +========================== + +On most hosts you should be able to use the scheme for automatically +figuring out which files are needed. In that case, you probably +don't need a special Makefile stub for that configuration. + +If the fully automatic scheme doesn't work, you may be able to get +by with defining EXTRA_OFILES in your Makefile stub. This is +a list of object file names that should be treated as required +for this configuration - they will be included in libiberty.a, +regardless of whatever might be in the C library. Index: vasprintf.c =================================================================== --- vasprintf.c (nonexistent) +++ vasprintf.c (revision 1765) @@ -0,0 +1,173 @@ +/* Like vsprintf but provides a pointer to malloc'd storage, which must + be freed by the caller. + Copyright (C) 1994 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 __STDC__ +#include +#else +#include +#endif +#include +#include +#include + +#ifdef TEST +int global_total_width; +#endif + +unsigned long strtoul (); +char *malloc (); + +static int +int_vasprintf (result, format, args) + char **result; + const char *format; + va_list *args; +{ + const char *p = format; + /* Add one to make sure that it is never zero, which might cause malloc + to return NULL. */ + int total_width = strlen (format) + 1; + va_list ap; + + memcpy ((PTR) &ap, (PTR) args, sizeof (va_list)); + + while (*p != '\0') + { + if (*p++ == '%') + { + while (strchr ("-+ #0", *p)) + ++p; + if (*p == '*') + { + ++p; + total_width += abs (va_arg (ap, int)); + } + else + total_width += strtoul (p, &p, 10); + if (*p == '.') + { + ++p; + if (*p == '*') + { + ++p; + total_width += abs (va_arg (ap, int)); + } + else + total_width += strtoul (p, &p, 10); + } + while (strchr ("hlL", *p)) + ++p; + /* Should be big enough for any format specifier except %s and floats. */ + total_width += 30; + switch (*p) + { + case 'd': + case 'i': + case 'o': + case 'u': + case 'x': + case 'X': + case 'c': + (void) va_arg (ap, int); + break; + case 'f': + case 'e': + case 'E': + case 'g': + case 'G': + (void) va_arg (ap, double); + /* Since an ieee double can have an exponent of 307, we'll + make the buffer wide enough to cover the gross case. */ + total_width += 307; + break; + case 's': + total_width += strlen (va_arg (ap, char *)); + break; + case 'p': + case 'n': + (void) va_arg (ap, char *); + break; + } + p++; + } + } +#ifdef TEST + global_total_width = total_width; +#endif + *result = malloc (total_width); + if (*result != NULL) + return vsprintf (*result, format, *args); + else + return 0; +} + +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); +} + +#ifdef TEST +void +checkit +#ifdef __STDC__ + (const char* format, ...) +#else + (va_alist) + va_dcl +#endif +{ + va_list args; + char *result; + +#ifdef __STDC__ + va_start (args, format); +#else + char *format; + va_start (args); + format = va_arg (args, char *); +#endif + vasprintf (&result, format, args); + if (strlen (result) < global_total_width) + printf ("PASS: "); + else + printf ("FAIL: "); + printf ("%d %s\n", global_total_width, result); +} + +int +main () +{ + checkit ("%d", 0x12345678); + checkit ("%200d", 5); + checkit ("%.300d", 6); + checkit ("%100.150d", 7); + checkit ("%s", "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\ +777777777777777777333333333333366666666666622222222222777777777777733333"); + checkit ("%f%s%d%s", 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx"); +} +#endif /* TEST */ Index: memcmp.c =================================================================== --- memcmp.c (nonexistent) +++ memcmp.c (revision 1765) @@ -0,0 +1,38 @@ +/* memcmp -- compare two memory regions. + 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) + +DESCRIPTION + Compare two memory regions and return less than, + equal to, or greater than zero, according to lexicographical + ordering of the compared regions. +*/ + +#include +#ifdef __STDC__ +#include +#else +#define size_t unsigned long +#endif + +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; + + while (count-- > 0) + { + if (*s1++ != *s2++) + return s1[-1] < s2[-1] ? -1 : 1; + } + return 0; +} + Index: acconfig.h =================================================================== --- acconfig.h (nonexistent) +++ acconfig.h (revision 1765) @@ -0,0 +1,11 @@ +/* Define if you have the sys_errlist variable. */ +#undef HAVE_SYS_ERRLIST + +/* Define if you have the sys_nerr variable. */ +#undef HAVE_SYS_NERR + +/* Define if you have the sys_siglist variable. */ +#undef HAVE_SYS_SIGLIST + +/* Define if you have the strerror function. */ +#undef HAVE_STRERROR Index: floatformat.c =================================================================== --- floatformat.c (nonexistent) +++ floatformat.c (revision 1765) @@ -0,0 +1,403 @@ +/* IEEE floating point support routines, for GDB, the GNU Debugger. + Copyright (C) 1991, 1994, 1999 Free Software Foundation, Inc. + +This file is part of GDB. + +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 of the License, 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. */ + +#include "floatformat.h" +#include /* ldexp */ +#ifdef __STDC__ +#include +extern void *memcpy (void *s1, const void *s2, size_t n); +extern void *memset (void *s, int c, size_t n); +#else +extern char *memcpy (); +extern char *memset (); +#endif + +/* The odds that CHAR_BIT will be anything but 8 are low enough that I'm not + going to bother with trying to muck around with whether it is defined in + a system header, what we do if not, etc. */ +#define FLOATFORMAT_CHAR_BIT 8 + +/* floatformats for IEEE single and double, big and little endian. */ +const struct floatformat floatformat_ieee_single_big = +{ + floatformat_big, 32, 0, 1, 8, 127, 255, 9, 23, floatformat_intbit_no +}; +const struct floatformat floatformat_ieee_single_little = +{ + floatformat_little, 32, 0, 1, 8, 127, 255, 9, 23, floatformat_intbit_no +}; +const struct floatformat floatformat_ieee_double_big = +{ + floatformat_big, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no +}; +const struct floatformat floatformat_ieee_double_little = +{ + floatformat_little, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no +}; + +/* floatformat for IEEE double, little endian byte order, with big endian word + ordering, as on the ARM. */ + +const struct floatformat floatformat_ieee_double_littlebyte_bigword = +{ + floatformat_littlebyte_bigword, 64, 0, 1, 11, 1023, 2047, 12, 52, floatformat_intbit_no +}; + +const struct floatformat floatformat_i387_ext = +{ + floatformat_little, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64, + floatformat_intbit_yes +}; +const struct floatformat floatformat_m68881_ext = +{ + /* Note that the bits from 16 to 31 are unused. */ + floatformat_big, 96, 0, 1, 15, 0x3fff, 0x7fff, 32, 64, floatformat_intbit_yes +}; +const struct floatformat floatformat_i960_ext = +{ + /* Note that the bits from 0 to 15 are unused. */ + floatformat_little, 96, 16, 17, 15, 0x3fff, 0x7fff, 32, 64, + floatformat_intbit_yes +}; +const struct floatformat floatformat_m88110_ext = +{ +#ifdef HARRIS_FLOAT_FORMAT + /* 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 +#else + floatformat_big, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64, + floatformat_intbit_yes +#endif /* HARRIS_FLOAT_FORMAT */ +}; +const struct floatformat floatformat_arm_ext = +{ + /* Bits 1 to 16 are unused. */ + floatformat_big, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64, + floatformat_intbit_yes +}; + +static unsigned long get_field PARAMS ((unsigned char *, + enum floatformat_byteorders, + unsigned int, + unsigned int, + unsigned int)); + +/* Extract a field which starts at START and is LEN bytes long. DATA and + TOTAL_LEN are the thing we are extracting it from, in byteorder ORDER. */ +static unsigned long +get_field (data, order, total_len, start, len) + unsigned char *data; + enum floatformat_byteorders order; + unsigned int total_len; + unsigned int start; + unsigned int len; +{ + unsigned long result; + unsigned int cur_byte; + int cur_bitshift; + + /* Start at the least significant part of the field. */ + cur_byte = (start + len) / FLOATFORMAT_CHAR_BIT; + if (order == floatformat_little) + cur_byte = (total_len / FLOATFORMAT_CHAR_BIT) - cur_byte - 1; + cur_bitshift = + ((start + len) % FLOATFORMAT_CHAR_BIT) - FLOATFORMAT_CHAR_BIT; + result = *(data + cur_byte) >> (-cur_bitshift); + cur_bitshift += FLOATFORMAT_CHAR_BIT; + if (order == floatformat_little) + ++cur_byte; + else + --cur_byte; + + /* Move towards the most significant part of the field. */ + while ((unsigned int) cur_bitshift < len) + { + if (len - cur_bitshift < FLOATFORMAT_CHAR_BIT) + /* This is the last byte; zero out the bits which are not part of + this field. */ + result |= + (*(data + cur_byte) & ((1 << (len - cur_bitshift)) - 1)) + << cur_bitshift; + else + result |= *(data + cur_byte) << cur_bitshift; + cur_bitshift += FLOATFORMAT_CHAR_BIT; + if (order == floatformat_little) + ++cur_byte; + else + --cur_byte; + } + return result; +} + +#ifndef min +#define min(a, b) ((a) < (b) ? (a) : (b)) +#endif + +/* Convert from FMT to a double. + FROM is the address of the extended float. + Store the double in *TO. */ + +void +floatformat_to_double (fmt, from, to) + const struct floatformat *fmt; + char *from; + double *to; +{ + unsigned char *ufrom = (unsigned char *)from; + double dto; + long exponent; + unsigned long mant; + unsigned int mant_bits, mant_off; + int mant_bits_left; + int special_exponent; /* It's a NaN, denorm or zero */ + + exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize, + fmt->exp_start, fmt->exp_len); + /* Note that if exponent indicates a NaN, we can't really do anything useful + (not knowing if the host has NaN's, or how to build one). So it will + end up as an infinity or something close; that is OK. */ + + mant_bits_left = fmt->man_len; + mant_off = fmt->man_start; + dto = 0.0; + + special_exponent = exponent == 0 || (unsigned long) exponent == fmt->exp_nan; + + /* Don't bias zero's, denorms or NaNs. */ + if (!special_exponent) + exponent -= fmt->exp_bias; + + /* Build the result algebraically. Might go infinite, underflow, etc; + who cares. */ + + /* If this format uses a hidden bit, explicitly add it in now. Otherwise, + increment the exponent by one to account for the integer bit. */ + + if (!special_exponent) + { + if (fmt->intbit == floatformat_intbit_no) + dto = ldexp (1.0, exponent); + else + exponent++; + } + + while (mant_bits_left > 0) + { + mant_bits = min (mant_bits_left, 32); + + mant = get_field (ufrom, fmt->byteorder, fmt->totalsize, + mant_off, mant_bits); + + dto += ldexp ((double)mant, exponent - mant_bits); + exponent -= mant_bits; + mant_off += mant_bits; + mant_bits_left -= mant_bits; + } + + /* Negate it if negative. */ + if (get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1)) + dto = -dto; + *to = dto; +} + +static void put_field PARAMS ((unsigned char *, enum floatformat_byteorders, + unsigned int, + unsigned int, + unsigned int, + unsigned long)); + +/* Set a field which starts at START and is LEN bytes long. DATA and + TOTAL_LEN are the thing we are extracting it from, in byteorder ORDER. */ +static void +put_field (data, order, total_len, start, len, stuff_to_put) + unsigned char *data; + enum floatformat_byteorders order; + unsigned int total_len; + unsigned int start; + unsigned int len; + unsigned long stuff_to_put; +{ + unsigned int cur_byte; + int cur_bitshift; + + /* Start at the least significant part of the field. */ + cur_byte = (start + len) / FLOATFORMAT_CHAR_BIT; + if (order == floatformat_little) + cur_byte = (total_len / FLOATFORMAT_CHAR_BIT) - cur_byte - 1; + cur_bitshift = + ((start + len) % FLOATFORMAT_CHAR_BIT) - FLOATFORMAT_CHAR_BIT; + *(data + cur_byte) &= + ~(((1 << ((start + len) % FLOATFORMAT_CHAR_BIT)) - 1) << (-cur_bitshift)); + *(data + cur_byte) |= + (stuff_to_put & ((1 << FLOATFORMAT_CHAR_BIT) - 1)) << (-cur_bitshift); + cur_bitshift += FLOATFORMAT_CHAR_BIT; + if (order == floatformat_little) + ++cur_byte; + else + --cur_byte; + + /* Move towards the most significant part of the field. */ + while ((unsigned int) cur_bitshift < len) + { + if (len - cur_bitshift < FLOATFORMAT_CHAR_BIT) + { + /* This is the last byte. */ + *(data + cur_byte) &= + ~((1 << (len - cur_bitshift)) - 1); + *(data + cur_byte) |= (stuff_to_put >> cur_bitshift); + } + else + *(data + cur_byte) = ((stuff_to_put >> cur_bitshift) + & ((1 << FLOATFORMAT_CHAR_BIT) - 1)); + cur_bitshift += FLOATFORMAT_CHAR_BIT; + if (order == floatformat_little) + ++cur_byte; + else + --cur_byte; + } +} + +/* The converse: convert the double *FROM to an extended float + and store where TO points. Neither FROM nor TO have any alignment + restrictions. */ + +void +floatformat_from_double (fmt, from, to) + const struct floatformat *fmt; + double *from; + char *to; +{ + double dfrom; + int exponent; + double mant; + unsigned int mant_bits, mant_off; + int mant_bits_left; + unsigned char *uto = (unsigned char *)to; + + memcpy (&dfrom, from, sizeof (dfrom)); + memset (uto, 0, fmt->totalsize / FLOATFORMAT_CHAR_BIT); + if (dfrom == 0) + return; /* Result is zero */ + if (dfrom != dfrom) + { + /* From is NaN */ + put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start, + fmt->exp_len, fmt->exp_nan); + /* Be sure it's not infinity, but NaN value is irrel */ + put_field (uto, fmt->byteorder, fmt->totalsize, fmt->man_start, + 32, 1); + return; + } + + /* If negative, set the sign bit. */ + if (dfrom < 0) + { + put_field (uto, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1, 1); + dfrom = -dfrom; + } + + /* How to tell an infinity from an ordinary number? FIXME-someday */ + + mant = frexp (dfrom, &exponent); + put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start, fmt->exp_len, + exponent + fmt->exp_bias - 1); + + mant_bits_left = fmt->man_len; + mant_off = fmt->man_start; + while (mant_bits_left > 0) + { + unsigned long mant_long; + mant_bits = mant_bits_left < 32 ? mant_bits_left : 32; + + mant *= 4294967296.0; + mant_long = (unsigned long)mant; + mant -= mant_long; + + /* If the integer bit is implicit, then we need to discard it. + If we are discarding a zero, we should be (but are not) creating + a denormalized number which means adjusting the exponent + (I think). */ + if ((unsigned int) mant_bits_left == fmt->man_len + && fmt->intbit == floatformat_intbit_no) + { + mant_long &= 0x7fffffff; + mant_bits -= 1; + } + else if (mant_bits < 32) + { + /* The bits we want are in the most significant MANT_BITS bits of + mant_long. Move them to the least significant. */ + mant_long >>= 32 - mant_bits; + } + + put_field (uto, fmt->byteorder, fmt->totalsize, + mant_off, mant_bits, mant_long); + mant_off += mant_bits; + mant_bits_left -= mant_bits; + } +} + + +#ifdef IEEE_DEBUG + +/* This is to be run on a host which uses IEEE floating point. */ + +void +ieee_test (n) + double n; +{ + double result; + char exten[16]; + + floatformat_to_double (&floatformat_ieee_double_big, &n, &result); + if (n != result) + printf ("Differ(to): %.20g -> %.20g\n", n, result); + floatformat_from_double (&floatformat_ieee_double_big, &n, &result); + if (n != result) + printf ("Differ(from): %.20g -> %.20g\n", n, result); + + floatformat_from_double (&floatformat_m68881_ext, &n, exten); + floatformat_to_double (&floatformat_m68881_ext, exten, &result); + if (n != result) + printf ("Differ(to+from): %.20g -> %.20g\n", n, result); + +#if IEEE_DEBUG > 1 + /* This is to be run on a host which uses 68881 format. */ + { + long double ex = *(long double *)exten; + if (ex != n) + printf ("Differ(from vs. extended): %.20g\n", n); + } +#endif +} + +int +main () +{ + ieee_test (0.5); + ieee_test (256.0); + ieee_test (0.12345); + ieee_test (234235.78907234); + ieee_test (-512.0); + ieee_test (-0.004321); + return 0; +} +#endif Index: strtod.c =================================================================== --- strtod.c (nonexistent) +++ strtod.c (revision 1765) @@ -0,0 +1,122 @@ +/* Implementation of strtod for systems with atof. + Copyright (C) 1991, 1995 Free Software Foundation, Inc. + +This file is part of the libiberty library. This library is free +software; you can redistribute it and/or modify it under the +terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) +any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +As a special exception, if you link this library with files +compiled with a GNU compiler to produce an executable, this does not cause +the resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why +the executable file might be covered by the GNU General Public License. */ + +#include + +extern double atof (); + +/* Disclaimer: this is currently just used by CHILL in GDB and therefore + has not been tested well. It may have been tested for nothing except + that it compiles. */ + +double +strtod (str, ptr) + char *str; + char **ptr; +{ + char *p; + + if (ptr == (char **)0) + return atof (str); + + p = str; + + while (isspace (*p)) + ++p; + + if (*p == '+' || *p == '-') + ++p; + + /* INF or INFINITY. */ + if ((p[0] == 'i' || p[0] == 'I') + && (p[1] == 'n' || p[1] == 'N') + && (p[2] == 'f' || p[2] == 'F')) + { + if ((p[3] == 'i' || p[3] == 'I') + && (p[4] == 'n' || p[4] == 'N') + && (p[5] == 'i' || p[5] == 'I') + && (p[6] == 't' || p[6] == 'T') + && (p[7] == 'y' || p[7] == 'Y')) + { + *ptr = p + 7; + return atof (str); + } + else + { + *ptr = p + 3; + return atof (str); + } + } + + /* NAN or NAN(foo). */ + if ((p[0] == 'n' || p[0] == 'N') + && (p[1] == 'a' || p[1] == 'A') + && (p[2] == 'n' || p[2] == 'N')) + { + p += 3; + if (*p == '(') + { + ++p; + while (*p != '\0' && *p != ')') + ++p; + if (*p == ')') + ++p; + } + *ptr = p; + return atof (str); + } + + /* digits, with 0 or 1 periods in it. */ + if (isdigit (*p) || *p == '.') + { + int got_dot = 0; + while (isdigit (*p) || (!got_dot && *p == '.')) + { + if (*p == '.') + got_dot = 1; + ++p; + } + + /* Exponent. */ + if (*p == 'e' || *p == 'E') + { + int i; + i = 1; + if (p[i] == '+' || p[i] == '-') + ++i; + if (isdigit (p[i])) + { + while (isdigit (p[i])) + ++i; + *ptr = p + i; + return atof (str); + } + } + *ptr = p; + return atof (str); + } + /* Didn't find any digits. Doesn't look like a number. */ + *ptr = str; + return 0.0; +} Index: xmemdup.c =================================================================== --- xmemdup.c (nonexistent) +++ xmemdup.c (revision 1765) @@ -0,0 +1,22 @@ +/* xmemdup.c -- Duplicate a memory buffer, using xcalloc. + This trivial function is in the public domain. + Jeff Garzik, September 1999. */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif +#include "ansidecl.h" +#include "libiberty.h" + +#include /* For size_t. */ + +PTR +xmemdup (input, copy_size, alloc_size) + const PTR input; + size_t copy_size; + size_t alloc_size; +{ + PTR output = xcalloc (1, alloc_size); + memcpy (output, input, copy_size); + return output; +} Index: random.c =================================================================== --- random.c (nonexistent) +++ random.c (revision 1765) @@ -0,0 +1,390 @@ +/* + * Copyright (c) 1983 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. [rescinded 22 July 1999] + * 4. 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. + * + * 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. + */ + +/* + * This is derived from the Berkeley source: + * @(#)random.c 5.5 (Berkeley) 7/6/88 + * It was reworked for the GNU C Library by Roland McGrath. + */ + +#include + +#if 0 + +#include +#include +#include +#include + +#else + +#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF for 32-bits */ +#define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF for 32-bits*/ + +#ifdef __STDC__ +# define PTR void * +# ifndef NULL +# define NULL (void *) 0 +# endif +#else +# define PTR char * +# ifndef NULL +# define NULL (void *) 0 +# endif +#endif + +#endif + +long int random (); + +/* An improved random number generation package. In addition to the standard + rand()/srand() like interface, this package also has a special state info + interface. The initstate() routine is called with a seed, an array of + bytes, and a count of how many bytes are being passed in; this array is + then initialized to contain information for random number generation with + that much state information. Good sizes for the amount of state + information are 32, 64, 128, and 256 bytes. The state can be switched by + calling the setstate() function with the same array as was initiallized + with initstate(). By default, the package runs with 128 bytes of state + information and generates far better random numbers than a linear + congruential generator. If the amount of state information is less than + 32 bytes, a simple linear congruential R.N.G. is used. Internally, the + state information is treated as an array of longs; the zeroeth element of + the array is the type of R.N.G. being used (small integer); the remainder + of the array is the state information for the R.N.G. Thus, 32 bytes of + state information will give 7 longs worth of state information, which will + allow a degree seven polynomial. (Note: The zeroeth word of state + information also has some other information stored in it; see setstate + for details). The random number generation technique is a linear feedback + shift register approach, employing trinomials (since there are fewer terms + to sum up that way). In this approach, the least significant bit of all + the numbers in the state table will act as a linear feedback shift register, + and will have period 2^deg - 1 (where deg is the degree of the polynomial + being used, assuming that the polynomial is irreducible and primitive). + The higher order bits will have longer periods, since their values are + also influenced by pseudo-random carries out of the lower bits. The + total period of the generator is approximately deg*(2**deg - 1); thus + doubling the amount of state information has a vast influence on the + period of the generator. Note: The deg*(2**deg - 1) is an approximation + only good for large deg, when the period of the shift register is the + dominant factor. With deg equal to seven, the period is actually much + longer than the 7*(2**7 - 1) predicted by this formula. */ + + + +/* For each of the currently supported random number generators, we have a + break value on the amount of state information (you need at least thi + bytes of state info to support this random number generator), a degree for + the polynomial (actually a trinomial) that the R.N.G. is based on, and + separation between the two lower order coefficients of the trinomial. */ + +/* Linear congruential. */ +#define TYPE_0 0 +#define BREAK_0 8 +#define DEG_0 0 +#define SEP_0 0 + +/* x**7 + x**3 + 1. */ +#define TYPE_1 1 +#define BREAK_1 32 +#define DEG_1 7 +#define SEP_1 3 + +/* x**15 + x + 1. */ +#define TYPE_2 2 +#define BREAK_2 64 +#define DEG_2 15 +#define SEP_2 1 + +/* x**31 + x**3 + 1. */ +#define TYPE_3 3 +#define BREAK_3 128 +#define DEG_3 31 +#define SEP_3 3 + +/* x**63 + x + 1. */ +#define TYPE_4 4 +#define BREAK_4 256 +#define DEG_4 63 +#define SEP_4 1 + + +/* Array versions of the above information to make code run faster. + Relies on fact that TYPE_i == i. */ + +#define MAX_TYPES 5 /* Max number of types above. */ + +static int degrees[MAX_TYPES] = { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 }; +static int seps[MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 }; + + + +/* Initially, everything is set up as if from: + initstate(1, randtbl, 128); + Note that this initialization takes advantage of the fact that srandom + advances the front and rear pointers 10*rand_deg times, and hence the + rear pointer which starts at 0 will also end up at zero; thus the zeroeth + element of the state information, which contains info about the current + position of the rear pointer is just + (MAX_TYPES * (rptr - state)) + TYPE_3 == TYPE_3. */ + +static long int randtbl[DEG_3 + 1] = + { TYPE_3, + 0x9a319039, 0x32d9c024, 0x9b663182, 0x5da1f342, + 0xde3b81e0, 0xdf0a6fb5, 0xf103bc02, 0x48f340fb, + 0x7449e56b, 0xbeb1dbb0, 0xab5c5918, 0x946554fd, + 0x8c2e680f, 0xeb3d799f, 0xb11ee0b7, 0x2d436b86, + 0xda672e2a, 0x1588ca88, 0xe369735d, 0x904f35f7, + 0xd7158fd6, 0x6fa6f051, 0x616e6b96, 0xac94efdc, + 0x36413f93, 0xc622c298, 0xf5a42ab8, 0x8a88d77b, + 0xf5ad9d0e, 0x8999220b, 0x27fb47b9 + }; + +/* FPTR and RPTR are two pointers into the state info, a front and a rear + pointer. These two pointers are always rand_sep places aparts, as they + cycle through the state information. (Yes, this does mean we could get + away with just one pointer, but the code for random is more efficient + this way). The pointers are left positioned as they would be from the call: + initstate(1, randtbl, 128); + (The position of the rear pointer, rptr, is really 0 (as explained above + in the initialization of randtbl) because the state table pointer is set + to point to randtbl[1] (as explained below).) */ + +static long int *fptr = &randtbl[SEP_3 + 1]; +static long int *rptr = &randtbl[1]; + + + +/* The following things are the pointer to the state information table, + the type of the current generator, the degree of the current polynomial + being used, and the separation between the two pointers. + Note that for efficiency of random, we remember the first location of + the state information, not the zeroeth. Hence it is valid to access + state[-1], which is used to store the type of the R.N.G. + Also, we remember the last location, since this is more efficient than + indexing every time to find the address of the last element to see if + the front and rear pointers have wrapped. */ + +static long int *state = &randtbl[1]; + +static int rand_type = TYPE_3; +static int rand_deg = DEG_3; +static int rand_sep = SEP_3; + +static long int *end_ptr = &randtbl[sizeof(randtbl) / sizeof(randtbl[0])]; + +/* Initialize the random number generator based on the given seed. If the + type is the trivial no-state-information type, just remember the seed. + Otherwise, initializes state[] based on the given "seed" via a linear + congruential generator. Then, the pointers are set to known locations + that are exactly rand_sep places apart. Lastly, it cycles the state + information a given number of times to get rid of any initial dependencies + introduced by the L.C.R.N.G. Note that the initialization of randtbl[] + for default usage relies on values produced by this routine. */ +void +srandom (x) + unsigned int x; +{ + state[0] = x; + if (rand_type != TYPE_0) + { + register long int i; + for (i = 1; i < rand_deg; ++i) + state[i] = (1103515145 * state[i - 1]) + 12345; + fptr = &state[rand_sep]; + rptr = &state[0]; + for (i = 0; i < 10 * rand_deg; ++i) + random(); + } +} + +/* Initialize the state information in the given array of N bytes for + future random number generation. Based on the number of bytes we + are given, and the break values for the different R.N.G.'s, we choose + the best (largest) one we can and set things up for it. srandom is + then called to initialize the state information. Note that on return + from srandom, we set state[-1] to be the type multiplexed with the current + value of the rear pointer; this is so successive calls to initstate won't + lose this information and will be able to restart with setstate. + Note: The first thing we do is save the current state, if any, just like + setstate so that it doesn't matter when initstate is called. + Returns a pointer to the old state. */ +PTR +initstate (seed, arg_state, n) + unsigned int seed; + PTR arg_state; + unsigned long n; +{ + PTR ostate = (PTR) &state[-1]; + + if (rand_type == TYPE_0) + state[-1] = rand_type; + else + state[-1] = (MAX_TYPES * (rptr - state)) + rand_type; + if (n < BREAK_1) + { + if (n < BREAK_0) + { + errno = EINVAL; + return NULL; + } + rand_type = TYPE_0; + rand_deg = DEG_0; + rand_sep = SEP_0; + } + else if (n < BREAK_2) + { + rand_type = TYPE_1; + rand_deg = DEG_1; + rand_sep = SEP_1; + } + else if (n < BREAK_3) + { + rand_type = TYPE_2; + rand_deg = DEG_2; + rand_sep = SEP_2; + } + else if (n < BREAK_4) + { + rand_type = TYPE_3; + rand_deg = DEG_3; + rand_sep = SEP_3; + } + else + { + rand_type = TYPE_4; + rand_deg = DEG_4; + rand_sep = SEP_4; + } + + state = &((long int *) arg_state)[1]; /* First location. */ + /* Must set END_PTR before srandom. */ + end_ptr = &state[rand_deg]; + srandom(seed); + if (rand_type == TYPE_0) + state[-1] = rand_type; + else + state[-1] = (MAX_TYPES * (rptr - state)) + rand_type; + + return ostate; +} + +/* Restore the state from the given state array. + Note: It is important that we also remember the locations of the pointers + in the current state information, and restore the locations of the pointers + from the old state information. This is done by multiplexing the pointer + location into the zeroeth word of the state information. Note that due + to the order in which things are done, it is OK to call setstate with the + same state as the current state + Returns a pointer to the old state information. */ + +PTR +setstate (arg_state) + PTR arg_state; +{ + register long int *new_state = (long int *) arg_state; + register int type = new_state[0] % MAX_TYPES; + register int rear = new_state[0] / MAX_TYPES; + PTR ostate = (PTR) &state[-1]; + + if (rand_type == TYPE_0) + state[-1] = rand_type; + else + state[-1] = (MAX_TYPES * (rptr - state)) + rand_type; + + switch (type) + { + case TYPE_0: + case TYPE_1: + case TYPE_2: + case TYPE_3: + case TYPE_4: + rand_type = type; + rand_deg = degrees[type]; + rand_sep = seps[type]; + break; + default: + /* State info munged. */ + errno = EINVAL; + return NULL; + } + + state = &new_state[1]; + if (rand_type != TYPE_0) + { + rptr = &state[rear]; + fptr = &state[(rear + rand_sep) % rand_deg]; + } + /* Set end_ptr too. */ + end_ptr = &state[rand_deg]; + + return ostate; +} + +/* If we are using the trivial TYPE_0 R.N.G., just do the old linear + congruential bit. Otherwise, we do our fancy trinomial stuff, which is the + same in all ther other cases due to all the global variables that have been + set up. The basic operation is to add the number at the rear pointer into + the one at the front pointer. Then both pointers are advanced to the next + location cyclically in the table. The value returned is the sum generated, + reduced to 31 bits by throwing away the "least random" low bit. + Note: The code takes advantage of the fact that both the front and + rear pointers can't wrap on the same call by not testing the rear + pointer if the front one has wrapped. Returns a 31-bit random number. */ + +long int +random () +{ + if (rand_type == TYPE_0) + { + state[0] = ((state[0] * 1103515245) + 12345) & LONG_MAX; + return state[0]; + } + else + { + long int i; + *fptr += *rptr; + /* Chucking least random bit. */ + i = (*fptr >> 1) & LONG_MAX; + ++fptr; + if (fptr >= end_ptr) + { + fptr = state; + ++rptr; + } + else + { + ++rptr; + if (rptr >= end_ptr) + rptr = state; + } + return i; + } +} Index: fnmatch.c =================================================================== --- fnmatch.c (nonexistent) +++ fnmatch.c (revision 1765) @@ -0,0 +1,225 @@ +/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc. + +NOTE: The canonical source of this file is maintained with the GNU C Library. +Bugs can be reported to bug-glibc@prep.ai.mit.edu. + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) any +later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#ifdef HAVE_CONFIG_H +#if defined (CONFIG_BROKETS) +/* We use instead of "config.h" so that a compilation + using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h + (which it would do because it found this file in $srcdir). */ +#include +#else +#include "config.h" +#endif +#endif + + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +/* This code to undef const added in libiberty. */ +#ifndef __STDC__ +/* This is a separate conditional since some stdc systems + reject `defined (const)'. */ +#ifndef const +#define const +#endif +#endif + +#include +#include +#include + + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself. This code is part of the GNU C + Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object files, + it is simpler to just do this in the source for each such file. */ + +#if defined (_LIBC) || !defined (__GNU_LIBRARY__) + + +#if !defined(__GNU_LIBRARY__) && !defined(STDC_HEADERS) +extern int errno; +#endif + +/* Match STRING against the filename pattern PATTERN, returning zero if + it matches, nonzero if not. */ +int +fnmatch (pattern, string, flags) + const char *pattern; + const char *string; + int flags; +{ + register const char *p = pattern, *n = string; + register unsigned char c; + +/* Note that this evalutes C many times. */ +#define FOLD(c) ((flags & FNM_CASEFOLD) && isupper (c) ? tolower (c) : (c)) + + while ((c = *p++) != '\0') + { + c = FOLD (c); + + switch (c) + { + case '?': + if (*n == '\0') + return FNM_NOMATCH; + else if ((flags & FNM_FILE_NAME) && *n == '/') + return FNM_NOMATCH; + else if ((flags & FNM_PERIOD) && *n == '.' && + (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/'))) + return FNM_NOMATCH; + break; + + case '\\': + if (!(flags & FNM_NOESCAPE)) + { + c = *p++; + c = FOLD (c); + } + if (FOLD ((unsigned char)*n) != c) + return FNM_NOMATCH; + break; + + case '*': + if ((flags & FNM_PERIOD) && *n == '.' && + (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/'))) + return FNM_NOMATCH; + + for (c = *p++; c == '?' || c == '*'; c = *p++, ++n) + if (((flags & FNM_FILE_NAME) && *n == '/') || + (c == '?' && *n == '\0')) + return FNM_NOMATCH; + + if (c == '\0') + return 0; + + { + unsigned char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c; + c1 = FOLD (c1); + for (--p; *n != '\0'; ++n) + if ((c == '[' || FOLD ((unsigned char)*n) == c1) && + fnmatch (p, n, flags & ~FNM_PERIOD) == 0) + return 0; + return FNM_NOMATCH; + } + + case '[': + { + /* Nonzero if the sense of the character class is inverted. */ + register int not; + + if (*n == '\0') + return FNM_NOMATCH; + + if ((flags & FNM_PERIOD) && *n == '.' && + (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/'))) + return FNM_NOMATCH; + + not = (*p == '!' || *p == '^'); + if (not) + ++p; + + c = *p++; + for (;;) + { + register unsigned char cstart = c, cend = c; + + if (!(flags & FNM_NOESCAPE) && c == '\\') + cstart = cend = *p++; + + cstart = cend = FOLD (cstart); + + if (c == '\0') + /* [ (unterminated) loses. */ + return FNM_NOMATCH; + + c = *p++; + c = FOLD (c); + + if ((flags & FNM_FILE_NAME) && c == '/') + /* [/] can never match. */ + return FNM_NOMATCH; + + if (c == '-' && *p != ']') + { + cend = *p++; + if (!(flags & FNM_NOESCAPE) && cend == '\\') + cend = *p++; + if (cend == '\0') + return FNM_NOMATCH; + cend = FOLD (cend); + + c = *p++; + } + + if (FOLD ((unsigned char)*n) >= cstart + && FOLD ((unsigned char)*n) <= cend) + goto matched; + + if (c == ']') + break; + } + if (!not) + return FNM_NOMATCH; + break; + + matched:; + /* Skip the rest of the [...] that already matched. */ + while (c != ']') + { + if (c == '\0') + /* [... (unterminated) loses. */ + return FNM_NOMATCH; + + c = *p++; + if (!(flags & FNM_NOESCAPE) && c == '\\') + /* XXX 1003.2d11 is unclear if this is right. */ + ++p; + } + if (not) + return FNM_NOMATCH; + } + break; + + default: + if (c != FOLD ((unsigned char)*n)) + return FNM_NOMATCH; + } + + ++n; + } + + if (*n == '\0') + return 0; + + if ((flags & FNM_LEADING_DIR) && *n == '/') + /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz". */ + return 0; + + return FNM_NOMATCH; +} + +#endif /* _LIBC or not __GNU_LIBRARY__. */ Index: putenv.c =================================================================== --- putenv.c (nonexistent) +++ putenv.c (revision 1765) @@ -0,0 +1,68 @@ +/* Copyright (C) 1991, 1994, 1995, 1996 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 + 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. + + 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#if defined (_AIX) && !defined (__GNUC__) + #pragma alloca +#endif + +#if HAVE_CONFIG_H +# include +#endif + +#include "ansidecl.h" + +#if HAVE_STDLIB_H +# include +#endif +#if HAVE_STRING_H +# include +#endif + +#ifdef HAVE_ALLOCA_H +# include +#else +# ifndef alloca +# ifdef __GNUC__ +# define alloca __builtin_alloca +# else +extern char *alloca (); +# endif /* __GNUC__ */ +# endif /* alloca */ +#endif /* HAVE_ALLOCA_H */ + +/* Below this point, it's verbatim code from the glibc-2.0 implementation */ + + +/* Put STRING, which is of the form "NAME=VALUE", in the environment. */ +int +putenv (string) + const char *string; +{ + const char *const name_end = strchr (string, '='); + + if (name_end) + { + char *name = (char *) alloca (name_end - string + 1); + memcpy (name, string, name_end - string); + name[name_end - string] = '\0'; + return setenv (name, name_end + 1, 1); + } + + unsetenv (string); + return 0; +} Index: getruntime.c =================================================================== --- getruntime.c (nonexistent) +++ getruntime.c (revision 1765) @@ -0,0 +1,90 @@ +/* Return time used so far, in microseconds. + Copyright (C) 1994, 1999 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. */ + +#include "config.h" + +#include "ansidecl.h" +#include "libiberty.h" + +/* There are several ways to get elapsed execution time; unfortunately no + single way is available for all host systems, nor are there reliable + ways to find out which way is correct for a given host. */ + +#include + +#if defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H) +#include +#include +#endif + +#ifdef HAVE_TIMES +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#include +#endif + +#ifdef HAVE_UNISTD_H +#include +#endif + +/* This is a fallback; if wrong, it will likely make obviously wrong + results. */ + +#ifndef CLOCKS_PER_SEC +#define CLOCKS_PER_SEC 1 +#endif + +#ifdef _SC_CLK_TCK +#define GNU_HZ sysconf(_SC_CLK_TCK) +#else +#ifdef HZ +#define GNU_HZ HZ +#else +#ifdef CLOCKS_PER_SEC +#define GNU_HZ CLOCKS_PER_SEC +#endif +#endif +#endif + +long +get_run_time () +{ +#if defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H) + struct rusage rusage; + + getrusage (0, &rusage); + return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec + + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec); +#else /* ! HAVE_GETRUSAGE */ +#ifdef HAVE_TIMES + struct tms tms; + + times (&tms); + return (tms.tms_utime + tms.tms_stime) * (1000000 / GNU_HZ); +#else /* ! HAVE_TIMES */ + /* Fall back on clock and hope it's correctly implemented. */ + const long clocks_per_sec = CLOCKS_PER_SEC; + if (clocks_per_sec <= 1000000) + return clock () * (1000000 / clocks_per_sec); + else + return clock () / clocks_per_sec; +#endif /* HAVE_TIMES */ +#endif /* HAVE_GETRUSAGE */ +} Index: hex.c =================================================================== --- hex.c (nonexistent) +++ hex.c (revision 1765) @@ -0,0 +1,33 @@ +/* Hex character manipulation support. + Copyright (C) 1995 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. */ + +#include "libiberty.h" + +char _hex_value[_hex_array_size]; + +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; +} Index: msdos.c =================================================================== --- msdos.c (nonexistent) +++ msdos.c (revision 1765) @@ -0,0 +1,15 @@ +char msg[] = "No vfork available - aborting\n"; +vfork() +{ + write(1, msg, sizeof(msg)); +} + +sigsetmask() +{ + /* no signals support in go32 (yet) */ +} + +waitpid() +{ + return -1; +} Index: asprintf.c =================================================================== --- asprintf.c (nonexistent) +++ asprintf.c (revision 1765) @@ -0,0 +1,57 @@ +/* Like sprintf but provides a pointer to malloc'd storage, which must + be freed by the caller. + Copyright (C) 1997 Free Software Foundation, Inc. + Contributed by Cygnus Solutions. + +This file is part of the libiberty library. +Libiberty is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +Libiberty is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with libiberty; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ + +#include "ansidecl.h" +#include "libiberty.h" + +#if defined (ANSI_PROTOTYPES) || defined (ALMOST_STDC) +#define USE_STDARG +#endif + +#ifdef USE_STDARG +#include +#else +#include +#endif + +/* VARARGS */ +#ifdef USE_STDARG +int +asprintf (char **buf, const char *fmt, ...) +#else +int +asprintf (buf, fmt, va_alist) + char **buf; + const char *fmt; + va_dcl +#endif +{ + int status; + va_list ap; +#ifdef USE_STDARG + va_start (ap, fmt); +#else + va_start (ap); +#endif + status = vasprintf (buf, fmt, ap); + va_end (ap); + return status; +} Index: strtol.c =================================================================== --- strtol.c (nonexistent) +++ strtol.c (revision 1765) @@ -0,0 +1,140 @@ +/*- + * Copyright (c) 1990 The 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. [rescinded 22 July 1999] + * 4. 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. + * + * 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. + */ + +#include +#include +#include +#if 0 +#include +#endif +#include "ansidecl.h" + +/* FIXME: It'd be nice to configure around these, but the include files are too + painful. These macros should at least be more portable than hardwired hex + constants. */ + +#ifndef ULONG_MAX +#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF */ +#endif + +#ifndef LONG_MAX +#define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF */ +#endif + +#ifndef LONG_MIN +#define LONG_MIN ((long)(~LONG_MAX)) /* 0x80000000 */ +#endif + +/* + * Convert a string to a long integer. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +long +strtol(nptr, endptr, base) + const char *nptr; + char **endptr; + register int base; +{ + register const char *s = nptr; + register unsigned long acc; + register int c; + register unsigned long cutoff; + register int neg = 0, any, cutlim; + + /* + * Skip white space and pick up leading +/- sign if any. + * If base is 0, allow 0x for hex and 0 for octal, else + * assume decimal; if base is already 16, allow 0x. + */ + do { + c = *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else if (c == '+') + c = *s++; + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + + /* + * Compute the cutoff value between legal numbers and illegal + * numbers. That is the largest legal value, divided by the + * base. An input number that is greater than this value, if + * followed by a legal input character, is too big. One that + * is equal to this value may be valid or not; the limit + * between valid and invalid numbers is then based on the last + * digit. For instance, if the range for longs is + * [-2147483648..2147483647] and the input base is 10, + * cutoff will be set to 214748364 and cutlim to either + * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated + * a value > 214748364, or equal but the next digit is > 7 (or 8), + * the number is too big, and we will return a range error. + * + * Set any if any `digits' consumed; make it negative to indicate + * overflow. + */ + cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; + cutlim = cutoff % (unsigned long)base; + cutoff /= (unsigned long)base; + for (acc = 0, any = 0;; c = *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + any = -1; + else { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) { + acc = neg ? LONG_MIN : LONG_MAX; + errno = ERANGE; + } else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = (char *) (any ? s - 1 : nptr); + return (acc); +} Index: vprintf.c =================================================================== --- vprintf.c (nonexistent) +++ vprintf.c (revision 1765) @@ -0,0 +1,15 @@ +#ifdef __STDC__ +#include +#else +#include +#endif +#include +#include +#undef vprintf +int +vprintf (format, ap) + const char *format; + va_list ap; +{ + return vfprintf (stdout, format, ap); +} Index: rindex.c =================================================================== --- rindex.c (nonexistent) +++ rindex.c (revision 1765) @@ -0,0 +1,11 @@ +/* Stub implementation of (obsolete) rindex(). */ + +extern char *strrchr (); + +char * +rindex (s, c) + char *s; + int c; +{ + return strrchr (s, c); +} Index: cplus-dem.c =================================================================== --- cplus-dem.c (nonexistent) +++ cplus-dem.c (revision 1765) @@ -0,0 +1,4689 @@ +/* Demangler for GNU C++ + Copyright 1989, 91, 94, 95, 96, 97, 98, 1999 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 + +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. */ + +/* This file exports two functions; cplus_mangle_opname and cplus_demangle. + + This file imports xmalloc and xrealloc, which are like malloc and + realloc except that they generate a fatal error if there is no + available memory. */ + +/* This file lives in both GCC and libiberty. When making changes, please + try not to break either. */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include + +#ifdef HAVE_STDLIB_H +#include +#else +char * malloc (); +char * realloc (); +#endif + +#include +#undef CURRENT_DEMANGLING_STYLE +#define CURRENT_DEMANGLING_STYLE work->options + +#include "libiberty.h" + +#define min(X,Y) (((X) < (Y)) ? (X) : (Y)) + +/* A value at least one greater than the maximum number of characters + that will be output when using the `%d' format with `printf'. */ +#define INTBUF_SIZE 32 + +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 + commonly used ones, and check to see if the marker we are looking for + is in that string. CPLUS_MARKER is usually '$' on systems where the + assembler can deal with that. Where the assembler can't, it's usually + '.' (but on many systems '.' is used for other things). We put the + current defined CPLUS_MARKER first (which defaults to '$'), followed + by the next most common value, followed by an explicit '$' in case + the value of CPLUS_MARKER is not '$'. + + We could avoid this if we could just get g++ to tell us what the actual + cplus marker character is as part of the debug information, perhaps by + ensuring that it is the character that terminates the gcc_compiled + marker symbol (FIXME). */ + +#if !defined (CPLUS_MARKER) +#define CPLUS_MARKER '$' +#endif + +enum demangling_styles current_demangling_style = gnu_demangling; + +static char cplus_markers[] = { CPLUS_MARKER, '.', '$', '\0' }; + +static char char_str[2] = { '\000', '\000' }; + +void +set_cplus_marker_for_demangling (ch) + int ch; +{ + cplus_markers[0] = ch; +} + +typedef struct string /* Beware: these aren't required to be */ +{ /* '\0' terminated. */ + char *b; /* pointer to start of string */ + char *p; /* pointer after last character */ + char *e; /* pointer after end of allocated space */ +} string; + +/* Stuff that is shared between sub-routines. + Using a shared structure allows cplus_demangle to be reentrant. */ + +struct work_stuff +{ + int options; + char **typevec; + char **ktypevec; + char **btypevec; + int numk; + int numb; + int ksize; + int bsize; + int ntypes; + int typevec_size; + int constructor; + int destructor; + int static_type; /* A static member function */ + int temp_start; /* index in demangled to start of template args */ + int type_quals; /* The type qualifiers. */ + int dllimported; /* Symbol imported from a PE DLL */ + char **tmpl_argvec; /* Template function arguments. */ + int ntmpl_args; /* The number of template function arguments. */ + int forgetting_types; /* Nonzero if we are not remembering the types + we see. */ + string* previous_argument; /* The last function argument demangled. */ + int nrepeats; /* The number of times to repeat the previous + argument. */ +}; + +#define PRINT_ANSI_QUALIFIERS (work -> options & DMGL_ANSI) +#define PRINT_ARG_TYPES (work -> options & DMGL_PARAMS) + +static const struct optable +{ + const char *in; + const char *out; + int flags; +} optable[] = { + {"nw", " new", DMGL_ANSI}, /* new (1.92, ansi) */ + {"dl", " delete", DMGL_ANSI}, /* new (1.92, ansi) */ + {"new", " new", 0}, /* old (1.91, and 1.x) */ + {"delete", " delete", 0}, /* old (1.91, and 1.x) */ + {"vn", " new []", DMGL_ANSI}, /* GNU, pending ansi */ + {"vd", " delete []", DMGL_ANSI}, /* GNU, pending ansi */ + {"as", "=", DMGL_ANSI}, /* ansi */ + {"ne", "!=", DMGL_ANSI}, /* old, ansi */ + {"eq", "==", DMGL_ANSI}, /* old, ansi */ + {"ge", ">=", DMGL_ANSI}, /* old, ansi */ + {"gt", ">", DMGL_ANSI}, /* old, ansi */ + {"le", "<=", DMGL_ANSI}, /* old, ansi */ + {"lt", "<", DMGL_ANSI}, /* old, ansi */ + {"plus", "+", 0}, /* old */ + {"pl", "+", DMGL_ANSI}, /* ansi */ + {"apl", "+=", DMGL_ANSI}, /* ansi */ + {"minus", "-", 0}, /* old */ + {"mi", "-", DMGL_ANSI}, /* ansi */ + {"ami", "-=", DMGL_ANSI}, /* ansi */ + {"mult", "*", 0}, /* old */ + {"ml", "*", DMGL_ANSI}, /* ansi */ + {"amu", "*=", DMGL_ANSI}, /* ansi (ARM/Lucid) */ + {"aml", "*=", DMGL_ANSI}, /* ansi (GNU/g++) */ + {"convert", "+", 0}, /* old (unary +) */ + {"negate", "-", 0}, /* old (unary -) */ + {"trunc_mod", "%", 0}, /* old */ + {"md", "%", DMGL_ANSI}, /* ansi */ + {"amd", "%=", DMGL_ANSI}, /* ansi */ + {"trunc_div", "/", 0}, /* old */ + {"dv", "/", DMGL_ANSI}, /* ansi */ + {"adv", "/=", DMGL_ANSI}, /* ansi */ + {"truth_andif", "&&", 0}, /* old */ + {"aa", "&&", DMGL_ANSI}, /* ansi */ + {"truth_orif", "||", 0}, /* old */ + {"oo", "||", DMGL_ANSI}, /* ansi */ + {"truth_not", "!", 0}, /* old */ + {"nt", "!", DMGL_ANSI}, /* ansi */ + {"postincrement","++", 0}, /* old */ + {"pp", "++", DMGL_ANSI}, /* ansi */ + {"postdecrement","--", 0}, /* old */ + {"mm", "--", DMGL_ANSI}, /* ansi */ + {"bit_ior", "|", 0}, /* old */ + {"or", "|", DMGL_ANSI}, /* ansi */ + {"aor", "|=", DMGL_ANSI}, /* ansi */ + {"bit_xor", "^", 0}, /* old */ + {"er", "^", DMGL_ANSI}, /* ansi */ + {"aer", "^=", DMGL_ANSI}, /* ansi */ + {"bit_and", "&", 0}, /* old */ + {"ad", "&", DMGL_ANSI}, /* ansi */ + {"aad", "&=", DMGL_ANSI}, /* ansi */ + {"bit_not", "~", 0}, /* old */ + {"co", "~", DMGL_ANSI}, /* ansi */ + {"call", "()", 0}, /* old */ + {"cl", "()", DMGL_ANSI}, /* ansi */ + {"alshift", "<<", 0}, /* old */ + {"ls", "<<", DMGL_ANSI}, /* ansi */ + {"als", "<<=", DMGL_ANSI}, /* ansi */ + {"arshift", ">>", 0}, /* old */ + {"rs", ">>", DMGL_ANSI}, /* ansi */ + {"ars", ">>=", DMGL_ANSI}, /* ansi */ + {"component", "->", 0}, /* old */ + {"pt", "->", DMGL_ANSI}, /* ansi; Lucid C++ form */ + {"rf", "->", DMGL_ANSI}, /* ansi; ARM/GNU form */ + {"indirect", "*", 0}, /* old */ + {"method_call", "->()", 0}, /* old */ + {"addr", "&", 0}, /* old (unary &) */ + {"array", "[]", 0}, /* old */ + {"vc", "[]", DMGL_ANSI}, /* ansi */ + {"compound", ", ", 0}, /* old */ + {"cm", ", ", DMGL_ANSI}, /* ansi */ + {"cond", "?:", 0}, /* old */ + {"cn", "?:", DMGL_ANSI}, /* pseudo-ansi */ + {"max", ">?", 0}, /* old */ + {"mx", ">?", DMGL_ANSI}, /* pseudo-ansi */ + {"min", "*", DMGL_ANSI}, /* ansi */ + {"sz", "sizeof ", DMGL_ANSI} /* pseudo-ansi */ +}; + +/* These values are used to indicate the various type varieties. + They are all non-zero so that they can be used as `success' + values. */ +typedef enum type_kind_t +{ + tk_none, + tk_pointer, + tk_reference, + tk_integral, + tk_bool, + tk_char, + tk_real +} type_kind_t; + +#define STRING_EMPTY(str) ((str) -> b == (str) -> p) +#define PREPEND_BLANK(str) {if (!STRING_EMPTY(str)) \ + string_prepend(str, " ");} +#define APPEND_BLANK(str) {if (!STRING_EMPTY(str)) \ + string_append(str, " ");} +#define LEN_STRING(str) ( (STRING_EMPTY(str))?0:((str)->p - (str)->b)) + +/* The scope separator appropriate for the language being demangled. */ + +#define SCOPE_STRING(work) ((work->options & DMGL_JAVA) ? "." : "::") + +#define ARM_VTABLE_STRING "__vtbl__" /* Lucid/ARM virtual table prefix */ +#define ARM_VTABLE_STRLEN 8 /* strlen (ARM_VTABLE_STRING) */ + +/* Prototypes for local functions */ + +static char * +mop_up PARAMS ((struct work_stuff *, string *, int)); + +static void +squangle_mop_up PARAMS ((struct work_stuff *)); + +#if 0 +static int +demangle_method_args PARAMS ((struct work_stuff *, const char **, string *)); +#endif + +static char * +internal_cplus_demangle PARAMS ((struct work_stuff *, const char *)); + +static int +demangle_template_template_parm PARAMS ((struct work_stuff *work, + const char **, string *)); + +static int +demangle_template PARAMS ((struct work_stuff *work, const char **, string *, + string *, int, int)); + +static int +arm_pt PARAMS ((struct work_stuff *, const char *, int, const char **, + const char **)); + +static int +demangle_class_name PARAMS ((struct work_stuff *, const char **, string *)); + +static int +demangle_qualified PARAMS ((struct work_stuff *, const char **, string *, + int, int)); + +static int +demangle_class PARAMS ((struct work_stuff *, const char **, string *)); + +static int +demangle_fund_type PARAMS ((struct work_stuff *, const char **, string *)); + +static int +demangle_signature PARAMS ((struct work_stuff *, const char **, string *)); + +static int +demangle_prefix PARAMS ((struct work_stuff *, const char **, string *)); + +static int +gnu_special PARAMS ((struct work_stuff *, const char **, string *)); + +static int +arm_special PARAMS ((const char **, string *)); + +static void +string_need PARAMS ((string *, int)); + +static void +string_delete PARAMS ((string *)); + +static void +string_init PARAMS ((string *)); + +static void +string_clear PARAMS ((string *)); + +#if 0 +static int +string_empty PARAMS ((string *)); +#endif + +static void +string_append PARAMS ((string *, const char *)); + +static void +string_appends PARAMS ((string *, string *)); + +static void +string_appendn PARAMS ((string *, const char *, int)); + +static void +string_prepend PARAMS ((string *, const char *)); + +static void +string_prependn PARAMS ((string *, const char *, int)); + +static void +string_append_template_idx PARAMS ((string *, int)); + +static int +get_count PARAMS ((const char **, int *)); + +static int +consume_count PARAMS ((const char **)); + +static int +consume_count_with_underscores PARAMS ((const char**)); + +static int +demangle_args PARAMS ((struct work_stuff *, const char **, string *)); + +static int +demangle_nested_args PARAMS ((struct work_stuff*, const char**, string*)); + +static int +do_type PARAMS ((struct work_stuff *, const char **, string *)); + +static int +do_arg PARAMS ((struct work_stuff *, const char **, string *)); + +static void +demangle_function_name PARAMS ((struct work_stuff *, const char **, string *, + const char *)); + +static void +remember_type PARAMS ((struct work_stuff *, const char *, int)); + +static void +remember_Btype PARAMS ((struct work_stuff *, const char *, int, int)); + +static int +register_Btype PARAMS ((struct work_stuff *)); + +static void +remember_Ktype PARAMS ((struct work_stuff *, const char *, int)); + +static void +forget_types PARAMS ((struct work_stuff *)); + +static void +forget_B_and_K_types PARAMS ((struct work_stuff *)); + +static void +string_prepends PARAMS ((string *, string *)); + +static int +demangle_template_value_parm PARAMS ((struct work_stuff*, const char**, + string*, type_kind_t)); + +static int +do_hpacc_template_const_value PARAMS ((struct work_stuff *, const char **, string *)); + +static int +do_hpacc_template_literal PARAMS ((struct work_stuff *, const char **, string *)); + +static int +snarf_numeric_literal PARAMS ((const char **, string *)); + +/* There is a TYPE_QUAL value for each type qualifier. They can be + combined by bitwise-or to form the complete set of qualifiers for a + type. */ + +#define TYPE_UNQUALIFIED 0x0 +#define TYPE_QUAL_CONST 0x1 +#define TYPE_QUAL_VOLATILE 0x2 +#define TYPE_QUAL_RESTRICT 0x4 + +static int +code_for_qualifier PARAMS ((int)); + +static const char* +qualifier_string PARAMS ((int)); + +static const char* +demangle_qualifier PARAMS ((int)); + +static int +demangle_expression PARAMS ((struct work_stuff *, const char **, string *, + type_kind_t)); + +static int +demangle_integral_value PARAMS ((struct work_stuff *, const char **, + string *)); + +static int +demangle_real_value PARAMS ((struct work_stuff *, const char **, string *)); + +static void +demangle_arm_hp_template PARAMS ((struct work_stuff *, const char **, int, + string *)); + +static void +recursively_demangle PARAMS ((struct work_stuff *, const char **, string *, + int)); + +/* Translate count to integer, consuming tokens in the process. + Conversion terminates on the first non-digit character. + + Trying to consume something that isn't a count results in no + consumption of input and a return of -1. + + Overflow consumes the rest of the digits, and returns -1. */ + +static int +consume_count (type) + const char **type; +{ + int count = 0; + + if (! isdigit ((unsigned char)**type)) + return -1; + + while (isdigit ((unsigned char)**type)) + { + count *= 10; + + /* Check for overflow. + We assume that count is represented using two's-complement; + no power of two is divisible by ten, so if an overflow occurs + when multiplying by ten, the result will not be a multiple of + ten. */ + if ((count % 10) != 0) + { + while (isdigit ((unsigned char) **type)) + (*type)++; + return -1; + } + + count += **type - '0'; + (*type)++; + } + + return (count); +} + + +/* Like consume_count, but for counts that are preceded 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 ((unsigned char)**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; +} + +/* C is the code for a type-qualifier. Return the TYPE_QUAL + corresponding to this qualifier. */ + +static int +code_for_qualifier (c) + int c; +{ + switch (c) + { + case 'C': + return TYPE_QUAL_CONST; + + case 'V': + return TYPE_QUAL_VOLATILE; + + case 'u': + return TYPE_QUAL_RESTRICT; + + default: + break; + } + + /* C was an invalid qualifier. */ + abort (); +} + +/* Return the string corresponding to the qualifiers given by + TYPE_QUALS. */ + +static const char* +qualifier_string (type_quals) + int type_quals; +{ + switch (type_quals) + { + case TYPE_UNQUALIFIED: + return ""; + + case TYPE_QUAL_CONST: + return "const"; + + case TYPE_QUAL_VOLATILE: + return "volatile"; + + case TYPE_QUAL_RESTRICT: + return "__restrict"; + + case TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE: + return "const volatile"; + + case TYPE_QUAL_CONST | TYPE_QUAL_RESTRICT: + return "const __restrict"; + + case TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT: + return "volatile __restrict"; + + case TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT: + return "const volatile __restrict"; + + default: + break; + } + + /* TYPE_QUALS was an invalid qualifier set. */ + abort (); +} + +/* C is the code for a type-qualifier. Return the string + corresponding to this qualifier. This function should only be + called with a valid qualifier code. */ + +static const char* +demangle_qualifier (c) + int c; +{ + return qualifier_string (code_for_qualifier (c)); +} + +int +cplus_demangle_opname (opname, result, options) + const char *opname; + char *result; + int options; +{ + int len, len1, ret; + string type; + struct work_stuff work[1]; + const char *tem; + + len = strlen(opname); + result[0] = '\0'; + ret = 0; + memset ((char *) work, 0, sizeof (work)); + work->options = options; + + if (opname[0] == '_' && opname[1] == '_' + && opname[2] == 'o' && opname[3] == 'p') + { + /* ANSI. */ + /* type conversion operator. */ + tem = opname + 4; + if (do_type (work, &tem, &type)) + { + strcat (result, "operator "); + strncat (result, type.b, type.p - type.b); + string_delete (&type); + ret = 1; + } + } + else if (opname[0] == '_' && opname[1] == '_' + && opname[2] >= 'a' && opname[2] <= 'z' + && opname[3] >= 'a' && opname[3] <= 'z') + { + if (opname[4] == '\0') + { + /* Operator. */ + size_t i; + for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) + { + if (strlen (optable[i].in) == 2 + && memcmp (optable[i].in, opname + 2, 2) == 0) + { + strcat (result, "operator"); + strcat (result, optable[i].out); + ret = 1; + break; + } + } + } + else + { + if (opname[2] == 'a' && opname[5] == '\0') + { + /* Assignment. */ + size_t i; + for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) + { + if (strlen (optable[i].in) == 3 + && memcmp (optable[i].in, opname + 2, 3) == 0) + { + strcat (result, "operator"); + strcat (result, optable[i].out); + ret = 1; + break; + } + } + } + } + } + else if (len >= 3 + && opname[0] == 'o' + && opname[1] == 'p' + && strchr (cplus_markers, opname[2]) != NULL) + { + /* see if it's an assignment expression */ + if (len >= 10 /* op$assign_ */ + && memcmp (opname + 3, "assign_", 7) == 0) + { + size_t i; + for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) + { + len1 = len - 10; + if ((int) strlen (optable[i].in) == len1 + && memcmp (optable[i].in, opname + 10, len1) == 0) + { + strcat (result, "operator"); + strcat (result, optable[i].out); + strcat (result, "="); + ret = 1; + break; + } + } + } + else + { + size_t i; + for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) + { + len1 = len - 3; + if ((int) strlen (optable[i].in) == len1 + && memcmp (optable[i].in, opname + 3, len1) == 0) + { + strcat (result, "operator"); + strcat (result, optable[i].out); + ret = 1; + break; + } + } + } + } + else if (len >= 5 && memcmp (opname, "type", 4) == 0 + && strchr (cplus_markers, opname[4]) != NULL) + { + /* type conversion operator */ + tem = opname + 5; + if (do_type (work, &tem, &type)) + { + strcat (result, "operator "); + strncat (result, type.b, type.p - type.b); + string_delete (&type); + ret = 1; + } + } + squangle_mop_up (work); + return ret; + +} +/* Takes operator name as e.g. "++" and returns mangled + operator name (e.g. "postincrement_expr"), or NULL if not found. + + If OPTIONS & DMGL_ANSI == 1, return the ANSI name; + if OPTIONS & DMGL_ANSI == 0, return the old GNU name. */ + +const char * +cplus_mangle_opname (opname, options) + const char *opname; + int options; +{ + size_t i; + int len; + + len = strlen (opname); + for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) + { + if ((int) strlen (optable[i].out) == len + && (options & DMGL_ANSI) == (optable[i].flags & DMGL_ANSI) + && memcmp (optable[i].out, opname, len) == 0) + return optable[i].in; + } + return (0); +} + +/* 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 + of the name will be returned; otherwise NULL will be returned. + It is the caller's responsibility to free the string which + is returned. + + The OPTIONS arg may contain one or more of the following bits: + + DMGL_ANSI ANSI qualifiers such as `const' and `void' are + included. + DMGL_PARAMS Function parameters are included. + + For example, + + cplus_demangle ("foo__1Ai", DMGL_PARAMS) => "A::foo(int)" + cplus_demangle ("foo__1Ai", DMGL_PARAMS | DMGL_ANSI) => "A::foo(int)" + cplus_demangle ("foo__1Ai", 0) => "A::foo" + + cplus_demangle ("foo__1Afe", DMGL_PARAMS) => "A::foo(float,...)" + cplus_demangle ("foo__1Afe", DMGL_PARAMS | DMGL_ANSI)=> "A::foo(float,...)" + cplus_demangle ("foo__1Afe", 0) => "A::foo" + + Note that any leading underscores, or other such characters prepended by + the compilation system, are presumed to have already been stripped from + MANGLED. */ + +char * +cplus_demangle (mangled, options) + const char *mangled; + int options; +{ + char *ret; + struct work_stuff work[1]; + memset ((char *) work, 0, sizeof (work)); + work -> options = options; + if ((work -> options & DMGL_STYLE_MASK) == 0) + work -> options |= (int) current_demangling_style & DMGL_STYLE_MASK; + + ret = internal_cplus_demangle (work, mangled); + squangle_mop_up (work); + return (ret); +} + + +/* This function performs most of what cplus_demangle use to do, but + to be able to demangle a name with a B, K or n code, we need to + have a longer term memory of what types have been seen. The original + now intializes and cleans up the squangle code info, while internal + calls go directly to this routine to avoid resetting that info. */ + +static char * +internal_cplus_demangle (work, mangled) + struct work_stuff *work; + const char *mangled; +{ + + string decl; + int success = 0; + char *demangled = NULL; + int s1,s2,s3,s4; + s1 = work->constructor; + s2 = work->destructor; + s3 = work->static_type; + s4 = work->type_quals; + work->constructor = work->destructor = 0; + work->type_quals = TYPE_UNQUALIFIED; + work->dllimported = 0; + + if ((mangled != NULL) && (*mangled != '\0')) + { + string_init (&decl); + + /* First check to see if gnu style demangling is active and if the + string to be demangled contains a CPLUS_MARKER. If so, attempt to + recognize one of the gnu special forms rather than looking for a + standard prefix. In particular, don't worry about whether there + is a "__" string in the mangled string. Consider "_$_5__foo" for + example. */ + + if ((AUTO_DEMANGLING || GNU_DEMANGLING)) + { + success = gnu_special (work, &mangled, &decl); + } + if (!success) + { + success = demangle_prefix (work, &mangled, &decl); + } + if (success && (*mangled != '\0')) + { + success = demangle_signature (work, &mangled, &decl); + } + if (work->constructor == 2) + { + string_prepend (&decl, "global constructors keyed to "); + work->constructor = 0; + } + else if (work->destructor == 2) + { + string_prepend (&decl, "global destructors keyed to "); + work->destructor = 0; + } + else if (work->dllimported == 1) + { + string_prepend (&decl, "import stub for "); + work->dllimported = 0; + } + demangled = mop_up (work, &decl, success); + } + work->constructor = s1; + work->destructor = s2; + work->static_type = s3; + work->type_quals = s4; + return (demangled); +} + + +/* Clear out and squangling related storage */ +static void +squangle_mop_up (work) + struct work_stuff *work; +{ + /* clean up the B and K type mangling types. */ + forget_B_and_K_types (work); + if (work -> btypevec != NULL) + { + free ((char *) work -> btypevec); + } + if (work -> ktypevec != NULL) + { + free ((char *) work -> ktypevec); + } +} + +/* Clear out any mangled storage */ + +static char * +mop_up (work, declp, success) + struct work_stuff *work; + string *declp; + int success; +{ + char *demangled = NULL; + + /* Discard the remembered types, if any. */ + + forget_types (work); + if (work -> typevec != NULL) + { + free ((char *) work -> typevec); + work -> typevec = NULL; + work -> typevec_size = 0; + } + if (work->tmpl_argvec) + { + int i; + + for (i = 0; i < work->ntmpl_args; i++) + if (work->tmpl_argvec[i]) + free ((char*) work->tmpl_argvec[i]); + + free ((char*) work->tmpl_argvec); + work->tmpl_argvec = NULL; + } + if (work->previous_argument) + { + string_delete (work->previous_argument); + free ((char*) work->previous_argument); + work->previous_argument = NULL; + } + + /* If demangling was successful, ensure that the demangled string is null + terminated and return it. Otherwise, free the demangling decl. */ + + if (!success) + { + string_delete (declp); + } + else + { + string_appendn (declp, "", 1); + demangled = declp -> b; + } + return (demangled); +} + +/* + +LOCAL FUNCTION + + demangle_signature -- demangle the signature part of a mangled name + +SYNOPSIS + + static int + demangle_signature (struct work_stuff *work, const char **mangled, + string *declp); + +DESCRIPTION + + Consume and demangle the signature portion of the mangled name. + + DECLP is the string where demangled output is being built. At + entry it contains the demangled root name from the mangled name + prefix. I.E. either a demangled operator name or the root function + name. In some special cases, it may contain nothing. + + *MANGLED points to the current unconsumed location in the mangled + name. As tokens are consumed and demangling is performed, the + pointer is updated to continuously point at the next token to + be consumed. + + Demangling GNU style mangled names is nasty because there is no + explicit token that marks the start of the outermost function + argument list. */ + +static int +demangle_signature (work, mangled, declp) + struct work_stuff *work; + const char **mangled; + string *declp; +{ + int success = 1; + int func_done = 0; + int expect_func = 0; + int expect_return_type = 0; + const char *oldmangled = NULL; + string trawname; + string tname; + + while (success && (**mangled != '\0')) + { + switch (**mangled) + { + case 'Q': + oldmangled = *mangled; + success = demangle_qualified (work, mangled, declp, 1, 0); + if (success) + remember_type (work, oldmangled, *mangled - oldmangled); + if (AUTO_DEMANGLING || GNU_DEMANGLING) + expect_func = 1; + oldmangled = NULL; + break; + + case 'K': + oldmangled = *mangled; + success = demangle_qualified (work, mangled, declp, 1, 0); + if (AUTO_DEMANGLING || GNU_DEMANGLING) + { + expect_func = 1; + } + oldmangled = NULL; + break; + + case 'S': + /* Static member function */ + if (oldmangled == NULL) + { + oldmangled = *mangled; + } + (*mangled)++; + work -> static_type = 1; + break; + + case 'C': + case 'V': + case 'u': + work->type_quals |= code_for_qualifier (**mangled); + + /* a qualified member function */ + if (oldmangled == NULL) + oldmangled = *mangled; + (*mangled)++; + break; + + case 'L': + /* Local class name follows after "Lnnn_" */ + if (HP_DEMANGLING) + { + while (**mangled && (**mangled != '_')) + (*mangled)++; + if (!**mangled) + success = 0; + else + (*mangled)++; + } + else + success = 0; + break; + + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + if (oldmangled == NULL) + { + oldmangled = *mangled; + } + work->temp_start = -1; /* uppermost call to demangle_class */ + success = demangle_class (work, mangled, declp); + if (success) + { + remember_type (work, oldmangled, *mangled - oldmangled); + } + if (AUTO_DEMANGLING || GNU_DEMANGLING || EDG_DEMANGLING) + { + /* EDG and others will have the "F", so we let the loop cycle + if we are looking at one. */ + if (**mangled != 'F') + expect_func = 1; + } + oldmangled = NULL; + break; + + case 'B': + { + string s; + success = do_type (work, mangled, &s); + if (success) + { + string_append (&s, SCOPE_STRING (work)); + string_prepends (declp, &s); + } + oldmangled = NULL; + expect_func = 1; + } + break; + + case 'F': + /* Function */ + /* ARM/HP style demangling includes a specific 'F' character after + the class name. For GNU style, it is just implied. So we can + safely just consume any 'F' at this point and be compatible + with either style. */ + + oldmangled = NULL; + func_done = 1; + (*mangled)++; + + /* For lucid/ARM/HP style we have to forget any types we might + have remembered up to this point, since they were not argument + types. GNU style considers all types seen as available for + back references. See comment in demangle_args() */ + + if (LUCID_DEMANGLING || ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING) + { + forget_types (work); + } + success = demangle_args (work, mangled, declp); + /* After picking off the function args, we expect to either + find the function return type (preceded by an '_') or the + end of the string. */ + if (success && (AUTO_DEMANGLING || EDG_DEMANGLING) && **mangled == '_') + { + ++(*mangled); + /* At this level, we do not care about the return type. */ + success = do_type (work, mangled, &tname); + string_delete (&tname); + } + + break; + + case 't': + /* G++ Template */ + string_init(&trawname); + string_init(&tname); + if (oldmangled == NULL) + { + oldmangled = *mangled; + } + success = demangle_template (work, mangled, &tname, + &trawname, 1, 1); + if (success) + { + remember_type (work, oldmangled, *mangled - oldmangled); + } + string_append (&tname, SCOPE_STRING (work)); + + string_prepends(declp, &tname); + if (work -> destructor & 1) + { + string_prepend (&trawname, "~"); + string_appends (declp, &trawname); + work->destructor -= 1; + } + if ((work->constructor & 1) || (work->destructor & 1)) + { + string_appends (declp, &trawname); + work->constructor -= 1; + } + string_delete(&trawname); + string_delete(&tname); + oldmangled = NULL; + expect_func = 1; + break; + + case '_': + if (GNU_DEMANGLING && expect_return_type) + { + /* Read the return type. */ + string return_type; + string_init (&return_type); + + (*mangled)++; + success = do_type (work, mangled, &return_type); + APPEND_BLANK (&return_type); + + string_prepends (declp, &return_type); + string_delete (&return_type); + break; + } + else + /* At the outermost level, we cannot have a return type specified, + so if we run into another '_' at this point we are dealing with + a mangled name that is either bogus, or has been mangled by + some algorithm we don't know how to deal with. So just + reject the entire demangling. */ + /* However, "_nnn" is an expected suffix for alternate entry point + numbered nnn for a function, with HP aCC, so skip over that + without reporting failure. pai/1997-09-04 */ + if (HP_DEMANGLING) + { + (*mangled)++; + while (**mangled && isdigit ((unsigned char)**mangled)) + (*mangled)++; + } + else + success = 0; + break; + + case 'H': + if (GNU_DEMANGLING) + { + /* A G++ template function. Read the template arguments. */ + success = demangle_template (work, mangled, declp, 0, 0, + 0); + if (!(work->constructor & 1)) + expect_return_type = 1; + (*mangled)++; + break; + } + else + /* fall through */ + {;} + + default: + if (AUTO_DEMANGLING || GNU_DEMANGLING) + { + /* Assume we have stumbled onto the first outermost function + argument token, and start processing args. */ + func_done = 1; + success = demangle_args (work, mangled, declp); + } + else + { + /* Non-GNU demanglers use a specific token to mark the start + of the outermost function argument tokens. Typically 'F', + for ARM/HP-demangling, for example. So if we find something + we are not prepared for, it must be an error. */ + success = 0; + } + break; + } + /* + if (AUTO_DEMANGLING || GNU_DEMANGLING) + */ + { + if (success && expect_func) + { + func_done = 1; + if (LUCID_DEMANGLING || ARM_DEMANGLING || EDG_DEMANGLING) + { + forget_types (work); + } + success = demangle_args (work, mangled, declp); + /* Since template include the mangling of their return types, + we must set expect_func to 0 so that we don't try do + demangle more arguments the next time we get here. */ + expect_func = 0; + } + } + } + if (success && !func_done) + { + if (AUTO_DEMANGLING || GNU_DEMANGLING) + { + /* With GNU style demangling, bar__3foo is 'foo::bar(void)', and + bar__3fooi is 'foo::bar(int)'. We get here when we find the + first case, and need to ensure that the '(void)' gets added to + the current declp. Note that with ARM/HP, the first case + represents the name of a static data member 'foo::bar', + which is in the current declp, so we leave it alone. */ + success = demangle_args (work, mangled, declp); + } + } + if (success && PRINT_ARG_TYPES) + { + if (work->static_type) + string_append (declp, " static"); + if (work->type_quals != TYPE_UNQUALIFIED) + { + APPEND_BLANK (declp); + string_append (declp, qualifier_string (work->type_quals)); + } + } + + return (success); +} + +#if 0 + +static int +demangle_method_args (work, mangled, declp) + struct work_stuff *work; + const char **mangled; + string *declp; +{ + int success = 0; + + if (work -> static_type) + { + string_append (declp, *mangled + 1); + *mangled += strlen (*mangled); + success = 1; + } + else + { + success = demangle_args (work, mangled, declp); + } + return (success); +} + +#endif + +static int +demangle_template_template_parm (work, mangled, tname) + struct work_stuff *work; + const char **mangled; + string *tname; +{ + int i; + int r; + int need_comma = 0; + int success = 1; + string temp; + + string_append (tname, "template <"); + /* get size of template parameter list */ + if (get_count (mangled, &r)) + { + for (i = 0; i < r; i++) + { + if (need_comma) + { + string_append (tname, ", "); + } + + /* Z for type parameters */ + if (**mangled == 'Z') + { + (*mangled)++; + string_append (tname, "class"); + } + /* z for template parameters */ + else if (**mangled == 'z') + { + (*mangled)++; + success = + demangle_template_template_parm (work, mangled, tname); + if (!success) + { + break; + } + } + else + { + /* temp is initialized in do_type */ + success = do_type (work, mangled, &temp); + if (success) + { + string_appends (tname, &temp); + } + string_delete(&temp); + if (!success) + { + break; + } + } + need_comma = 1; + } + + } + if (tname->p[-1] == '>') + string_append (tname, " "); + string_append (tname, "> class"); + return (success); +} + +static int +demangle_expression (work, mangled, s, tk) + struct work_stuff *work; + const char** mangled; + string* s; + type_kind_t tk; +{ + int need_operator = 0; + int success; + + success = 1; + string_appendn (s, "(", 1); + (*mangled)++; + while (success && **mangled != 'W' && **mangled != '\0') + { + if (need_operator) + { + size_t i; + size_t len; + + success = 0; + + len = strlen (*mangled); + + for (i = 0; + i < sizeof (optable) / sizeof (optable [0]); + ++i) + { + size_t l = strlen (optable[i].in); + + if (l <= len + && memcmp (optable[i].in, *mangled, l) == 0) + { + string_appendn (s, " ", 1); + string_append (s, optable[i].out); + string_appendn (s, " ", 1); + success = 1; + (*mangled) += l; + break; + } + } + + if (!success) + break; + } + else + need_operator = 1; + + success = demangle_template_value_parm (work, mangled, s, tk); + } + + if (**mangled != 'W') + success = 0; + else + { + string_appendn (s, ")", 1); + (*mangled)++; + } + + return success; +} + +static int +demangle_integral_value (work, mangled, s) + struct work_stuff *work; + const char** mangled; + string* s; +{ + int success; + + if (**mangled == 'E') + success = demangle_expression (work, mangled, s, tk_integral); + else if (**mangled == 'Q' || **mangled == 'K') + success = demangle_qualified (work, mangled, s, 0, 1); + else + { + int value; + + success = 0; + + /* Negative numbers are indicated with a leading `m'. */ + if (**mangled == 'm') + { + string_appendn (s, "-", 1); + (*mangled)++; + } + + /* Read the rest of the number. */ + value = consume_count_with_underscores (mangled); + if (value != -1) + { + char buf[INTBUF_SIZE]; + sprintf (buf, "%d", value); + string_append (s, buf); + + /* If the next character is an underscore, skip it. */ + if (**mangled == '_') + (*mangled)++; + + /* All is well. */ + success = 1; + } + } + + return success; +} + +/* Demangle the real value in MANGLED. */ + +static int +demangle_real_value (work, mangled, s) + struct work_stuff *work; + const char **mangled; + string* s; +{ + if (**mangled == 'E') + return demangle_expression (work, mangled, s, tk_real); + + if (**mangled == 'm') + { + string_appendn (s, "-", 1); + (*mangled)++; + } + while (isdigit ((unsigned char)**mangled)) + { + string_appendn (s, *mangled, 1); + (*mangled)++; + } + if (**mangled == '.') /* fraction */ + { + string_appendn (s, ".", 1); + (*mangled)++; + while (isdigit ((unsigned char)**mangled)) + { + string_appendn (s, *mangled, 1); + (*mangled)++; + } + } + if (**mangled == 'e') /* exponent */ + { + string_appendn (s, "e", 1); + (*mangled)++; + while (isdigit ((unsigned char)**mangled)) + { + string_appendn (s, *mangled, 1); + (*mangled)++; + } + } + + return 1; +} + +static int +demangle_template_value_parm (work, mangled, s, tk) + struct work_stuff *work; + const char **mangled; + string* s; + type_kind_t tk; +{ + int success = 1; + + if (**mangled == 'Y') + { + /* The next argument is a template parameter. */ + int idx; + + (*mangled)++; + idx = consume_count_with_underscores (mangled); + if (idx == -1 + || (work->tmpl_argvec && idx >= work->ntmpl_args) + || consume_count_with_underscores (mangled) == -1) + return -1; + if (work->tmpl_argvec) + string_append (s, work->tmpl_argvec[idx]); + else + string_append_template_idx (s, idx); + } + else if (tk == tk_integral) + success = demangle_integral_value (work, mangled, s); + else if (tk == tk_char) + { + char tmp[2]; + int val; + if (**mangled == 'm') + { + string_appendn (s, "-", 1); + (*mangled)++; + } + string_appendn (s, "'", 1); + val = consume_count(mangled); + if (val <= 0) + success = 0; + else + { + tmp[0] = (char)val; + tmp[1] = '\0'; + string_appendn (s, &tmp[0], 1); + string_appendn (s, "'", 1); + } + } + else if (tk == tk_bool) + { + int val = consume_count (mangled); + if (val == 0) + string_appendn (s, "false", 5); + else if (val == 1) + string_appendn (s, "true", 4); + else + success = 0; + } + else if (tk == tk_real) + success = demangle_real_value (work, mangled, s); + else if (tk == tk_pointer || tk == tk_reference) + { + if (**mangled == 'Q') + success = demangle_qualified (work, mangled, s, + /*isfuncname=*/0, + /*append=*/1); + else + { + int symbol_len = consume_count (mangled); + if (symbol_len == -1) + return -1; + if (symbol_len == 0) + string_appendn (s, "0", 1); + else + { + char *p = xmalloc (symbol_len + 1), *q; + strncpy (p, *mangled, symbol_len); + p [symbol_len] = '\0'; + /* We use cplus_demangle here, rather than + internal_cplus_demangle, because the name of the entity + mangled here does not make use of any of the squangling + or type-code information we have built up thus far; it is + mangled independently. */ + q = cplus_demangle (p, work->options); + if (tk == tk_pointer) + string_appendn (s, "&", 1); + /* FIXME: Pointer-to-member constants should get a + qualifying class name here. */ + if (q) + { + string_append (s, q); + free (q); + } + else + string_append (s, p); + free (p); + } + *mangled += symbol_len; + } + } + + return success; +} + +/* Demangle the template name in MANGLED. The full name of the + template (e.g., S) is placed in TNAME. The name without the + template parameters (e.g. S) is placed in TRAWNAME if TRAWNAME is + non-NULL. If IS_TYPE is nonzero, this template is a type template, + not a function template. If both IS_TYPE and REMEMBER are nonzero, + the tmeplate is remembered in the list of back-referenceable + types. */ + +static int +demangle_template (work, mangled, tname, trawname, is_type, remember) + struct work_stuff *work; + const char **mangled; + string *tname; + string *trawname; + int is_type; + int remember; +{ + int i; + int r; + int need_comma = 0; + int success = 0; + const char *start; + int is_java_array = 0; + string temp; + int bindex = 0; + + (*mangled)++; + if (is_type) + { + if (remember) + bindex = register_Btype (work); + start = *mangled; + /* get template name */ + if (**mangled == 'z') + { + int idx; + (*mangled)++; + (*mangled)++; + + idx = consume_count_with_underscores (mangled); + if (idx == -1 + || (work->tmpl_argvec && idx >= work->ntmpl_args) + || consume_count_with_underscores (mangled) == -1) + return (0); + + if (work->tmpl_argvec) + { + string_append (tname, work->tmpl_argvec[idx]); + if (trawname) + string_append (trawname, work->tmpl_argvec[idx]); + } + else + { + string_append_template_idx (tname, idx); + if (trawname) + string_append_template_idx (trawname, idx); + } + } + else + { + if ((r = consume_count (mangled)) <= 0 + || (int) strlen (*mangled) < r) + { + return (0); + } + is_java_array = (work -> options & DMGL_JAVA) + && strncmp (*mangled, "JArray1Z", 8) == 0; + if (! is_java_array) + { + string_appendn (tname, *mangled, r); + } + if (trawname) + string_appendn (trawname, *mangled, r); + *mangled += r; + } + } + if (!is_java_array) + string_append (tname, "<"); + /* get size of template parameter list */ + if (!get_count (mangled, &r)) + { + return (0); + } + if (!is_type) + { + /* Create an array for saving the template argument values. */ + work->tmpl_argvec = (char**) xmalloc (r * sizeof (char *)); + work->ntmpl_args = r; + for (i = 0; i < r; i++) + work->tmpl_argvec[i] = 0; + } + for (i = 0; i < r; i++) + { + if (need_comma) + { + string_append (tname, ", "); + } + /* Z for type parameters */ + if (**mangled == 'Z') + { + (*mangled)++; + /* temp is initialized in do_type */ + success = do_type (work, mangled, &temp); + if (success) + { + string_appends (tname, &temp); + + if (!is_type) + { + /* Save the template argument. */ + int len = temp.p - temp.b; + work->tmpl_argvec[i] = xmalloc (len + 1); + memcpy (work->tmpl_argvec[i], temp.b, len); + work->tmpl_argvec[i][len] = '\0'; + } + } + string_delete(&temp); + if (!success) + { + break; + } + } + /* z for template parameters */ + else if (**mangled == 'z') + { + int r2; + (*mangled)++; + success = demangle_template_template_parm (work, mangled, tname); + + if (success + && (r2 = consume_count (mangled)) > 0 + && (int) strlen (*mangled) >= r2) + { + string_append (tname, " "); + string_appendn (tname, *mangled, r2); + if (!is_type) + { + /* Save the template argument. */ + int len = r2; + work->tmpl_argvec[i] = xmalloc (len + 1); + memcpy (work->tmpl_argvec[i], *mangled, len); + work->tmpl_argvec[i][len] = '\0'; + } + *mangled += r2; + } + if (!success) + { + break; + } + } + else + { + string param; + string* s; + + /* otherwise, value parameter */ + + /* temp is initialized in do_type */ + success = do_type (work, mangled, &temp); + string_delete(&temp); + if (!success) + break; + + if (!is_type) + { + s = ¶m; + string_init (s); + } + else + s = tname; + + success = demangle_template_value_parm (work, mangled, s, + (type_kind_t) success); + + if (!success) + { + if (!is_type) + string_delete (s); + success = 0; + break; + } + + if (!is_type) + { + int len = s->p - s->b; + work->tmpl_argvec[i] = xmalloc (len + 1); + memcpy (work->tmpl_argvec[i], s->b, len); + work->tmpl_argvec[i][len] = '\0'; + + string_appends (tname, s); + string_delete (s); + } + } + need_comma = 1; + } + if (is_java_array) + { + string_append (tname, "[]"); + } + else + { + if (tname->p[-1] == '>') + string_append (tname, " "); + string_append (tname, ">"); + } + + if (is_type && remember) + remember_Btype (work, tname->b, LEN_STRING (tname), bindex); + + /* + if (work -> static_type) + { + string_append (declp, *mangled + 1); + *mangled += strlen (*mangled); + success = 1; + } + else + { + success = demangle_args (work, mangled, declp); + } + } + */ + return (success); +} + +static int +arm_pt (work, mangled, n, anchor, args) + struct work_stuff *work; + const char *mangled; + int n; + const char **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__"))) + { + int len; + *args = *anchor + 6; + len = consume_count (args); + if (len == -1) + return 0; + if (*args + len == mangled + n && **args == '_') + { + ++*args; + return 1; + } + } + if (AUTO_DEMANGLING || EDG_DEMANGLING) + { + if ((*anchor = mystrstr (mangled, "__tm__")) + || (*anchor = mystrstr (mangled, "__ps__")) + || (*anchor = mystrstr (mangled, "__pt__"))) + { + int len; + *args = *anchor + 6; + len = consume_count (args); + if (len == -1) + return 0; + if (*args + len == mangled + n && **args == '_') + { + ++*args; + return 1; + } + } + else if ((*anchor = mystrstr (mangled, "__S"))) + { + int len; + *args = *anchor + 3; + len = consume_count (args); + if (len == -1) + return 0; + if (*args + len == mangled + n && **args == '_') + { + ++*args; + return 1; + } + } + } + + return 0; +} + +static void +demangle_arm_hp_template (work, mangled, n, declp) + struct work_stuff *work; + const char **mangled; + int n; + string *declp; +{ + const char *p; + const char *args; + const char *e = *mangled + n; + string arg; + + /* Check for HP aCC template spec: classXt1t2 where t1, t2 are + template args */ + if (HP_DEMANGLING && ((*mangled)[n] == 'X')) + { + char *start_spec_args = NULL; + + /* First check for and omit template specialization pseudo-arguments, + such as in "Spec<#1,#1.*>" */ + start_spec_args = strchr (*mangled, '<'); + if (start_spec_args && (start_spec_args - *mangled < n)) + string_appendn (declp, *mangled, start_spec_args - *mangled); + else + string_appendn (declp, *mangled, n); + (*mangled) += n + 1; + string_init (&arg); + if (work->temp_start == -1) /* non-recursive call */ + work->temp_start = declp->p - declp->b; + string_append (declp, "<"); + while (1) + { + string_clear (&arg); + switch (**mangled) + { + case 'T': + /* 'T' signals a type parameter */ + (*mangled)++; + if (!do_type (work, mangled, &arg)) + goto hpacc_template_args_done; + break; + + case 'U': + case 'S': + /* 'U' or 'S' signals an integral value */ + if (!do_hpacc_template_const_value (work, mangled, &arg)) + goto hpacc_template_args_done; + break; + + case 'A': + /* 'A' signals a named constant expression (literal) */ + if (!do_hpacc_template_literal (work, mangled, &arg)) + goto hpacc_template_args_done; + break; + + default: + /* Today, 1997-09-03, we have only the above types + of template parameters */ + /* FIXME: maybe this should fail and return null */ + goto hpacc_template_args_done; + } + string_appends (declp, &arg); + /* Check if we're at the end of template args. + 0 if at end of static member of template class, + _ if done with template args for a function */ + if ((**mangled == '\000') || (**mangled == '_')) + break; + else + string_append (declp, ","); + } + hpacc_template_args_done: + string_append (declp, ">"); + string_delete (&arg); + if (**mangled == '_') + (*mangled)++; + return; + } + /* ARM template? (Also handles HP cfront extensions) */ + else if (arm_pt (work, *mangled, n, &p, &args)) + { + string type_str; + + string_init (&arg); + string_appendn (declp, *mangled, p - *mangled); + if (work->temp_start == -1) /* non-recursive call */ + work->temp_start = declp->p - declp->b; + string_append (declp, "<"); + /* should do error checking here */ + while (args < e) { + string_clear (&arg); + + /* Check for type or literal here */ + switch (*args) + { + /* HP cfront extensions to ARM for template args */ + /* spec: Xt1Lv1 where t1 is a type, v1 is a literal value */ + /* FIXME: We handle only numeric literals for HP cfront */ + case 'X': + /* A typed constant value follows */ + args++; + if (!do_type (work, &args, &type_str)) + goto cfront_template_args_done; + string_append (&arg, "("); + string_appends (&arg, &type_str); + string_append (&arg, ")"); + if (*args != 'L') + goto cfront_template_args_done; + args++; + /* Now snarf a literal value following 'L' */ + if (!snarf_numeric_literal (&args, &arg)) + goto cfront_template_args_done; + break; + + case 'L': + /* Snarf a literal following 'L' */ + args++; + if (!snarf_numeric_literal (&args, &arg)) + goto cfront_template_args_done; + break; + default: + /* Not handling other HP cfront stuff */ + if (!do_type (work, &args, &arg)) + goto cfront_template_args_done; + } + string_appends (declp, &arg); + string_append (declp, ","); + } + cfront_template_args_done: + string_delete (&arg); + if (args >= e) + --declp->p; /* remove extra comma */ + string_append (declp, ">"); + } + else if (n>10 && strncmp (*mangled, "_GLOBAL_", 8) == 0 + && (*mangled)[9] == 'N' + && (*mangled)[8] == (*mangled)[10] + && strchr (cplus_markers, (*mangled)[8])) + { + /* A member of the anonymous namespace. */ + string_append (declp, "{anonymous}"); + } + else + { + if (work->temp_start == -1) /* non-recursive call only */ + work->temp_start = 0; /* disable in recursive calls */ + string_appendn (declp, *mangled, n); + } + *mangled += n; +} + +/* Extract a class name, possibly a template with arguments, from the + mangled string; qualifiers, local class indicators, etc. have + already been dealt with */ + +static int +demangle_class_name (work, mangled, declp) + struct work_stuff *work; + const char **mangled; + string *declp; +{ + int n; + int success = 0; + + n = consume_count (mangled); + if (n == -1) + return 0; + if ((int) strlen (*mangled) >= n) + { + demangle_arm_hp_template (work, mangled, n, declp); + success = 1; + } + + return (success); +} + +/* + +LOCAL FUNCTION + + demangle_class -- demangle a mangled class sequence + +SYNOPSIS + + static int + demangle_class (struct work_stuff *work, const char **mangled, + strint *declp) + +DESCRIPTION + + DECLP points to the buffer into which demangling is being done. + + *MANGLED points to the current token to be demangled. On input, + it points to a mangled class (I.E. "3foo", "13verylongclass", etc.) + On exit, it points to the next token after the mangled class on + success, or the first unconsumed token on failure. + + If the CONSTRUCTOR or DESTRUCTOR flags are set in WORK, then + we are demangling a constructor or destructor. In this case + we prepend "class::class" or "class::~class" to DECLP. + + Otherwise, we prepend "class::" to the current DECLP. + + Reset the constructor/destructor flags once they have been + "consumed". This allows demangle_class to be called later during + the same demangling, to do normal class demangling. + + Returns 1 if demangling is successful, 0 otherwise. + +*/ + +static int +demangle_class (work, mangled, declp) + struct work_stuff *work; + const char **mangled; + string *declp; +{ + int success = 0; + int btype; + string class_name; + char *save_class_name_end = 0; + + string_init (&class_name); + btype = register_Btype (work); + if (demangle_class_name (work, mangled, &class_name)) + { + save_class_name_end = class_name.p; + if ((work->constructor & 1) || (work->destructor & 1)) + { + /* adjust so we don't include template args */ + if (work->temp_start && (work->temp_start != -1)) + { + class_name.p = class_name.b + work->temp_start; + } + string_prepends (declp, &class_name); + if (work -> destructor & 1) + { + string_prepend (declp, "~"); + work -> destructor -= 1; + } + else + { + work -> constructor -= 1; + } + } + class_name.p = save_class_name_end; + remember_Ktype (work, class_name.b, LEN_STRING(&class_name)); + remember_Btype (work, class_name.b, LEN_STRING(&class_name), btype); + string_prepend (declp, SCOPE_STRING (work)); + string_prepends (declp, &class_name); + success = 1; + } + string_delete (&class_name); + return (success); +} + +/* + +LOCAL FUNCTION + + demangle_prefix -- consume the mangled name prefix and find signature + +SYNOPSIS + + static int + demangle_prefix (struct work_stuff *work, const char **mangled, + string *declp); + +DESCRIPTION + + Consume and demangle the prefix of the mangled name. + + DECLP points to the string buffer into which demangled output is + placed. On entry, the buffer is empty. On exit it contains + the root function name, the demangled operator name, or in some + special cases either nothing or the completely demangled result. + + MANGLED points to the current pointer into the mangled name. As each + token of the mangled name is consumed, it is updated. Upon entry + the current mangled name pointer points to the first character of + the mangled name. Upon exit, it should point to the first character + of the signature if demangling was successful, or to the first + unconsumed character if demangling of the prefix was unsuccessful. + + Returns 1 on success, 0 otherwise. + */ + +static int +demangle_prefix (work, mangled, declp) + struct work_stuff *work; + const char **mangled; + string *declp; +{ + int success = 1; + const char *scan; + int i; + + if (strlen(*mangled) > 6 + && (strncmp(*mangled, "_imp__", 6) == 0 + || strncmp(*mangled, "__imp_", 6) == 0)) + { + /* it's a symbol imported from a PE dynamic library. Check for both + new style prefix _imp__ and legacy __imp_ used by older versions + of dlltool. */ + (*mangled) += 6; + work->dllimported = 1; + } + else if (strlen(*mangled) >= 11 && strncmp(*mangled, "_GLOBAL_", 8) == 0) + { + char *marker = strchr (cplus_markers, (*mangled)[8]); + if (marker != NULL && *marker == (*mangled)[10]) + { + if ((*mangled)[9] == 'D') + { + /* it's a GNU global destructor to be executed at program exit */ + (*mangled) += 11; + work->destructor = 2; + if (gnu_special (work, mangled, declp)) + return success; + } + else if ((*mangled)[9] == 'I') + { + /* it's a GNU global constructor to be executed at program init */ + (*mangled) += 11; + work->constructor = 2; + if (gnu_special (work, mangled, declp)) + return success; + } + } + } + else if ((ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING) && strncmp(*mangled, "__std__", 7) == 0) + { + /* it's a ARM global destructor to be executed at program exit */ + (*mangled) += 7; + work->destructor = 2; + } + else if ((ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING) && strncmp(*mangled, "__sti__", 7) == 0) + { + /* it's a ARM global constructor to be executed at program initial */ + (*mangled) += 7; + work->constructor = 2; + } + + /* This block of code is a reduction in strength time optimization + of: + scan = mystrstr (*mangled, "__"); */ + + { + scan = *mangled; + + do { + scan = strchr (scan, '_'); + } while (scan != NULL && *++scan != '_'); + + if (scan != NULL) --scan; + } + + if (scan != NULL) + { + /* We found a sequence of two or more '_', ensure that we start at + the last pair in the sequence. */ + i = strspn (scan, "_"); + if (i > 2) + { + scan += (i - 2); + } + } + + if (scan == NULL) + { + success = 0; + } + else if (work -> static_type) + { + if (!isdigit ((unsigned char)scan[0]) && (scan[0] != 't')) + { + success = 0; + } + } + else if ((scan == *mangled) + && (isdigit ((unsigned char)scan[2]) || (scan[2] == 'Q') + || (scan[2] == 't') || (scan[2] == 'K') || (scan[2] == 'H'))) + { + /* The ARM says nothing about the mangling of local variables. + But cfront mangles local variables by prepending __ + to them. As an extension to ARM demangling we handle this case. */ + if ((LUCID_DEMANGLING || ARM_DEMANGLING || HP_DEMANGLING) + && isdigit ((unsigned char)scan[2])) + { + *mangled = scan + 2; + consume_count (mangled); + string_append (declp, *mangled); + *mangled += strlen (*mangled); + success = 1; + } + else + { + /* 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. A GNU + style member-template constructor starts with 'H'. */ + if (!(LUCID_DEMANGLING || ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING)) + work -> constructor += 1; + *mangled = scan + 2; + } + } + else if (ARM_DEMANGLING && scan[2] == 'p' && scan[3] == 't') + { + /* Cfront-style parameterized type. Handled later as a signature. */ + success = 1; + + /* ARM template? */ + demangle_arm_hp_template (work, mangled, strlen (*mangled), declp); + } + else if (EDG_DEMANGLING && ((scan[2] == 't' && scan[3] == 'm') + || (scan[2] == 'p' && scan[3] == 's') + || (scan[2] == 'p' && scan[3] == 't'))) + { + /* EDG-style parameterized type. Handled later as a signature. */ + success = 1; + + /* EDG template? */ + demangle_arm_hp_template (work, mangled, strlen (*mangled), declp); + } + else if ((scan == *mangled) && !isdigit ((unsigned char)scan[2]) + && (scan[2] != 't')) + { + /* Mangled name starts with "__". Skip over any leading '_' characters, + then find the next "__" that separates the prefix from the signature. + */ + if (!(ARM_DEMANGLING || LUCID_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING) + || (arm_special (mangled, declp) == 0)) + { + while (*scan == '_') + { + scan++; + } + if ((scan = mystrstr (scan, "__")) == NULL || (*(scan + 2) == '\0')) + { + /* No separator (I.E. "__not_mangled"), or empty signature + (I.E. "__not_mangled_either__") */ + success = 0; + } + else + { + const char *tmp; + + /* Look for the LAST occurrence of __, allowing names to + have the '__' sequence embedded in them. */ + if (!(ARM_DEMANGLING || HP_DEMANGLING)) + { + while ((tmp = mystrstr (scan + 2, "__")) != NULL) + scan = tmp; + } + if (*(scan + 2) == '\0') + success = 0; + else + demangle_function_name (work, mangled, declp, scan); + } + } + } + else if (*(scan + 2) != '\0') + { + /* Mangled name does not start with "__" but does have one somewhere + in there with non empty stuff after it. Looks like a global + function name. */ + demangle_function_name (work, mangled, declp, scan); + } + else + { + /* Doesn't look like a mangled name */ + success = 0; + } + + if (!success && (work->constructor == 2 || work->destructor == 2)) + { + string_append (declp, *mangled); + *mangled += strlen (*mangled); + success = 1; + } + return (success); +} + +/* + +LOCAL FUNCTION + + gnu_special -- special handling of gnu mangled strings + +SYNOPSIS + + static int + gnu_special (struct work_stuff *work, const char **mangled, + string *declp); + + +DESCRIPTION + + Process some special GNU style mangling forms that don't fit + the normal pattern. For example: + + _$_3foo (destructor for class foo) + _vt$foo (foo virtual table) + _vt$foo$bar (foo::bar virtual table) + __vt_foo (foo virtual table, new style with thunks) + _3foo$varname (static data member) + _Q22rs2tu$vw (static data member) + __t6vector1Zii (constructor with template) + __thunk_4__$_7ostream (virtual function thunk) + */ + +static int +gnu_special (work, mangled, declp) + struct work_stuff *work; + const char **mangled; + string *declp; +{ + int n; + int success = 1; + const char *p; + + if ((*mangled)[0] == '_' + && strchr (cplus_markers, (*mangled)[1]) != NULL + && (*mangled)[2] == '_') + { + /* Found a GNU style destructor, get past "__" */ + (*mangled) += 3; + work -> destructor += 1; + } + else if ((*mangled)[0] == '_' + && (((*mangled)[1] == '_' + && (*mangled)[2] == 'v' + && (*mangled)[3] == 't' + && (*mangled)[4] == '_') + || ((*mangled)[1] == 'v' + && (*mangled)[2] == 't' + && strchr (cplus_markers, (*mangled)[3]) != NULL))) + { + /* Found a GNU style virtual table, get past "_vt" + and create the decl. Note that we consume the entire mangled + input string, which means that demangle_signature has no work + to do. */ + if ((*mangled)[2] == 'v') + (*mangled) += 5; /* New style, with thunks: "__vt_" */ + else + (*mangled) += 4; /* Old style, no thunks: "_vt" */ + while (**mangled != '\0') + { + switch (**mangled) + { + case 'Q': + case 'K': + success = demangle_qualified (work, mangled, declp, 0, 1); + break; + case 't': + success = demangle_template (work, mangled, declp, 0, 1, + 1); + break; + default: + if (isdigit((unsigned char)*mangled[0])) + { + n = consume_count(mangled); + /* We may be seeing a too-large size, or else a + "." indicating a static local symbol. In + any case, declare victory and move on; *don't* try + to use n to allocate. */ + if (n > (int) strlen (*mangled)) + { + success = 1; + break; + } + } + else + { + n = strcspn (*mangled, cplus_markers); + } + string_appendn (declp, *mangled, n); + (*mangled) += n; + } + + p = strpbrk (*mangled, cplus_markers); + if (success && ((p == NULL) || (p == *mangled))) + { + if (p != NULL) + { + string_append (declp, SCOPE_STRING (work)); + (*mangled)++; + } + } + else + { + success = 0; + break; + } + } + if (success) + string_append (declp, " virtual table"); + } + else if ((*mangled)[0] == '_' + && (strchr("0123456789Qt", (*mangled)[1]) != NULL) + && (p = strpbrk (*mangled, cplus_markers)) != NULL) + { + /* static data member, "_3foo$varname" for example */ + (*mangled)++; + switch (**mangled) + { + case 'Q': + case 'K': + success = demangle_qualified (work, mangled, declp, 0, 1); + break; + case 't': + success = demangle_template (work, mangled, declp, 0, 1, 1); + break; + default: + n = consume_count (mangled); + if (n < 0 || n > (long) strlen (*mangled)) + { + success = 0; + break; + } + string_appendn (declp, *mangled, n); + (*mangled) += n; + } + if (success && (p == *mangled)) + { + /* Consumed everything up to the cplus_marker, append the + variable name. */ + (*mangled)++; + string_append (declp, SCOPE_STRING (work)); + n = strlen (*mangled); + string_appendn (declp, *mangled, n); + (*mangled) += n; + } + else + { + success = 0; + } + } + else if (strncmp (*mangled, "__thunk_", 8) == 0) + { + int delta; + + (*mangled) += 8; + delta = consume_count (mangled); + if (delta == -1) + success = 0; + else + { + char *method = internal_cplus_demangle (work, ++*mangled); + + if (method) + { + char buf[50]; + sprintf (buf, "virtual function thunk (delta:%d) for ", -delta); + string_append (declp, buf); + string_append (declp, method); + free (method); + n = strlen (*mangled); + (*mangled) += n; + } + else + { + success = 0; + } + } + } + else if (strncmp (*mangled, "__t", 3) == 0 + && ((*mangled)[3] == 'i' || (*mangled)[3] == 'f')) + { + p = (*mangled)[3] == 'i' ? " type_info node" : " type_info function"; + (*mangled) += 4; + switch (**mangled) + { + case 'Q': + case 'K': + success = demangle_qualified (work, mangled, declp, 0, 1); + break; + case 't': + success = demangle_template (work, mangled, declp, 0, 1, 1); + break; + default: + success = demangle_fund_type (work, mangled, declp); + break; + } + if (success && **mangled != '\0') + success = 0; + if (success) + string_append (declp, p); + } + else + { + success = 0; + } + return (success); +} + +static void +recursively_demangle(work, mangled, result, namelength) + struct work_stuff *work; + const char **mangled; + string *result; + int namelength; +{ + char * recurse = (char *)NULL; + char * recurse_dem = (char *)NULL; + + recurse = (char *) xmalloc (namelength + 1); + memcpy (recurse, *mangled, namelength); + recurse[namelength] = '\000'; + + recurse_dem = cplus_demangle (recurse, work->options); + + if (recurse_dem) + { + string_append (result, recurse_dem); + free (recurse_dem); + } + else + { + string_appendn (result, *mangled, namelength); + } + free (recurse); + *mangled += namelength; +} + +/* + +LOCAL FUNCTION + + arm_special -- special handling of ARM/lucid mangled strings + +SYNOPSIS + + static int + arm_special (const char **mangled, + string *declp); + + +DESCRIPTION + + Process some special ARM style mangling forms that don't fit + the normal pattern. For example: + + __vtbl__3foo (foo virtual table) + __vtbl__3foo__3bar (bar::foo virtual table) + + */ + +static int +arm_special (mangled, declp) + const char **mangled; + string *declp; +{ + int n; + int success = 1; + const char *scan; + + if (strncmp (*mangled, ARM_VTABLE_STRING, ARM_VTABLE_STRLEN) == 0) + { + /* Found a ARM style virtual table, get past ARM_VTABLE_STRING + and create the decl. Note that we consume the entire mangled + input string, which means that demangle_signature has no work + to do. */ + scan = *mangled + ARM_VTABLE_STRLEN; + while (*scan != '\0') /* first check it can be demangled */ + { + n = consume_count (&scan); + if (n == -1) + { + return (0); /* no good */ + } + scan += n; + if (scan[0] == '_' && scan[1] == '_') + { + scan += 2; + } + } + (*mangled) += ARM_VTABLE_STRLEN; + while (**mangled != '\0') + { + n = consume_count (mangled); + if (n == -1 + || n > (long) strlen (*mangled)) + return 0; + string_prependn (declp, *mangled, n); + (*mangled) += n; + if ((*mangled)[0] == '_' && (*mangled)[1] == '_') + { + string_prepend (declp, "::"); + (*mangled) += 2; + } + } + string_append (declp, " virtual table"); + } + else + { + success = 0; + } + return (success); +} + +/* + +LOCAL FUNCTION + + demangle_qualified -- demangle 'Q' qualified name strings + +SYNOPSIS + + static int + demangle_qualified (struct work_stuff *, const char *mangled, + string *result, int isfuncname, int append); + +DESCRIPTION + + Demangle a qualified name, such as "Q25Outer5Inner" which is + the mangled form of "Outer::Inner". The demangled output is + prepended or appended to the result string according to the + state of the append flag. + + If isfuncname is nonzero, then the qualified name we are building + is going to be used as a member function name, so if it is a + constructor or destructor function, append an appropriate + constructor or destructor name. I.E. for the above example, + the result for use as a constructor is "Outer::Inner::Inner" + and the result for use as a destructor is "Outer::Inner::~Inner". + +BUGS + + Numeric conversion is ASCII dependent (FIXME). + + */ + +static int +demangle_qualified (work, mangled, result, isfuncname, append) + struct work_stuff *work; + const char **mangled; + string *result; + int isfuncname; + int append; +{ + int qualifiers = 0; + int success = 1; + char num[2]; + string temp; + string last_name; + int bindex = register_Btype (work); + + /* We only make use of ISFUNCNAME if the entity is a constructor or + destructor. */ + isfuncname = (isfuncname + && ((work->constructor & 1) || (work->destructor & 1))); + + string_init (&temp); + string_init (&last_name); + + if ((*mangled)[0] == 'K') + { + /* Squangling qualified name reuse */ + int idx; + (*mangled)++; + idx = consume_count_with_underscores (mangled); + if (idx == -1 || idx >= work -> numk) + success = 0; + else + string_append (&temp, work -> ktypevec[idx]); + } + else + switch ((*mangled)[1]) + { + case '_': + /* GNU mangled name with more than 9 classes. The count is preceded + by an underscore (to distinguish it from the <= 9 case) and followed + by an underscore. */ + (*mangled)++; + qualifiers = consume_count_with_underscores (mangled); + if (qualifiers == -1) + success = 0; + break; + + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + /* The count is in a single digit. */ + num[0] = (*mangled)[1]; + num[1] = '\0'; + qualifiers = atoi (num); + + /* If there is an underscore after the digit, skip it. This is + said to be for ARM-qualified names, but the ARM makes no + mention of such an underscore. Perhaps cfront uses one. */ + if ((*mangled)[2] == '_') + { + (*mangled)++; + } + (*mangled) += 2; + break; + + case '0': + default: + success = 0; + } + + if (!success) + return success; + + /* Pick off the names and collect them in the temp buffer in the order + in which they are found, separated by '::'. */ + + while (qualifiers-- > 0) + { + int remember_K = 1; + string_clear (&last_name); + + if (*mangled[0] == '_') + (*mangled)++; + + if (*mangled[0] == 't') + { + /* Here we always append to TEMP since we will want to use + the template name without the template parameters as a + constructor or destructor name. The appropriate + (parameter-less) value is returned by demangle_template + in LAST_NAME. We do not remember the template type here, + in order to match the G++ mangling algorithm. */ + success = demangle_template(work, mangled, &temp, + &last_name, 1, 0); + if (!success) + break; + } + else if (*mangled[0] == 'K') + { + int idx; + (*mangled)++; + idx = consume_count_with_underscores (mangled); + if (idx == -1 || idx >= work->numk) + success = 0; + else + string_append (&temp, work->ktypevec[idx]); + remember_K = 0; + + if (!success) break; + } + else + { + if (EDG_DEMANGLING) + { + int namelength; + /* Now recursively demangle the qualifier + * This is necessary to deal with templates in + * mangling styles like EDG */ + namelength = consume_count (mangled); + if (namelength == -1) + { + success = 0; + break; + } + recursively_demangle(work, mangled, &temp, namelength); + } + else + { + success = do_type (work, mangled, &last_name); + if (!success) + break; + string_appends (&temp, &last_name); + } + } + + if (remember_K) + remember_Ktype (work, temp.b, LEN_STRING (&temp)); + + if (qualifiers > 0) + string_append (&temp, SCOPE_STRING (work)); + } + + remember_Btype (work, temp.b, LEN_STRING (&temp), bindex); + + /* If we are using the result as a function name, we need to append + the appropriate '::' separated constructor or destructor name. + We do this here because this is the most convenient place, where + we already have a pointer to the name and the length of the name. */ + + if (isfuncname) + { + string_append (&temp, SCOPE_STRING (work)); + if (work -> destructor & 1) + string_append (&temp, "~"); + string_appends (&temp, &last_name); + } + + /* Now either prepend the temp buffer to the result, or append it, + depending upon the state of the append flag. */ + + if (append) + string_appends (result, &temp); + else + { + if (!STRING_EMPTY (result)) + string_append (&temp, SCOPE_STRING (work)); + string_prepends (result, &temp); + } + + string_delete (&last_name); + string_delete (&temp); + return (success); +} + +/* + +LOCAL FUNCTION + + get_count -- convert an ascii count to integer, consuming tokens + +SYNOPSIS + + static int + get_count (const char **type, int *count) + +DESCRIPTION + + Assume that *type points at a count in a mangled name; set + *count to its value, and set *type to the next character after + the count. There are some weird rules in effect here. + + If *type does not point at a string of digits, return zero. + + If *type points at a string of digits followed by an + underscore, set *count to their value as an integer, advance + *type to point *after the underscore, and return 1. + + If *type points at a string of digits not followed by an + underscore, consume only the first digit. Set *count to its + value as an integer, leave *type pointing after that digit, + and return 1. + + The excuse for this odd behavior: in the ARM and HP demangling + styles, a type can be followed by a repeat count of the form + `Nxy', where: + + `x' is a single digit specifying how many additional copies + of the type to append to the argument list, and + + `y' is one or more digits, specifying the zero-based index of + the first repeated argument in the list. Yes, as you're + unmangling the name you can figure this out yourself, but + it's there anyway. + + So, for example, in `bar__3fooFPiN51', the first argument is a + pointer to an integer (`Pi'), and then the next five arguments + are the same (`N5'), and the first repeat is the function's + second argument (`1'). +*/ + +static int +get_count (type, count) + const char **type; + int *count; +{ + const char *p; + int n; + + if (!isdigit ((unsigned char)**type)) + return (0); + else + { + *count = **type - '0'; + (*type)++; + if (isdigit ((unsigned char)**type)) + { + p = *type; + n = *count; + do + { + n *= 10; + n += *p - '0'; + p++; + } + while (isdigit ((unsigned char)*p)); + if (*p == '_') + { + *type = p + 1; + *count = n; + } + } + } + return (1); +} + +/* RESULT will be initialised here; it will be freed on failure. The + value returned is really a type_kind_t. */ + +static int +do_type (work, mangled, result) + struct work_stuff *work; + const char **mangled; + string *result; +{ + int n; + int done; + int success; + string decl; + const char *remembered_type; + int type_quals; + string btype; + type_kind_t tk = tk_none; + + string_init (&btype); + string_init (&decl); + string_init (result); + + done = 0; + success = 1; + while (success && !done) + { + int member; + switch (**mangled) + { + + /* A pointer type */ + case 'P': + case 'p': + (*mangled)++; + if (! (work -> options & DMGL_JAVA)) + string_prepend (&decl, "*"); + if (tk == tk_none) + tk = tk_pointer; + break; + + /* A reference type */ + case 'R': + (*mangled)++; + string_prepend (&decl, "&"); + if (tk == tk_none) + tk = tk_reference; + break; + + /* An array */ + case 'A': + { + ++(*mangled); + if (!STRING_EMPTY (&decl) + && (decl.b[0] == '*' || decl.b[0] == '&')) + { + string_prepend (&decl, "("); + string_append (&decl, ")"); + } + string_append (&decl, "["); + if (**mangled != '_') + success = demangle_template_value_parm (work, mangled, &decl, + tk_integral); + if (**mangled == '_') + ++(*mangled); + string_append (&decl, "]"); + break; + } + + /* A back reference to a previously seen type */ + case 'T': + (*mangled)++; + if (!get_count (mangled, &n) || n >= work -> ntypes) + { + success = 0; + } + else + { + remembered_type = work -> typevec[n]; + mangled = &remembered_type; + } + break; + + /* A function */ + case 'F': + (*mangled)++; + if (!STRING_EMPTY (&decl) + && (decl.b[0] == '*' || decl.b[0] == '&')) + { + string_prepend (&decl, "("); + string_append (&decl, ")"); + } + /* After picking off the function args, we expect to either find the + function return type (preceded by an '_') or the end of the + string. */ + if (!demangle_nested_args (work, mangled, &decl) + || (**mangled != '_' && **mangled != '\0')) + { + success = 0; + break; + } + if (success && (**mangled == '_')) + (*mangled)++; + break; + + case 'M': + case 'O': + { + type_quals = TYPE_UNQUALIFIED; + + member = **mangled == 'M'; + (*mangled)++; + + string_append (&decl, ")"); + + /* We don't need to prepend `::' for a qualified name; + demangle_qualified will do that for us. */ + if (**mangled != 'Q') + string_prepend (&decl, SCOPE_STRING (work)); + + if (isdigit ((unsigned char)**mangled)) + { + n = consume_count (mangled); + if (n == -1 + || (int) strlen (*mangled) < n) + { + success = 0; + break; + } + string_prependn (&decl, *mangled, n); + *mangled += n; + } + else if (**mangled == 'X' || **mangled == 'Y') + { + string temp; + do_type (work, mangled, &temp); + string_prepends (&decl, &temp); + } + else if (**mangled == 't') + { + string temp; + string_init (&temp); + success = demangle_template (work, mangled, &temp, + NULL, 1, 1); + if (success) + { + string_prependn (&decl, temp.b, temp.p - temp.b); + string_clear (&temp); + } + else + break; + } + else if (**mangled == 'Q') + { + success = demangle_qualified (work, mangled, &decl, + /*isfuncnam=*/0, + /*append=*/0); + if (!success) + break; + } + else + { + success = 0; + break; + } + + string_prepend (&decl, "("); + if (member) + { + switch (**mangled) + { + case 'C': + case 'V': + case 'u': + type_quals |= code_for_qualifier (**mangled); + (*mangled)++; + break; + + default: + break; + } + + if (*(*mangled)++ != 'F') + { + success = 0; + break; + } + } + if ((member && !demangle_nested_args (work, mangled, &decl)) + || **mangled != '_') + { + success = 0; + break; + } + (*mangled)++; + if (! PRINT_ANSI_QUALIFIERS) + { + break; + } + if (type_quals != TYPE_UNQUALIFIED) + { + APPEND_BLANK (&decl); + string_append (&decl, qualifier_string (type_quals)); + } + break; + } + case 'G': + (*mangled)++; + break; + + case 'C': + case 'V': + case 'u': + if (PRINT_ANSI_QUALIFIERS) + { + if (!STRING_EMPTY (&decl)) + string_prepend (&decl, " "); + + string_prepend (&decl, demangle_qualifier (**mangled)); + } + (*mangled)++; + break; + /* + } + */ + + /* fall through */ + default: + done = 1; + break; + } + } + + if (success) switch (**mangled) + { + /* A qualified name, such as "Outer::Inner". */ + case 'Q': + case 'K': + { + success = demangle_qualified (work, mangled, result, 0, 1); + break; + } + + /* A back reference to a previously seen squangled type */ + case 'B': + (*mangled)++; + if (!get_count (mangled, &n) || n >= work -> numb) + success = 0; + else + string_append (result, work->btypevec[n]); + break; + + case 'X': + case 'Y': + /* A template parm. We substitute the corresponding argument. */ + { + int idx; + + (*mangled)++; + idx = consume_count_with_underscores (mangled); + + if (idx == -1 + || (work->tmpl_argvec && idx >= work->ntmpl_args) + || consume_count_with_underscores (mangled) == -1) + { + success = 0; + break; + } + + if (work->tmpl_argvec) + string_append (result, work->tmpl_argvec[idx]); + else + string_append_template_idx (result, idx); + + success = 1; + } + break; + + default: + success = demangle_fund_type (work, mangled, result); + if (tk == tk_none) + tk = (type_kind_t) success; + break; + } + + if (success) + { + if (!STRING_EMPTY (&decl)) + { + string_append (result, " "); + string_appends (result, &decl); + } + } + else + string_delete (result); + string_delete (&decl); + + if (success) + /* Assume an integral type, if we're not sure. */ + return (int) ((tk == tk_none) ? tk_integral : tk); + else + return 0; +} + +/* Given a pointer to a type string that represents a fundamental type + argument (int, long, unsigned int, etc) in TYPE, a pointer to the + string in which the demangled output is being built in RESULT, and + the WORK structure, decode the types and add them to the result. + + For example: + + "Ci" => "const int" + "Sl" => "signed long" + "CUs" => "const unsigned short" + + The value returned is really a type_kind_t. */ + +static int +demangle_fund_type (work, mangled, result) + struct work_stuff *work; + const char **mangled; + string *result; +{ + int done = 0; + int success = 1; + char buf[10]; + int dec = 0; + string btype; + type_kind_t tk = tk_integral; + + string_init (&btype); + + /* First pick off any type qualifiers. There can be more than one. */ + + while (!done) + { + switch (**mangled) + { + case 'C': + case 'V': + case 'u': + if (PRINT_ANSI_QUALIFIERS) + { + if (!STRING_EMPTY (result)) + string_prepend (result, " "); + string_prepend (result, demangle_qualifier (**mangled)); + } + (*mangled)++; + break; + case 'U': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "unsigned"); + break; + case 'S': /* signed char only */ + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "signed"); + break; + case 'J': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "__complex"); + break; + default: + done = 1; + break; + } + } + + /* Now pick off the fundamental type. There can be only one. */ + + switch (**mangled) + { + case '\0': + case '_': + break; + case 'v': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "void"); + break; + case 'x': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "long long"); + break; + case 'l': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "long"); + break; + case 'i': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "int"); + break; + case 's': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "short"); + break; + case 'b': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "bool"); + tk = tk_bool; + break; + case 'c': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "char"); + tk = tk_char; + break; + case 'w': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "wchar_t"); + tk = tk_char; + break; + case 'r': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "long double"); + tk = tk_real; + break; + case 'd': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "double"); + tk = tk_real; + break; + case 'f': + (*mangled)++; + APPEND_BLANK (result); + string_append (result, "float"); + tk = tk_real; + break; + case 'G': + (*mangled)++; + if (!isdigit ((unsigned char)**mangled)) + { + success = 0; + break; + } + case 'I': + (*mangled)++; + if (**mangled == '_') + { + int i; + (*mangled)++; + for (i = 0; + i < (long) sizeof (buf) - 1 && **mangled && **mangled != '_'; + (*mangled)++, i++) + buf[i] = **mangled; + if (**mangled != '_') + { + success = 0; + break; + } + buf[i] = '\0'; + (*mangled)++; + } + else + { + strncpy (buf, *mangled, 2); + buf[2] = '\0'; + *mangled += min (strlen (*mangled), 2); + } + sscanf (buf, "%x", &dec); + sprintf (buf, "int%i_t", dec); + APPEND_BLANK (result); + string_append (result, buf); + break; + + /* fall through */ + /* An explicit type, such as "6mytype" or "7integer" */ + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + { + int bindex = register_Btype (work); + string btype; + string_init (&btype); + if (demangle_class_name (work, mangled, &btype)) { + remember_Btype (work, btype.b, LEN_STRING (&btype), bindex); + APPEND_BLANK (result); + string_appends (result, &btype); + } + else + success = 0; + string_delete (&btype); + break; + } + case 't': + { + success = demangle_template (work, mangled, &btype, 0, 1, 1); + string_appends (result, &btype); + break; + } + default: + success = 0; + break; + } + + return success ? ((int) tk) : 0; +} + + +/* Handle a template's value parameter for HP aCC (extension from ARM) + **mangled points to 'S' or 'U' */ + +static int +do_hpacc_template_const_value (work, mangled, result) + struct work_stuff *work ATTRIBUTE_UNUSED; + const char **mangled; + string *result; +{ + int unsigned_const; + + if (**mangled != 'U' && **mangled != 'S') + return 0; + + unsigned_const = (**mangled == 'U'); + + (*mangled)++; + + switch (**mangled) + { + case 'N': + string_append (result, "-"); + /* fall through */ + case 'P': + (*mangled)++; + break; + case 'M': + /* special case for -2^31 */ + string_append (result, "-2147483648"); + (*mangled)++; + return 1; + default: + return 0; + } + + /* We have to be looking at an integer now */ + if (!(isdigit ((unsigned char)**mangled))) + return 0; + + /* We only deal with integral values for template + parameters -- so it's OK to look only for digits */ + while (isdigit ((unsigned char)**mangled)) + { + char_str[0] = **mangled; + string_append (result, char_str); + (*mangled)++; + } + + if (unsigned_const) + string_append (result, "U"); + + /* FIXME? Some day we may have 64-bit (or larger :-) ) constants + with L or LL suffixes. pai/1997-09-03 */ + + return 1; /* success */ +} + +/* Handle a template's literal parameter for HP aCC (extension from ARM) + **mangled is pointing to the 'A' */ + +static int +do_hpacc_template_literal (work, mangled, result) + struct work_stuff *work; + const char **mangled; + string *result; +{ + int literal_len = 0; + char * recurse; + char * recurse_dem; + + if (**mangled != 'A') + return 0; + + (*mangled)++; + + literal_len = consume_count (mangled); + + if (literal_len <= 0) + return 0; + + /* Literal parameters are names of arrays, functions, etc. and the + canonical representation uses the address operator */ + string_append (result, "&"); + + /* Now recursively demangle the literal name */ + recurse = (char *) xmalloc (literal_len + 1); + memcpy (recurse, *mangled, literal_len); + recurse[literal_len] = '\000'; + + recurse_dem = cplus_demangle (recurse, work->options); + + if (recurse_dem) + { + string_append (result, recurse_dem); + free (recurse_dem); + } + else + { + string_appendn (result, *mangled, literal_len); + } + (*mangled) += literal_len; + free (recurse); + + return 1; +} + +static int +snarf_numeric_literal (args, arg) + const char ** args; + string * arg; +{ + if (**args == '-') + { + char_str[0] = '-'; + string_append (arg, char_str); + (*args)++; + } + else if (**args == '+') + (*args)++; + + if (!isdigit ((unsigned char)**args)) + return 0; + + while (isdigit ((unsigned char)**args)) + { + char_str[0] = **args; + string_append (arg, char_str); + (*args)++; + } + + return 1; +} + +/* Demangle the next argument, given by MANGLED into RESULT, which + *should be an uninitialized* string. It will be initialized here, + and free'd should anything go wrong. */ + +static int +do_arg (work, mangled, result) + struct work_stuff *work; + const char **mangled; + string *result; +{ + /* Remember where we started so that we can record the type, for + non-squangling type remembering. */ + const char *start = *mangled; + + string_init (result); + + if (work->nrepeats > 0) + { + --work->nrepeats; + + if (work->previous_argument == 0) + return 0; + + /* We want to reissue the previous type in this argument list. */ + string_appends (result, work->previous_argument); + return 1; + } + + if (**mangled == 'n') + { + /* A squangling-style repeat. */ + (*mangled)++; + work->nrepeats = consume_count(mangled); + + if (work->nrepeats <= 0) + /* This was not a repeat count after all. */ + return 0; + + if (work->nrepeats > 9) + { + if (**mangled != '_') + /* The repeat count should be followed by an '_' in this + case. */ + return 0; + else + (*mangled)++; + } + + /* Now, the repeat is all set up. */ + return do_arg (work, mangled, result); + } + + /* Save the result in WORK->previous_argument so that we can find it + if it's repeated. Note that saving START is not good enough: we + do not want to add additional types to the back-referenceable + type vector when processing a repeated type. */ + if (work->previous_argument) + string_clear (work->previous_argument); + else + { + work->previous_argument = (string*) xmalloc (sizeof (string)); + string_init (work->previous_argument); + } + + if (!do_type (work, mangled, work->previous_argument)) + return 0; + + string_appends (result, work->previous_argument); + + remember_type (work, start, *mangled - start); + return 1; +} + +static void +remember_type (work, start, len) + struct work_stuff *work; + const char *start; + int len; +{ + char *tem; + + if (work->forgetting_types) + return; + + if (work -> ntypes >= work -> typevec_size) + { + if (work -> typevec_size == 0) + { + work -> typevec_size = 3; + work -> typevec + = (char **) xmalloc (sizeof (char *) * work -> typevec_size); + } + else + { + work -> typevec_size *= 2; + work -> typevec + = (char **) xrealloc ((char *)work -> typevec, + sizeof (char *) * work -> typevec_size); + } + } + tem = xmalloc (len + 1); + memcpy (tem, start, len); + tem[len] = '\0'; + work -> typevec[work -> ntypes++] = tem; +} + + +/* Remember a K type class qualifier. */ +static void +remember_Ktype (work, start, len) + struct work_stuff *work; + const char *start; + int len; +{ + char *tem; + + if (work -> numk >= work -> ksize) + { + if (work -> ksize == 0) + { + work -> ksize = 5; + work -> ktypevec + = (char **) xmalloc (sizeof (char *) * work -> ksize); + } + else + { + work -> ksize *= 2; + work -> ktypevec + = (char **) xrealloc ((char *)work -> ktypevec, + sizeof (char *) * work -> ksize); + } + } + tem = xmalloc (len + 1); + memcpy (tem, start, len); + tem[len] = '\0'; + work -> ktypevec[work -> numk++] = tem; +} + +/* Register a B code, and get an index for it. B codes are registered + as they are seen, rather than as they are completed, so map > + registers map > as B0, and temp as B1 */ + +static int +register_Btype (work) + struct work_stuff *work; +{ + int ret; + + if (work -> numb >= work -> bsize) + { + if (work -> bsize == 0) + { + work -> bsize = 5; + work -> btypevec + = (char **) xmalloc (sizeof (char *) * work -> bsize); + } + else + { + work -> bsize *= 2; + work -> btypevec + = (char **) xrealloc ((char *)work -> btypevec, + sizeof (char *) * work -> bsize); + } + } + ret = work -> numb++; + work -> btypevec[ret] = NULL; + return(ret); +} + +/* Store a value into a previously registered B code type. */ + +static void +remember_Btype (work, start, len, index) + struct work_stuff *work; + const char *start; + int len, index; +{ + char *tem; + + tem = xmalloc (len + 1); + memcpy (tem, start, len); + tem[len] = '\0'; + work -> btypevec[index] = tem; +} + +/* Lose all the info related to B and K type codes. */ +static void +forget_B_and_K_types (work) + struct work_stuff *work; +{ + int i; + + while (work -> numk > 0) + { + i = --(work -> numk); + if (work -> ktypevec[i] != NULL) + { + free (work -> ktypevec[i]); + work -> ktypevec[i] = NULL; + } + } + + while (work -> numb > 0) + { + i = --(work -> numb); + if (work -> btypevec[i] != NULL) + { + free (work -> btypevec[i]); + work -> btypevec[i] = NULL; + } + } +} +/* Forget the remembered types, but not the type vector itself. */ + +static void +forget_types (work) + struct work_stuff *work; +{ + int i; + + while (work -> ntypes > 0) + { + i = --(work -> ntypes); + if (work -> typevec[i] != NULL) + { + free (work -> typevec[i]); + work -> typevec[i] = NULL; + } + } +} + +/* Process the argument list part of the signature, after any class spec + has been consumed, as well as the first 'F' character (if any). For + example: + + "__als__3fooRT0" => process "RT0" + "complexfunc5__FPFPc_PFl_i" => process "PFPc_PFl_i" + + DECLP must be already initialised, usually non-empty. It won't be freed + on failure. + + Note that g++ differs significantly from ARM and lucid style mangling + with regards to references to previously seen types. For example, given + the source fragment: + + class foo { + public: + foo::foo (int, foo &ia, int, foo &ib, int, foo &ic); + }; + + foo::foo (int, foo &ia, int, foo &ib, int, foo &ic) { ia = ib = ic; } + void foo (int, foo &ia, int, foo &ib, int, foo &ic) { ia = ib = ic; } + + g++ produces the names: + + __3fooiRT0iT2iT2 + foo__FiR3fooiT1iT1 + + while lcc (and presumably other ARM style compilers as well) produces: + + foo__FiR3fooT1T2T1T2 + __ct__3fooFiR3fooT1T2T1T2 + + Note that g++ bases its type numbers starting at zero and counts all + previously seen types, while lucid/ARM bases its type numbers starting + at one and only considers types after it has seen the 'F' character + indicating the start of the function args. For lucid/ARM style, we + account for this difference by discarding any previously seen types when + we see the 'F' character, and subtracting one from the type number + reference. + + */ + +static int +demangle_args (work, mangled, declp) + struct work_stuff *work; + const char **mangled; + string *declp; +{ + string arg; + int need_comma = 0; + int r; + int t; + const char *tem; + char temptype; + + if (PRINT_ARG_TYPES) + { + string_append (declp, "("); + if (**mangled == '\0') + { + string_append (declp, "void"); + } + } + + while ((**mangled != '_' && **mangled != '\0' && **mangled != 'e') + || work->nrepeats > 0) + { + if ((**mangled == 'N') || (**mangled == 'T')) + { + temptype = *(*mangled)++; + + if (temptype == 'N') + { + if (!get_count (mangled, &r)) + { + return (0); + } + } + else + { + r = 1; + } + if ((HP_DEMANGLING || ARM_DEMANGLING || EDG_DEMANGLING) && work -> ntypes >= 10) + { + /* If we have 10 or more types we might have more than a 1 digit + index so we'll have to consume the whole count here. This + will lose if the next thing is a type name preceded by a + count but it's impossible to demangle that case properly + anyway. Eg if we already have 12 types is T12Pc "(..., type1, + Pc, ...)" or "(..., type12, char *, ...)" */ + if ((t = consume_count(mangled)) <= 0) + { + return (0); + } + } + else + { + if (!get_count (mangled, &t)) + { + return (0); + } + } + if (LUCID_DEMANGLING || ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING) + { + t--; + } + /* Validate the type index. Protect against illegal indices from + malformed type strings. */ + if ((t < 0) || (t >= work -> ntypes)) + { + return (0); + } + while (work->nrepeats > 0 || --r >= 0) + { + tem = work -> typevec[t]; + if (need_comma && PRINT_ARG_TYPES) + { + string_append (declp, ", "); + } + if (!do_arg (work, &tem, &arg)) + { + return (0); + } + if (PRINT_ARG_TYPES) + { + string_appends (declp, &arg); + } + string_delete (&arg); + need_comma = 1; + } + } + else + { + if (need_comma && PRINT_ARG_TYPES) + string_append (declp, ", "); + if (!do_arg (work, mangled, &arg)) + return (0); + if (PRINT_ARG_TYPES) + string_appends (declp, &arg); + string_delete (&arg); + need_comma = 1; + } + } + + if (**mangled == 'e') + { + (*mangled)++; + if (PRINT_ARG_TYPES) + { + if (need_comma) + { + string_append (declp, ","); + } + string_append (declp, "..."); + } + } + + if (PRINT_ARG_TYPES) + { + string_append (declp, ")"); + } + return (1); +} + +/* Like demangle_args, but for demangling the argument lists of function + and method pointers or references, not top-level declarations. */ + +static int +demangle_nested_args (work, mangled, declp) + struct work_stuff *work; + const char **mangled; + string *declp; +{ + string* saved_previous_argument; + int result; + int saved_nrepeats; + + /* The G++ name-mangling algorithm does not remember types on nested + argument lists, unless -fsquangling is used, and in that case the + type vector updated by remember_type is not used. So, we turn + off remembering of types here. */ + ++work->forgetting_types; + + /* For the repeat codes used with -fsquangling, we must keep track of + the last argument. */ + saved_previous_argument = work->previous_argument; + saved_nrepeats = work->nrepeats; + work->previous_argument = 0; + work->nrepeats = 0; + + /* Actually demangle the arguments. */ + result = demangle_args (work, mangled, declp); + + /* Restore the previous_argument field. */ + if (work->previous_argument) + string_delete (work->previous_argument); + work->previous_argument = saved_previous_argument; + --work->forgetting_types; + work->nrepeats = saved_nrepeats; + + return result; +} + +static void +demangle_function_name (work, mangled, declp, scan) + struct work_stuff *work; + const char **mangled; + string *declp; + const char *scan; +{ + size_t i; + string type; + const char *tem; + + string_appendn (declp, (*mangled), scan - (*mangled)); + string_need (declp, 1); + *(declp -> p) = '\0'; + + /* Consume the function name, including the "__" separating the name + from the signature. We are guaranteed that SCAN points to the + separator. */ + + (*mangled) = scan + 2; + /* We may be looking at an instantiation of a template function: + foo__Xt1t2_Ft3t4, where t1, t2, ... are template arguments and a + following _F marks the start of the function arguments. Handle + the template arguments first. */ + + if (HP_DEMANGLING && (**mangled == 'X')) + { + demangle_arm_hp_template (work, mangled, 0, declp); + /* This leaves MANGLED pointing to the 'F' marking func args */ + } + + if (LUCID_DEMANGLING || ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING) + { + + /* See if we have an ARM style constructor or destructor operator. + If so, then just record it, clear the decl, and return. + We can't build the actual constructor/destructor decl until later, + when we recover the class name from the signature. */ + + if (strcmp (declp -> b, "__ct") == 0) + { + work -> constructor += 1; + string_clear (declp); + return; + } + else if (strcmp (declp -> b, "__dt") == 0) + { + work -> destructor += 1; + string_clear (declp); + return; + } + } + + if (declp->p - declp->b >= 3 + && declp->b[0] == 'o' + && declp->b[1] == 'p' + && strchr (cplus_markers, declp->b[2]) != NULL) + { + /* see if it's an assignment expression */ + if (declp->p - declp->b >= 10 /* op$assign_ */ + && memcmp (declp->b + 3, "assign_", 7) == 0) + { + for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) + { + int len = declp->p - declp->b - 10; + if ((int) strlen (optable[i].in) == len + && memcmp (optable[i].in, declp->b + 10, len) == 0) + { + string_clear (declp); + string_append (declp, "operator"); + string_append (declp, optable[i].out); + string_append (declp, "="); + break; + } + } + } + else + { + for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) + { + int len = declp->p - declp->b - 3; + if ((int) strlen (optable[i].in) == len + && memcmp (optable[i].in, declp->b + 3, len) == 0) + { + string_clear (declp); + string_append (declp, "operator"); + string_append (declp, optable[i].out); + break; + } + } + } + } + else if (declp->p - declp->b >= 5 && memcmp (declp->b, "type", 4) == 0 + && strchr (cplus_markers, declp->b[4]) != NULL) + { + /* type conversion operator */ + tem = declp->b + 5; + if (do_type (work, &tem, &type)) + { + string_clear (declp); + string_append (declp, "operator "); + string_appends (declp, &type); + string_delete (&type); + } + } + else if (declp->b[0] == '_' && declp->b[1] == '_' + && declp->b[2] == 'o' && declp->b[3] == 'p') + { + /* ANSI. */ + /* type conversion operator. */ + tem = declp->b + 4; + if (do_type (work, &tem, &type)) + { + string_clear (declp); + string_append (declp, "operator "); + string_appends (declp, &type); + string_delete (&type); + } + } + else if (declp->b[0] == '_' && declp->b[1] == '_' + && declp->b[2] >= 'a' && declp->b[2] <= 'z' + && declp->b[3] >= 'a' && declp->b[3] <= 'z') + { + if (declp->b[4] == '\0') + { + /* Operator. */ + for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) + { + if (strlen (optable[i].in) == 2 + && memcmp (optable[i].in, declp->b + 2, 2) == 0) + { + string_clear (declp); + string_append (declp, "operator"); + string_append (declp, optable[i].out); + break; + } + } + } + else + { + if (declp->b[2] == 'a' && declp->b[5] == '\0') + { + /* Assignment. */ + for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++) + { + if (strlen (optable[i].in) == 3 + && memcmp (optable[i].in, declp->b + 2, 3) == 0) + { + string_clear (declp); + string_append (declp, "operator"); + string_append (declp, optable[i].out); + break; + } + } + } + } + } +} + +/* a mini string-handling package */ + +static void +string_need (s, n) + string *s; + int n; +{ + int tem; + + if (s->b == NULL) + { + if (n < 32) + { + n = 32; + } + s->p = s->b = xmalloc (n); + s->e = s->b + n; + } + else if (s->e - s->p < n) + { + tem = s->p - s->b; + n += tem; + n *= 2; + s->b = xrealloc (s->b, n); + s->p = s->b + tem; + s->e = s->b + n; + } +} + +static void +string_delete (s) + string *s; +{ + if (s->b != NULL) + { + free (s->b); + s->b = s->e = s->p = NULL; + } +} + +static void +string_init (s) + string *s; +{ + s->b = s->p = s->e = NULL; +} + +static void +string_clear (s) + string *s; +{ + s->p = s->b; +} + +#if 0 + +static int +string_empty (s) + string *s; +{ + return (s->b == s->p); +} + +#endif + +static void +string_append (p, s) + string *p; + const char *s; +{ + int n; + if (s == NULL || *s == '\0') + return; + n = strlen (s); + string_need (p, n); + memcpy (p->p, s, n); + p->p += n; +} + +static void +string_appends (p, s) + string *p, *s; +{ + int n; + + if (s->b != s->p) + { + n = s->p - s->b; + string_need (p, n); + memcpy (p->p, s->b, n); + p->p += n; + } +} + +static void +string_appendn (p, s, n) + string *p; + const char *s; + int n; +{ + if (n != 0) + { + string_need (p, n); + memcpy (p->p, s, n); + p->p += n; + } +} + +static void +string_prepend (p, s) + string *p; + const char *s; +{ + if (s != NULL && *s != '\0') + { + string_prependn (p, s, strlen (s)); + } +} + +static void +string_prepends (p, s) + string *p, *s; +{ + if (s->b != s->p) + { + string_prependn (p, s->b, s->p - s->b); + } +} + +static void +string_prependn (p, s, n) + string *p; + const char *s; + int n; +{ + char *q; + + if (n != 0) + { + string_need (p, n); + for (q = p->p - 1; q >= p->b; q--) + { + q[n] = q[0]; + } + memcpy (p->b, s, n); + p->p += n; + } +} + +static void +string_append_template_idx (s, idx) + string *s; + int idx; +{ + char buf[INTBUF_SIZE + 1 /* 'T' */]; + sprintf(buf, "T%d", idx); + string_append (s, buf); +} + +/* To generate a standalone demangler program for testing purposes, + just compile and link this file with -DMAIN and libiberty.a. When + run, it demangles each command line arg, or each stdin string, and + prints the result on stdout. */ + +#ifdef MAIN + +#include "getopt.h" + +static const char *program_name; +static const char *program_version = VERSION; +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 +demangle_it (mangled_name) + char *mangled_name; +{ + char *result; + + result = cplus_demangle (mangled_name, flags); + if (result == NULL) + { + printf ("%s\n", mangled_name); + } + else + { + printf ("%s\n", result); + free (result); + } +} + +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", + program_name); + exit (status); +} + +#define MBUF_SIZE 32767 +char mbuffer[MBUF_SIZE]; + +/* Defined in the automatically-generated underscore.c. */ +extern int prepends_underscore; + +int strip_underscore = 0; + +static struct option long_options[] = { + {"strip-underscores", no_argument, 0, '_'}, + {"format", required_argument, 0, 's'}, + {"help", no_argument, 0, 'h'}, + {"java", no_argument, 0, 'j'}, + {"no-strip-underscores", no_argument, 0, 'n'}, + {"version", no_argument, 0, 'v'}, + {0, no_argument, 0, 0} +}; + +/* More 'friendly' abort that prints the line and file. + config.h can #define abort fancy_abort if you like that sort of thing. */ + +void +fancy_abort () +{ + fatal ("Internal gcc abort."); +} + + +static const char * +standard_symbol_characters PARAMS ((void)); + +static const char * +hp_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. */ + +static const char * +standard_symbol_characters () +{ + return "_$."; +} + + +/* Return the string of non-alnum characters that may occur + as a valid symbol name component in an HP object file. + + Note that, since HP's compiler generates object code straight from + C++ source, without going through an assembler, its mangled + identifiers can use all sorts of characters that no assembler would + tolerate, so the alphabet this function creates is a little odd. + Here are some sample mangled identifiers offered by HP: + + typeid*__XT24AddressIndExpClassMember_ + [Vftptr]key:__dt__32OrdinaryCompareIndExpClassMemberFv + __ct__Q2_9Elf64_Dyn18{unnamed.union.#1}Fv + + This still seems really weird to me, since nowhere else in this + file is there anything to recognize curly brackets, parens, etc. + I've talked with Srikanth , and he assures me + this is right, but I still strongly suspect that there's a + misunderstanding here. + + If we decide it's better for c++filt to use HP's assembler syntax + to scrape identifiers out of its input, here's the definition of + the symbol name syntax from the HP assembler manual: + + Symbols are composed of uppercase and lowercase letters, decimal + digits, dollar symbol, period (.), ampersand (&), pound sign(#) and + underscore (_). A symbol can begin with a letter, digit underscore or + dollar sign. If a symbol begins with a digit, it must contain a + non-digit character. + + So have fun. */ +static const char * +hp_symbol_characters () +{ + return "_$.<>#,*&[]:(){}"; +} + + +extern int main PARAMS ((int, char **)); + +int +main (argc, argv) + int argc; + char **argv; +{ + char *result; + int c; + const char *valid_symbols; + + program_name = argv[0]; + + strip_underscore = prepends_underscore; + + while ((c = getopt_long (argc, argv, "_ns:j", long_options, (int *) 0)) != EOF) + { + switch (c) + { + case '?': + usage (stderr, 1); + break; + case 'h': + usage (stdout, 0); + case 'n': + strip_underscore = 0; + break; + case 'v': + printf ("GNU %s (C++ demangler), version %s\n", program_name, program_version); + return (0); + case '_': + strip_underscore = 1; + break; + case 'j': + 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); + } + break; + } + } + + if (optind < argc) + { + for ( ; optind < argc; optind++) + { + demangle_it (argv[optind]); + } + } + else + { + switch (current_demangling_style) + { + case gnu_demangling: + case lucid_demangling: + case arm_demangling: + case edg_demangling: + valid_symbols = standard_symbol_characters (); + break; + case hp_demangling: + valid_symbols = hp_symbol_characters (); + break; + default: + /* Folks should explicitly indicate the appropriate alphabet for + each demangling. Providing a default would allow the + question to go unconsidered. */ + abort (); + } + + for (;;) + { + int i = 0; + c = getchar (); + /* Try to read a label. */ + while (c != EOF && (isalnum (c) || strchr (valid_symbols, c))) + { + if (i >= MBUF_SIZE-1) + break; + mbuffer[i++] = c; + c = getchar (); + } + if (i > 0) + { + int skip_first = 0; + + if (mbuffer[0] == '.') + ++skip_first; + if (strip_underscore && mbuffer[skip_first] == '_') + ++skip_first; + + if (skip_first > i) + skip_first = i; + + mbuffer[i] = 0; + + result = cplus_demangle (mbuffer + skip_first, flags); + if (result) + { + if (mbuffer[0] == '.') + putc ('.', stdout); + fputs (result, stdout); + free (result); + } + else + fputs (mbuffer, stdout); + + fflush (stdout); + } + if (c == EOF) + break; + putchar (c); + } + } + + return (0); +} + +static void +fatal (str) + const char *str; +{ + fprintf (stderr, "%s: %s\n", program_name, str); + exit (1); +} + +PTR +xmalloc (size) + size_t size; +{ + register PTR value = (PTR) malloc (size); + if (value == 0) + fatal ("virtual memory exhausted"); + return value; +} + +PTR +xrealloc (ptr, size) + PTR ptr; + size_t size; +{ + register PTR value = (PTR) realloc (ptr, size); + if (value == 0) + fatal ("virtual memory exhausted"); + return value; +} +#endif /* main */ Index: mpw-config.in =================================================================== --- mpw-config.in (nonexistent) +++ mpw-config.in (revision 1765) @@ -0,0 +1,7 @@ +# MPW configuration fragment for libiberty. + +Echo '/* config.h. Generated by mpw-configure. */' > "{o}"config.new + +MoveIfChange "{o}"config.new "{o}"config.h + + Index: memset.c =================================================================== --- memset.c (nonexistent) +++ memset.c (revision 1765) @@ -0,0 +1,19 @@ +/* memset + This implementation is in the public domain. */ + +#include +#ifdef __STDC__ +#include +#else +#define size_t unsigned long +#endif + +PTR +DEFUN(memset, (dest, val, len), + PTR dest AND register int val AND register size_t len) +{ + register unsigned char *ptr = (unsigned char*)dest; + while (len-- > 0) + *ptr++ = val; + return dest; +} Index: alloca.c =================================================================== --- alloca.c (nonexistent) +++ alloca.c (revision 1765) @@ -0,0 +1,505 @@ +/* alloca.c -- allocate automatically reclaimed memory + (Mostly) portable public-domain implementation -- D A Gwyn + + This implementation of the PWB library alloca function, + which is used to allocate space off the run-time stack so + that it is automatically reclaimed upon procedure exit, + was inspired by discussions with J. Q. Johnson of Cornell. + J.Otto Tennant contributed the Cray support. + + There are some preprocessor constants that can + be defined when compiling for your specific system, for + improved efficiency; however, the defaults should be okay. + + The general concept of this implementation is to keep + track of all alloca-allocated blocks, and reclaim any + that are found to be deeper in the stack than the current + invocation. This heuristic does not reclaim storage as + soon as it becomes invalid, but it will do so eventually. + + As a special case, alloca(0) reclaims storage without + allocating any. It is a good idea to use alloca(0) in + your main control loop, etc. to force garbage collection. */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_STRING_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#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 */ + +/* 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 (); +#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. + + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ + +#ifndef STACK_DIRECTION +#define STACK_DIRECTION 0 /* Direction unknown. */ +#endif + +#if STACK_DIRECTION != 0 + +#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ + +#else /* STACK_DIRECTION == 0; need run-time code. */ + +static int stack_dir; /* 1 or -1 once known. */ +#define STACK_DIR stack_dir + +static void +find_stack_direction () +{ + static char *addr = NULL; /* Address of first `dummy', once known. */ + auto char dummy; /* To get stack address. */ + + if (addr == NULL) + { /* Initial entry. */ + addr = ADDRESS_FUNCTION (dummy); + + find_stack_direction (); /* Recurse once. */ + } + else + { + /* Second entry. */ + if (ADDRESS_FUNCTION (dummy) > addr) + stack_dir = 1; /* Stack grew upward. */ + else + stack_dir = -1; /* Stack grew downward. */ + } +} + +#endif /* STACK_DIRECTION == 0 */ + +/* An "alloca header" is used to: + (a) chain together all alloca'ed blocks; + (b) keep track of stack depth. + + It is very important that sizeof(header) agree with malloc + alignment chunk size. The following default should work okay. */ + +#ifndef ALIGN_SIZE +#define ALIGN_SIZE sizeof(double) +#endif + +typedef union hdr +{ + char align[ALIGN_SIZE]; /* To force sizeof(header). */ + struct + { + union hdr *next; /* For chaining headers. */ + char *deep; /* For stack depth measure. */ + } h; +} header; + +static header *last_alloca_header = NULL; /* -> last alloca header. */ + +/* Return a pointer to at least SIZE bytes of storage, + which will be automatically reclaimed upon exit from + the procedure that called alloca. Originally, this space + was supposed to be taken from the current stack frame of the + 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; +{ + auto char probe; /* Probes stack depth: */ + register char *depth = ADDRESS_FUNCTION (probe); + +#if STACK_DIRECTION == 0 + if (STACK_DIR == 0) /* Unknown growth direction. */ + find_stack_direction (); +#endif + + /* Reclaim garbage, defined as all alloca'd storage that + was allocated from deeper in the stack than currently. */ + + { + 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. */ + + hp = np; /* -> next header. */ + } + else + break; /* Rest are not deeper. */ + + last_alloca_header = hp; /* -> last valid storage. */ + +#ifdef emacs + UNBLOCK_INPUT; +#endif + } + + if (size == 0) + return NULL; /* No allocation required. */ + + /* Allocate combined header + user data storage. */ + + { + register pointer new = malloc (sizeof (header) + size); + /* Address of header. */ + + if (new == 0) + abort(); + + ((header *) new)->h.next = last_alloca_header; + ((header *) new)->h.deep = depth; + + last_alloca_header = (header *) new; + + /* User storage begins just after header. */ + + return (pointer) ((char *) new + sizeof (header)); + } +} + +#if defined (CRAY) && defined (CRAY_STACKSEG_END) + +#ifdef DEBUG_I00AFUNC +#include +#endif + +#ifndef CRAY_STACK +#define CRAY_STACK +#ifndef CRAY2 +/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */ +struct stack_control_header + { + long shgrow:32; /* Number of times stack has grown. */ + long shaseg:32; /* Size of increments to stack. */ + long shhwm:32; /* High water mark of stack. */ + long shsize:32; /* Current size of stack (all segments). */ + }; + +/* The stack segment linkage control information occurs at + the high-address end of a stack segment. (The stack + grows from low addresses to high addresses.) The initial + part of the stack segment linkage control information is + 0200 (octal) words. This provides for register storage + for the routine which overflows the stack. */ + +struct stack_segment_linkage + { + long ss[0200]; /* 0200 overflow words. */ + long sssize:32; /* Number of words in this segment. */ + long ssbase:32; /* Offset to stack base. */ + long:32; + long sspseg:32; /* Offset to linkage control of previous + segment of stack. */ + long:32; + long sstcpt:32; /* Pointer to task common address block. */ + long sscsnm; /* Private control structure number for + microtasking. */ + long ssusr1; /* Reserved for user. */ + long ssusr2; /* Reserved for user. */ + long sstpid; /* Process ID for pid based multi-tasking. */ + long ssgvup; /* Pointer to multitasking thread giveup. */ + long sscray[7]; /* Reserved for Cray Research. */ + long ssa0; + long ssa1; + long ssa2; + long ssa3; + long ssa4; + long ssa5; + long ssa6; + long ssa7; + long sss0; + long sss1; + long sss2; + long sss3; + long sss4; + long sss5; + long sss6; + long sss7; + }; + +#else /* CRAY2 */ +/* The following structure defines the vector of words + returned by the STKSTAT library routine. */ +struct stk_stat + { + long now; /* Current total stack size. */ + long maxc; /* Amount of contiguous space which would + be required to satisfy the maximum + stack demand to date. */ + long high_water; /* Stack high-water mark. */ + long overflows; /* Number of stack overflow ($STKOFEN) calls. */ + long hits; /* Number of internal buffer hits. */ + long extends; /* Number of block extensions. */ + long stko_mallocs; /* Block allocations by $STKOFEN. */ + long underflows; /* Number of stack underflow calls ($STKRETN). */ + long stko_free; /* Number of deallocations by $STKRETN. */ + long stkm_free; /* Number of deallocations by $STKMRET. */ + long segments; /* Current number of stack segments. */ + long maxs; /* Maximum number of stack segments so far. */ + long pad_size; /* Stack pad size. */ + long current_address; /* Current stack segment address. */ + long current_size; /* Current stack segment size. This + number is actually corrupted by STKSTAT to + include the fifteen word trailer area. */ + long initial_address; /* Address of initial segment. */ + long initial_size; /* Size of initial segment. */ + }; + +/* The following structure describes the data structure which trails + any stack segment. I think that the description in 'asdef' is + out of date. I only describe the parts that I am sure about. */ + +struct stk_trailer + { + long this_address; /* Address of this block. */ + long this_size; /* Size of this block (does not include + this trailer). */ + long unknown2; + long unknown3; + long link; /* Address of trailer block of previous + segment. */ + long unknown5; + long unknown6; + long unknown7; + long unknown8; + long unknown9; + long unknown10; + long unknown11; + long unknown12; + long unknown13; + long unknown14; + }; + +#endif /* CRAY2 */ +#endif /* not CRAY_STACK */ + +#ifdef CRAY2 +/* Determine a "stack measure" for an arbitrary ADDRESS. + I doubt that "lint" will like this much. */ + +static long +i00afunc (long *address) +{ + struct stk_stat status; + struct stk_trailer *trailer; + long *block, size; + long result = 0; + + /* We want to iterate through all of the segments. The first + step is to get the stack status structure. We could do this + more quickly and more directly, perhaps, by referencing the + $LM00 common block, but I know that this works. */ + + STKSTAT (&status); + + /* Set up the iteration. */ + + trailer = (struct stk_trailer *) (status.current_address + + status.current_size + - 15); + + /* There must be at least one stack segment. Therefore it is + a fatal error if "trailer" is null. */ + + if (trailer == 0) + abort (); + + /* Discard segments that do not contain our argument address. */ + + while (trailer != 0) + { + block = (long *) trailer->this_address; + size = trailer->this_size; + if (block == 0 || size == 0) + abort (); + trailer = (struct stk_trailer *) trailer->link; + if ((block <= address) && (address < (block + size))) + break; + } + + /* Set the result to the offset in this segment and add the sizes + of all predecessor segments. */ + + result = address - block; + + if (trailer == 0) + { + return result; + } + + do + { + if (trailer->this_size <= 0) + abort (); + result += trailer->this_size; + trailer = (struct stk_trailer *) trailer->link; + } + while (trailer != 0); + + /* We are done. Note that if you present a bogus address (one + not in any segment), you will get a different number back, formed + from subtracting the address of the first block. This is probably + not what you want. */ + + return (result); +} + +#else /* not CRAY2 */ +/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP. + Determine the number of the cell within the stack, + given the address of the cell. The purpose of this + routine is to linearize, in some sense, stack addresses + for alloca. */ + +static long +i00afunc (long address) +{ + long stkl = 0; + + long size, pseg, this_segment, stack; + long result = 0; + + struct stack_segment_linkage *ssptr; + + /* Register B67 contains the address of the end of the + current stack segment. If you (as a subprogram) store + your registers on the stack and find that you are past + the contents of B67, you have overflowed the segment. + + B67 also points to the stack segment linkage control + area, which is what we are really interested in. */ + + stkl = CRAY_STACKSEG_END (); + ssptr = (struct stack_segment_linkage *) stkl; + + /* If one subtracts 'size' from the end of the segment, + one has the address of the first word of the segment. + + If this is not the first segment, 'pseg' will be + nonzero. */ + + pseg = ssptr->sspseg; + size = ssptr->sssize; + + this_segment = stkl - size; + + /* It is possible that calling this routine itself caused + a stack overflow. Discard stack segments which do not + contain the target address. */ + + while (!(this_segment <= address && address <= stkl)) + { +#ifdef DEBUG_I00AFUNC + fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl); +#endif + if (pseg == 0) + break; + stkl = stkl - pseg; + ssptr = (struct stack_segment_linkage *) stkl; + size = ssptr->sssize; + pseg = ssptr->sspseg; + this_segment = stkl - size; + } + + result = address - this_segment; + + /* If you subtract pseg from the current end of the stack, + you get the address of the previous stack segment's end. + This seems a little convoluted to me, but I'll bet you save + a cycle somewhere. */ + + while (pseg != 0) + { +#ifdef DEBUG_I00AFUNC + fprintf (stderr, "%011o %011o\n", pseg, size); +#endif + stkl = stkl - pseg; + ssptr = (struct stack_segment_linkage *) stkl; + size = ssptr->sssize; + pseg = ssptr->sspseg; + result += size; + } + return (result); +} + +#endif /* not CRAY2 */ +#endif /* CRAY */ + +#endif /* no alloca */ +#endif /* not GCC version 2 */ Index: clock.c =================================================================== --- clock.c (nonexistent) +++ clock.c (revision 1765) @@ -0,0 +1,91 @@ +/* ANSI-compatible clock function. + Copyright (C) 1994, 1995, 1999 Free Software Foundation, Inc. + +This file is part of the libiberty library. This library is free +software; you can redistribute it and/or modify it under the +terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) +any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU CC; see the file COPYING. If not, write to +the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +As a special exception, if you link this library with files +compiled with a GNU compiler to produce an executable, this does not cause +the resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why +the executable file might be covered by the GNU General Public License. */ + +#include "config.h" + +#ifdef HAVE_GETRUSAGE +#include +#include +#endif + +#ifdef HAVE_TIMES +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#include +#endif + +#ifdef HAVE_UNISTD_H +#include +#endif + +#ifdef _SC_CLK_TCK +#define GNU_HZ sysconf(_SC_CLK_TCK) +#else +#ifdef HZ +#define GNU_HZ HZ +#else +#ifdef CLOCKS_PER_SEC +#define GNU_HZ CLOCKS_PER_SEC +#endif +#endif +#endif + +/* FIXME: should be able to declare as clock_t. */ + +long +clock () +{ +#ifdef HAVE_GETRUSAGE + struct rusage rusage; + + getrusage (0, &rusage); + return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec + + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec); +#else +#ifdef HAVE_TIMES + struct tms tms; + + times (&tms); + return (tms.tms_utime + tms.tms_stime) * (1000000 / GNU_HZ); +#else +#ifdef VMS + struct + { + int proc_user_time; + int proc_system_time; + int child_user_time; + int child_system_time; + } vms_times; + + times (&vms_times); + return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000; +#else + /* A fallback, if nothing else available. */ + return 0; +#endif /* VMS */ +#endif /* HAVE_TIMES */ +#endif /* HAVE_GETRUSAGE */ +} + Index: COPYING.LIB =================================================================== --- COPYING.LIB (nonexistent) +++ COPYING.LIB (revision 1765) @@ -0,0 +1,482 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 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 library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + 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 Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, 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 or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the 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 a program 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. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + 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, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +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. + + 1. 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. + + 2. 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: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) 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.) + +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. + + 3. 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. + + 4. 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. + + 5. 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. + + 6. As an exception to the Sections above, you may also compile 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: + + a) 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.) + + b) 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. + + c) 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. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + 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 source code 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. + + 7. 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: + + a) 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. + + b) 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. + + 8. 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. + + 9. 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. + + 10. 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 to +this License. + + 11. 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. + + 12. 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. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library 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. + + 14. 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. + + NO WARRANTY + + 15. 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. + + 16. 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 OF TERMS AND CONDITIONS + + Appendix: 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. + + + Copyright (C) + + This library 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. + + 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library 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 + +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: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! Index: calloc.c =================================================================== --- calloc.c (nonexistent) +++ calloc.c (revision 1765) @@ -0,0 +1,29 @@ +/* calloc -- allocate memory which has been initialized to zero. + This function is in the public domain. */ + +#include "ansidecl.h" +#include "libiberty.h" + +#ifdef ANSI_PROTOTYPES +#include +#else +#define size_t unsigned long +#endif + +/* For systems with larger pointers than ints, this must be declared. */ +PTR malloc PARAMS ((size_t)); + +PTR +calloc (nelem, elsize) + size_t nelem, elsize; +{ + register PTR ptr; + + if (nelem == 0 || elsize == 0) + nelem = elsize = 1; + + ptr = malloc (nelem * elsize); + if (ptr) bzero (ptr, nelem * elsize); + + return ptr; +}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.