Vendor import of byacc 20120526

Approved by:	des (mentor, implicit)
This commit is contained in:
Baptiste Daroussin 2012-05-28 22:29:47 +00:00
parent aec86590e4
commit 15d0187d62
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/byacc/dist/; revision=236206
svn path=/vendor/byacc/20120526/; revision=236207; tag=vendor/byacc/20120526
12 changed files with 113 additions and 58 deletions

34
CHANGES
View File

@ -1,3 +1,37 @@
2012-05-26 Thomas E. Dickey <tom@invisible-island.net>
* package/debian/changelog, package/byacc.spec, VERSION: bump
* reader.c:
some versions of gcc may warn that bp is not set in mark_symbol, e.g.,
if GCC_NORETURN is not handled; appease the compiler.
* reader.c:
use the declared types Assoc_t and Value_t in some places where compiler only
cared about char versus short.
* reader.c:
use TMALLOC() and TREALLOC() macros to simplify allocation/reallocation
(no object change)
* defs.h:
add fallbacks for GCC_NORETURN and GCC_UNUSED to make it simpler for *BSD
packagers to build without configure script. Also remove duplicate declaration
of pure_parser variable (prompted by patch by Baptiste Daroussin).
Also define new TMALLOC and TREALLOC macros to simplify/replace MALLOC and
REALLOC macros.
* symtab.c:
use TMALLOC() and TREALLOC() macros to simplify allocation/reallocation
(no object change)
2012-05-25 Thomas E. Dickey <tom@invisible-island.net>
* output.c, main.c, verbose.c, mkpar.c, lr0.c:
use TMALLOC() and TREALLOC() macros to simplify allocation/reallocation
(no object change)
2012-01-15 Thomas E. Dickey <tom@invisible-island.net>
* package/debian/copyright: bump

View File

@ -1 +1 @@
20120115
20120526

21
defs.h
View File

@ -1,4 +1,4 @@
/* $Id: defs.h,v 1.36 2011/12/20 01:31:16 tom Exp $ */
/* $Id: defs.h,v 1.37 2012/05/26 15:23:00 tom Exp $ */
#ifdef HAVE_CONFIG_H
#include <config.h>
@ -11,6 +11,10 @@
#include <ctype.h>
#include <stdio.h>
#if defined(__cplusplus) /* __cplusplus, etc. */
#define class myClass
#endif
#define YYMAJOR 1
#define YYMINOR 9
@ -132,9 +136,11 @@
#define CALLOC(k,n) (calloc((size_t)(k),(size_t)(n)))
#define FREE(x) (free((char*)(x)))
#define MALLOC(n) (malloc((size_t)(n)))
#define TMALLOC(t,n) ((t*) malloc((size_t)(n) * sizeof(t)))
#define NEW(t) ((t*)allocate(sizeof(t)))
#define NEW2(n,t) ((t*)allocate(((size_t)(n)*sizeof(t))))
#define REALLOC(p,n) (realloc((char*)(p),(size_t)(n)))
#define TREALLOC(t,p,n) ((t*)realloc((char*)(p), (size_t)(n) * sizeof(t)))
#define DO_FREE(x) if (x) { FREE(x); x = 0; }
@ -302,7 +308,6 @@ extern char *nullable;
extern bucket *first_symbol;
extern bucket *last_symbol;
extern int pure_parser;
extern int nstates;
extern core *first_state;
extern shifts *first_shift;
@ -343,12 +348,22 @@ extern bucket *lookup(const char *);
extern bucket *make_bucket(const char *);
#ifndef GCC_NORETURN
#if defined(__dead2)
#define GCC_NORETURN __dead2
#elif defined(__dead)
#define GCC_NORETURN __dead
#else
#define GCC_NORETURN /* nothing */
#endif
#endif
#ifndef GCC_UNUSED
#if defined(__unused)
#define GCC_UNUSED __unused
#else
#define GCC_UNUSED /* nothing */
#endif
#endif
/* closure.c */
extern void closure(Value_t * nucleus, int n);
@ -422,7 +437,7 @@ extern void output(void);
extern void reader(void);
/* skeleton.c */
extern void write_section(FILE *fp, const char *const section[]);
extern void write_section(FILE * fp, const char *const section[]);
/* verbose.c */
extern void verbose(void);

4
lr0.c
View File

