Use the more standard files xalloc.h' and xmalloc.c' instead of

Bison's `allocate.c' and `alloc.h'.  This patch was surprisingly
difficult and introduced a lot of core dump.  It turns out that
Bison used an implementation of `xmalloc' based on `calloc', and
at various places it does depend upon the initialization to 0.  I
have not tried to isolate the pertinent places, and all the former
calls to Bison's `xmalloc' are now using `XCALLOC'.  Someday,
someone should address this issue.
* src/allocate.c, src/alloc.h, m4/bison-decl.m4: Remove.
* lib/xmalloc.c, lib/xalloc.h, m4/malloc.m4, m4/realloc.m4: New
files.
Adjust dependencies.
* src/warshall.h: New file.
Propagate.
This commit is contained in:
Akim Demaille
2000-10-02 08:48:32 +00:00
parent 340ef48922
commit d7913476c4
28 changed files with 593 additions and 438 deletions

View File

@@ -1,3 +1,21 @@
2000-10-02 Akim Demaille <akim@epita.fr>
Use the more standard files `xalloc.h' and `xmalloc.c' instead of
Bison's `allocate.c' and `alloc.h'. This patch was surprisingly
difficult and introduced a lot of core dump. It turns out that
Bison used an implementation of `xmalloc' based on `calloc', and
at various places it does depend upon the initialization to 0. I
have not tried to isolate the pertinent places, and all the former
calls to Bison's `xmalloc' are now using `XCALLOC'. Someday,
someone should address this issue.
* src/allocate.c, src/alloc.h, m4/bison-decl.m4: Remove.
* lib/xmalloc.c, lib/xalloc.h, m4/malloc.m4, m4/realloc.m4: New
files.
Adjust dependencies.
* src/warshall.h: New file.
Propagate.
2000-10-02 Akim Demaille <akim@epita.fr> 2000-10-02 Akim Demaille <akim@epita.fr>
Various anti-`extern in *.c' changes. Various anti-`extern in *.c' changes.

View File

@@ -64,7 +64,8 @@ AM_C_PROTOTYPES
# Checks for library functions. # Checks for library functions.
AC_FUNC_ALLOCA AC_FUNC_ALLOCA
AC_CHECK_FUNCS(mkstemp setlocale) AC_CHECK_FUNCS(mkstemp setlocale)
BISON_NEED_DECLARATIONS(calloc realloc) jm_FUNC_MALLOC
jm_FUNC_REALLOC
ALL_LINGUAS="de es et fr ja nl ru" ALL_LINGUAS="de es et fr ja nl ru"
AM_GNU_GETTEXT AM_GNU_GETTEXT

View File

@@ -6,8 +6,8 @@ noinst_LIBRARIES = libbison.a
INCLUDES = -I.. -I$(srcdir) -I../intl INCLUDES = -I.. -I$(srcdir) -I../intl
libbison_a_SOURCES = getopt.c getopt1.c libbison_a_SOURCES = getopt.c getopt1.c xmalloc.c
noinst_HEADERS = getopt.h noinst_HEADERS = getopt.h xalloc.h
libbison_a_LIBADD = @LIBOBJS@ @ALLOCA@ libbison_a_LIBADD = @LIBOBJS@ @ALLOCA@
libbison_a_DEPENDENCIES = $(libbison_a_LIBADD) libbison_a_DEPENDENCIES = $(libbison_a_LIBADD)

87
lib/xalloc.h Normal file
View File

@@ -0,0 +1,87 @@
/* xalloc.h -- malloc with out-of-memory checking
Copyright (C) 1990-1998, 1999 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef XALLOC_H_
# define XALLOC_H_
# ifndef PARAMS
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
# define PARAMS(Args) Args
# else
# define PARAMS(Args) ()
# endif
# endif
# ifndef __attribute__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
# define __attribute__(x)
# endif
# endif
# ifndef ATTRIBUTE_NORETURN
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
# endif
/* Exit value when the requested amount of memory is not available.
It is initialized to EXIT_FAILURE, but the caller may set it to
some other value. */
extern int xalloc_exit_failure;
/* If this pointer is non-zero, run the specified function upon each
allocation failure. It is initialized to zero. */
extern void (*xalloc_fail_func) PARAMS ((void));
/* If XALLOC_FAIL_FUNC is undefined or a function that returns, this
message must be non-NULL. It is translated via gettext.
The default value is "Memory exhausted". */
extern char *const xalloc_msg_memory_exhausted;
/* This function is always triggered when memory is exhausted. It is
in charge of honoring the three previous items. This is the
function to call when one wants the program to die because of a
memory allocation failure. */
extern void xalloc_die PARAMS ((void)) ATTRIBUTE_NORETURN;
void *xmalloc PARAMS ((size_t n));
void *xcalloc PARAMS ((size_t n, size_t s));
void *xrealloc PARAMS ((void *p, size_t n));
char *xstrdup PARAMS ((const char *str));
# define XMALLOC(Type, N_items) ((Type *) xmalloc (sizeof (Type) * (N_items)))
# define XCALLOC(Type, N_items) ((Type *) xcalloc (sizeof (Type), (N_items)))
# define XREALLOC(Ptr, Type, N_items) \
((Type *) xrealloc ((void *) (Ptr), sizeof (Type) * (N_items)))
/* Declare and alloc memory for VAR of type TYPE. */
# define NEW(Type, Var) Type *(Var) = XMALLOC (Type, 1)
/* Free VAR only if non NULL. */
# define XFREE(Var) \
do { \
if (Var) \
free (Var); \
} while (0)
/* Return a pointer to a malloc'ed copy of the array SRC of NUM elements. */
# define CCLONE(Src, Num) \
(memcpy (xmalloc (sizeof (*Src) * (Num)), (Src), sizeof (*Src) * (Num)))
/* Return a malloc'ed copy of SRC. */
# define CLONE(Src) CCLONE (Src, 1)
#endif /* !XALLOC_H_ */

117
lib/xmalloc.c Normal file
View File

@@ -0,0 +1,117 @@
/* xmalloc.c -- malloc with out of memory checking
Copyright (C) 1990-1997, 98, 99 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#if STDC_HEADERS
# include <stdlib.h>
#else
void *calloc ();
void *malloc ();
void *realloc ();
void free ();
#endif
#if ENABLE_NLS
# include <libintl.h>
# define _(Text) gettext (Text)
#else
# define textdomain(Domain)
# define _(Text) Text
#endif
#define N_(Text) Text
#include "error.h"
#include "xalloc.h"
#ifndef EXIT_FAILURE
# define EXIT_FAILURE 1
#endif
#ifndef HAVE_DONE_WORKING_MALLOC_CHECK
you must run the autoconf test for a properly working malloc -- see malloc.m4
#endif
#ifndef HAVE_DONE_WORKING_REALLOC_CHECK
you must run the autoconf test for a properly working realloc -- see realloc.m4
#endif
/* Exit value when the requested amount of memory is not available.
The caller may set it to some other value. */
int xalloc_exit_failure = EXIT_FAILURE;
/* If non NULL, call this function when memory is exhausted. */
void (*xalloc_fail_func) PARAMS ((void)) = 0;
/* If XALLOC_FAIL_FUNC is NULL, or does return, display this message
before exiting when memory is exhausted. Goes through gettext. */
char *const xalloc_msg_memory_exhausted = N_("Memory exhausted");
void
xalloc_die (void)
{
if (xalloc_fail_func)
(*xalloc_fail_func) ();
error (xalloc_exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted));
/* The `noreturn' cannot be given to error, since it may return if
its first argument is 0. To help compilers understand the
xalloc_die does terminate, call exit. */
exit (EXIT_FAILURE);
}
/* Allocate N bytes of memory dynamically, with error checking. */
void *
xmalloc (size_t n)
{
void *p;
p = malloc (n);
if (p == 0)
xalloc_die ();
return p;
}
/* Change the size of an allocated block of memory P to N bytes,
with error checking.
If P is NULL, run xmalloc. */
void *
xrealloc (void *p, size_t n)
{
p = realloc (p, n);
if (p == 0)
xalloc_die ();
return p;
}
/* Allocate memory for N elements of S bytes, with error checking. */
void *
xcalloc (size_t n, size_t s)
{
void *p;
p = calloc (n, s);
if (p == 0)
xalloc_die ();
return p;
}

View File

@@ -1,10 +1,11 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*- ## Process this file with automake to produce Makefile.in -*-Makefile-*-
EXTRA_DIST = \ EXTRA_DIST = \
atconfig.m4 \ atconfig.m4 \
bison-decl.m4 \
error.m4 \ error.m4 \
gettext.m4 \ gettext.m4 \
lcmessage.m4 \ lcmessage.m4 \
m4.m4 \ m4.m4 \
malloc.m4 \
progtest.m4 \ progtest.m4 \
realloc.m4 \
warning.m4 warning.m4

View File

