aboutsummaryrefslogtreecommitdiff
path: root/src/gram.y
AgeCommit message (Collapse)AuthorFiles
2018-05-23gdbmtool: accept commands from command line as well as from fileSergey Poznyakoff1
Commands can be supplied to gdbmtool in three ways: 1. From a file, using the --file (-f) option: gdbmtool -f comfile 2. From the command line, if first argument is the database name: gdbmtool test.db count \; fetch mykey \; avail Note the use of semicolon to delimit commands. 3. From the interactive shell, if neither of the above is used. * src/Makefile.am: Add new sources. * src/gdbmtool.c: Use new stream functions for input. * src/gdbmtool.h (setsource): Remove proto. (instream_t): New data type. (instream_name, instream_read) (instream_close, instream_interactive) (instream_eq): New functions. (instream_stdin_create) (instream_argv_create) (instream_file_create) (interactive, input_context_push): New protos. * src/gram.y: Accept ; in place of newline. * src/input-argv.c: New file. * src/input-file.c: New file. * src/input-rl.c: Rewrite to provide instream_t API. * src/input-std.c: Likewise. * src/lex.l: Rewrite. * tests/.gitignore: Update. * tests/Makefile.am: Add new tests. Incorporate DejaGNU tests. * tests/config/default.exp: New file. * tests/gdbmtool/base.exp: New file. * tests/gdbmtool00.at: New file. * tests/gdbmtool01.at: New file. * tests/gdbmtool02.at: New file. * tests/testsuite.at: Include new tests.
2018-01-01Happy GNU YearSergey Poznyakoff1
2017-01-02Happy GNU YearSergey Poznyakoff1
2016-07-25Add debug info.Sergey Poznyakoff1
* configure.ac: Fix description wording. * src/Makefile.am [GDBM_COND_DEBUG_ENABLE]: Don't define GDBM_DEBUG_ENABLE. * tests/Makefile.am: Likewise. * src/debug.c (gdbm_debug_printer) (gdbm_debug_flags): New globals. (gdbm_debug_token, gdbm_debug_parse_state) (gdbm_debug_datum): New functions. * src/gdbm.h.in [@GDBM_DEBUG_ENABLE@]: Define GDBM_DEBUG_ENABLE. (gdbm_debug_printer_t): New typedef. (gdbm_debug_printer, gdbm_debug_flags): New externs. (GDBM_DEBUG_ERR,GDBM_DEBUG_OPEN) (GDBM_DEBUG_READ,GDBM_DEBUG_STORE) (GDBM_DEBUG_LOOKUP,GDBM_DEBUG_ALL): New defines. (gdbm_debug_token,gdbm_debug_parse_state) (gdbm_debug_datum): New protos. * src/gdbmdefs.h (GDBM_DEBUG,GDBM_DEBUG_DATUM): New macros. * src/findkey.c: Add debugging info. * src/gdbmfetch.c: Likewise. * src/gdbmopen.c: Likewise. * src/gdbmseq.c: Likewise. * src/gdbmstore.c: Likewise. * src/gdbmtool.c (open_handler): Allow the use of ~/ (command) <repeat,variadic>: New members. (run_command): Handle variadic functions. (run_last_command): New command. In interactive mode, repeats the last command if it was marked with repeat=1 (currently, only "next"). New command: "debug". (all functions): Use terror instead of fprintf(stderr,...); * src/gdbmtool.h (handler_param) <vararg>: New member. (run_last_command): New proto. * src/gram.y: Call run_last_command) on empty input. * tests/gtload.c: New option: -debug=
2016-07-12Line-editing support in gdbmtoolSergey Poznyakoff1
* configure.ac: Check if GNU Readline is available. * src/Makefile.am: Add new files. * src/input-rl.c: New file. * src/input-std.c: New file. * src/gdbmtool.c (handler_param): Move declaration to the header file. (quit_handler): Call input_done. (command_tab): Add the "history" command. (command_generator): New function. (slist_new_s, slist_new_l) (slist_insert): New functions. (main): Call input_init and input_done. * src/gdbmtool.h: New protos. * src/gram.y: Use slist_insert to construct string lists. * src/lex.l (read_input): Remove. Use input_read instead. (print_prompt_at_bol): New function. (print_prompt): Remove. (make_prompt): New function. * NEWS: Document changes. * README: Document readline support. * doc/gdbm.texi: Document line editing in gdbmtool. * doc/gdbmtool.1: Likewise.
2016-05-16Update copyright yearsSergey Poznyakoff1
2016-05-16Minor improvementsSergey Poznyakoff1
* src/gdbmtool.c (_gdbm_print_bucket_cache): Use %zu to print size_t. * src/gdbmtool.h (variable_unset): New proto. (yyerror): Argument is char const *. src/gram.y: Likewise. * src/lex.l: Add option noinput * src/parseopt.c (print_option_descr): Use fwrite instead of printf. * src/var.c: Fix initializers to suppress warnings.
2013-05-16Provide support for a simplified "define" construct.Sergey Poznyakoff1
* doc/gdbm.texinfo: Document the "define" statement. * src/datconv.c: Support short and ushort data types. * src/gdbmtool.c: Don't call checkdb prior to handling the "hash" command. * src/gram.y: Support simplified definition construct: "define key|content type".
2013-05-16Improve handling of the variables.Sergey Poznyakoff1
* src/gdbmtool.c (opendb): Allow for unset variables. * src/gram.y: Improve error detection. * src/lex.l: Handle multiline strings. (pe_file_name): file_name can be NULL. * src/var.c (VARF_PROT): New flag. Protects the variable from being unset. (vartab): Use VARF_PROT if needed. (s2b): Fix return values. (variable_set, variable_unset): Return error if attempting to unset a variable marked with VARF_PROT. * doc/gdbm.info: Update. * doc/gdbmtool.1: Update.
2013-05-15Add "pager" variable and "unset" command.Sergey Poznyakoff1
* 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.
2013-05-14Change variable support.Sergey Poznyakoff1
* 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.
2013-05-14Provide "open" and "close" commands; implement new variables.Sergey Poznyakoff1
* src/datconv.c (datum_format): Don't print field delimiter after the last field. (dsprint): Bugfix. * src/gdbmload.c (gdbm_load_from_file): Return GDBM_NO_DBNAME when loading from bdb dump and the database pointer is NULL. * src/gdbmtool.c (opendb, checkdb): New auxiliary functions. (begin handlers): call checkdb. (import_handler): Special handling for GDBM_NO_DBNAME. (status_handler): Print more info. (command_tab): Call checkdb prior to handlers that expect an open database. New commands: open, close (gdbmarg_string, gdbmarg_datum) (gdbmarg_kvpair): Take pointer to locus as the 2nd argument. All uses changed. (coerce): Include locus info in the diagnostic message. (main): Don't open database right away. * src/gdbmtool.h (GDBMTOOL_DEFFILE): New define. (gdbmarg) <loc>: New member. (VART_INT): New variable typ.e (VAR_ERR_FAILURE): New error code. (variable_is_set, varible_mode_name): New protos. * src/gram.y: Provide printable token names for error messages. Pass locus to gdbmarg initialization functions. * src/lex.l (vparse_error): Fix output. * src/var.c (variable) <v.num, hook, hook_data>: New members. (vartab): Define more variables. (variable_set): Accept value of any valid datatype. (variable_mode_name, variable_is_set): New functions.
2013-05-13Add "set" and "define" to the main command table.Sergey Poznyakoff1
* src/gdbmtool.c: Include gram.h (command) <tok>: New member. (command_tab): List "define" and "set". (find_command): Rewrite as command_lookup, with different return type and signature. (run_command): Take struct command * as its first argument. * src/gdbmtool.h (command_lookup): New proto. (run_command): Change signature. (datadef_locate): Rename to datadef_lookup. All uses changed. * src/gram.y: Update. * src/lex.l: Change handling of IDENT rules.
2013-05-13Implement shell variables in gdbmtool.Sergey Poznyakoff1
* src/var.c: New file. * src/datconv.c (datum_format): Remove the "delim" parameter, use "delim1" and "delim2" shell variables instead. * src/gdbmtool.c: Remove "prompt" command. Use "set ps[12]" instead. (print_prompt): Move to lex.l * src/gdbmtool.h (variable_set) (variable_get, variable_print_all): New protos. * src/gram.y: Handle the "set" command. * src/lex.l: Update.
2013-05-13Handle structured key and content data in gdbmtool.Sergey Poznyakoff1
* src/datconv.c: New file. * src/Makefile.am (gdbmtool_SOURCES): Add datconv.c. * src/gdbmtool.h (slist, kvpair): New structures. (gdbmarg): Keep various types of data depending on the value of the type member. (slist_new, slist_free) (kvpair_string, kvpair_list): New protos. (gdbmarg_new): Remove. (gdbmarg_string, gdbmarg_datum) (gdbmarg_kvpair, gdbmarg_free) (gdbmarg_destroy): New protos. (xd_expand, xd_store, datadef_locate): New protos. (field, dsegm): New structs. (dsegm_new, dsegm_new_field, dsegm_free_list): New protos. * src/gdbmtool.c: Rewrite. * src/gram.y: Change grammar to allow for defining key and content structure and for supplying structured data as arguments to fetch, store and similar functions. * src/lex.l: Handle new token types. * tests/dtload.c (main): Fix parser. * tests/gtload.c: Likewise.
2013-05-11Rewrite gdbmtool parser.Sergey Poznyakoff1
* src/testgdbm.c: Remove. * src/gdbmtool.c: New file. * src/gdbmtool.h: New file. * src/gram.y: New file. * src/lex.l: New file. * src/Makefile.am: Update.

Return to:

Send suggestions and report system problems to the System administrator.