@ -1,4 +1,4 @@
/* $Id: lr0.c,v 1.12 2010/06/09 08:53:17 tom Exp $ */
/* $Id: lr0.c,v 1.13 2012/05/26 00:40:47 tom Exp $ */
#include "defs.h"
@ -538,7 +538,7 @@ set_nullable(void)
int empty;
int done_flag;
nullable = MALLOC(nsyms);
nullable = TMALLOC(char, nsyms);
NO_SPACE(nullable);
for (i = 0; i < nsyms; ++i)

6
main.c
View File

@ -1,4 +1,4 @@
/* $Id: main.c,v 1.38 2012/01/14 01:01:15 tom Exp $ */
/* $Id: main.c,v 1.39 2012/05/26 00:50:20 tom Exp $ */
#include <signal.h>
#include <unistd.h> /* for _exit() */
@ -367,7 +367,7 @@ allocate(size_t n)
}
#define CREATE_FILE_NAME(dest, suffix) \
dest = MALLOC(len + strlen(suffix) + 1); \
dest = TMALLOC(char, len + strlen(suffix) + 1); \
NO_SPACE(dest); \
strcpy(dest, file_prefix); \
strcpy(dest + len, suffix)
@ -398,7 +398,7 @@ create_file_names(void)
if (prefix != NULL)
{
len = (size_t) (prefix - output_file_name);
file_prefix = (char *)MALLOC(len + 1);
file_prefix = TMALLOC(char, len + 1);
NO_SPACE(file_prefix);
strncpy(file_prefix, output_file_name, len)[len] = 0;
}

View File

@ -1,4 +1,4 @@
/* $Id: mkpar.c,v 1.11 2010/06/09 08:53:17 tom Exp $ */
/* $Id: mkpar.c,v 1.12 2012/05/26 00:42:18 tom Exp $ */
#include "defs.h"
@ -180,7 +180,7 @@ unused_rules(void)
int i;
action *p;
rules_used = (Value_t *) MALLOC((unsigned)nrules * sizeof(Value_t));
rules_used = TMALLOC(Value_t, nrules);
NO_SPACE(rules_used);
for (i = 0; i < nrules; ++i)

View File

@ -1,4 +1,4 @@
/* $Id: output.c,v 1.43 2012/01/14 17:03:52 tom Exp $ */
/* $Id: output.c,v 1.44 2012/05/26 01:13:02 tom Exp $ */
#include "defs.h"
@ -557,10 +557,10 @@ pack_vector(int vector)
}
while (newmax <= loc);
table = (Value_t *) REALLOC(table, (unsigned)newmax * sizeof(Value_t));
table = TREALLOC(Value_t, table, newmax);
NO_SPACE(table);
check = (Value_t *) REALLOC(check, (unsigned)newmax * sizeof(Value_t));
check = TREALLOC(Value_t, check, newmax);
NO_SPACE(check);
for (l = maxtable; l < newmax; ++l)
@ -919,7 +919,7 @@ output_debug(void)
++outline;
fprintf(code_file, "#define YYMAXTOKEN %d\n", max);
symnam = (const char **)MALLOC((unsigned)(max + 1) * sizeof(char *));
symnam = TMALLOC(const char *, max + 1);
NO_SPACE(symnam);
/* Note that it is not necessary to initialize the element */

View File

@ -1,8 +1,8 @@
Summary: byacc - public domain Berkeley LALR Yacc parser generator
%define AppProgram byacc
%define AppVersion 20120115
%define AppVersion 20120526
%define UseProgram yacc
# $XTermId: byacc.spec,v 1.13 2012/01/15 19:30:29 tom Exp $
# $XTermId: byacc.spec,v 1.14 2012/05/26 16:13:45 tom Exp $
Name: %{AppProgram}
Version: %{AppVersion}
Release: 1

View File

@ -1,3 +1,9 @@
byacc (20120526) unstable; urgency=low
* minor code-cleanup.
-- Thomas E. Dickey <dickey@invisible-island.net> Sat, 26 May 2012 12:14:17 -0400
byacc (20120115) unstable; urgency=low
* add testcases, improve documentation for "-s" option.

View File

