Module Name: src
Committed By: christos
Date: Sat Sep 10 21:29:04 UTC 2011
Modified Files:
src/external/bsd/byacc/dist: closure.c defs.h error.c lalr.c lr0.c
main.c mkpar.c output.c reader.c skeleton.c symtab.c verbose.c
warshall.c yacc.1
src/external/bsd/byacc/dist/test: error.tab.c error.tab.h ftp.tab.c
ftp.tab.h ftp.y
Log Message:
merge changes.
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/byacc/dist/closure.c \
src/external/bsd/byacc/dist/lr0.c src/external/bsd/byacc/dist/mkpar.c \
src/external/bsd/byacc/dist/symtab.c \
src/external/bsd/byacc/dist/verbose.c \
src/external/bsd/byacc/dist/warshall.c
cvs rdiff -u -r1.4 -r1.5 src/external/bsd/byacc/dist/defs.h \
src/external/bsd/byacc/dist/lalr.c
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/byacc/dist/error.c \
src/external/bsd/byacc/dist/main.c src/external/bsd/byacc/dist/reader.c
cvs rdiff -u -r1.7 -r1.8 src/external/bsd/byacc/dist/output.c
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/byacc/dist/skeleton.c
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/byacc/dist/yacc.1
cvs rdiff -u -r1.3 -r1.4 src/external/bsd/byacc/dist/test/error.tab.c \
src/external/bsd/byacc/dist/test/ftp.tab.c \
src/external/bsd/byacc/dist/test/ftp.y
cvs rdiff -u -r1.2 -r1.3 src/external/bsd/byacc/dist/test/error.tab.h \
src/external/bsd/byacc/dist/test/ftp.tab.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/bsd/byacc/dist/closure.c
diff -u src/external/bsd/byacc/dist/closure.c:1.5 src/external/bsd/byacc/dist/closure.c:1.6
--- src/external/bsd/byacc/dist/closure.c:1.5 Sat Dec 25 18:43:30 2010
+++ src/external/bsd/byacc/dist/closure.c Sat Sep 10 17:29:04 2011
@@ -1,10 +1,11 @@
-/* $NetBSD: closure.c,v 1.5 2010/12/25 23:43:30 christos Exp $ */
+/* $NetBSD: closure.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
+
/* Id: closure.c,v 1.9 2010/06/09 08:21:47 tom Exp */
#include "defs.h"
#include <sys/cdefs.h>
-__RCSID("$NetBSD: closure.c,v 1.5 2010/12/25 23:43:30 christos Exp $");
+__RCSID("$NetBSD: closure.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
Value_t *itemset;
Value_t *itemsetend;
Index: src/external/bsd/byacc/dist/lr0.c
diff -u src/external/bsd/byacc/dist/lr0.c:1.5 src/external/bsd/byacc/dist/lr0.c:1.6
--- src/external/bsd/byacc/dist/lr0.c:1.5 Sat Dec 25 18:43:30 2010
+++ src/external/bsd/byacc/dist/lr0.c Sat Sep 10 17:29:04 2011
@@ -1,10 +1,10 @@
-/* $NetBSD: lr0.c,v 1.5 2010/12/25 23:43:30 christos Exp $ */
+/* $NetBSD: lr0.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
/* Id: lr0.c,v 1.12 2010/06/09 08:53:17 tom Exp */
#include "defs.h"
#include <sys/cdefs.h>
-__RCSID("$NetBSD: lr0.c,v 1.5 2010/12/25 23:43:30 christos Exp $");
+__RCSID("$NetBSD: lr0.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
static core *new_state(int symbol);
static Value_t get_state(int symbol);
Index: src/external/bsd/byacc/dist/mkpar.c
diff -u src/external/bsd/byacc/dist/mkpar.c:1.5 src/external/bsd/byacc/dist/mkpar.c:1.6
--- src/external/bsd/byacc/dist/mkpar.c:1.5 Sat Dec 25 18:43:30 2010
+++ src/external/bsd/byacc/dist/mkpar.c Sat Sep 10 17:29:04 2011
@@ -1,10 +1,10 @@
-/* $NetBSD: mkpar.c,v 1.5 2010/12/25 23:43:30 christos Exp $ */
+/* $NetBSD: mkpar.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
/* Id: mkpar.c,v 1.11 2010/06/09 08:53:17 tom Exp */
#include "defs.h"
#include <sys/cdefs.h>
-__RCSID("$NetBSD: mkpar.c,v 1.5 2010/12/25 23:43:30 christos Exp $");
+__RCSID("$NetBSD: mkpar.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
static action *add_reduce(action *actions, int ruleno, int symbol);
static action *add_reductions(int stateno, action *actions);
Index: src/external/bsd/byacc/dist/symtab.c
diff -u src/external/bsd/byacc/dist/symtab.c:1.5 src/external/bsd/byacc/dist/symtab.c:1.6
--- src/external/bsd/byacc/dist/symtab.c:1.5 Sat Dec 25 18:43:30 2010
+++ src/external/bsd/byacc/dist/symtab.c Sat Sep 10 17:29:04 2011
@@ -1,10 +1,10 @@
-/* $NetBSD: symtab.c,v 1.5 2010/12/25 23:43:30 christos Exp $ */
+/* $NetBSD: symtab.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
/* Id: symtab.c,v 1.9 2010/11/24 15:12:29 tom Exp */
#include "defs.h"
#include <sys/cdefs.h>
-__RCSID("$NetBSD: symtab.c,v 1.5 2010/12/25 23:43:30 christos Exp $");
+__RCSID("$NetBSD: symtab.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
/* TABLE_SIZE is the number of entries in the symbol table. */
/* TABLE_SIZE must be a power of two. */
Index: src/external/bsd/byacc/dist/verbose.c
diff -u src/external/bsd/byacc/dist/verbose.c:1.5 src/external/bsd/byacc/dist/verbose.c:1.6
--- src/external/bsd/byacc/dist/verbose.c:1.5 Sat Dec 25 18:43:30 2010
+++ src/external/bsd/byacc/dist/verbose.c Sat Sep 10 17:29:04 2011
@@ -1,10 +1,10 @@
-/* $NetBSD: verbose.c,v 1.5 2010/12/25 23:43:30 christos Exp $ */
+/* $NetBSD: verbose.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
/* Id: verbose.c,v 1.9 2010/06/09 08:58:29 tom Exp */
#include "defs.h"
#include <sys/cdefs.h>
-__RCSID("$NetBSD: verbose.c,v 1.5 2010/12/25 23:43:30 christos Exp $");
+__RCSID("$NetBSD: verbose.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
static void log_conflicts(void);
static void log_unused(void);
Index: src/external/bsd/byacc/dist/warshall.c
diff -u src/external/bsd/byacc/dist/warshall.c:1.5 src/external/bsd/byacc/dist/warshall.c:1.6
--- src/external/bsd/byacc/dist/warshall.c:1.5 Sat Dec 25 18:43:30 2010
+++ src/external/bsd/byacc/dist/warshall.c Sat Sep 10 17:29:04 2011
@@ -1,10 +1,10 @@
-/* $NetBSD: warshall.c,v 1.5 2010/12/25 23:43:30 christos Exp $ */
+/* $NetBSD: warshall.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
/* Id: warshall.c,v 1.7 2010/06/06 22:48:51 tom Exp */
#include "defs.h"
#include <sys/cdefs.h>
-__RCSID("$NetBSD: warshall.c,v 1.5 2010/12/25 23:43:30 christos Exp $");
+__RCSID("$NetBSD: warshall.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
static void
transitive_closure(unsigned *R, int n)
Index: src/external/bsd/byacc/dist/defs.h
diff -u src/external/bsd/byacc/dist/defs.h:1.4 src/external/bsd/byacc/dist/defs.h:1.5
--- src/external/bsd/byacc/dist/defs.h:1.4 Thu Dec 23 21:58:20 2010
+++ src/external/bsd/byacc/dist/defs.h Sat Sep 10 17:29:04 2011
@@ -1,9 +1,9 @@
-/* $NetBSD: defs.h,v 1.4 2010/12/24 02:58:20 christos Exp $ */
+/* $NetBSD: defs.h,v 1.5 2011/09/10 21:29:04 christos Exp $ */
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
-/* Id: defs.h,v 1.30 2010/11/26 15:19:36 tom Exp */
+/* Id: defs.h,v 1.35 2011/09/07 08:55:03 tom Exp */
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -76,10 +76,12 @@
#if defined(VMS)
#define CODE_SUFFIX "_code.c"
#define DEFINES_SUFFIX "_tab.h"
+#define EXTERNS_SUFFIX "_tab.i"
#define OUTPUT_SUFFIX "_tab.c"
#else
#define CODE_SUFFIX ".code.c"
#define DEFINES_SUFFIX ".tab.h"
+#define EXTERNS_SUFFIX ".tab.i"
#define OUTPUT_SUFFIX ".tab.c"
#endif
#define VERBOSE_SUFFIX ".output"
@@ -230,6 +232,7 @@
extern char dflag;
extern char gflag;
+extern char iflag;
extern char lflag;
extern char rflag;
extern char tflag;
@@ -244,24 +247,29 @@
extern int exit_code;
extern int pure_parser;
-extern const char * const banner[];
-extern const char * const xdecls[];
-extern const char * const tables[];
-extern const char * const hdr_defs[];
-extern const char * const hdr_vars[];
-extern const char * const body_1[];
-extern const char * const body_vars[];
-extern const char * const body_2[];
-extern const char * const body_3[];
-extern const char * const trailer[];
-extern const char * const trailer_2[];
+extern const char *const banner[];
+extern const char *const xdecls[];
+extern const char *const tables[];
+extern const char *const global_vars[];
+extern const char *const impure_vars[];
+extern const char *const hdr_defs[];
+extern const char *const hdr_vars[];
+extern const char *const body_1[];
+extern const char *const body_vars[];
+extern const char *const body_2[];
+extern const char *const body_3[];
+extern const char *const trailer[];
+extern const char *const trailer_2[];
extern char *code_file_name;
extern char *input_file_name;
+extern char *defines_file_name;
+extern char *externs_file_name;
extern FILE *action_file;
extern FILE *code_file;
extern FILE *defines_file;
+extern FILE *externs_file;
extern FILE *input_file;
extern FILE *output_file;
extern FILE *text_file;
@@ -353,36 +361,37 @@
/* error.c */
extern void default_action_warning(void);
-extern void dollar_error(int a_lineno, char *a_line, char *a_cptr);
+extern void dollar_error(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN;
extern void dollar_warning(int a_lineno, int i);
-extern void fatal(const char *msg);
-extern void illegal_character(char *c_cptr);
-extern void illegal_tag(int t_lineno, char *t_line, char *t_cptr);
-extern void no_grammar(void);
-extern void no_space(void);
-extern void open_error(const char *filename);
-extern void over_unionized(char *u_cptr);
+extern void fatal(const char *msg) GCC_NORETURN;
+extern void illegal_character(char *c_cptr) GCC_NORETURN;
+extern void illegal_tag(int t_lineno, char *t_line, char *t_cptr) GCC_NORETURN;
+extern void missing_brace(void) GCC_NORETURN;
+extern void no_grammar(void) GCC_NORETURN;
+extern void no_space(void) GCC_NORETURN;
+extern void open_error(const char *filename) GCC_NORETURN;
+extern void over_unionized(char *u_cptr) GCC_NORETURN;
extern void prec_redeclared(void);
extern void reprec_warning(char *s);
extern void restarted_warning(void);
extern void retyped_warning(char *s);
extern void revalued_warning(char *s);
-extern __dead void syntax_error(int st_lineno, char *st_line, char *st_cptr) GCC_NORETURN;
-extern void terminal_lhs(int s_lineno);
-extern void terminal_start(char *s);
-extern void tokenized_start(char *s);
-extern void undefined_goal(char *s);
+extern void syntax_error(int st_lineno, char *st_line, char *st_cptr) GCC_NORETURN;
+extern void terminal_lhs(int s_lineno) GCC_NORETURN;
+extern void terminal_start(char *s) GCC_NORETURN;
+extern void tokenized_start(char *s) GCC_NORETURN;
+extern void undefined_goal(char *s) GCC_NORETURN;
extern void undefined_symbol_warning(char *s);
-extern void unexpected_EOF(void);
-extern void unknown_rhs(int i);
-extern void unterminated_action(int a_lineno, char *a_line, char *a_cptr);
-extern void unterminated_comment(int c_lineno, char *c_line, char *c_cptr);
-extern void unterminated_string(int s_lineno, char *s_line, char *s_cptr);
-extern void unterminated_text(int t_lineno, char *t_line, char *t_cptr);
-extern void unterminated_union(int u_lineno, char *u_line, char *u_cptr);
-extern void untyped_lhs(void);
-extern void untyped_rhs(int i, char *s);
-extern void used_reserved(char *s);
+extern void unexpected_EOF(void) GCC_NORETURN;
+extern void unknown_rhs(int i) GCC_NORETURN;
+extern void unterminated_action(int a_lineno, char *a_line, char *a_cptr) GCC_NORETURN;
+extern void unterminated_comment(int c_lineno, char *c_line, char *c_cptr) GCC_NORETURN;
+extern void unterminated_string(int s_lineno, char *s_line, char *s_cptr) GCC_NORETURN;
+extern void unterminated_text(int t_lineno, char *t_line, char *t_cptr) GCC_NORETURN;
+extern void unterminated_union(int u_lineno, char *u_line, char *u_cptr) GCC_NORETURN;
+extern void untyped_lhs(void) GCC_NORETURN;
+extern void untyped_rhs(int i, char *s) GCC_NORETURN;
+extern void used_reserved(char *s) GCC_NORETURN;
/* graph.c */
extern void graph(void);
@@ -403,7 +412,7 @@
extern void show_shifts(void);
/* main.c */
-extern char *allocate(size_t n);
+extern void *allocate(size_t n);
extern void done(int k) GCC_NORETURN;
/* mkpar.c */
@@ -417,7 +426,7 @@
extern void reader(void);
/* skeleton.c */
-extern void write_section(const char * const section[]);
+extern void write_section(FILE *fp, const char *const section[]);
/* verbose.c */
extern void verbose(void);
Index: src/external/bsd/byacc/dist/lalr.c
diff -u src/external/bsd/byacc/dist/lalr.c:1.4 src/external/bsd/byacc/dist/lalr.c:1.5
--- src/external/bsd/byacc/dist/lalr.c:1.4 Sat Dec 25 18:43:30 2010
+++ src/external/bsd/byacc/dist/lalr.c Sat Sep 10 17:29:04 2011
@@ -1,10 +1,10 @@
-/* $NetBSD: lalr.c,v 1.4 2010/12/25 23:43:30 christos Exp $ */
+/* $NetBSD: lalr.c,v 1.5 2011/09/10 21:29:04 christos Exp $ */
/* Id: lalr.c,v 1.9 2009/10/27 09:49:27 tom Exp */
#include "defs.h"
#include <sys/cdefs.h>
-__RCSID("$NetBSD: lalr.c,v 1.4 2010/12/25 23:43:30 christos Exp $");
+__RCSID("$NetBSD: lalr.c,v 1.5 2011/09/10 21:29:04 christos Exp $");
typedef struct shorts
{
Index: src/external/bsd/byacc/dist/error.c
diff -u src/external/bsd/byacc/dist/error.c:1.6 src/external/bsd/byacc/dist/error.c:1.7
--- src/external/bsd/byacc/dist/error.c:1.6 Sat Dec 25 18:43:30 2010
+++ src/external/bsd/byacc/dist/error.c Sat Sep 10 17:29:04 2011
@@ -1,10 +1,10 @@
-/* $NetBSD: error.c,v 1.6 2010/12/25 23:43:30 christos Exp $ */
-/* Id: error.c,v 1.8 2010/11/24 15:10:20 tom Exp */
+/* $NetBSD: error.c,v 1.7 2011/09/10 21:29:04 christos Exp $ */
+/* Id: error.c,v 1.9 2011/09/05 23:27:43 tom Exp */
#include "defs.h"
#include <sys/cdefs.h>
-__RCSID("$NetBSD: error.c,v 1.6 2010/12/25 23:43:30 christos Exp $");
+__RCSID("$NetBSD: error.c,v 1.7 2011/09/10 21:29:04 christos Exp $");
/* routines for printing error messages */
@@ -30,6 +30,14 @@
}
void
+missing_brace(void)
+{
+ fprintf(stderr, "%s: e - line %d of \"%s\", missing '}'\n",
+ myname, lineno, input_file_name);
+ done(1);
+}
+
+void
unexpected_EOF(void)
{
fprintf(stderr, "%s: e - line %d of \"%s\", unexpected end-of-file\n",
Index: src/external/bsd/byacc/dist/main.c
diff -u src/external/bsd/byacc/dist/main.c:1.6 src/external/bsd/byacc/dist/main.c:1.7
--- src/external/bsd/byacc/dist/main.c:1.6 Sat Dec 25 18:43:30 2010
+++ src/external/bsd/byacc/dist/main.c Sat Sep 10 17:29:04 2011
@@ -1,17 +1,45 @@
-/* $NetBSD: main.c,v 1.6 2010/12/25 23:43:30 christos Exp $ */
-/* Id: main.c,v 1.30 2010/11/24 15:13:39 tom Exp */
+/* $NetBSD: main.c,v 1.7 2011/09/10 21:29:04 christos Exp $ */
+/* Id: main.c,v 1.36 2011/09/06 22:44:45 tom Exp */
#include "defs.h"
#include <sys/cdefs.h>
-__RCSID("$NetBSD: main.c,v 1.6 2010/12/25 23:43:30 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.7 2011/09/10 21:29:04 christos Exp $");
#include <signal.h>
#include <unistd.h> /* for _exit() */
+#if defined(HAVE_ATEXIT)
+# ifdef HAVE_MKSTEMP
+# define USE_MKSTEMP 1
+# elif defined(HAVE_FCNTL_H)
+# define USE_MKSTEMP 1
+# include <fcntl.h> /* for open(), O_EXCL, etc. */
+# else
+# define USE_MKSTEMP 0
+# endif
+#else
+# define USE_MKSTEMP 0
+#endif
+
+#if USE_MKSTEMP
+#include <sys/types.h>
+#include <sys/stat.h>
+
+typedef struct _my_tmpfiles
+{
+ struct _my_tmpfiles *next;
+ char *name;
+}
+MY_TMPFILES;
+
+static MY_TMPFILES *my_tmpfiles;
+#endif /* USE_MKSTEMP */
+
char dflag;
char gflag;
+char iflag;
char lflag;
static char oflag;
char rflag;
@@ -32,7 +60,9 @@
char *code_file_name;
char *input_file_name = empty_string;
-static char *defines_file_name;
+char *defines_file_name;
+char *externs_file_name;
+
static char *graph_file_name;
static char *output_file_name;
static char *verbose_file_name;
@@ -41,6 +71,7 @@
/* with rules until the parser is written */
FILE *code_file; /* y.code.c (used when the -r option is specified) */
FILE *defines_file; /* y.tab.h */
+FILE *externs_file; /* y.tab.i */
FILE *input_file; /* the input file */
FILE *output_file; /* y.tab.c */
FILE *text_file; /* a temp file, used to save text until all */
@@ -111,6 +142,9 @@
if (dflag)
DO_FREE(defines_file_name);
+ if (iflag)
+ DO_FREE(externs_file_name);
+
if (oflag)
DO_FREE(output_file_name);
@@ -166,6 +200,7 @@
,"Options:"
," -b file_prefix set filename prefix (default \"y.\")"
," -d write definitions (y.tab.h)"
+ ," -i write interface (y.tab.i)"
," -g write a graphical description"
," -l suppress #line directives"
," -o output_file (default \"y.tab.c\")"
@@ -199,6 +234,10 @@
gflag = 1;
break;
+ case 'i':
+ iflag = 1;
+ break;
+
case 'l':
lflag = 1;
break;
@@ -314,10 +353,10 @@
input_file_name = argv[i];
}
-char *
+void *
allocate(size_t n)
{
- char *p;
+ void *p;
p = NULL;
if (n)
@@ -339,17 +378,22 @@
{
size_t len;
const char *defines_suffix;
+ const char *externs_suffix;
char *prefix;
prefix = NULL;
defines_suffix = DEFINES_SUFFIX;
+ externs_suffix = EXTERNS_SUFFIX;
/* compute the file_prefix from the user provided output_file_name */
if (output_file_name != 0)
{
if (!(prefix = strstr(output_file_name, ".tab.c"))
&& (prefix = strstr(output_file_name, ".c")))
+ {
defines_suffix = ".h";
+ externs_suffix = ".i";
+ }
}
if (prefix != NULL)
@@ -410,6 +454,11 @@
}
}
+ if (iflag)
+ {
+ CREATE_FILE_NAME(externs_file_name, externs_suffix);
+ }
+
if (vflag)
{
CREATE_FILE_NAME(verbose_file_name, VERBOSE_SUFFIX);
@@ -426,6 +475,134 @@
}
}
+#if USE_MKSTEMP
+static void
+close_tmpfiles(void)
+{
+ while (my_tmpfiles != 0)
+ {
+ MY_TMPFILES *next = my_tmpfiles->next;
+
+ chmod(my_tmpfiles->name, 0644);
+ unlink(my_tmpfiles->name);
+
+ free(my_tmpfiles->name);
+ free(my_tmpfiles);
+
+ my_tmpfiles = next;
+ }
+}
+
+#ifndef HAVE_MKSTEMP
+static int
+my_mkstemp(char *temp)
+{
+ int fd;
+ char *dname;
+ char *fname;
+ char *name;
+
+ /*
+ * Split-up to use tempnam, rather than tmpnam; the latter (like
+ * mkstemp) is unusable on Windows.
+ */
+ if ((fname = strrchr(temp, '/')) != 0)
+ {
+ dname = strdup(temp);
+ dname[++fname - temp] = '\0';
+ }
+ else
+ {
+ dname = 0;
+ fname = temp;
+ }
+ if ((name = tempnam(dname, fname)) != 0)
+ {
+ fd = open(name, O_CREAT | O_EXCL | O_RDWR);
+ strcpy(temp, name);
+ }
+ else
+ {
+ fd = -1;
+ }
+
+ if (dname != 0)
+ free(dname);
+
+ return fd;
+}
+#define mkstemp(s) my_mkstemp(s)
+#endif
+
+#endif
+
+/*
+ * tmpfile() should be adequate, except that it may require special privileges
+ * to use, e.g., MinGW and Windows 7 where it tries to use the root directory.
+ */
+static FILE *
+open_tmpfile(const char *label)
+{
+ FILE *result;
+#if USE_MKSTEMP
+ int fd;
+ const char *tmpdir;
+ char *name;
+ const char *mark;
+
+ if ((tmpdir = getenv("TMPDIR")) == 0 || access(tmpdir, W_OK) != 0)
+ {
+#ifdef P_tmpdir
+ tmpdir = P_tmpdir;
+#else
+ tmpdir = "/tmp";
+#endif
+ if (access(tmpdir, W_OK) != 0)
+ tmpdir = ".";
+ }
+
+ name = malloc(strlen(tmpdir) + 10 + strlen(label));
+
+ result = 0;
+ if (name != 0)
+ {
+ if ((mark = strrchr(label, '_')) == 0)
+ mark = label + strlen(label);
+
+ sprintf(name, "%s/%.*sXXXXXX", tmpdir, (int)(mark - label), label);
+ fd = mkstemp(name);
+ if (fd >= 0)
+ {
+ result = fdopen(fd, "w+");
+ if (result != 0)
+ {
+ MY_TMPFILES *item;
+
+ if (my_tmpfiles == 0)
+ {
+ atexit(close_tmpfiles);
+ }
+
+ item = NEW(MY_TMPFILES);
+ NO_SPACE(item);
+
+ item->name = name;
+ NO_SPACE(item->name);
+
+ item->next = my_tmpfiles;
+ my_tmpfiles = item;
+ }
+ }
+ }
+#else
+ result = tmpfile();
+#endif
+
+ if (result == 0)
+ open_error(label);
+ return result;
+}
+
static void
open_files(void)
{
@@ -438,13 +615,8 @@
open_error(input_file_name);
}
- action_file = tmpfile();
- if (action_file == 0)
- open_error("action_file");
-
- text_file = tmpfile();
- if (text_file == 0)
- open_error("text_file");
+ action_file = open_tmpfile("action_file");
+ text_file = open_tmpfile("text_file");
if (vflag)
{
@@ -475,9 +647,14 @@
defines_file = fopen(defines_file_name, "w");
if (defines_file == 0)
open_error(defines_file_name);
- union_file = tmpfile();
- if (union_file == 0)
- open_error("union_file");
+ union_file = open_tmpfile("union_file");
+ }
+
+ if (iflag)
+ {
+ externs_file = fopen(externs_file_name, "w");
+ if (externs_file == 0)
+ open_error(externs_file_name);
}
output_file = fopen(output_file_name, "w");
Index: src/external/bsd/byacc/dist/reader.c
diff -u src/external/bsd/byacc/dist/reader.c:1.6 src/external/bsd/byacc/dist/reader.c:1.7
--- src/external/bsd/byacc/dist/reader.c:1.6 Sat Dec 25 18:43:30 2010
+++ src/external/bsd/byacc/dist/reader.c Sat Sep 10 17:29:04 2011
@@ -1,10 +1,10 @@
-/* $NetBSD: reader.c,v 1.6 2010/12/25 23:43:30 christos Exp $ */
-/* Id: reader.c,v 1.31 2010/11/26 12:30:40 tom Exp */
+/* $NetBSD: reader.c,v 1.7 2011/09/10 21:29:04 christos Exp $ */
+/* Id: reader.c,v 1.33 2011/09/06 22:56:53 tom Exp */
#include "defs.h"
#include <sys/cdefs.h>
-__RCSID("$NetBSD: reader.c,v 1.6 2010/12/25 23:43:30 christos Exp $");
+__RCSID("$NetBSD: reader.c,v 1.7 2011/09/10 21:29:04 christos Exp $");
/* The line size must be a positive integer. One hundred was chosen */
/* because few lines in Yacc input grammars exceed 100 characters. */
@@ -694,6 +694,8 @@
for (i = 0; (c = *cptr++) != '}'; i++)
{
+ if (c == '\0')
+ missing_brace();
if (c == EOF)
unexpected_EOF();
buf[i] = (char)c;
@@ -2202,7 +2204,7 @@
void
reader(void)
{
- write_section(banner);
+ write_section(code_file, banner);
create_symbol_table();
read_declarations();
read_grammar();
Index: src/external/bsd/byacc/dist/output.c
diff -u src/external/bsd/byacc/dist/output.c:1.7 src/external/bsd/byacc/dist/output.c:1.8
--- src/external/bsd/byacc/dist/output.c:1.7 Sat Dec 25 18:43:30 2010
+++ src/external/bsd/byacc/dist/output.c Sat Sep 10 17:29:04 2011
@@ -1,10 +1,10 @@
-/* $NetBSD: output.c,v 1.7 2010/12/25 23:43:30 christos Exp $ */
-/* Id: output.c,v 1.37 2010/11/27 17:28:29 tom Exp */
+/* $NetBSD: output.c,v 1.8 2011/09/10 21:29:04 christos Exp $ */
+/* Id: output.c,v 1.41 2011/09/08 09:25:40 tom Exp */
#include "defs.h"
#include <sys/cdefs.h>
-__RCSID("$NetBSD: output.c,v 1.7 2010/12/25 23:43:30 christos Exp $");
+__RCSID("$NetBSD: output.c,v 1.8 2011/09/10 21:29:04 christos Exp $");
#define StaticOrR (rflag ? "" : "static ")
#define CountLine(fp) (!rflag || ((fp) == code_file))
@@ -26,33 +26,34 @@
static int high;
static void
-putc_code(int c)
+putc_code(FILE * fp, int c)
{
- if (c == '\n')
+ if ((c == '\n') && (fp == code_file))
++outline;
- putc(c, code_file);
+ putc(c, fp);
}
static void
-putl_code(const char *s)
+putl_code(FILE * fp, const char *s)
{
- ++outline;
- fputs(s, code_file);
+ if (fp == code_file)
+ ++outline;
+ fputs(s, fp);
}
static void
-puts_code(const char *s)
+puts_code(FILE * fp, const char *s)
{
- fputs(s, code_file);
+ fputs(s, fp);
}
static void
-write_code_lineno(void)
+write_code_lineno(FILE * fp)
{
- if (!lflag)
+ if (!lflag && (fp == code_file))
{
++outline;
- fprintf(code_file, line_format, outline, code_file_name);
+ fprintf(fp, line_format, outline, code_file_name);
}
}
@@ -822,7 +823,7 @@
}
static void
-output_defines(void)
+output_defines(FILE * fp)
{
int c, i;
char *s;
@@ -832,51 +833,48 @@
s = symbol_name[i];
if (is_C_identifier(s))
{
- puts_code("#define ");
- if (dflag)
- fprintf(defines_file, "#define ");
+ fprintf(fp, "#define ");
c = *s;
if (c == '"')
{
while ((c = *++s) != '"')
{
- putc(c, code_file);
- if (dflag)
- putc(c, defines_file);
+ putc(c, fp);
}
}
else
{
do
{
- putc(c, code_file);
- if (dflag)
- putc(c, defines_file);
+ putc(c, fp);
}
while ((c = *++s) != 0);
}
- ++outline;
- fprintf(code_file, " %d\n", symbol_value[i]);
- if (dflag)
- fprintf(defines_file, " %d\n", symbol_value[i]);
+ if (fp == code_file)
+ ++outline;
+ fprintf(fp, " %d\n", symbol_value[i]);
}
}
- ++outline;
- fprintf(code_file, "#define YYERRCODE %d\n", symbol_value[1]);
+ if (fp == code_file)
+ ++outline;
+ if (fp != defines_file || iflag)
+ fprintf(fp, "#define YYERRCODE %d\n", symbol_value[1]);
- if (dflag && unionized)
+ if (fp == defines_file || (iflag && !dflag))
{
- rewind(union_file);
- while ((c = getc(union_file)) != EOF)
- putc(c, defines_file);
- fprintf(defines_file, "extern YYSTYPE %slval;\n",
- symbol_prefix);
+ if (unionized)
+ {
+ rewind(union_file);
+ while ((c = getc(union_file)) != EOF)
+ putc(c, fp);
+ fprintf(fp, "extern YYSTYPE %slval;\n", symbol_prefix);
+ }
}
}
static void
-output_stored_text(void)
+output_stored_text(FILE * fp)
{
int c;
FILE *in;
@@ -887,12 +885,12 @@
in = text_file;
if ((c = getc(in)) == EOF)
return;
- putc_code(c);
+ putc_code(fp, c);
while ((c = getc(in)) != EOF)
{
- putc_code(c);
+ putc_code(fp, c);
}
- write_code_lineno();
+ write_code_lineno(fp);
}
static void
@@ -905,10 +903,10 @@
++outline;
fprintf(code_file, "#define YYFINAL %d\n", final_state);
- putl_code("#ifndef YYDEBUG\n");
+ putl_code(code_file, "#ifndef YYDEBUG\n");
++outline;
fprintf(code_file, "#define YYDEBUG %d\n", tflag);
- putl_code("#endif\n");
+ putl_code(code_file, "#endif\n");
if (rflag)
{
@@ -1116,26 +1114,25 @@
}
static void
-output_pure_parser(void)
+output_pure_parser(FILE * fp)
{
- putc_code('\n');
+ putc_code(fp, '\n');
- outline += 1;
- fprintf(code_file, "#define YYPURE %d\n", pure_parser);
-
- putc_code('\n');
+ if (fp == code_file)
+ outline += 1;
+ fprintf(fp, "#define YYPURE %d\n", pure_parser);
+ putc_code(fp, '\n');
}
static void
-output_stype(void)
+output_stype(FILE * fp)
{
if (!unionized && ntags == 0)
{
- putc_code('\n');
- putl_code("#ifndef YYSTYPE\n");
- putl_code("typedef int YYSTYPE;\n");
- putl_code("#endif\n");
- putc_code('\n');
+ putc_code(fp, '\n');
+ putl_code(fp, "#ifndef YYSTYPE\n");
+ putl_code(fp, "typedef int YYSTYPE;\n");
+ putl_code(fp, "#endif\n");
}
}
@@ -1156,7 +1153,7 @@
if ((c = getc(in)) == EOF)
return;
write_input_lineno();
- putc_code(c);
+ putc_code(code_file, c);
last = c;
}
else
@@ -1164,24 +1161,24 @@
write_input_lineno();
do
{
- putc_code(c);
+ putc_code(code_file, c);
}
while ((c = *++cptr) != '\n');
- putc_code(c);
+ putc_code(code_file, c);
last = '\n';
}
while ((c = getc(in)) != EOF)
{
- putc_code(c);
+ putc_code(code_file, c);
last = c;
}
if (last != '\n')
{
- putc_code('\n');
+ putc_code(code_file, '\n');
}
- write_code_lineno();
+ write_code_lineno(code_file);
}
static void
@@ -1194,135 +1191,136 @@
return;
last = c;
- putc_code(c);
+ putc_code(code_file, c);
while ((c = getc(action_file)) != EOF)
{
- putc_code(c);
+ putc_code(code_file, c);
last = c;
}
if (last != '\n')
{
- putc_code('\n');
+ putc_code(code_file, '\n');
}
- write_code_lineno();
+ write_code_lineno(code_file);
}
static void
-output_parse_decl(void)
+output_parse_decl(FILE * fp)
{
- putl_code("/* compatibility with bison */\n");
- putl_code("#ifdef YYPARSE_PARAM\n");
- putl_code("/* compatibility with FreeBSD */\n");
- putl_code("# ifdef YYPARSE_PARAM_TYPE\n");
- putl_code("# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)\n");
- putl_code("# else\n");
- putl_code("# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)\n");
- putl_code("# endif\n");
- putl_code("#else\n");
+ putl_code(fp, "\n");
+ putl_code(fp, "/* compatibility with bison */\n");
+ putl_code(fp, "#ifdef YYPARSE_PARAM\n");
+ putl_code(fp, "/* compatibility with FreeBSD */\n");
+ putl_code(fp, "# ifdef YYPARSE_PARAM_TYPE\n");
+ putl_code(fp,
+ "# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)\n");
+ putl_code(fp, "# else\n");
+ putl_code(fp, "# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)\n");
+ putl_code(fp, "# endif\n");
+ putl_code(fp, "#else\n");
- puts_code("# define YYPARSE_DECL() yyparse(");
+ puts_code(fp, "# define YYPARSE_DECL() yyparse(");
if (!parse_param)
- puts_code("void");
+ puts_code(fp, "void");
else
{
param *p;
for (p = parse_param; p; p = p->next)
- fprintf(code_file, "%s %s%s%s", p->type, p->name, p->type2,
+ fprintf(fp, "%s %s%s%s", p->type, p->name, p->type2,
p->next ? ", " : "");
}
- putl_code(")\n");
+ putl_code(fp, ")\n");
- putl_code("#endif\n");
- putl_code("\n");
+ putl_code(fp, "#endif\n");
}
static void
-output_lex_decl(void)
+output_lex_decl(FILE * fp)
{
- putl_code("/* Parameters sent to lex. */\n");
- putl_code("#ifdef YYLEX_PARAM\n");
+ putl_code(fp, "\n");
+ putl_code(fp, "/* Parameters sent to lex. */\n");
+ putl_code(fp, "#ifdef YYLEX_PARAM\n");
if (pure_parser)
{
- putl_code("# define YYLEX_DECL() yylex(YYSTYPE *yylval, "
+ putl_code(fp, "# define YYLEX_DECL() yylex(YYSTYPE *yylval, "
"void *YYLEX_PARAM)\n");
- putl_code("# define YYLEX yylex(&yylval, YYLEX_PARAM)\n");
+ putl_code(fp, "# define YYLEX yylex(&yylval, YYLEX_PARAM)\n");
}
else
{
- putl_code("# define YYLEX_DECL() yylex(void *YYLEX_PARAM)\n");
- putl_code("# define YYLEX yylex(YYLEX_PARAM)\n");
+ putl_code(fp, "# define YYLEX_DECL() yylex(void *YYLEX_PARAM)\n");
+ putl_code(fp, "# define YYLEX yylex(YYLEX_PARAM)\n");
}
- putl_code("#else\n");
+ putl_code(fp, "#else\n");
if (pure_parser && lex_param)
{
param *p;
- puts_code("# define YYLEX_DECL() yylex(YYSTYPE *yylval, ");
+ puts_code(fp, "# define YYLEX_DECL() yylex(YYSTYPE *yylval, ");
for (p = lex_param; p; p = p->next)
- fprintf(code_file, "%s %s%s%s", p->type, p->name, p->type2,
+ fprintf(fp, "%s %s%s%s", p->type, p->name, p->type2,
p->next ? ", " : "");
- putl_code(")\n");
+ putl_code(fp, ")\n");
- puts_code("# define YYLEX yylex(&yylval, ");
+ puts_code(fp, "# define YYLEX yylex(&yylval, ");
for (p = lex_param; p; p = p->next)
- fprintf(code_file, "%s%s", p->name, p->next ? ", " : "");
- putl_code(")\n");
+ fprintf(fp, "%s%s", p->name, p->next ? ", " : "");
+ putl_code(fp, ")\n");
}
else if (pure_parser)
{
- putl_code("# define YYLEX_DECL() yylex(YYSTYPE *yylval)\n");
- putl_code("# define YYLEX yylex(&yylval)\n");
+ putl_code(fp, "# define YYLEX_DECL() yylex(YYSTYPE *yylval)\n");
+ putl_code(fp, "# define YYLEX yylex(&yylval)\n");
}
else if (lex_param)
{
param *p;
- puts_code("# define YYLEX_DECL() yylex(");
+ puts_code(fp, "# define YYLEX_DECL() yylex(");
for (p = lex_param; p; p = p->next)
- fprintf(code_file, "%s %s%s%s", p->type, p->name, p->type2,
+ fprintf(fp, "%s %s%s%s", p->type, p->name, p->type2,
p->next ? ", " : "");
- putl_code(")\n");
+ putl_code(fp, ")\n");
- puts_code("# define YYLEX yylex(");
+ puts_code(fp, "# define YYLEX yylex(");
for (p = lex_param; p; p = p->next)
- fprintf(code_file, "%s%s", p->name, p->next ? ", " : "");
- putl_code(")\n");
+ fprintf(fp, "%s%s", p->name, p->next ? ", " : "");
+ putl_code(fp, ")\n");
}
else
{
- putl_code("# define YYLEX_DECL() yylex(void)\n");
- putl_code("# define YYLEX yylex()\n");
+ putl_code(fp, "# define YYLEX_DECL() yylex(void)\n");
+ putl_code(fp, "# define YYLEX yylex()\n");
}
- putl_code("#endif\n");
- putl_code("\n");
+ putl_code(fp, "#endif\n");
}
static void
-output_error_decl(void)
+output_error_decl(FILE * fp)
{
- putl_code("/* Parameters sent to yyerror. */\n");
+ putl_code(fp, "\n");
+ putl_code(fp, "/* Parameters sent to yyerror. */\n");
if (parse_param)
{
param *p;
- putl_code("#define YYERROR_DECL() yyerror(");
+ fprintf(fp, "#define YYERROR_DECL() yyerror(");
for (p = parse_param; p; p = p->next)
- fprintf(code_file, "%s %s%s, ", p->type, p->name, p->type2);
- putl_code("const char *s)\n");
+ fprintf(fp, "%s %s%s, ", p->type, p->name, p->type2);
+ putl_code(fp, "const char *s)\n");
- puts_code("#define YYERROR_CALL(msg) yyerror(");
+ puts_code(fp, "#define YYERROR_CALL(msg) yyerror(");
for (p = parse_param; p; p = p->next)
- fprintf(code_file, "%s, ", p->name);
+ fprintf(fp, "%s, ", p->name);
- putl_code("msg)\n");
+ putl_code(fp, "msg)\n");
}
else
{
- putl_code("#define YYERROR_DECL() yyerror(const char *s)\n");
- putl_code("#define YYERROR_CALL(msg) yyerror(msg)\n");
+ putl_code(fp, "#define YYERROR_DECL() yyerror(const char *s)\n");
+ putl_code(fp, "#define YYERROR_CALL(msg) yyerror(msg)\n");
}
- putl_code("\n");
}
static void
@@ -1367,33 +1365,92 @@
static void
output_yyerror_call(const char *msg)
{
- puts_code(" yyerror(");
+ FILE *fp = code_file;
+
+ puts_code(fp, " yyerror(");
if (parse_param)
{
param *p;
for (p = parse_param; p; p = p->next)
- fprintf(code_file, "%s, ", p->name);
+ fprintf(fp, "%s, ", p->name);
+ }
+ puts_code(fp, "\"");
+ puts_code(fp, msg);
+ putl_code(fp, "\");\n");
+}
+
+static void
+output_externs(FILE * fp, const char *const section[])
+{
+ int c;
+ int i;
+ const char *s;
+
+ for (i = 0; (s = section[i]) != 0; ++i)
+ {
+ if (*s && *s != '#')
+ fputs("extern\t", fp);
+ while ((c = *s) != 0)
+ {
+ putc(c, fp);
+ ++s;
+ }
+ if (fp == code_file)
+ ++outline;
+ putc('\n', fp);
}
- puts_code("\"");
- puts_code(msg);
- putl_code("\");\n");
}
void
output(void)
{
+ FILE *fp;
+
free_itemsets();
free_shifts();
free_reductions();
- output_prefix(output_file);
- output_pure_parser();
- output_stored_text();
- output_stype();
- output_parse_decl();
- output_lex_decl();
- output_error_decl();
- write_section(xdecls);
- output_defines();
+
+ if (iflag)
+ {
+ ++outline;
+ fprintf(code_file, "#include \"%s\"\n", externs_file_name);
+ fp = externs_file;
+ }
+ else
+ fp = code_file;
+
+ output_prefix(iflag ? externs_file : output_file);
+ output_pure_parser(fp);
+ output_stored_text(fp);
+ output_stype(fp);
+ output_parse_decl(fp);
+ output_lex_decl(fp);
+ output_error_decl(fp);
+ write_section(fp, xdecls);
+
+ if (iflag)
+ {
+ output_externs(externs_file, global_vars);
+ if (!pure_parser)
+ output_externs(externs_file, impure_vars);
+ }
+
+ if (iflag)
+ {
+ ++outline;
+ fprintf(code_file, "#include \"%s\"\n", defines_file_name);
+ if (!dflag)
+ output_defines(externs_file);
+ }
+ else
+ {
+ putc_code(code_file, '\n');
+ output_defines(code_file);
+ }
+
+ if (dflag)
+ output_defines(defines_file);
+
output_rule_data();
output_yydefred();
output_actions();
@@ -1402,27 +1459,32 @@
if (rflag)
{
output_prefix(code_file);
- write_section(xdecls);
- write_section(tables);
+ write_section(code_file, xdecls);
+ write_section(code_file, tables);
+ }
+ write_section(code_file, global_vars);
+ if (!pure_parser)
+ {
+ write_section(code_file, impure_vars);
}
- write_section(hdr_defs);
+ write_section(code_file, hdr_defs);
if (!pure_parser)
{
- write_section(hdr_vars);
+ write_section(code_file, hdr_vars);
}
output_trailing_text();
- write_section(body_1);
+ write_section(code_file, body_1);
if (pure_parser)
{
- write_section(body_vars);
+ write_section(code_file, body_vars);
}
- write_section(body_2);
+ write_section(code_file, body_2);
output_yyerror_call("syntax error");
- write_section(body_3);
+ write_section(code_file, body_3);
output_semantic_actions();
- write_section(trailer);
+ write_section(code_file, trailer);
output_yyerror_call("yacc stack overflow");
- write_section(trailer_2);
+ write_section(code_file, trailer_2);
}
#ifdef NO_LEAKS
Index: src/external/bsd/byacc/dist/skeleton.c
diff -u src/external/bsd/byacc/dist/skeleton.c:1.9 src/external/bsd/byacc/dist/skeleton.c:1.10
--- src/external/bsd/byacc/dist/skeleton.c:1.9 Sat Dec 25 18:43:30 2010
+++ src/external/bsd/byacc/dist/skeleton.c Sat Sep 10 17:29:04 2011
@@ -1,10 +1,10 @@
-/* $NetBSD: skeleton.c,v 1.9 2010/12/25 23:43:30 christos Exp $ */
-/* Id: skeleton.c,v 1.27 2010/11/26 17:24:00 tom Exp */
+/* $NetBSD: skeleton.c,v 1.10 2011/09/10 21:29:04 christos Exp $ */
+/* Id: skeleton.c,v 1.31 2011/09/07 09:37:59 tom Exp */
#include "defs.h"
#include <sys/cdefs.h>
-__RCSID("$NetBSD: skeleton.c,v 1.9 2010/12/25 23:43:30 christos Exp $");
+__RCSID("$NetBSD: skeleton.c,v 1.10 2011/09/10 21:29:04 christos Exp $");
/* The definition of yysccsid in the banner should be replaced with */
/* a #pragma ident directive if the target C compiler supports */
@@ -18,7 +18,7 @@
/* the body either are not useful outside of semantic actions or */
/* are conditional. */
-const char * const banner[] =
+const char *const banner[] =
{
"#ifndef lint",
"static const char yysccsid[] = \"@(#)yaccpar 1.9 (Berkeley) 02/21/93\";",
@@ -45,8 +45,9 @@
0
};
-const char * const xdecls[] =
+const char *const xdecls[] =
{
+ "",
"extern int YYPARSE_DECL();",
#ifdef notdef
"extern int YYLEX_DECL();",
@@ -55,7 +56,7 @@
0
};
-const char * const tables[] =
+const char *const tables[] =
{
"extern short yylhs[];",
"extern short yylen[];",
@@ -74,8 +75,27 @@
0
};
-const char * const hdr_defs[] =
+const char *const global_vars[] =
+{
+ "",
+ "int yydebug;",
+ "int yynerrs;",
+ 0
+};
+
+const char *const impure_vars[] =
+{
+ "",
+ "int yyerrflag;",
+ "int yychar;",
+ "YYSTYPE yyval;",
+ "YYSTYPE yylval;",
+ 0
+};
+
+const char *const hdr_defs[] =
{
+ "",
"/* define the initial stack-sizes */",
"#ifdef YYSTACKSIZE",
"#undef YYMAXDEPTH",
@@ -91,9 +111,6 @@
"",
"#define YYINITSTACKSIZE 500",
"",
- "int yydebug;",
- "int yynerrs;",
- "",
"typedef struct {",
" unsigned stacksize;",
" short *s_base;",
@@ -105,19 +122,14 @@
0
};
-const char * const hdr_vars[] =
+const char *const hdr_vars[] =
{
- "int yyerrflag;",
- "int yychar;",
- "YYSTYPE yyval;",
- "YYSTYPE yylval;",
- "",
"/* variables for the parser stack */",
"static YYSTACKDATA yystack;",
0
};
-const char * const body_vars[] =
+const char *const body_vars[] =
{
" int yyerrflag;",
" int yychar;",
@@ -129,7 +141,7 @@
0
};
-const char * const body_1[] =
+const char *const body_1[] =
{
"",
"#if YYDEBUG",
@@ -155,18 +167,14 @@
" newsize = YYMAXDEPTH;",
"",
" i = data->s_mark - data->s_base;",
- " newss = (data->s_base != 0)",
- " ? (short *)realloc(data->s_base, newsize * sizeof(*newss))",
- " : (short *)malloc(newsize * sizeof(*newss));",
+ " newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));",
" if (newss == 0)",
" return -1;",
"",
" data->s_base = newss;",
" data->s_mark = newss + i;",
"",
- " newvs = (data->l_base != 0)",
- " ? (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs))",
- " : (YYSTYPE *)malloc(newsize * sizeof(*newvs));",
+ " newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));",
" if (newvs == 0)",
" return -1;",
"",
@@ -200,7 +208,7 @@
0
};
-const char * const body_2[] =
+const char *const body_2[] =
{
" int yym, yyn, yystate;",
"#if YYDEBUG",
@@ -275,7 +283,7 @@
0
};
-const char * const body_3[] =
+const char *const body_3[] =
{
"",
" goto yyerrlab;",
@@ -354,7 +362,7 @@
0
};
-const char * const trailer[] =
+const char *const trailer[] =
{
" }",
" yystack.s_mark -= yym;",
@@ -410,7 +418,7 @@
0
};
-const char * const trailer_2[] =
+const char *const trailer_2[] =
{
"",
"yyabort:",
@@ -425,22 +433,21 @@
};
void
-write_section(const char * const section[])
+write_section(FILE * fp, const char *const section[])
{
int c;
int i;
const char *s;
- FILE *f;
- f = code_file;
for (i = 0; (s = section[i]) != 0; ++i)
{
- ++outline;
while ((c = *s) != 0)
{
- putc(c, f);
+ putc(c, fp);
++s;
}
- putc('\n', f);
+ if (fp == code_file)
+ ++outline;
+ putc('\n', fp);
}
}
Index: src/external/bsd/byacc/dist/yacc.1
diff -u src/external/bsd/byacc/dist/yacc.1:1.3 src/external/bsd/byacc/dist/yacc.1:1.4
--- src/external/bsd/byacc/dist/yacc.1:1.3 Thu Dec 23 21:58:21 2010
+++ src/external/bsd/byacc/dist/yacc.1 Sat Sep 10 17:29:04 2011
@@ -1,14 +1,14 @@
-.\" $NetBSD: yacc.1,v 1.3 2010/12/24 02:58:21 christos Exp $
+.\" $NetBSD: yacc.1,v 1.4 2011/09/10 21:29:04 christos Exp $
.\"
-.\" Id: yacc.1,v 1.11 2010/11/26 16:27:11 tom Exp
+.\" Id: yacc.1,v 1.12 2011/09/08 00:40:44 tom Exp
.\"
.\" .TH YACC 1 "July\ 15,\ 1990"
.\" .UC 6
-.TH YACC 1 "November 26, 2010" "Berkeley Yacc" "User Commands"
+.TH YACC 1 "September 7, 2011" "Berkeley Yacc" "User Commands"
.SH NAME
Yacc \- an LALR(1) parser generator
.SH SYNOPSIS
-.B yacc [ -dglrtv ] [ \-b
+.B yacc [ -dgilrtv ] [ \-b
.I file_prefix
.B ] [ \-p
.I symbol_prefix
@@ -38,17 +38,32 @@
.TP
.B \-d
The \fB-d\fR option causes the header file
-.IR y.tab.h
+.BR y.tab.h
to be written.
+It contains #define's for the token identifiers.
.TP
.B \-g
The
.B \-g
option causes a graphical description of the generated LALR(1) parser to
be written to the file
-.IR y.dot
+.BR y.dot
in graphviz format, ready to be processed by dot(1).
.TP
+.B \-i
+The \fB-i\fR option causes a supplementary header file
+.BR y.tab.i
+to be written.
+It contains extern declarations
+and supplementary #define's as needed to map the conventional \fIyacc\fP
+\fByy\fP-prefixed names to whatever the \fB-p\fP option may specify.
+The code file, e.g., \fBy.tab.c\fP is modified to #include this file
+as well as the \fBy.tab.h\fP file, enforcing consistent usage of the
+symbols defined in those files.
+.IP
+The supplementary header file makes it simpler to separate compilation
+of lex- and yacc-files.
+.TP
.B \-l
If the
.B \-l
@@ -75,7 +90,7 @@
the string denoted by
.IR symbol_prefix.
The default prefix is the string
-.IR yy.
+.BR yy.
.TP
.B \-P
create a reentrant parser, e.g., "%pure-parser".
Index: src/external/bsd/byacc/dist/test/error.tab.c
diff -u src/external/bsd/byacc/dist/test/error.tab.c:1.3 src/external/bsd/byacc/dist/test/error.tab.c:1.4
--- src/external/bsd/byacc/dist/test/error.tab.c:1.3 Thu Dec 23 21:58:21 2010
+++ src/external/bsd/byacc/dist/test/error.tab.c Sat Sep 10 17:29:04 2011
@@ -1,8 +1,8 @@
-/* $NetBSD: error.tab.c,v 1.3 2010/12/24 02:58:21 christos Exp $ */
+/* $NetBSD: error.tab.c,v 1.4 2011/09/10 21:29:04 christos Exp $ */
#ifndef lint
/* static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; */
-static char rcsid[] = "$NetBSD: error.tab.c,v 1.3 2010/12/24 02:58:21 christos Exp $";
+static char rcsid[] = "$NetBSD: error.tab.c,v 1.4 2011/09/10 21:29:04 christos Exp $";
#endif
#define YYBYACC 1
@@ -129,7 +129,6 @@
#define YYERROR_CALL(msg) yyerror(msg)
extern int YYPARSE_DECL();
-extern int YYLEX_DECL();
#define YYERRCODE 256
static const short error_lhs[] = { -1,
@@ -172,6 +171,15 @@
};
#endif
+
+int yydebug;
+int yynerrs;
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
@@ -187,9 +195,6 @@
#define YYINITSTACKSIZE 500
-int yydebug;
-int yynerrs;
-
typedef struct {
unsigned stacksize;
short *s_base;
@@ -198,17 +203,17 @@
YYSTYPE *l_base;
YYSTYPE *l_mark;
} YYSTACKDATA;
-int yyerrflag;
-int yychar;
-YYSTYPE yyval;
-YYSTYPE yylval;
-
/* variables for the parser stack */
static YYSTACKDATA yystack;
#line 4 "error.y"
#include <stdio.h>
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
int
main(void)
{
@@ -227,7 +232,7 @@
{
printf("%s\n", s);
}
-#line 228 "error.tab.c"
+#line 233 "error.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -252,18 +257,14 @@
newsize = YYMAXDEPTH;
i = data->s_mark - data->s_base;
- newss = (data->s_base != 0)
- ? (short *)realloc(data->s_base, newsize * sizeof(*newss))
- : (short *)malloc(newsize * sizeof(*newss));
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;
data->s_base = newss;
data->s_mark = newss + i;
- newvs = (data->l_base != 0)
- ? (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs))
- : (YYSTYPE *)malloc(newsize * sizeof(*newvs));
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
if (newvs == 0)
return -1;
Index: src/external/bsd/byacc/dist/test/ftp.tab.c
diff -u src/external/bsd/byacc/dist/test/ftp.tab.c:1.3 src/external/bsd/byacc/dist/test/ftp.tab.c:1.4
--- src/external/bsd/byacc/dist/test/ftp.tab.c:1.3 Thu Dec 23 21:58:21 2010
+++ src/external/bsd/byacc/dist/test/ftp.tab.c Sat Sep 10 17:29:04 2011
@@ -1,8 +1,8 @@
-/* $NetBSD: ftp.tab.c,v 1.3 2010/12/24 02:58:21 christos Exp $ */
+/* $NetBSD: ftp.tab.c,v 1.4 2011/09/10 21:29:04 christos Exp $ */
#ifndef lint
/* static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; */
-static char rcsid[] = "$NetBSD: ftp.tab.c,v 1.3 2010/12/24 02:58:21 christos Exp $";
+static char rcsid[] = "$NetBSD: ftp.tab.c,v 1.4 2011/09/10 21:29:04 christos Exp $";
#endif
#define YYBYACC 1
@@ -211,7 +211,6 @@
#define YYERROR_CALL(msg) yyerror(msg)
extern int YYPARSE_DECL();
-extern int YYLEX_DECL();
#define A 257
#define B 258
@@ -513,6 +512,15 @@
};
#endif
+
+int yydebug;
+int yynerrs;
+
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
+
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
@@ -528,9 +536,6 @@
#define YYINITSTACKSIZE 500
-int yydebug;
-int yynerrs;
-
typedef struct {
unsigned stacksize;
short *s_base;
@@ -539,14 +544,14 @@
YYSTYPE *l_base;
YYSTYPE *l_mark;
} YYSTACKDATA;
-int yyerrflag;
-int yychar;
-YYSTYPE yyval;
-YYSTYPE yylval;
-
/* variables for the parser stack */
static YYSTACKDATA yystack;
-#line 688 "ftp.y"
+#line 689 "ftp.y"
+
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
extern jmp_buf errcatch;
@@ -1037,7 +1042,11 @@
(stbuf.st_mode&S_IFMT) != S_IFREG)
reply(550, "%s: not a plain file.", filename);
else
+#ifdef HAVE_LONG_LONG
+ reply(213, "%llu", (long long) stbuf.st_size);
+#else
reply(213, "%lu", stbuf.st_size);
+#endif
break;}
case TYPE_A: {
FILE *fin;
@@ -1069,7 +1078,7 @@
reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]);
}
}
-#line 1070 "ftp.tab.c"
+#line 1079 "ftp.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -1094,18 +1103,14 @@
newsize = YYMAXDEPTH;
i = data->s_mark - data->s_base;
- newss = (data->s_base != 0)
- ? (short *)realloc(data->s_base, newsize * sizeof(*newss))
- : (short *)malloc(newsize * sizeof(*newss));
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;
data->s_base = newss;
data->s_mark = newss + i;
- newvs = (data->l_base != 0)
- ? (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs))
- : (YYSTYPE *)malloc(newsize * sizeof(*newvs));
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
if (newvs == 0)
return -1;
@@ -1430,7 +1435,7 @@
case 17:
#line 255 "ftp.y"
{
- if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
+ if (yystack.l_mark[-3] && yystack.l_mark[-1] != 0)
send_file_list((char *) yystack.l_mark[-1]);
if (yystack.l_mark[-1] != 0)
free((char *) yystack.l_mark[-1]);
@@ -1700,8 +1705,9 @@
register struct tm *t;
t = gmtime(&stbuf.st_mtime);
reply(213,
- "19%02d%02d%02d%02d%02d%02d",
- t->tm_year, t->tm_mon+1, t->tm_mday,
+ "%04d%02d%02d%02d%02d%02d",
+ 1900 + t->tm_year,
+ t->tm_mon+1, t->tm_mday,
t->tm_hour, t->tm_min, t->tm_sec);
}
}
@@ -1710,20 +1716,20 @@
}
break;
case 45:
-#line 499 "ftp.y"
+#line 500 "ftp.y"
{
reply(221, "Goodbye.");
dologout(0);
}
break;
case 46:
-#line 504 "ftp.y"
+#line 505 "ftp.y"
{
yyerrok;
}
break;
case 47:
-#line 509 "ftp.y"
+#line 510 "ftp.y"
{
if (yystack.l_mark[-3] && yystack.l_mark[-1]) {
fromname = renamefrom((char *) yystack.l_mark[-1]);
@@ -1734,13 +1740,13 @@
}
break;
case 49:
-#line 523 "ftp.y"
+#line 524 "ftp.y"
{
*(const char **)(&(yyval)) = "";
}
break;
case 52:
-#line 534 "ftp.y"
+#line 535 "ftp.y"
{
register char *a, *p;
@@ -1752,116 +1758,116 @@
}
break;
case 53:
-#line 546 "ftp.y"
+#line 547 "ftp.y"
{
yyval = FORM_N;
}
break;
case 54:
-#line 550 "ftp.y"
+#line 551 "ftp.y"
{
yyval = FORM_T;
}
break;
case 55:
-#line 554 "ftp.y"
+#line 555 "ftp.y"
{
yyval = FORM_C;
}
break;
case 56:
-#line 560 "ftp.y"
+#line 561 "ftp.y"
{
cmd_type = TYPE_A;
cmd_form = FORM_N;
}
break;
case 57:
-#line 565 "ftp.y"
+#line 566 "ftp.y"
{
cmd_type = TYPE_A;
cmd_form = yystack.l_mark[0];
}
break;
case 58:
-#line 570 "ftp.y"
+#line 571 "ftp.y"
{
cmd_type = TYPE_E;
cmd_form = FORM_N;
}
break;
case 59:
-#line 575 "ftp.y"
+#line 576 "ftp.y"
{
cmd_type = TYPE_E;
cmd_form = yystack.l_mark[0];
}
break;
case 60:
-#line 580 "ftp.y"
+#line 581 "ftp.y"
{
cmd_type = TYPE_I;
}
break;
case 61:
-#line 584 "ftp.y"
+#line 585 "ftp.y"
{
cmd_type = TYPE_L;
cmd_bytesz = NBBY;
}
break;
case 62:
-#line 589 "ftp.y"
+#line 590 "ftp.y"
{
cmd_type = TYPE_L;
cmd_bytesz = yystack.l_mark[0];
}
break;
case 63:
-#line 595 "ftp.y"
+#line 596 "ftp.y"
{
cmd_type = TYPE_L;
cmd_bytesz = yystack.l_mark[0];
}
break;
case 64:
-#line 602 "ftp.y"
+#line 603 "ftp.y"
{
yyval = STRU_F;
}
break;
case 65:
-#line 606 "ftp.y"
+#line 607 "ftp.y"
{
yyval = STRU_R;
}
break;
case 66:
-#line 610 "ftp.y"
+#line 611 "ftp.y"
{
yyval = STRU_P;
}
break;
case 67:
-#line 616 "ftp.y"
+#line 617 "ftp.y"
{
yyval = MODE_S;
}
break;
case 68:
-#line 620 "ftp.y"
+#line 621 "ftp.y"
{
yyval = MODE_B;
}
break;
case 69:
-#line 624 "ftp.y"
+#line 625 "ftp.y"
{
yyval = MODE_C;
}
break;
case 70:
-#line 630 "ftp.y"
+#line 631 "ftp.y"
{
/*
* Problem: this production is used for all pathname
@@ -1880,7 +1886,7 @@
}
break;
case 72:
-#line 652 "ftp.y"
+#line 653 "ftp.y"
{
register int ret, dec, multby, digit;
@@ -1905,7 +1911,7 @@
}
break;
case 73:
-#line 677 "ftp.y"
+#line 678 "ftp.y"
{
if (logged_in)
yyval = 1;
@@ -1915,7 +1921,7 @@
}
}
break;
-#line 1916 "ftp.tab.c"
+#line 1922 "ftp.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
Index: src/external/bsd/byacc/dist/test/ftp.y
diff -u src/external/bsd/byacc/dist/test/ftp.y:1.3 src/external/bsd/byacc/dist/test/ftp.y:1.4
--- src/external/bsd/byacc/dist/test/ftp.y:1.3 Thu Dec 23 21:58:21 2010
+++ src/external/bsd/byacc/dist/test/ftp.y Sat Sep 10 17:29:04 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: ftp.y,v 1.3 2010/12/24 02:58:21 christos Exp $ */
+/* $NetBSD: ftp.y,v 1.4 2011/09/10 21:29:04 christos Exp $ */
/*
* Copyright (c) 1985, 1988 Regents of the University of California.
@@ -17,7 +17,7 @@
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* from: @(#)ftpcmd.y 5.20.1.1 (Berkeley) 3/2/89
- * $NetBSD: ftp.y,v 1.3 2010/12/24 02:58:21 christos Exp $
+ * $NetBSD: ftp.y,v 1.4 2011/09/10 21:29:04 christos Exp $
*/
/*
@@ -29,7 +29,7 @@
#ifndef lint
static char sccsid[] = "@(#)ftpcmd.y 5.20.1.1 (Berkeley) 3/2/89";
-static char rcsid[] = "$NetBSD: ftp.y,v 1.3 2010/12/24 02:58:21 christos Exp $";
+static char rcsid[] = "$NetBSD: ftp.y,v 1.4 2011/09/10 21:29:04 christos Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -259,7 +259,7 @@
}
| NLST check_login SP STRING CRLF
= {
- if ($2 && $4 != 0)
+ if ($2 && $4 != 0)
send_file_list((char *) $4);
if ($4 != 0)
free((char *) $4);
@@ -522,7 +522,7 @@
}
}
;
-
+
username: STRING
;
@@ -536,7 +536,7 @@
byte_size: NUMBER
;
-host_port: NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA
+host_port: NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA
NUMBER COMMA NUMBER
= {
register char *a, *p;
@@ -693,6 +693,11 @@
%%
+#ifdef YYBYACC
+extern int YYLEX_DECL();
+static void YYERROR_DECL();
+#endif
+
extern jmp_buf errcatch;
static void upper(char *);
@@ -1182,7 +1187,11 @@
(stbuf.st_mode&S_IFMT) != S_IFREG)
reply(550, "%s: not a plain file.", filename);
else
- reply(213, "%llu", (long long)stbuf.st_size);
+#ifdef HAVE_LONG_LONG
+ reply(213, "%llu", (long long) stbuf.st_size);
+#else
+ reply(213, "%lu", stbuf.st_size);
+#endif
break;}
case TYPE_A: {
FILE *fin;
Index: src/external/bsd/byacc/dist/test/error.tab.h
diff -u src/external/bsd/byacc/dist/test/error.tab.h:1.2 src/external/bsd/byacc/dist/test/error.tab.h:1.3
--- src/external/bsd/byacc/dist/test/error.tab.h:1.2 Wed Oct 28 20:56:20 2009
+++ src/external/bsd/byacc/dist/test/error.tab.h Sat Sep 10 17:29:04 2011
@@ -1,2 +1 @@
-/* $NetBSD: error.tab.h,v 1.2 2009/10/29 00:56:20 christos Exp $ */
-
+/* $NetBSD: error.tab.h,v 1.3 2011/09/10 21:29:04 christos Exp $ */
Index: src/external/bsd/byacc/dist/test/ftp.tab.h
diff -u src/external/bsd/byacc/dist/test/ftp.tab.h:1.2 src/external/bsd/byacc/dist/test/ftp.tab.h:1.3
--- src/external/bsd/byacc/dist/test/ftp.tab.h:1.2 Wed Oct 28 20:56:20 2009
+++ src/external/bsd/byacc/dist/test/ftp.tab.h Sat Sep 10 17:29:04 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: ftp.tab.h,v 1.2 2009/10/29 00:56:20 christos Exp $ */
+/* $NetBSD: ftp.tab.h,v 1.3 2011/09/10 21:29:04 christos Exp $ */
#define A 257
#define B 258