@@ -1,48 +0,0 @@
dnl FIXME: This should be soon obsoleted by AC_CHECK_DECL.
dnl See whether we need a declaration for a function.
dnl BISON_NEED_DECLARATION(FUNCTION [, EXTRA-HEADER-FILES])
AC_DEFUN(BISON_NEED_DECLARATION,
[AC_MSG_CHECKING([whether $1 must be declared])
AC_CACHE_VAL(bison_cv_decl_needed_$1,
[AC_TRY_COMPILE([
#include <stdio.h>
#ifdef HAVE_STRING_H
#include <string.h>
#else
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifndef HAVE_RINDEX
#define rindex strrchr
#endif
#ifndef HAVE_INDEX
#define index strchr
#endif
$2],
[char *(*pfn) = (char *(*)) $1],
eval "bison_cv_decl_needed_$1=no", eval "bison_cv_decl_needed_$1=yes")])
if eval "test \"`echo '$bison_cv_decl_needed_'$1`\" = yes"; then
AC_MSG_RESULT(yes)
bison_tr_decl=NEED_DECLARATION_`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
AC_DEFINE_UNQUOTED($bison_tr_decl)
else
AC_MSG_RESULT(no)
fi
])dnl
dnl Check multiple functions to see whether each needs a declaration.
dnl BISON_NEED_DECLARATIONS(FUNCTION... [, EXTRA-HEADER-FILES])
AC_DEFUN(BISON_NEED_DECLARATIONS,
[for ac_func in $1
do
BISON_NEED_DECLARATION($ac_func, $2)
done
])

35
m4/malloc.m4 Normal file
View File

@@ -0,0 +1,35 @@
#serial 3
dnl From Jim Meyering.
dnl Determine whether malloc accepts 0 as its argument.
dnl If it doesn't, arrange to use the replacement function.
dnl
AC_DEFUN(jm_FUNC_MALLOC,
[
dnl xmalloc.c requires that this symbol be defined so it doesn't
dnl mistakenly use a broken malloc -- as it might if this test were omitted.
AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_MALLOC_CHECK, 1,
[Define if the malloc check has been performed. ])
AC_CACHE_CHECK([for working malloc], jm_cv_func_working_malloc,
[AC_TRY_RUN([
char *malloc ();
int
main ()
{
exit (malloc (0) ? 0 : 1);
}
],
jm_cv_func_working_malloc=yes,
jm_cv_func_working_malloc=no,
dnl When crosscompiling, assume malloc is broken.
jm_cv_func_working_malloc=no)
])
if test $jm_cv_func_working_malloc = no; then
AC_SUBST(LIBOBJS)
LIBOBJS="$LIBOBJS malloc.$ac_objext"
AC_DEFINE_UNQUOTED(malloc, rpl_malloc,
[Define to rpl_malloc if the replacement function should be used.])
fi
])

35
m4/realloc.m4 Normal file
View File

@@ -0,0 +1,35 @@
#serial 3
dnl From Jim Meyering.
dnl Determine whether realloc works when both arguments are 0.
dnl If it doesn't, arrange to use the replacement function.
dnl
AC_DEFUN(jm_FUNC_REALLOC,
[
dnl xmalloc.c requires that this symbol be defined so it doesn't
dnl mistakenly use a broken realloc -- as it might if this test were omitted.
AC_DEFINE_UNQUOTED(HAVE_DONE_WORKING_REALLOC_CHECK, 1,
[Define if the realloc check has been performed. ])
AC_CACHE_CHECK([for working realloc], jm_cv_func_working_realloc,
[AC_TRY_RUN([
char *realloc ();
int
main ()
{
exit (realloc (0, 0) ? 0 : 1);
}
],
jm_cv_func_working_realloc=yes,
jm_cv_func_working_realloc=no,
dnl When crosscompiling, assume realloc is broken.
jm_cv_func_working_realloc=no)
])
if test $jm_cv_func_working_realloc = no; then
AC_SUBST(LIBOBJS)
LIBOBJS="$LIBOBJS realloc.$ac_objext"
AC_DEFINE_UNQUOTED(realloc, rpl_realloc,
[Define to rpl_realloc if the replacement function should be used.])
fi
])

View File

@@ -23,7 +23,7 @@
The entry point is generate_states. */ The entry point is generate_states. */
#include "system.h" #include "system.h"
#include "alloc.h" #include "xalloc.h"
#include "gram.h" #include "gram.h"
#include "state.h" #include "state.h"
#include "complain.h" #include "complain.h"
@@ -68,7 +68,7 @@ allocate_itemsets (void)
short *symbol_count; short *symbol_count;
count = 0; count = 0;
symbol_count = NEW2 (nsyms, short); symbol_count = XCALLOC (short, nsyms);
itemp = ritem; itemp = ritem;
symbol = *itemp++; symbol = *itemp++;
@@ -88,8 +88,8 @@ allocate_itemsets (void)
appears as an item, which is symbol_count[symbol]. appears as an item, which is symbol_count[symbol].
We allocate that much space for each symbol. */ We allocate that much space for each symbol. */
kernel_base = NEW2 (nsyms, short *); kernel_base = XCALLOC (short *, nsyms);
kernel_items = NEW2 (count, short); kernel_items = XCALLOC (short, count);
count = 0; count = 0;
for (i = 0; i < nsyms; i++) for (i = 0; i < nsyms; i++)
@@ -99,7 +99,7 @@ allocate_itemsets (void)
} }
shift_symbol = symbol_count; shift_symbol = symbol_count;
kernel_end = NEW2 (nsyms, short *); kernel_end = XCALLOC (short *, nsyms);
} }
@@ -108,22 +108,22 @@ allocate_storage (void)
{ {
allocate_itemsets (); allocate_itemsets ();
shiftset = NEW2 (nsyms, short); shiftset = XCALLOC (short, nsyms);
redset = NEW2 (nrules + 1, short); redset = XCALLOC (short, nrules + 1);
state_table = NEW2 (STATE_TABLE_SIZE, core *); state_table = XCALLOC (core *, STATE_TABLE_SIZE);
} }
static void static void
free_storage (void) free_storage (void)
{ {
FREE (shift_symbol); XFREE (shift_symbol);
FREE (redset); XFREE (redset);
FREE (shiftset); XFREE (shiftset);
FREE (kernel_base); XFREE (kernel_base);
FREE (kernel_end); XFREE (kernel_end);
FREE (kernel_items); XFREE (kernel_items);
FREE (state_table); XFREE (state_table);
} }
@@ -211,7 +211,7 @@ new_state (int symbol)
n = iend - isp1; n = iend - isp1;
p = p =
(core *) xmalloc ((unsigned) (sizeof (core) + (n - 1) * sizeof (short))); (core *) xcalloc ((unsigned) (sizeof (core) + (n - 1) * sizeof (short)), 1);
p->accessing_symbol = symbol; p->accessing_symbol = symbol;
p->number = nstates; p->number = nstates;
p->nitems = n; p->nitems = n;
@@ -349,7 +349,7 @@ new_states (void)
{ {
core *p; core *p;
p = (core *) xmalloc ((unsigned) (sizeof (core) - sizeof (short))); p = (core *) xcalloc ((unsigned) (sizeof (core) - sizeof (short)), 1);
first_state = last_state = this_state = p; first_state = last_state = this_state = p;
nstates = 1; nstates = 1;
} }
@@ -363,8 +363,8 @@ save_shifts (void)
short *sp2; short *sp2;
short *send; short *send;
p = (shifts *) xmalloc ((unsigned) (sizeof (shifts) + p = (shifts *) xcalloc ((unsigned) (sizeof (shifts) +
(nshifts - 1) * sizeof (short))); (nshifts - 1) * sizeof (short)), 1);
p->number = this_state->number; p->number = this_state->number;
p->nshifts = nshifts; p->nshifts = nshifts;
@@ -400,7 +400,7 @@ insert_start_shift (void)
core *statep; core *statep;
shifts *sp; shifts *sp;
statep = (core *) xmalloc ((unsigned) (sizeof (core) - sizeof (short))); statep = (core *) xcalloc ((unsigned) (sizeof (core) - sizeof (short)), 1);
statep->number = nstates; statep->number = nstates;
statep->accessing_symbol = start_symbol; statep->accessing_symbol = start_symbol;
@@ -408,7 +408,7 @@ insert_start_shift (void)
last_state = statep; last_state = statep;
/* Make a shift from this state to (what will be) the final state. */ /* Make a shift from this state to (what will be) the final state. */
sp = NEW (shifts); sp = XCALLOC (shifts, 1);
sp->number = nstates++; sp->number = nstates++;
sp->nshifts = 1; sp->nshifts = 1;
sp->shifts[0] = nstates; sp->shifts[0] = nstates;
@@ -465,10 +465,10 @@ augment_automaton (void)
if (sp && sp->number == k) if (sp && sp->number == k)
{ {
sp2 = (shifts *) xmalloc ((unsigned) (sizeof (shifts) sp2 = (shifts *) xcalloc ((unsigned) (sizeof (shifts)
+ +
sp->nshifts * sp->nshifts *
sizeof (short))); sizeof (short)), 1);
sp2->number = k; sp2->number = k;
sp2->nshifts = sp->nshifts + 1; sp2->nshifts = sp->nshifts + 1;
sp2->shifts[0] = nstates; sp2->shifts[0] = nstates;
@@ -481,11 +481,11 @@ augment_automaton (void)
sp1->next = sp2; sp1->next = sp2;
if (sp == last_shift) if (sp == last_shift)
last_shift = sp2; last_shift = sp2;
FREE (sp); XFREE (sp);
} }
else else
{ {
sp2 = NEW (shifts); sp2 = XCALLOC (shifts, 1);
sp2->number = k; sp2->number = k;
sp2->nshifts = 1; sp2->nshifts = 1;
sp2->shifts[0] = nstates; sp2->shifts[0] = nstates;
@@ -504,8 +504,8 @@ augment_automaton (void)
going to the next-to-final state (yet to be made). */ going to the next-to-final state (yet to be made). */
sp = first_shift; sp = first_shift;
sp2 = (shifts *) xmalloc (sizeof (shifts) sp2 = (shifts *) xcalloc (sizeof (shifts)
+ sp->nshifts * sizeof (short)); + sp->nshifts * sizeof (short), 1);
sp2->nshifts = sp->nshifts + 1; sp2->nshifts = sp->nshifts + 1;
/* Stick this shift into the vector at the proper place. */ /* Stick this shift into the vector at the proper place. */
@@ -527,7 +527,7 @@ augment_automaton (void)
if (last_shift == sp) if (last_shift == sp)
last_shift = sp2; last_shift = sp2;
FREE (sp); XFREE (sp);
/* Create the next-to-final state, with shift to /* Create the next-to-final state, with shift to
what will be the final state. */ what will be the final state. */
@@ -538,7 +538,7 @@ augment_automaton (void)
{ {
/* The initial state didn't even have any shifts. /* The initial state didn't even have any shifts.
Give it one shift, to the next-to-final state. */ Give it one shift, to the next-to-final state. */
sp = NEW (shifts); sp = XCALLOC (shifts, 1);
sp->nshifts = 1; sp->nshifts = 1;
sp->shifts[0] = nstates; sp->shifts[0] = nstates;
@@ -556,7 +556,7 @@ augment_automaton (void)
/* There are no shifts for any state. /* There are no shifts for any state.
Make one shift, from the initial state to the next-to-final state. */ Make one shift, from the initial state to the next-to-final state. */
sp = NEW (shifts); sp = XCALLOC (shifts, 1);
sp->nshifts = 1; sp->nshifts = 1;
sp->shifts[0] = nstates; sp->shifts[0] = nstates;
@@ -572,13 +572,13 @@ augment_automaton (void)
/* Make the final state--the one that follows a shift from the /* Make the final state--the one that follows a shift from the
next-to-final state. next-to-final state.
The symbol for that shift is 0 (end-of-file). */ The symbol for that shift is 0 (end-of-file). */
statep = (core *) xmalloc ((unsigned) (sizeof (core) - sizeof (short))); statep = (core *) xcalloc ((unsigned) (sizeof (core) - sizeof (short)), 1);
statep->number = nstates; statep->number = nstates;
last_state->next = statep; last_state->next = statep;
last_state = statep; last_state = statep;
/* Make the shift from the final state to the termination state. */ /* Make the shift from the final state to the termination state. */
sp = NEW (shifts); sp = XCALLOC (shifts, 1);
sp->number = nstates++; sp->number = nstates++;
sp->nshifts = 1; sp->nshifts = 1;
sp->shifts[0] = nstates; sp->shifts[0] = nstates;
@@ -590,7 +590,7 @@ augment_automaton (void)
final_state = nstates; final_state = nstates;
/* Make the termination state. */ /* Make the termination state. */
statep = (core *) xmalloc ((unsigned) (sizeof (core) - sizeof (short))); statep = (core *) xcalloc ((unsigned) (sizeof (core) - sizeof (short)), 1);
statep->number = nstates++; statep->number = nstates++;
last_state->next = statep; last_state->next = statep;
last_state = statep; last_state = statep;
@@ -629,8 +629,8 @@ save_reductions (void)
if (count) if (count)
{ {
p = (reductions *) xmalloc ((unsigned) (sizeof (reductions) + p = (reductions *) xcalloc ((unsigned) (sizeof (reductions) +
(count - 1) * sizeof (short))); (count - 1) * sizeof (short)), 1);
p->number = this_state->number; p->number = this_state->number;
p->nreds = count; p->nreds = count;

View File

@@ -10,7 +10,7 @@ LDADD = @INTLLIBS@ ../lib/libbison.a
bin_PROGRAMS = bison bin_PROGRAMS = bison
bison_SOURCES = LR0.c allocate.c closure.c complain.c conflicts.c \ bison_SOURCES = LR0.c closure.c complain.c conflicts.c \
derives.c \ derives.c \
files.c getargs.c gram.c lalr.c lex.c main.c nullable.c \ files.c getargs.c gram.c lalr.c lex.c main.c nullable.c \
output.c \ output.c \
@@ -18,11 +18,11 @@ bison_SOURCES = LR0.c allocate.c closure.c complain.c conflicts.c \
EXTRA_bison_SOURCES = vmsgetargs.c EXTRA_bison_SOURCES = vmsgetargs.c
noinst_HEADERS = LR0.h alloc.h closure.h complain.h conflicts.h \ noinst_HEADERS = LR0.h closure.h complain.h conflicts.h \
derives.h \ derives.h \
files.h getargs.h gram.h lalr.h lex.h nullable.h \ files.h getargs.h gram.h lalr.h lex.h nullable.h \
output.h state.h \ output.h state.h \
print.h reader.h reduce.h symtab.h system.h types.h print.h reader.h reduce.h symtab.h warshall.h system.h types.h
data_DATA = bison.simple bison.hairy data_DATA = bison.simple bison.hairy

View File

@@ -1,36 +0,0 @@
/* Storage allocation interface for bison,
Copyright (C) 1984, 1989 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
Bison 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.
Bison 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 Bison; see the file COPYING. 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
#define NEW(t) ((t *) xmalloc((unsigned) sizeof(t)))
#define NEW2(n, t) ((t *) xmalloc((unsigned) ((n) * sizeof(t))))
#ifdef __STDC__
#define FREE(x) (x ? (void) free((char *) (x)) : (void)0)
#else
#define FREE(x) ((x) != 0 && (free ((char *) (x)), 0))
#endif
extern char *xmalloc PARAMS((register unsigned));
extern char *xrealloc PARAMS((register char *, register unsigned));

View File

@@ -1,79 +0,0 @@
/* Allocate and clear storage for bison,
Copyright (C) 1984, 1989 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
Bison 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.
Bison 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 Bison; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "system.h"
#ifdef NEED_DECLARATION_CALLOC
#if defined (__STDC__) || defined (_MSC_VER)
extern void *calloc ();
#else
extern char *calloc ();
#endif
#endif /* NEED_DECLARATION_CALLOC */
#ifdef NEED_DECLARATION_REALLOC
#if defined (__STDC__) || defined (_MSC_VER)
extern void *realloc ();
#else
extern char *realloc ();
#endif
#endif /* NEED_DECLARATION_REALLOC */
extern char *xmalloc PARAMS((register unsigned));
extern char *xrealloc PARAMS((register char *, register unsigned));
extern void done PARAMS((int));
extern char *program_name;
char *
xmalloc (register unsigned n)
{
register char *block;
/* Avoid uncertainty about what an arg of 0 will do. */
if (n == 0)
n = 1;
block = calloc (n, 1);
if (block == NULL)
{
fprintf (stderr, _("%s: memory exhausted\n"), program_name);
done (1);
}
return block;
}
char *
xrealloc (register char *block, register unsigned n)
{
/* Avoid uncertainty about what an arg of 0 will do. */
if (n == 0)
n = 1;
block = realloc (block, n);
if (block == NULL)
{
fprintf (stderr, _("%s: memory exhausted\n"), program_name);
done (1);
}
return block;
}

View File

@@ -19,10 +19,11 @@
02111-1307, USA. */ 02111-1307, USA. */
#include "system.h" #include "system.h"
#include "alloc.h" #include "xalloc.h"
#include "gram.h" #include "gram.h"
#include "closure.h" #include "closure.h"
#include "derives.h" #include "derives.h"
#include "warshall.h"
short *itemset; short *itemset;
short *itemsetend; short *itemsetend;
@@ -122,7 +123,7 @@ set_firsts (void)
varsetsize = rowsize = WORDSIZE (nvars); varsetsize = rowsize = WORDSIZE (nvars);
firsts = NEW2 (nvars * rowsize, unsigned); firsts = XCALLOC (unsigned, nvars * rowsize);
row = firsts; row = firsts;
for (i = ntokens; i < nsyms; i++) for (i = ntokens; i < nsyms; i++)
@@ -171,7 +172,7 @@ set_fderives (void)
int ruleno; int ruleno;
int i; int i;
fderives = NEW2 (nvars * rulesetsize, unsigned) - ntokens * rulesetsize; fderives = XCALLOC (unsigned, nvars * rulesetsize) - ntokens * rulesetsize;
set_firsts (); set_firsts ();
@@ -208,17 +209,17 @@ set_fderives (void)
print_fderives (); print_fderives ();
#endif #endif
FREE (firsts); XFREE (firsts);
} }
void void
new_closure (int n) new_closure (int n)
{ {
itemset = NEW2 (n, short); itemset = XCALLOC (short, n);
rulesetsize = WORDSIZE (nrules + 1); rulesetsize = WORDSIZE (nrules + 1);
ruleset = NEW2 (rulesetsize, unsigned); ruleset = XCALLOC (unsigned, rulesetsize);
set_fderives (); set_fderives ();
} }
@@ -310,7 +311,7 @@ closure (short *core, int n)
void void
free_closure (void) free_closure (void)
{ {
FREE (itemset); XFREE (itemset);
FREE (ruleset); XFREE (ruleset);
FREE (fderives + ntokens * rulesetsize); XFREE (fderives + ntokens * rulesetsize);
} }

View File

@@ -20,7 +20,7 @@
#include "system.h" #include "system.h"
#include "getargs.h" #include "getargs.h"
#include "alloc.h" #include "xalloc.h"
#include "files.h" #include "files.h"
#include "gram.h" #include "gram.h"
#include "state.h" #include "state.h"
@@ -95,7 +95,7 @@ resolve_sr_conflict (int state, int lookaheadnum)
unsigned *fp1; unsigned *fp1;
unsigned *fp2; unsigned *fp2;
int redprec; int redprec;
errs *errp = (errs *) xmalloc (sizeof (errs) + ntokens * sizeof (short)); errs *errp = (errs *) xcalloc (sizeof (errs) + ntokens * sizeof (short), 1);
short *errtokens = errp->errs; short *errtokens = errp->errs;
/* find the rule to reduce by to get precedence of reduction */ /* find the rule to reduce by to get precedence of reduction */
@@ -175,7 +175,7 @@ resolve_sr_conflict (int state, int lookaheadnum)
/* Some tokens have been explicitly made errors. Allocate /* Some tokens have been explicitly made errors. Allocate
a permanent errs structure for this state, to record them. */ a permanent errs structure for this state, to record them. */
i = (char *) errtokens - (char *) errp; i = (char *) errtokens - (char *) errp;
err_table[state] = (errs *) xmalloc ((unsigned int) i); err_table[state] = (errs *) xcalloc ((unsigned int) i, 1);
bcopy (errp, err_table[state], i); bcopy (errp, err_table[state], i);
} }
else else
@@ -269,11 +269,11 @@ initialize_conflicts (void)
{ {
int i; int i;
conflicts = NEW2 (nstates, char); conflicts = XCALLOC (char, nstates);
shiftset = NEW2 (tokensetsize, unsigned); shiftset = XCALLOC (unsigned, tokensetsize);
lookaheadset = NEW2 (tokensetsize, unsigned); lookaheadset = XCALLOC (unsigned, tokensetsize);
err_table = NEW2 (nstates, errs *); err_table = XCALLOC (errs *, nstates);
any_conflicts = 0; any_conflicts = 0;
@@ -718,7 +718,7 @@ print_reductions (int state)
void void
finalize_conflicts (void) finalize_conflicts (void)
{ {
FREE (conflicts); XFREE (conflicts);
FREE (shiftset); XFREE (shiftset);
FREE (lookaheadset); XFREE (lookaheadset);
} }

View File

@@ -25,7 +25,7 @@
*/ */
#include "system.h" #include "system.h"
#include "alloc.h" #include "xalloc.h"
#include "types.h" #include "types.h"
#include "gram.h" #include "gram.h"
#include "derives.h" #include "derives.h"
@@ -37,8 +37,8 @@ short **derives;
static void static void
print_derives (void) print_derives (void)
{ {
register int i; int i;
register short *sp; short *sp;
printf (_("\n\n\nDERIVES\n\n")); printf (_("\n\n\nDERIVES\n\n"));
@@ -60,15 +60,15 @@ print_derives (void)
void void
set_derives (void) set_derives (void)
{ {
register int i; int i;
register int lhs; int lhs;
register shorts *p; shorts *p;
register short *q; short *q;
register shorts **dset; shorts **dset;
register shorts *delts; shorts *delts;
dset = NEW2 (nvars, shorts *) - ntokens; dset = XCALLOC (shorts *, nvars) - ntokens;
delts = NEW2 (nrules + 1, shorts); delts = XCALLOC (shorts, nrules + 1);
p = delts; p = delts;
for (i = nrules; i > 0; i--) for (i = nrules; i > 0; i--)
@@ -83,8 +83,8 @@ set_derives (void)
} }
} }
derives = NEW2 (nvars, short *) - ntokens; derives = XCALLOC (short *, nvars) - ntokens;
q = NEW2 (nvars + nrules, short); q = XCALLOC (short, nvars + nrules);
for (i = ntokens; i < nsyms; i++) for (i = ntokens; i < nsyms; i++)
{ {
@@ -102,13 +102,13 @@ set_derives (void)
print_derives (); print_derives ();
#endif #endif
FREE (dset + ntokens); XFREE (dset + ntokens);
FREE (delts); XFREE (delts);
} }
void void
free_derives (void) free_derives (void)
{ {
FREE (derives[ntokens]); XFREE (derives[ntokens]);
FREE (derives + ntokens); XFREE (derives + ntokens);
} }

View File

@@ -43,7 +43,7 @@
#include "getargs.h" #include "getargs.h"
#include "files.h" #include "files.h"
#include "alloc.h" #include "xalloc.h"
#include "gram.h" #include "gram.h"
#include "complain.h" #include "complain.h"
@@ -90,7 +90,7 @@ stringappend (const char *string1, int end1, const char *string2)
while (*cp1++) while (*cp1++)
i++; i++;
ostring = NEW2 (i + end1 + 1, char); ostring = XCALLOC (char, i + end1 + 1);
cp = ostring; cp = ostring;
cp1 = string1; cp1 = string1;
@@ -213,7 +213,7 @@ open_files (void)
short_base_length = strlen (spec_file_prefix); short_base_length = strlen (spec_file_prefix);
/* Count room for `.tab'. */ /* Count room for `.tab'. */
base_length = short_base_length + 4; base_length = short_base_length + 4;
name_base = (char *) xmalloc (base_length + 1); name_base = XMALLOC (char, base_length + 1);
/* Append `.tab'. */ /* Append `.tab'. */
strcpy (name_base, spec_file_prefix); strcpy (name_base, spec_file_prefix);
#ifdef VMS #ifdef VMS
@@ -263,7 +263,7 @@ open_files (void)
cp = getenv ("INIT"); cp = getenv ("INIT");
if (filename == 0 && cp != NULL) if (filename == 0 && cp != NULL)
{ {
filename = xmalloc (strlen (cp) + strlen (PFILE) + 2); filename = XMALLOC (char, strlen (cp) + strlen (PFILE) + 2);
strcpy (filename, cp); strcpy (filename, cp);
cp = filename + strlen (filename); cp = filename + strlen (filename);
*cp++ = '/'; *cp++ = '/';
@@ -372,7 +372,7 @@ open_extra_files (void)
cp = getenv ("INIT"); cp = getenv ("INIT");
if (filename == 0 && cp != NULL) if (filename == 0 && cp != NULL)
{ {
filename = xmalloc (strlen (cp) + strlen (PFILE1) + 2); filename = XMALLOC (char, strlen (cp) + strlen (PFILE1) + 2);
strcpy (filename, cp); strcpy (filename, cp);
cp = filename + strlen (filename); cp = filename + strlen (filename);
*cp++ = '/'; *cp++ = '/';

View File

@@ -26,7 +26,7 @@
#include "system.h" #include "system.h"
#include "types.h" #include "types.h"
#include "LR0.h" #include "LR0.h"
#include "alloc.h" #include "xalloc.h"
#include "gram.h" #include "gram.h"
#include "complain.h" #include "complain.h"
#include "lalr.h" #include "lalr.h"
@@ -123,8 +123,8 @@ digraph (short **relation)
int i; int i;
infinity = ngotos + 2; infinity = ngotos + 2;
INDEX = NEW2 (ngotos + 1, short); INDEX = XCALLOC (short, ngotos + 1);
VERTICES = NEW2 (ngotos + 1, short); VERTICES = XCALLOC (short, ngotos + 1);
top = 0; top = 0;
R = relation; R = relation;
@@ -138,8 +138,8 @@ digraph (short **relation)
traverse (i); traverse (i);
} }
FREE (INDEX); XFREE (INDEX);
FREE (VERTICES); XFREE (VERTICES);
} }
static void static void
@@ -147,7 +147,7 @@ set_state_table (void)
{ {
core *sp; core *sp;
state_table = NEW2 (nstates, core *); state_table = XCALLOC (core *, nstates);
for (sp = first_state; sp; sp = sp->next) for (sp = first_state; sp; sp = sp->next)
state_table[sp->number] = sp; state_table[sp->number] = sp;
@@ -159,7 +159,7 @@ set_accessing_symbol (void)
{ {
core *sp; core *sp;
accessing_symbol = NEW2 (nstates, short); accessing_symbol = XCALLOC (short, nstates);
for (sp = first_state; sp; sp = sp->next) for (sp = first_state; sp; sp = sp->next)
accessing_symbol[sp->number] = sp->accessing_symbol; accessing_symbol[sp->number] = sp->accessing_symbol;
@@ -171,7 +171,7 @@ set_shift_table (void)
{ {
shifts *sp; shifts *sp;
shift_table = NEW2 (nstates, shifts *); shift_table = XCALLOC (shifts *, nstates);
for (sp = first_shift; sp; sp = sp->next) for (sp = first_shift; sp; sp = sp->next)
shift_table[sp->number] = sp; shift_table[sp->number] = sp;
@@ -183,7 +183,7 @@ set_reduction_table (void)
{ {
reductions *rp; reductions *rp;
reduction_table = NEW2 (nstates, reductions *); reduction_table = XCALLOC (reductions *, nstates);
for (rp = first_reduction; rp; rp = rp->next) for (rp = first_reduction; rp; rp = rp->next)
reduction_table[rp->number] = rp; reduction_table[rp->number] = rp;
@@ -227,8 +227,8 @@ initialize_LA (void)
shifts *sp; shifts *sp;
short *np; short *np;
consistent = NEW2 (nstates, char); consistent = XCALLOC (char, nstates);
lookaheads = NEW2 (nstates + 1, short); lookaheads = XCALLOC (short, nstates + 1);
count = 0; count = 0;
for (i = 0; i < nstates; i++) for (i = 0; i < nstates; i++)
@@ -260,15 +260,15 @@ initialize_LA (void)
if (count == 0) if (count == 0)
{ {
LA = NEW2 (1 * tokensetsize, unsigned); LA = XCALLOC (unsigned, 1 * tokensetsize);
LAruleno = NEW2 (1, short); LAruleno = XCALLOC (short, 1);
lookback = NEW2 (1, shorts *); lookback = XCALLOC (shorts *, 1);
} }
else else
{ {
LA = NEW2 (count * tokensetsize, unsigned); LA = XCALLOC (unsigned, count * tokensetsize);
LAruleno = NEW2 (count, short); LAruleno = XCALLOC (short, count);
lookback = NEW2 (count, shorts *); lookback = XCALLOC (shorts *, count);
} }
np = LAruleno; np = LAruleno;
@@ -295,8 +295,8 @@ set_goto_map (void)
int state2; int state2;
int state1; int state1;
goto_map = NEW2 (nvars + 1, short) - ntokens; goto_map = XCALLOC (short, nvars + 1) - ntokens;
temp_map = NEW2 (nvars + 1, short) - ntokens; temp_map = XCALLOC (short, nvars + 1) - ntokens;
ngotos = 0; ngotos = 0;
for (sp = first_shift; sp; sp = sp->next) for (sp = first_shift; sp; sp = sp->next)
@@ -329,8 +329,8 @@ set_goto_map (void)
goto_map[nsyms] = ngotos; goto_map[nsyms] = ngotos;
temp_map[nsyms] = ngotos; temp_map[nsyms] = ngotos;
from_state = NEW2 (ngotos, short); from_state = XCALLOC (short, ngotos);
to_state = NEW2 (ngotos, short); to_state = XCALLOC (short, ngotos);
for (sp = first_shift; sp; sp = sp->next) for (sp = first_shift; sp; sp = sp->next)
{ {
@@ -349,7 +349,7 @@ set_goto_map (void)
} }
} }
FREE (temp_map + ntokens); XFREE (temp_map + ntokens);
} }
@@ -402,10 +402,10 @@ initialize_F (void)
int nwords; int nwords;
nwords = ngotos * tokensetsize; nwords = ngotos * tokensetsize;
F = NEW2 (nwords, unsigned); F = XCALLOC (unsigned, nwords);
reads = NEW2 (ngotos, short *); reads = XCALLOC (short *, ngotos);
edge = NEW2 (ngotos + 1, short); edge = XCALLOC (short, ngotos + 1);
nedges = 0; nedges = 0;
rowp = F; rowp = F;
@@ -435,7 +435,7 @@ initialize_F (void)
if (nedges) if (nedges)
{ {
reads[i] = rp = NEW2 (nedges + 1, short); reads[i] = rp = XCALLOC (short, nedges + 1);
for (j = 0; j < nedges; j++) for (j = 0; j < nedges; j++)
rp[j] = edge[j]; rp[j] = edge[j];
@@ -453,11 +453,11 @@ initialize_F (void)
for (i = 0; i < ngotos; i++) for (i = 0; i < ngotos; i++)
{ {
if (reads[i]) if (reads[i])
FREE (reads[i]); XFREE (reads[i]);
} }
FREE (reads); XFREE (reads);
FREE (edge); XFREE (edge);
} }
@@ -482,7 +482,7 @@ add_lookback_edge (int stateno, int ruleno, int gotono)
assert (found); assert (found);
sp = NEW (shorts); sp = XCALLOC (shorts, 1);
sp->next = lookback[i]; sp->next = lookback[i];
sp->value = gotono; sp->value = gotono;
lookback[i] = sp; lookback[i] = sp;
@@ -499,7 +499,7 @@ transpose (short **R_arg, int n)
int i; int i;
int k; int k;
nedges = NEW2 (n, short); nedges = XCALLOC (short, n);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
@@ -511,22 +511,22 @@ transpose (short **R_arg, int n)
} }
} }
new_R = NEW2 (n, short *); new_R = XCALLOC (short *, n);
temp_R = NEW2 (n, short *); temp_R = XCALLOC (short *, n);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
k = nedges[i]; k = nedges[i];
if (k > 0) if (k > 0)
{ {
sp = NEW2 (k + 1, short); sp = XCALLOC (short, k + 1);
new_R[i] = sp; new_R[i] = sp;
temp_R[i] = sp; temp_R[i] = sp;
sp[k] = -1; sp[k] = -1;
} }
} }
FREE (nedges); XFREE (nedges);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
@@ -538,7 +538,7 @@ transpose (short **R_arg, int n)
} }
} }
FREE (temp_R); XFREE (temp_R);
return new_R; return new_R;
} }
@@ -565,9 +565,9 @@ build_relations (void)
short *states; short *states;
short **new_includes; short **new_includes;
includes = NEW2 (ngotos, short *); includes = XCALLOC (short *, ngotos);
edge = NEW2 (ngotos + 1, short); edge = XCALLOC (short, ngotos + 1);
states = NEW2 (maxrhs + 1, short); states = XCALLOC (short, maxrhs + 1);
for (i = 0; i < ngotos; i++) for (i = 0; i < ngotos; i++)
{ {
@@ -619,7 +619,7 @@ build_relations (void)
if (nedges) if (nedges)
{ {
includes[i] = shortp = NEW2 (nedges + 1, short); includes[i] = shortp = XCALLOC (short, nedges + 1);
for (j = 0; j < nedges; j++) for (j = 0; j < nedges; j++)
shortp[j] = edge[j]; shortp[j] = edge[j];
shortp[nedges] = -1; shortp[nedges] = -1;
@@ -630,14 +630,14 @@ build_relations (void)
for (i = 0; i < ngotos; i++) for (i = 0; i < ngotos; i++)
if (includes[i]) if (includes[i])
FREE (includes[i]); XFREE (includes[i]);
FREE (includes); XFREE (includes);
includes = new_includes; includes = new_includes;
FREE (edge); XFREE (edge);
FREE (states); XFREE (states);
} }
@@ -652,10 +652,10 @@ compute_FOLLOWS (void)
for (i = 0; i < ngotos; i++) for (i = 0; i < ngotos; i++)
{ {
if (includes[i]) if (includes[i])
FREE (includes[i]); XFREE (includes[i]);
} }
FREE (includes); XFREE (includes);
} }
@@ -693,12 +693,12 @@ compute_lookaheads (void)
for (sp = lookback[i]; sp; sp = sptmp) for (sp = lookback[i]; sp; sp = sptmp)
{ {
sptmp = sp->next; sptmp = sp->next;
FREE (sp); XFREE (sp);
} }
} }
FREE (lookback); XFREE (lookback);
FREE (F); XFREE (F);
} }

