aboutsummaryrefslogtreecommitdiff
path: root/src/gdbmtool.c
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/gdbmtool.c
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/gdbmtool.c')
-rw-r--r--src/gdbmtool.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/gdbmtool.c b/src/gdbmtool.c
index 6083edc..93cc175 100644
--- a/src/gdbmtool.c
+++ b/src/gdbmtool.c
@@ -54,19 +54,25 @@ opendb (char *dbname)
if (variable_get ("cachesize", VART_INT, (void**) &cache_size))
abort ();
- if (variable_get ("blocksize", VART_INT, (void**) &block_size))
- abort ();
-
- if (!variable_is_set ("lock"))
+ switch (variable_get ("blocksize", VART_INT, (void**) &block_size))
+ {
+ case VAR_OK:
+ case VAR_ERR_NOTSET:
+ break;
+ default:
+ abort ();
+ }
+
+ if (!variable_is_true ("lock"))
flags |= GDBM_NOLOCK;
- if (!variable_is_set ("mmap"))
+ if (!variable_is_true ("mmap"))
flags |= GDBM_NOMMAP;
- if (variable_is_set ("sync"))
+ if (variable_is_true ("sync"))
flags |= GDBM_SYNC;
if (open_mode == GDBM_NEWDB)
{
- if (interactive && variable_is_set ("confirm") &&
+ if (interactive && variable_is_true ("confirm") &&
access (dbname, F_OK) == 0)
{
if (!getyn (_("database %s already exists; overwrite"), dbname))
@@ -935,6 +941,9 @@ struct command command_tab[] = {
{ S(set), T_SET,
NULL, NULL, NULL,
{ { "[var=value...]" }, { NULL } }, N_("set or list variables") },
+ { S(unset), T_UNSET,
+ NULL, NULL, NULL,
+ { { "var..." }, { NULL } }, N_("unset variables") },
{ S(define), T_DEF,
NULL, NULL, NULL,
{ { "key|content", ARG_STRING },
@@ -1322,10 +1331,12 @@ run_command (struct command *cmd, struct gdbmarglist *arglist)
{
int i;
struct gdbmarg *arg;
- char *pager = getenv ("PAGER");
+ char *pager = NULL;
char argbuf[128];
size_t expected_lines, *expected_lines_ptr;
FILE *pagfp = NULL;
+
+ variable_get ("pager", VART_STRING, (void**) &pager);
arg = arglist ? arglist->head : NULL;
@@ -1487,6 +1498,7 @@ main (int argc, char *argv[])
sort_commands ();
variable_set ("open", VART_STRING, "wrcreat");
+ variable_set ("pager", VART_STRING, getenv ("PAGER"));
for (opt = parseopt_first (argc, argv, optab);
opt != EOF;

Return to:

Send suggestions and report system problems to the System administrator.