@ -1,4 +1,4 @@
/* $Id: reader.c,v 1.33 2011/09/06 22:56:53 tom Exp $ */
/* $Id: reader.c,v 1.36 2012/05/26 16:05:41 tom Exp $ */
#include "defs.h"
@ -52,7 +52,7 @@ cachec(int c)
if (cinc >= cache_size)
{
cache_size += 256;
cache = REALLOC(cache, cache_size);
cache = TREALLOC(char, cache, cache_size);
NO_SPACE(cache);
}
cache[cinc] = (char)c;
@ -83,7 +83,7 @@ get_line(void)
if (line)
FREE(line);
linesize = LINESIZE + 1;
line = MALLOC(linesize);
line = TMALLOC(char, linesize);
NO_SPACE(line);
}
@ -100,7 +100,7 @@ get_line(void)
if (++i >= linesize)
{
linesize += LINESIZE;
line = REALLOC(line, linesize);
line = TREALLOC(char, line, linesize);
NO_SPACE(line);
}
c = getc(f);
@ -124,7 +124,7 @@ dup_line(void)
s = line;
while (*s != '\n')
++s;
p = MALLOC(s - line + 1);
p = TMALLOC(char, s - line + 1);
NO_SPACE(p);
s = line;
@ -684,7 +684,7 @@ copy_param(int k)
if (c == '}')
goto out;
buf = MALLOC(linesize);
buf = TMALLOC(char, linesize);
NO_SPACE(buf);
for (i = 0; (c = *cptr++) != '}'; i++)
@ -732,7 +732,7 @@ copy_param(int k)
name = i + 1;
p = MALLOC(sizeof(*p));
p = TMALLOC(param, 1);
NO_SPACE(p);
p->type2 = strdup(buf + type2);
@ -889,7 +889,7 @@ get_literal(void)
FREE(s_line);
n = cinc;
s = MALLOC(n);
s = TMALLOC(char, n);
NO_SPACE(s);
for (i = 0; i < n; ++i)
@ -1057,14 +1057,14 @@ get_tag(void)
if (ntags >= tagmax)
{
tagmax += 16;
tag_table = (char **)
tag_table =
(tag_table
? REALLOC(tag_table, (unsigned)tagmax * sizeof(char *))
: MALLOC((unsigned)tagmax * sizeof(char *)));
? TREALLOC(char *, tag_table, tagmax)
: TMALLOC(char *, tagmax));
NO_SPACE(tag_table);
}
s = MALLOC(cinc);
s = TMALLOC(char, cinc);
NO_SPACE(s);
strcpy(s, cache);
@ -1245,7 +1245,7 @@ read_declarations(void)
int c, k;
cache_size = 256;
cache = MALLOC(cache_size);
cache = TMALLOC(char, cache_size);
NO_SPACE(cache);
for (;;)
@ -1315,7 +1315,7 @@ initialize_grammar(void)
nitems = 4;
maxitems = 300;
pitem = (bucket **)MALLOC((unsigned)maxitems * sizeof(bucket *));
pitem = TMALLOC(bucket *, maxitems);
NO_SPACE(pitem);
pitem[0] = 0;
@ -1326,21 +1326,21 @@ initialize_grammar(void)
nrules = 3;
maxrules = 100;
plhs = (bucket **)MALLOC((unsigned)maxrules * sizeof(bucket *));
plhs = TMALLOC(bucket *, maxrules);
NO_SPACE(plhs);
plhs[0] = 0;
plhs[1] = 0;
plhs[2] = 0;
rprec = (short *)MALLOC((unsigned)maxrules * sizeof(short));
rprec = TMALLOC(Value_t, maxrules);
NO_SPACE(rprec);
rprec[0] = 0;
rprec[1] = 0;
rprec[2] = 0;
rassoc = (char *)MALLOC((unsigned)maxrules * sizeof(char));
rassoc = TMALLOC(Assoc_t, maxrules);
NO_SPACE(rassoc);
rassoc[0] = TOKEN;
@ -1352,7 +1352,7 @@ static void
expand_items(void)
{
maxitems += 300;
pitem = (bucket **)REALLOC(pitem, (unsigned)maxitems * sizeof(bucket *));
pitem = TREALLOC(bucket *, pitem, maxitems);
NO_SPACE(pitem);
}
@ -1361,13 +1361,13 @@ expand_rules(void)
{
maxrules += 100;
plhs = (bucket **)REALLOC(plhs, (unsigned)maxrules * sizeof(bucket *));
plhs = TREALLOC(bucket *, plhs, maxrules);
NO_SPACE(plhs);
rprec = (short *)REALLOC(rprec, (unsigned)maxrules * sizeof(short));
rprec = TREALLOC(Value_t, rprec, maxrules);
NO_SPACE(rprec);
rassoc = (char *)REALLOC(rassoc, (unsigned)maxrules * sizeof(char));
rassoc = TREALLOC(Assoc_t, rassoc, maxrules);
NO_SPACE(rassoc);
}
@ -1779,7 +1779,7 @@ static int
mark_symbol(void)
{
int c;
bucket *bp;
bucket *bp = NULL;
c = cptr[1];
if (c == '%' || c == '\\')
@ -1883,7 +1883,7 @@ pack_names(void)
for (bp = first_symbol; bp; bp = bp->next)
name_pool_size += strlen(bp->name) + 1;
name_pool = MALLOC(name_pool_size);
name_pool = TMALLOC(char, name_pool_size);
NO_SPACE(name_pool);
strcpy(name_pool, "$accept");
@ -1938,7 +1938,7 @@ protect_string(char *src, char **des)
len++;
}
*des = d = (char *)MALLOC(len);
*des = d = TMALLOC(char, len);
NO_SPACE(d);
s = src;
@ -1970,19 +1970,19 @@ pack_symbols(void)
start_symbol = (Value_t) ntokens;
nvars = nsyms - ntokens;
symbol_name = (char **)MALLOC((unsigned)nsyms * sizeof(char *));
symbol_name = TMALLOC(char *, nsyms);
NO_SPACE(symbol_name);
symbol_value = (short *)MALLOC((unsigned)nsyms * sizeof(short));
symbol_value = TMALLOC(Value_t, nsyms);
NO_SPACE(symbol_value);
symbol_prec = (short *)MALLOC((unsigned)nsyms * sizeof(short));
symbol_prec = TMALLOC(short, nsyms);
NO_SPACE(symbol_prec);
symbol_assoc = MALLOC(nsyms);
symbol_assoc = TMALLOC(char, nsyms);
NO_SPACE(symbol_assoc);
v = (bucket **)MALLOC((unsigned)nsyms * sizeof(bucket *));
v = TMALLOC(bucket *, nsyms);
NO_SPACE(v);
v[0] = 0;
@ -2082,7 +2082,7 @@ pack_symbols(void)
if (gflag)
{
symbol_pname = (char **)MALLOC((unsigned)nsyms * sizeof(char *));
symbol_pname = TMALLOC(char *, nsyms);
NO_SPACE(symbol_pname);
for (i = 0; i < nsyms; ++i)
@ -2100,19 +2100,19 @@ pack_grammar(void)
Assoc_t assoc;
Value_t prec2;
ritem = (short *)MALLOC((unsigned)nitems * sizeof(short));
ritem = TMALLOC(Value_t, nitems);
NO_SPACE(ritem);
rlhs = (short *)MALLOC((unsigned)nrules * sizeof(short));
rlhs = TMALLOC(Value_t, nrules);
NO_SPACE(rlhs);
rrhs = (short *)MALLOC((unsigned)(nrules + 1) * sizeof(short));
rrhs = TMALLOC(Value_t, nrules + 1);
NO_SPACE(rrhs);
rprec = (short *)REALLOC(rprec, (unsigned)nrules * sizeof(short));
rprec = TREALLOC(Value_t, rprec, nrules);
NO_SPACE(rprec);
rassoc = REALLOC(rassoc, nrules);
rassoc = TREALLOC(Assoc_t, rassoc, nrules);
NO_SPACE(rassoc);
ritem[0] = -1;

View File

@ -1,4 +1,4 @@
/* $Id: symtab.c,v 1.9 2010/11/24 15:12:29 tom Exp $ */
/* $Id: symtab.c,v 1.10 2012/05/26 15:16:12 tom Exp $ */
#include "defs.h"
@ -33,13 +33,13 @@ make_bucket(const char *name)
assert(name != 0);
bp = (bucket *)MALLOC(sizeof(bucket));
bp = TMALLOC(bucket, 1);
NO_SPACE(bp);
bp->link = 0;
bp->next = 0;
bp->name = MALLOC(strlen(name) + 1);
bp->name = TMALLOC(char, strlen(name) + 1);
NO_SPACE(bp->name);
bp->tag = 0;
@ -82,7 +82,7 @@ create_symbol_table(void)
int i;
bucket *bp;
symbol_table = (bucket **)MALLOC(TABLE_SIZE * sizeof(bucket *));
symbol_table = TMALLOC(bucket *, TABLE_SIZE);
NO_SPACE(symbol_table);
for (i = 0; i < TABLE_SIZE; i++)

View File

@ -1,4 +1,4 @@
/* $Id: verbose.c,v 1.9 2010/06/09 08:58:29 tom Exp $ */
/* $Id: verbose.c,v 1.10 2012/05/26 00:45:17 tom Exp $ */
#include "defs.h"
@ -23,7 +23,7 @@ verbose(void)
if (!vflag)
return;
null_rules = (short *)MALLOC((unsigned)nrules * sizeof(short));
null_rules = TMALLOC(short, nrules);
NO_SPACE(null_rules);
fprintf(verbose_file, "\f\n");