View File

@@ -24,7 +24,7 @@
#include "getopt.h" /* for optarg */ #include "getopt.h" /* for optarg */
#include "symtab.h" #include "symtab.h"
#include "lex.h" #include "lex.h"
#include "alloc.h" #include "xalloc.h"
#include "complain.h" #include "complain.h"
#include "gram.h" #include "gram.h"
@@ -48,7 +48,7 @@ void
init_lex (void) init_lex (void)
{ {
maxtoken = 100; maxtoken = 100;
token_buffer = NEW2 (maxtoken + 1, char); token_buffer = XCALLOC (char, maxtoken + 1);
unlexed = -1; unlexed = -1;
} }
@@ -58,7 +58,7 @@ grow_token_buffer (char *p)
{ {
int offset = p - token_buffer; int offset = p - token_buffer;
maxtoken *= 2; maxtoken *= 2;
token_buffer = (char *) xrealloc (token_buffer, maxtoken + 1); token_buffer = XREALLOC (token_buffer, char, maxtoken + 1);
return token_buffer + offset; return token_buffer + offset;
} }

View File

@@ -32,6 +32,7 @@
#include "nullable.h" #include "nullable.h"
#include "print.h" #include "print.h"
#include "LR0.h" #include "LR0.h"
#include "conflicts.h"
/* The name this program was run with, for messages. */ /* The name this program was run with, for messages. */
char *program_name; char *program_name;

