diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-05-14 16:08:34 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-05-14 16:08:34 +0000 |
commit | 8cbaa44e2f1b80dd8954a0e06e0bc8a52494237f (patch) | |
tree | acb81d52eed9a1e4f72a02b251b4bfb76691ef25 /src/lex.l | |
parent | 045ec749566683e9a4471a81901b7a3f37066376 (diff) | |
download | gdbm-8cbaa44e2f1b80dd8954a0e06e0bc8a52494237f.tar.gz gdbm-8cbaa44e2f1b80dd8954a0e06e0bc8a52494237f.tar.bz2 |
Change variable support.
* src/util.c: New file.
* src/Makefile.am: Add new files.
* src/gdbmtool.c (open_mode): New variable.
(terror): Remove.
(mkfilename, tildexpand): Move to util.c
(opendb): Use open_mode.
(import_handler): Likewise.
(optab): New option -N (--norc).
* src/gdbmtool.h (vparse_error): Rename to vlerror.
(parse_error): Rename to lerror.
(syntax_error): Rename tp terror.
All uses updated.
(VAR_ERR_FAILURE): Remove.
(VAR_ERR_BADVALUE): New error code.
(variable_mode_name): Remove.
(mkfilename, tildexpand)
(vgetyn, getyn): New protos.
* src/lex.l (initialized): New static.
(setsource): Set initialized.
(vlerror): Print locus only if the lexer has been
initialized.
* src/var.c: Rewrite.
Diffstat (limited to 'src/lex.l')
-rw-r--r-- | src/lex.l | 23 |
1 files changed, 13 insertions, 10 deletions
@@ -74,7 +74,8 @@ static struct context *context_tos; static ino_t ino; static dev_t dev; int interactive; /* Are we running in interactive mode? */ - +static int initialized; + static void context_push () { @@ -144,28 +145,28 @@ setsource (const char *name, int intr) { if (stat (name, &st)) { - syntax_error (_("cannot open `%s': %s"), name, strerror (errno)); + terror (_("cannot open `%s': %s"), name, strerror (errno)); return -1; } else if (!S_ISREG (st.st_mode)) { - syntax_error (_("%s is not a regular file"), name); + terror (_("%s is not a regular file"), name); return -1; } cp = findctx (&st); if (cp) { - syntax_error (_("recursive sourcing")); + terror (_("recursive sourcing")); if (cp->parent) - parse_error (&cp->locus, _("%s already sourced here"), name); + lerror (&cp->locus, _("%s already sourced here"), name); return 1; } fp = fopen (name, "r"); if (!fp) { - syntax_error (_("cannot open %s for reading: %s"), name, + terror (_("cannot open %s for reading: %s"), name, strerror (errno)); return 1; } @@ -185,6 +186,8 @@ setsource (const char *name, int intr) point.line = 1; point.col = 0; + initialized = 1; + return 0; } %} @@ -419,11 +422,11 @@ escape (int c) } void -vparse_error (struct locus *loc, const char *fmt, va_list ap) +vlerror (struct locus *loc, const char *fmt, va_list ap) { if (!interactive) fprintf (stderr, "%s: ", progname); - if (loc) + if (initialized && loc && loc->beg.file) { YY_LOCATION_PRINT (stderr, *loc); fprintf (stderr, ": "); @@ -433,12 +436,12 @@ vparse_error (struct locus *loc, const char *fmt, va_list ap) } void -parse_error (struct locus *loc, const char *fmt, ...) +lerror (struct locus *loc, const char *fmt, ...) { va_list ap; va_start (ap, fmt); - vparse_error (loc, fmt, ap); + vlerror (loc, fmt, ap); va_end (ap); } |