aboutsummaryrefslogtreecommitdiff
path: root/src/gram.y
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-05-15 16:17:51 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2013-05-15 16:17:51 +0000
commit9b83ca8638cdb8c4deafcc48d8157fe0e8da1740 (patch)
treea0dfd21b21a5cb9916afc8fb03928fa68847fe26 /src/gram.y
parent8cbaa44e2f1b80dd8954a0e06e0bc8a52494237f (diff)
downloadgdbm-9b83ca8638cdb8c4deafcc48d8157fe0e8da1740.tar.gz
gdbm-9b83ca8638cdb8c4deafcc48d8157fe0e8da1740.tar.bz2
Add "pager" variable and "unset" command.
* src/gdbmtool.c (command_tab) <unset>: New command. (run_command): Get pager value from the variable. * src/gdbmtool.h (VAR_ERR_NOTSET): New error code. (variable_is_true): New function. Replaces variable_is_set, which changed semantics. * src/gram.y: Implement the unset command. * src/var.c: Support the "unset variable" notion. (VARF_INIT): New flag. (VAR_IS_SET): New define. (vartab): Mark initialized variables with VARF_INIT. New variable "pager". (open_hook): v can be NULL. (variable_set): NULL value unsets the variable. (variable_unset): New function. (variable_get): Return VAR_ERR_NOTSET if the variable is not set. (variable_is_true): Renamed from variable_is_set. (variable_is_set): New function. * src/gdbmdefs.h: Fix some typos.
Diffstat (limited to 'src/gram.y')
-rw-r--r--src/gram.y36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/gram.y b/src/gram.y
index a54ef0e..b939d8e 100644
--- a/src/gram.y
+++ b/src/gram.y
@@ -31,7 +31,9 @@ struct dsegm *dsdef[DS_MAX];
T_PAD "pad"
T_DEF "define"
T_SET "set"
+ T_UNSET "unset"
T_BOGUS
+
%token <cmd> T_CMD "command verb"
%token <num> T_NUM "number"
%token <string> T_IDENT "identifier" T_WORD "word"
@@ -244,14 +246,15 @@ set : T_SET
{
variable_print_all (stdout);
}
- | T_SET varlist
+ | T_SET asgnlist
+ | T_UNSET varlist
;
-varlist : var
- | varlist var
+asgnlist : asgn
+ | asgnlist asgn
;
-var : T_IDENT
+asgn : T_IDENT
{
int t = 1;
int rc;
@@ -304,6 +307,31 @@ var : T_IDENT
free ($3);
}
;
+
+varlist : var
+ | varlist var
+ ;
+
+var : T_IDENT
+ {
+ int rc = variable_unset ($1);
+ switch (rc)
+ {
+ case VAR_OK:
+ break;
+
+ case VAR_ERR_NOTDEF:
+ lerror (&@1, _("no such variable: %s"), $1);
+ break;
+
+ case VAR_ERR_BADVALUE:
+ lerror (&@1, _("%s: variable cannot be unset"), $1);
+ break;
+ }
+ free($1);
+ }
+ ;
+
%%
void

Return to:

Send suggestions and report system problems to the System administrator.