View File

@@ -26,7 +26,7 @@
#include "system.h" #include "system.h"
#include "types.h" #include "types.h"
#include "gram.h" #include "gram.h"
#include "alloc.h" #include "xalloc.h"
#include "nullable.h" #include "nullable.h"
char *nullable = NULL; char *nullable = NULL;
@@ -52,17 +52,17 @@ set_nullable (void)
fprintf (stderr, _("Entering set_nullable")); fprintf (stderr, _("Entering set_nullable"));
#endif #endif
nullable = NEW2 (nvars, char) - ntokens; nullable = XCALLOC (char, nvars) - ntokens;
squeue = NEW2 (nvars, short); squeue = XCALLOC (short, nvars);
s1 = s2 = squeue; s1 = s2 = squeue;
rcount = NEW2 (nrules + 1, short); rcount = XCALLOC (short, nrules + 1);
rsets = NEW2 (nvars, shorts *) - ntokens; rsets = XCALLOC (shorts *, nvars) - ntokens;
/* This is said to be more elements than we actually use. /* This is said to be more elements than we actually use.
Supposedly nitems - nrules is enough. Supposedly nitems - nrules is enough.
But why take the risk? */ But why take the risk? */
relts = NEW2 (nitems + nvars + 1, shorts); relts = XCALLOC (shorts, nitems + nvars + 1);
p = relts; p = relts;
r = ritem; r = ritem;
@@ -122,15 +122,15 @@ set_nullable (void)
} }
} }
FREE (squeue); XFREE (squeue);
FREE (rcount); XFREE (rcount);
FREE (rsets + ntokens); XFREE (rsets + ntokens);
FREE (relts); XFREE (relts);
} }
void void
free_nullable (void) free_nullable (void)
{ {
FREE (nullable + ntokens); XFREE (nullable + ntokens);
} }

