summaryrefslogtreecommitdiffstats
path: root/contrib/byacc
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2012-09-14 21:17:53 +0000
committerbapt <bapt@FreeBSD.org>2012-09-14 21:17:53 +0000
commita06756dafd4a9ec683a791e05584f7f4184c6ec6 (patch)
tree9c923f8191c691c871a9764cfcfe3137f0e3da40 /contrib/byacc
parentf75087e0ad660b033e93958dddd3513be0401d53 (diff)
downloadFreeBSD-src-a06756dafd4a9ec683a791e05584f7f4184c6ec6.zip
FreeBSD-src-a06756dafd4a9ec683a791e05584f7f4184c6ec6.tar.gz
update to version 20120526
Diffstat (limited to 'contrib/byacc')
-rw-r--r--contrib/byacc/CHANGES34
-rw-r--r--contrib/byacc/VERSION2
-rw-r--r--contrib/byacc/defs.h22
-rw-r--r--contrib/byacc/lr0.c4
-rw-r--r--contrib/byacc/main.c8
-rw-r--r--contrib/byacc/mkpar.c4
-rw-r--r--contrib/byacc/output.c8
-rw-r--r--contrib/byacc/package/byacc.spec4
-rw-r--r--contrib/byacc/package/debian/changelog6
-rw-r--r--contrib/byacc/reader.c72
-rw-r--r--contrib/byacc/symtab.c8
-rw-r--r--contrib/byacc/verbose.c4
12 files changed, 115 insertions, 61 deletions
diff --git a/contrib/byacc/CHANGES b/contrib/byacc/CHANGES
index 66c5da0..c3c43c5 100644
--- a/contrib/byacc/CHANGES
+++ b/contrib/byacc/CHANGES
@@ -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
diff --git a/contrib/byacc/VERSION b/contrib/byacc/VERSION
index b15d73f..507b92b 100644
--- a/contrib/byacc/VERSION
+++ b/contrib/byacc/VERSION
@@ -1 +1 @@
-20120115
+20120526
diff --git a/contrib/byacc/defs.h b/contrib/byacc/defs.h
index 7be5748..4d1a407 100644
--- a/contrib/byacc/defs.h
+++ b/contrib/byacc/defs.h
@@ -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; }
@@ -241,6 +247,7 @@ extern char *line;
extern int lineno;
extern int outline;
extern int exit_code;
+extern int pure_parser;
extern const char *const banner[];
extern const char *const xdecls[];
@@ -301,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;
@@ -342,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);
@@ -421,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);
diff --git a/contrib/byacc/lr0.c b/contrib/byacc/lr0.c
index 0759973..641f9f8 100644
--- a/contrib/byacc/lr0.c
+++ b/contrib/byacc/lr0.c
@@ -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)
diff --git a/contrib/byacc/main.c b/contrib/byacc/main.c
index 0405a99..bcd7d50 100644
--- a/contrib/byacc/main.c
+++ b/contrib/byacc/main.c
@@ -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() */
@@ -163,7 +163,7 @@ done(int k)
}
static void
-onintr(__unused int sig)
+onintr(int sig GCC_UNUSED)
{
got_intr = 1;
done(EXIT_FAILURE);
@@ -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;
}
diff --git a/contrib/byacc/mkpar.c b/contrib/byacc/mkpar.c
index f9f2b5c..b2e36ab 100644
--- a/contrib/byacc/mkpar.c
+++ b/contrib/byacc/mkpar.c
@@ -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)
diff --git a/contrib/byacc/output.c b/contrib/byacc/output.c
index 33b10c6..331726d 100644
--- a/contrib/byacc/output.c
+++ b/contrib/byacc/output.c
@@ -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 */
diff --git a/contrib/byacc/package/byacc.spec b/contrib/byacc/package/byacc.spec
index 8f1fbb5..b8be31a 100644
--- a/contrib/byacc/package/byacc.spec
+++ b/contrib/byacc/package/byacc.spec
@@ -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
diff --git a/contrib/byacc/package/debian/changelog b/contrib/byacc/package/debian/changelog
index 98c08e2..f159879 100644
--- a/contrib/byacc/package/debian/changelog
+++ b/contrib/byacc/package/debian/changelog
@@ -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.
diff --git a/contrib/byacc/reader.c b/contrib/byacc/reader.c
index d41e92a..6b24d7d 100644
--- a/contrib/byacc/reader.c
+++ b/contrib/byacc/reader.c
@@ -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;
@@ -685,7 +685,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++)
@@ -733,7 +733,7 @@ copy_param(int k)
name = i + 1;
- p = MALLOC(sizeof(*p));
+ p = TMALLOC(param, 1);
NO_SPACE(p);
p->type2 = strdup(buf + type2);
@@ -890,7 +890,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)
@@ -1058,14 +1058,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);
@@ -1246,7 +1246,7 @@ read_declarations(void)
int c, k;
cache_size = 256;
- cache = MALLOC(cache_size);
+ cache = TMALLOC(char, cache_size);
NO_SPACE(cache);
for (;;)
@@ -1316,7 +1316,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;
@@ -1327,21 +1327,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;
@@ -1353,7 +1353,7 @@ static void
expand_items(void)
{
maxitems += 300;
- pitem = (bucket **)REALLOC(pitem, (unsigned)maxitems * sizeof(bucket *));
+ pitem = TREALLOC(bucket *, pitem, maxitems);
NO_SPACE(pitem);
}
@@ -1362,13 +1362,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);
}
@@ -1780,9 +1780,7 @@ static int
mark_symbol(void)
{
int c;
- bucket *bp;
-
- bp = NULL;
+ bucket *bp = NULL;
c = cptr[1];
if (c == '%' || c == '\\')
@@ -1886,7 +1884,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");
@@ -1941,7 +1939,7 @@ protect_string(char *src, char **des)
len++;
}
- *des = d = (char *)MALLOC(len);
+ *des = d = TMALLOC(char, len);
NO_SPACE(d);
s = src;
@@ -1973,19 +1971,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;
@@ -2085,7 +2083,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)
@@ -2103,19 +2101,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;
diff --git a/contrib/byacc/symtab.c b/contrib/byacc/symtab.c
index 1327eaf..9839180 100644
--- a/contrib/byacc/symtab.c
+++ b/contrib/byacc/symtab.c
@@ -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++)
diff --git a/contrib/byacc/verbose.c b/contrib/byacc/verbose.c
index 118f8b4..3e6ea28 100644
--- a/contrib/byacc/verbose.c
+++ b/contrib/byacc/verbose.c
@@ -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");
OpenPOWER on IntegriCloud