View File

@@ -92,7 +92,7 @@
#include "system.h" #include "system.h"
#include "getargs.h" #include "getargs.h"
#include "alloc.h" #include "xalloc.h"
#include "files.h" #include "files.h"
#include "gram.h" #include "gram.h"
#include "LR0.h" #include "LR0.h"
@@ -452,7 +452,7 @@ output_rule_data (void)
output_short_table (ftable, "yyr1", rlhs, output_short_table (ftable, "yyr1", rlhs,
0, 1, nrules + 1); 0, 1, nrules + 1);
FREE (rlhs + 1); XFREE (rlhs + 1);
putc ('\n', ftable); putc ('\n', ftable);
@@ -483,7 +483,7 @@ static const short yyr2[] = { 0", ftable);
putc ('\n', ftable); putc ('\n', ftable);
fprintf (ftable, "%6d\n};\n", nitems - rrhs[nrules] - 1); fprintf (ftable, "%6d\n};\n", nitems - rrhs[nrules] - 1);
FREE (rrhs + 1); XFREE (rrhs + 1);
} }
@@ -699,8 +699,8 @@ save_row (int state)
if (count == 0) if (count == 0)
return; return;
froms[state] = sp1 = sp = NEW2 (count, short); froms[state] = sp1 = sp = XCALLOC (short, count);
tos[state] = sp2 = NEW2 (count, short); tos[state] = sp2 = XCALLOC (short, count);
for (i = 0; i < ntokens; i++) for (i = 0; i < ntokens; i++)
{ {
@@ -728,19 +728,19 @@ static void
token_actions (void) token_actions (void)
{ {
int i; int i;
short *yydefact = NEW2 (nstates, short); short *yydefact = XCALLOC (short, nstates);
actrow = NEW2 (ntokens, short); actrow = XCALLOC (short, ntokens);
for (i = 0; i < nstates; ++i) for (i = 0; i < nstates; ++i)
{ {
yydefact[i] = action_row (i); yydefact[i] = action_row (i);
save_row (i); save_row (i);
} }
FREE (actrow); XFREE (actrow);
output_short_table (ftable, "yydefact", yydefact, output_short_table (ftable, "yydefact", yydefact,
yydefact[0], 1, nstates); yydefact[0], 1, nstates);
FREE (yydefact); XFREE (yydefact);
} }
@@ -749,12 +749,12 @@ free_shifts (void)
{ {
shifts *sp, *sptmp; /* JF derefrenced freed ptr */ shifts *sp, *sptmp; /* JF derefrenced freed ptr */
FREE (shift_table); XFREE (shift_table);
for (sp = first_shift; sp; sp = sptmp) for (sp = first_shift; sp; sp = sptmp)
{ {
sptmp = sp->next; sptmp = sp->next;
FREE (sp); XFREE (sp);
} }
} }
@@ -764,12 +764,12 @@ free_reductions (void)
{ {
reductions *rp, *rptmp; /* JF fixed freed ptr */ reductions *rp, *rptmp; /* JF fixed freed ptr */
FREE (reduction_table); XFREE (reduction_table);
for (rp = first_reduction; rp; rp = rptmp) for (rp = first_reduction; rp; rp = rptmp)
{ {
rptmp = rp->next; rptmp = rp->next;
FREE (rp); XFREE (rp);
} }
} }
@@ -802,8 +802,8 @@ save_column (int symbol, int default_state)
symno = symbol - ntokens + nstates; symno = symbol - ntokens + nstates;
froms[symno] = sp1 = sp = NEW2 (count, short); froms[symno] = sp1 = sp = XCALLOC (short, count);
tos[symno] = sp2 = NEW2 (count, short); tos[symno] = sp2 = XCALLOC (short, count);
for (i = m; i < n; i++) for (i = m; i < n; i++)
{ {
@@ -869,7 +869,7 @@ goto_actions (void)
{ {
int i, j, k; int i, j, k;
state_count = NEW2 (nstates, short); state_count = XCALLOC (short, nstates);
k = default_goto (ntokens); k = default_goto (ntokens);
fprintf (ftable, "\nstatic const short yydefgoto[] = {%6d", k); fprintf (ftable, "\nstatic const short yydefgoto[] = {%6d", k);
@@ -896,7 +896,7 @@ goto_actions (void)
} }
fprintf (ftable, "\n};\n"); fprintf (ftable, "\n};\n");
FREE (state_count); XFREE (state_count);
} }
@@ -912,7 +912,7 @@ sort_actions (void)
int t; int t;
int w; int w;
order = NEW2 (nvectors, short); order = XCALLOC (short, nvectors);
nentries = 0; nentries = 0;
for (i = 0; i < nvectors; i++) for (i = 0; i < nvectors; i++)
@@ -1049,10 +1049,10 @@ pack_table (void)
int place; int place;
int state; int state;
base = NEW2 (nvectors, short); base = XCALLOC (short, nvectors);
pos = NEW2 (nentries, short); pos = XCALLOC (short, nentries);
table = NEW2 (MAXTABLE, short); table = XCALLOC (short, MAXTABLE);
check = NEW2 (MAXTABLE, short); check = XCALLOC (short, MAXTABLE);
lowzero = 0; lowzero = 0;
high = 0; high = 0;
@@ -1079,14 +1079,14 @@ pack_table (void)
for (i = 0; i < nvectors; i++) for (i = 0; i < nvectors; i++)
{ {
if (froms[i]) if (froms[i])
FREE (froms[i]); XFREE (froms[i]);
if (tos[i]) if (tos[i])
FREE (tos[i]); XFREE (tos[i]);
} }
FREE (froms); XFREE (froms);
FREE (tos); XFREE (tos);
FREE (pos); XFREE (pos);
} }
/* the following functions output yytable, yycheck /* the following functions output yytable, yycheck
@@ -1103,7 +1103,7 @@ output_base (void)
output_short_table (ftable, "yypgoto", base, output_short_table (ftable, "yypgoto", base,
base[nstates], nstates + 1, nvectors); base[nstates], nstates + 1, nvectors);
FREE (base); XFREE (base);
} }
@@ -1113,7 +1113,7 @@ output_table (void)
fprintf (ftable, "\n\n#define\tYYLAST\t\t%d\n\n\n", high); fprintf (ftable, "\n\n#define\tYYLAST\t\t%d\n\n\n", high);
output_short_table (ftable, "yytable", table, output_short_table (ftable, "yytable", table,
table[0], 1, high + 1); table[0], 1, high + 1);
FREE (table); XFREE (table);
} }
@@ -1122,7 +1122,7 @@ output_check (void)
{ {
output_short_table (ftable, "yycheck", check, output_short_table (ftable, "yycheck", check,
check[0], 1, high + 1); check[0], 1, high + 1);
FREE (check); XFREE (check);
} }
/* compute and output yydefact, yydefgoto, yypact, yypgoto, yytable /* compute and output yydefact, yydefgoto, yypact, yypgoto, yytable
@@ -1133,23 +1133,23 @@ output_actions (void)
{ {
nvectors = nstates + nvars; nvectors = nstates + nvars;
froms = NEW2 (nvectors, short *); froms = XCALLOC (short *, nvectors);
tos = NEW2 (nvectors, short *); tos = XCALLOC (short *, nvectors);
tally = NEW2 (nvectors, short); tally = XCALLOC (short, nvectors);
width = NEW2 (nvectors, short); width = XCALLOC (short, nvectors);
token_actions (); token_actions ();
free_shifts (); free_shifts ();
free_reductions (); free_reductions ();
FREE (lookaheads); XFREE (lookaheads);
FREE (LA); XFREE (LA);
FREE (LAruleno); XFREE (LAruleno);
FREE (accessing_symbol); XFREE (accessing_symbol);
goto_actions (); goto_actions ();
FREE (goto_map + ntokens); XFREE (goto_map + ntokens);
FREE (from_state); XFREE (from_state);
FREE (to_state); XFREE (to_state);
sort_actions (); sort_actions ();
pack_table (); pack_table ();
@@ -1264,12 +1264,12 @@ free_itemsets (void)
{ {
core *cp, *cptmp; core *cp, *cptmp;
FREE (state_table); XFREE (state_table);
for (cp = first_state; cp; cp = cptmp) for (cp = first_state; cp; cp = cptmp)
{ {
cptmp = cp->next; cptmp = cp->next;
FREE (cp); XFREE (cp);
} }
} }
@@ -1321,7 +1321,7 @@ output (void)
/* if (semantic_parser) */ /* if (semantic_parser) */
/* This is now unconditional because debugging printouts can use it. */ /* This is now unconditional because debugging printouts can use it. */
output_gram (); output_gram ();
FREE (ritem); XFREE (ritem);
if (semantic_parser) if (semantic_parser)
output_stos (); output_stos ();
output_rule_data (); output_rule_data ();

View File

@@ -20,7 +20,7 @@
#include "system.h" #include "system.h"
#include "alloc.h" #include "xalloc.h"
#include "files.h" #include "files.h"
#include "gram.h" #include "gram.h"
#include "LR0.h" #include "LR0.h"
@@ -29,7 +29,7 @@
#include "getargs.h" #include "getargs.h"
#include "state.h" #include "state.h"
#include "reader.h" #include "reader.h"
#include "print.h"
#if 0 #if 0
static void static void

View File

@@ -23,7 +23,7 @@
#include "system.h" #include "system.h"
#include "getargs.h" #include "getargs.h"
#include "files.h" #include "files.h"
#include "alloc.h" #include "xalloc.h"
#include "symtab.h" #include "symtab.h"
#include "lex.h" #include "lex.h"
#include "gram.h" #include "gram.h"
@@ -390,7 +390,7 @@ parse_token_decl (int what_is, int what_is_not)
if (token == TYPENAME) if (token == TYPENAME)
{ {
k = strlen (token_buffer); k = strlen (token_buffer);
typename = NEW2 (k + 1, char); typename = XCALLOC (char, k + 1);
strcpy (typename, token_buffer); strcpy (typename, token_buffer);
value_components_used = 1; value_components_used = 1;
symbol = NULL; symbol = NULL;
@@ -516,7 +516,7 @@ parse_type_decl (void)
} }
k = strlen (token_buffer); k = strlen (token_buffer);
name = NEW2 (k + 1, char); name = XCALLOC (char, k + 1);
strcpy (name, token_buffer); strcpy (name, token_buffer);
for (;;) for (;;)
@@ -585,7 +585,7 @@ parse_assoc_decl (int assoc)
case TYPENAME: case TYPENAME:
k = strlen (token_buffer); k = strlen (token_buffer);
name = NEW2 (k + 1, char); name = XCALLOC (char, k + 1);
strcpy (name, token_buffer); strcpy (name, token_buffer);
break; break;
@@ -774,7 +774,7 @@ parse_thong_decl (void)
if (token == TYPENAME) if (token == TYPENAME)
{ {
k = strlen (token_buffer); k = strlen (token_buffer);
typename = NEW2 (k + 1, char); typename = XCALLOC (char, k + 1);
strcpy (typename, token_buffer); strcpy (typename, token_buffer);
value_components_used = 1; value_components_used = 1;
token = lex (); /* fetch first token */ token = lex (); /* fetch first token */
@@ -1216,8 +1216,7 @@ record_rule_line (void)
if (nrules >= rline_allocated) if (nrules >= rline_allocated)
{ {
rline_allocated = nrules * 2; rline_allocated = nrules * 2;
rline = (short *) xrealloc ((char *) rline, rline = XREALLOC (rline, short, rline_allocated);
rline_allocated * sizeof (short));
} }
rline[nrules] = lineno; rline[nrules] = lineno;
} }
@@ -1263,7 +1262,7 @@ get_type (void)
} }
k = strlen (token_buffer); k = strlen (token_buffer);
name = NEW2 (k + 1, char); name = XCALLOC (char, k + 1);
strcpy (name, token_buffer); strcpy (name, token_buffer);
for (;;) for (;;)
@@ -1361,7 +1360,7 @@ readgram (void)
record_rule_line (); record_rule_line ();
p = NEW (symbol_list); p = XCALLOC (symbol_list, 1);
p->sym = lhs; p->sym = lhs;
crule1 = p1; crule1 = p1;
@@ -1439,19 +1438,19 @@ readgram (void)
nrules++; nrules++;
nitems++; nitems++;
record_rule_line (); record_rule_line ();
p = NEW (symbol_list); p = XCALLOC (symbol_list, 1);
if (crule1) if (crule1)
crule1->next = p; crule1->next = p;
else else
grammar = p; grammar = p;
p->sym = sdummy; p->sym = sdummy;
crule1 = NEW (symbol_list); crule1 = XCALLOC (symbol_list, 1);
p->next = crule1; p->next = crule1;
crule1->next = crule; crule1->next = crule;
/* insert the dummy generated by that rule into this rule. */ /* insert the dummy generated by that rule into this rule. */
nitems++; nitems++;
p = NEW (symbol_list); p = XCALLOC (symbol_list, 1);
p->sym = sdummy; p->sym = sdummy;
p1->next = p; p1->next = p;
p1 = p; p1 = p;
@@ -1462,7 +1461,7 @@ readgram (void)
if (t == IDENTIFIER) if (t == IDENTIFIER)
{ {
nitems++; nitems++;
p = NEW (symbol_list); p = XCALLOC (symbol_list, 1);
p->sym = symval; p->sym = symval;
p1->next = p; p1->next = p;
p1 = p; p1 = p;
@@ -1477,7 +1476,7 @@ readgram (void)
} /* end of read rhs of rule */ } /* end of read rhs of rule */
/* Put an empty link in the list to mark the end of this rule */ /* Put an empty link in the list to mark the end of this rule */
p = NEW (symbol_list); p = XCALLOC (symbol_list, 1);
p1->next = p; p1->next = p;
p1 = p; p1 = p;
@@ -1672,13 +1671,13 @@ packsymbols (void)
/* int lossage = 0; JF set but not used */ /* int lossage = 0; JF set but not used */
tags = NEW2 (nsyms + 1, char *); tags = XCALLOC (char *, nsyms + 1);
tags[0] = DOLLAR; tags[0] = DOLLAR;
user_toknums = NEW2 (nsyms + 1, short); user_toknums = XCALLOC (short, nsyms + 1);
user_toknums[0] = 0; user_toknums[0] = 0;
sprec = NEW2 (nsyms, short); sprec = XCALLOC (short, nsyms);
sassoc = NEW2 (nsyms, short); sassoc = XCALLOC (short, nsyms);
max_user_token_number = 256; max_user_token_number = 256;
last_user_token_number = 256; last_user_token_number = 256;
@@ -1749,7 +1748,7 @@ packsymbols (void)
{ {
int j; int j;
token_translations = NEW2 (max_user_token_number + 1, short); token_translations = XCALLOC (short, max_user_token_number + 1);
/* initialize all entries for literal tokens to 2, the internal /* initialize all entries for literal tokens to 2, the internal
token number for $undefined., which represents all invalid token number for $undefined., which represents all invalid
@@ -1827,12 +1826,12 @@ packgram (void)
bucket *ruleprec; bucket *ruleprec;
ritem = NEW2 (nitems + 1, short); ritem = XCALLOC (short, nitems + 1);
rlhs = NEW2 (nrules, short) - 1; rlhs = XCALLOC (short, nrules) - 1;
rrhs = NEW2 (nrules, short) - 1; rrhs = XCALLOC (short, nrules) - 1;
rprec = NEW2 (nrules, short) - 1; rprec = XCALLOC (short, nrules) - 1;
rprecsym = NEW2 (nrules, short) - 1; rprecsym = XCALLOC (short, nrules) - 1;
rassoc = NEW2 (nrules, short) - 1; rassoc = XCALLOC (short, nrules) - 1;
itemno = 0; itemno = 0;
ruleno = 1; ruleno = 1;
@@ -1906,7 +1905,7 @@ reader (void)
nrules = 0; nrules = 0;
nitems = 0; nitems = 0;
rline_allocated = 10; rline_allocated = 10;
rline = NEW2 (rline_allocated, short); rline = XCALLOC (short, rline_allocated);
typed = 0; typed = 0;
lastprec = 0; lastprec = 0;

View File

@@ -29,7 +29,7 @@
#include "getargs.h" #include "getargs.h"
#include "files.h" #include "files.h"
#include "gram.h" #include "gram.h"
#include "alloc.h" #include "xalloc.h"
#include "complain.h" #include "complain.h"
#include "reduce.h" #include "reduce.h"
#include "reader.h" #include "reader.h"
@@ -122,7 +122,7 @@ useless_nonterminals (void)
/* N is set as built. Np is set being built this iteration. P is /* N is set as built. Np is set being built this iteration. P is
set of all productions which have a RHS all in N. */ set of all productions which have a RHS all in N. */
Np = NEW2 (WORDSIZE (nvars), unsigned); Np = XCALLOC (unsigned, WORDSIZE (nvars));
/* The set being computed is a set of nonterminals which can derive /* The set being computed is a set of nonterminals which can derive
the empty string or strings consisting of all terminals. At each the empty string or strings consisting of all terminals. At each
@@ -162,7 +162,7 @@ useless_nonterminals (void)
Np = N; Np = N;
N = Ns; N = Ns;
} }
FREE (N); XFREE (N);
N = Np; N = Np;
} }
@@ -198,8 +198,8 @@ inaccessable_symbols (void)
terminals are printed (if running in verbose mode) so that the terminals are printed (if running in verbose mode) so that the
user can know. */ user can know. */
Vp = NEW2 (WORDSIZE (nsyms), unsigned); Vp = XCALLOC (unsigned, WORDSIZE (nsyms));
Pp = NEW2 (WORDSIZE (nrules + 1), unsigned); Pp = XCALLOC (unsigned, WORDSIZE (nrules + 1));
/* If the start symbol isn't useful, then nothing will be useful. */ /* If the start symbol isn't useful, then nothing will be useful. */
if (!BITISSET (N, start_symbol - ntokens)) if (!BITISSET (N, start_symbol - ntokens))
@@ -236,7 +236,7 @@ inaccessable_symbols (void)
} }
end_iteration: end_iteration:
FREE (V); XFREE (V);
V = Vp; V = Vp;
/* Tokens 0, 1, and 2 are internal to Bison. Consider them useful. */ /* Tokens 0, 1, and 2 are internal to Bison. Consider them useful. */
@@ -244,7 +244,7 @@ end_iteration:
SETBIT (V, 1); /* error token */ SETBIT (V, 1); /* error token */
SETBIT (V, 2); /* some undefined token */ SETBIT (V, 2); /* some undefined token */
FREE (P); XFREE (P);
P = Pp; P = Pp;
nuseful_productions = bits_size (P, WORDSIZE (nrules + 1)); nuseful_productions = bits_size (P, WORDSIZE (nrules + 1));
@@ -340,7 +340,7 @@ reduce_grammar_tables (void)
number. -1 in the map means it was useless and is being number. -1 in the map means it was useless and is being
eliminated. */ eliminated. */
nontermmap = NEW2 (nvars, short) - ntokens; nontermmap = XCALLOC (short, nvars) - ntokens;
for (i = ntokens; i < nsyms; i++) for (i = ntokens; i < nsyms; i++)
nontermmap[i] = -1; nontermmap[i] = -1;
@@ -513,10 +513,10 @@ reduce_grammar (void)
/* Allocate the global sets used to compute the reduced grammar */ /* Allocate the global sets used to compute the reduced grammar */
N = NEW2 (WORDSIZE (nvars), unsigned); N = XCALLOC (unsigned, WORDSIZE (nvars));
P = NEW2 (WORDSIZE (nrules + 1), unsigned); P = XCALLOC (unsigned, WORDSIZE (nrules + 1));
V = NEW2 (WORDSIZE (nsyms), unsigned); V = XCALLOC (unsigned, WORDSIZE (nsyms));
V1 = NEW2 (WORDSIZE (nsyms), unsigned); V1 = XCALLOC (unsigned, WORDSIZE (nsyms));
useless_nonterminals (); useless_nonterminals ();
inaccessable_symbols (); inaccessable_symbols ();
@@ -558,7 +558,7 @@ reduce_grammar (void)
done_reducing: done_reducing:
/* Free the global sets used to compute the reduced grammar */ /* Free the global sets used to compute the reduced grammar */
FREE (N); XFREE (N);
FREE (V); XFREE (V);
FREE (P); XFREE (P);
} }

View File

@@ -20,7 +20,7 @@ Boston, MA 02111-1307, USA. */
#include "system.h" #include "system.h"
#include "alloc.h" #include "xalloc.h"
#include "symtab.h" #include "symtab.h"
#include "gram.h" #include "gram.h"
@@ -56,7 +56,7 @@ copys (const char *s)
for (cp = s; *cp; cp++) for (cp = s; *cp; cp++)
i++; i++;
result = xmalloc((unsigned int)i); result = XMALLOC(char, i);
strcpy(result, s); strcpy(result, s);
return result; return result;
} }
@@ -67,7 +67,7 @@ tabinit (void)
{ {
/* register int i; JF unused */ /* register int i; JF unused */
symtab = NEW2(TABSIZE, bucket *); symtab = XCALLOC (bucket *, TABSIZE);
firstsymbol = NULL; firstsymbol = NULL;
lastsymbol = NULL; lastsymbol = NULL;
@@ -97,7 +97,7 @@ getsym (const char *key)
{ {
nsyms++; nsyms++;
bp = NEW(bucket); bp = XCALLOC (bucket, 1);
bp->link = symtab[hashval]; bp->link = symtab[hashval];
bp->next = NULL; bp->next = NULL;
bp->tag = copys(key); bp->tag = copys(key);
@@ -135,11 +135,11 @@ free_symtab (void)
bptmp = bp->link; bptmp = bp->link;
#if 0 /* This causes crashes because one string can appear more than once. */ #if 0 /* This causes crashes because one string can appear more than once. */
if (bp->type_name) if (bp->type_name)
FREE(bp->type_name); XFREE(bp->type_name);
#endif #endif
FREE(bp); XFREE(bp);
bp = bptmp; bp = bptmp;
} }
} }
FREE(symtab); XFREE(symtab);
} }

View File

@@ -1,41 +1,39 @@
/* Generate transitive closure of a matrix, /* Generate transitive closure of a matrix,
Copyright (C) 1984, 1989 Free Software Foundation, Inc. Copyright (C) 1984, 1989, 2000 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler. This file is part of Bison, the GNU Compiler Compiler.
Bison is free software; you can redistribute it and/or modify Bison is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
Bison is distributed in the hope that it will be useful, Bison is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Bison; see the file COPYING. If not, write to along with Bison; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include "system.h" #include "system.h"
#include "warshall.h"
void RTC PARAMS((unsigned *, int)); /* Given n by n matrix of bits R, modify its contents to be the
transive closure of what was given. */
/* given n by n matrix of bits R, modify its contents
to be the transive closure of what was given. */
static void static void
TC (unsigned *R, int n) TC (unsigned *R, int n)
{ {
register int rowsize; int rowsize;
register unsigned mask; unsigned mask;
register unsigned *rowj; unsigned *rowj;
register unsigned *rp; unsigned *rp;
register unsigned *rend; unsigned *rend;
register unsigned *ccol; unsigned *ccol;
unsigned *relend; unsigned *relend;
unsigned *cword; unsigned *cword;
@@ -88,10 +86,10 @@ TC (unsigned *R, int n)
void void
RTC (unsigned *R, int n) RTC (unsigned *R, int n)
{ {
register int rowsize; int rowsize;
register unsigned mask; unsigned mask;
register unsigned *rp; unsigned *rp;
register unsigned *relend; unsigned *relend;
TC(R, n); TC(R, n);

25
src/warshall.h Normal file
View File

@@ -0,0 +1,25 @@
/* Generate transitive closure of a matrix,
Copyright (C) 1984, 1989, 2000 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
Bison 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.
Bison 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 Bison; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef WARSHALL_H_
# define WARSHALL_H_
void RTC PARAMS ((unsigned *, int));
#endif /* !WARSHALL_H_ */