Age | Commit message (Collapse) | Author | Files |
|
yylloc reflects the location of the current token. Its end
point does not necessarily coincide with the current scanner
point.
|
|
Remove the grecs_current_locus_point variable. Use yylloc.end directly.
For git-parser.c and path-parser.c, provide a static replacement.
|
|
|
|
When external preprocessing is required, each source file is preprocessed
separately. This means that if you use #include or #include_once
statements, a separate copy of external preprocessor will be started
for each included file. In other words, when both internal and external
preprocessing is used, the order is: external first, internal next.
Previous versions of grecs implemented opposite order, when one external
preprocessor was started, which obtained input from the internal
preprocessor.
One concequence of this is that any macros defined in a configuration file
are no longer visible for files included from it.
* include/grecs/lex.h (grecs_parse_line_directive)
(grecs_parse_line_directive_cpp): Change signature.
* include/grecs/preproc.h (grecs_preproc_init)
(grecs_preproc_done)
(grecs_preproc_run): Remove.
(grecs_preprocess): New proto.
* src/grecs-lex.l: Rewrite.
* src/Make.am: Remove preproc.c
* src/preproc.c: Remove.
* src/bind-lex.l: Update calls to grecs_parse_line_directive*
functions.
* src/dhcpd-lex.l: Likewise.
* tests/Makefile.am: Add new tests.
* tests/testsuite.at: Inlcude new tests.
* tests/epp.at: New file.
* tests/ipp.at: New file.
* tests/fpp.c: Rename to tests/failpp.c
* tests/gcfpp.c: New file.
* tests/incl01.at: Change expected strings.
* tests/ppexit.at: Change expected strings.
|
|
* doc/grecs-syntax.texi: Document new preprocessor statements.
* include/grecs/preproc.h (grecs_preproc_extrn_shutdown): Return int.
* src/grecs-lex.l: Handle new preprocessor statements.
* src/preproc.c (grecs_preproc_extrn_shutdown): Return error code.
Bail out unless the preprocessor command terminates with code 0.
* tests/Makefile.am: Add new tests.
* tests/testsuite.at: Include new tests.
* tests/abend.at: New test.
* tests/error.at: Likewise.
* tests/warning.at: Likewise.
|
|
|
|
|
|
* .gitmodules: New module: wordsplit
* Makefile.am: Distribute wordsplit files.
* am/grecs.m4 (GRECS_INCLUDES): Add wordsplit directory
* doc/Makefile.am (dist_man_MANS): Distribute wordsplit/wordsplit.3
* doc/wordsplit.3: Remove.
* include/Makefile.am (GRECS_HDR): Add wordsplit/wordsplit.
* include/wordsplit.h: Remove.
* src/Make-inst.am: Define nodist_libgrecs_la_SOURCES.
* src/Make-shared.am: Likewise.
* src/Make-static.am: Define nodist_libgrecs_a_SOURCES.
* src/Make.am (GRECS_SRC): Remove wordsplit.c
(NODIST_GRECS_SRC): Define to wordsplit.c
(VPATH): Add the wordsplit directory.
* src/wordsplit.c: Remove.
* tests/wordsplit.at: Remove.
* tests/wsp.c: Remove.
* tests/Makefile.am: Build separate testsuite for wordsplit. Use VPATH
to build wsp.
* tests/.gitignore: Update.
|
|
are set
* lib/wordsplit.h (WRDSO_GETVARPREF): New option.
* lib/wordsplit.c (wordsplit_find_env): Rewrite as wsplt_env_lookup
wsplt_env_getvar): New function.
(expvar): Select preference of wsplt_env_lookup vs. wsplt_env_getvar
depending on the value if WRDSO_GETVARPREF option.
|
|
Up to now the parser incorrectly accepted the use of compound statement
keyword in scalar context, unless the keyword description had non NULL
value in the callback field. This change fixes it.
It also defines several assertion functions for use inm callbacks.
* src/tree.c (grecs_value_type_string): New function.
(find_keyword): Take into account node type.
(nodeproc,reduceproc): Leave error reporting to find_keyword.
* tests/set.at: Change expected error string.
* include/grecs/tree.h (grecs_assert_value_type)
(grecs_assert_scalar_stmt)
(grecs_assert_node_value_type): New protos.
* include/grecs/value.h (grecs_value_type_string): New proto.
* src/Make.am: Add assert.c
* src/assert.c: New file.
* src/format.c (grecs_data_type_string): Add i18n markers to the
returned strings.
|
|
* include/wordsplit.h (wordsplit) <ws_errctx>: New field.
* src/wordsplit.c (wordsplit_init): Initialize ws_errctx.
(expvar,wordsplit_pathexpand): Save error context.
(wordsplit_clearerr): Free error context.
(wordsplit_perror): Use error context if available.
* tests/wordsplit.at: Reflect changes.
|
|
|
|
|
|
This improves 3e07e3ad
* include/wordsplit.h (ws_paramv,ws_paramc)
(ws_parambuf,ws_paramidx,ws_paramsiz): New fields.
(WRDSO_PARAMV,WRDSO_PARAM_NEGIDX): New options.
(WRDSE_BADPARAM): New error code.
(wordsplit_free_parambuf): New proto.
* src/wordsplit.c (wordsplit_init): Initialize new fields.
(wsplt_assign_var): Fix double-free and memory leak.
(expvar): Expand positional parameters.
(begin_var_p): Add '#'
(wordsplit_free_envbuf): Fix condition.
(wordsplit_free_parambuf): New function.
(wordsplit_free): Call wordsplit_free_parambuf.
(_wordsplit_errstr): New error description.
* tests/wordsplit.at: Update wsp invocations.
Test positional parameters.
* tests/wsp.c: Rewrite.
|
|
refs
* include/wordsplit.h (WRDSO_NOVARSPLIT)
(WRDSO_NOCMDSPLIT): New options.
* src/wordsplit.c (scan_word): Treat any variable reference, even
containing whitespace, as a single word if WRDSO_NOVARSPLIT is set.
Ditto for commands and WRDSO_NOCMDSPLIT.
* tests/wordsplit.at: Add new tests.
* tests/wsp.c: Recognize novarsplit and nocmdsplit
options.
For future use: recognize bskeep_words, bskeep_quote, bskeep.
|
|
Positional variables ($N and ${N}) are recognized. Variable names in
curly braces follow the same rules as unadorned ones.
This commit also changes memory reallocation strategy in wsplt_assign_var.
If ws_envbuf needs to be expanded, new allocation size is selected as
3/2 of the previous allocation, if that size is less than max(size_t).
|
|
* include/wordsplit.h (WRDSO_ARGV): Remove.
* src/wordsplit.c (expcmd): Always split command line into arguments.
This fixes https://savannah.gnu.org/bugs/?54830
* tests/wsp.c: Implement internal commands, instead of
calling shell ones. This fixes https://savannah.gnu.org/bugs/?54829.
* tests/wordsplit.at: Rewrite command expansion tests.
|
|
* include/grecs/json.h (jsonlex_cleanup): New proto.
* src/json-lex.l (jsonlex_setup): Initialize parser state.
Initialize json_current_locus_point.file to a non-NULL value.
(jsonlex_cleanup): New function.
* src/json-gram.y (json_parse_string): Call jsonlex_cleanup before returning.
* src/diag.c (default_print_diag): Print the passed errcode argument,
instead of errno.
|
|
This feature allows the user to limit the number of words returned
by a call to wordsplit. When the number of words in expansion reaches
the predefined limit, the rest of input line will be expanded and returned
as a single last word.
For example, to parse a /etc/passwd line:
struct wordsplit ws;
ws.ws_delim = ":";
ws.ws_maxwords = 7;
ws.ws_options = WRDSO_MAXWORDS;
wordsplit(str, &ws, WRDSF_NOVAR | WRDSF_NOCMD | WRDSF_DELIM | WRDSF_OPTIONS);
* doc/wordsplit.3: Document the maxwords feature.
* include/wordsplit.h (wordsplit) <ws_maxwords>
<ws_wordi>: New members.
(WRDSO_MAXWORDS): New option.
* src/wordsplit.c (WSP_RETURN_DELIMS): New macro.
(_wsplt_subsplit): Rewrite.
(wordsplit_init0): Don't reset node list.
(wordsplit_init): Initialize ws_wordi and the node list.
(wsnode_insert): Correctly insert lists.
(coalesce_segment): Additional safety check.
(wsnode_tail_coalesce): New static function.
(wordsplit_finish): Postprocess delimiters.
(expvar,expcmd): Use new _wsplt_subsplit.
(wordsplit_varexp): Don't try to expand delimiter nodes.
(skip_delim): Remove delimiter processing. It is now done
in wordsplit_finish.
(scan_word): New argument 'consume_all' instructs it to
consume the rest of input as one token.
(wordsplit_process_list): Handle wsp->ws_maxwords setting.
This also fixed a long-standing bug: quotes weren't processed
in WRDSF_NOSPLIT mode. See the testcase 59 (incremental nosplit).
(wordsplit_run): Rewrite.
(wordsplit_free): Free node list.
* tests/wordsplit.at: Update for the new wsp output format.
(incremental nosplit): Expect correct output.
Add tests for the maxwords feature.
* tests/wsp.c (maxwords): New flag.
Print the ws_wordi value as "TOTALS" at the end of each run.
|
|
* README.submodule: Fix the description.
* include/wordsplit.h: Fix typo.
|
|
* src/wordsplit.c (expvar): Gracefully handle NULL values in
ENV_KV environment.
* src/wordsplit.h: Fix typo in a comment.
* doc/wordsplit.3: Update.
|
|
This includes the following commits pushed between
2015-09-19 and 2017-10-10:
090c7b9a Allow ws_getvar to set value to NULL and
return MU_WRDSE_OK.
The value is processed as if it were "", i.e.
MU_WRDSE_UNDEF is returned.
64313fdf Fix MU_WRDSF_INCREMENTAL | MU_WRDSF_NOSPLIT
46d7640f Add wordsplit_append function
151eb4b9 Fix nested expansions and command expansions
occurring after variable expansions.
ad3cc340 Replace void wordsplit_getwords with
int wordsplit_get_words.
* include/wordsplit.h (wordsplit_get_words): New function.
(wordsplit_getwords): Mark as deprecated.
(wordsplit_append): New function.
* src/wordsplit.c (wordsplit_append): New function. MU 46d7640f.
(expvar): Treat NULL value as "". MU 090c7b9a.
(expcmd): Allow command and variable expansions in subsplit.
(exptab): Change ordering of expansions so that command expansion
occurs first. This fixes nested expansions and command expansions
occurring after variable expansions. MU 151eb4b9.
(wordsplit_process_list): Update wsp->ws_endp in nosplit mode. This
fixes wordsplit MU_WRDSF_INCREMENTAL | MU_WRDSF_NOSPLIT. MU 64313fdf.
(wordsplit_get_words): New function. MU ad3cc340.
* tests/wordsplit.at: Test the above changes.
* tests/wsp.c: Accept extra arguments to append using wordsplit_append.
|
|
* include/grecs/sockaddr.h (grecs_sockaddr_str): New proto.
|
|
* include/grecs/sockaddr.h (grecs_sockaddr) <str>: New member.
(grecs_sockaddr_to_str): New proto.
* src/sockaddr.c (grecs_sockaddr_new): Initialize str.
(grecs_sockaddr_free): Free str.
(grecs_sockaddr_str): New function.
* src/tree.c (grecs_node_unlink): Fix.
|
|
* include/grecs/list.h (grecs_list_remove): New proto.
* include/grecs/symtab.h (grecs_symtab_count_entries):
Rename to grecs_symtab_count.
* src/list.c (grecs_list_remove): New function.
(grecs_list_remove_tail, grecs_list_clear)
(grecs_list_locate,grecs_list_index): Treat NULL list
as empty list.
* src/symtab.c: Defer table modifications during iteration
(symtab_defer_type): New enum.
(grecs_symtab)<elcount,itr_level,defer_list>: New members.
(symtab_defer_op): New static function.
(grecs_symtab_remove): When called during iteration, add the
entry to the defer_del deferment list, unless it is already
in defer_add, in which case remove it from there.
Update elcount.
(grecs_symtab_lookup_or_install): Defer addition when iterating.
Update elcount.
(grecs_symtab_clear): Reset elcount to 0.
(grecs_symtab_create): Initialize elcount.
(grecs_symtab_foreach): Process deferred modifications.
|
|
|
|
The adjacent string concatenation feature doesn't work well with
multiple-argument statements. The common example (found in GNU
pies) is the "env" statement:
env "PATH=/sbin:$PATH" "PRELOAD=true"
The intent was to pass it two arguments, but in fact they get
concatenated into one.
To control this, the grecs_parser_options variable is introduced.
If it has the GRECS_OPTION_QUOTED_STRING_CONCAT bit set, adjacent
string concatenation is enabled. By default it is disabled.
The GRECS_OPTION_ADJUST_STRING_LOCATIONS bit controls the way the
quoted sring locations are computed. If it is set, the beginning of
the string is counted at the first character after the opening double
quote, and its end at the character immediately preceding the closing
double quote. Otherwise, both double-quote characters are included in
the location (the default).
The change is backward incompatible.
* doc/grecs-syntax.texi: Update.
* include/grecs/parser.h (grecs_adjust_string_locations): Remove.
(grecs_parser_options): New extern.
* src/grecs-lex.l: QSTRING is returned only if
GRECS_OPTION_QUOTED_STRING_CONCAT option is set.
The GRECS_OPTION_ADJUST_STRING_LOCATIONS option controls string locus
adjustment.
* src/parser.c (grecs_adjust_string_locations): Remove.
(grecs_parser_options): New variable.
* tests/Makefile.am: Add strcat.at, stradj.at
* tests/testsuite.at: Likewise.
* tests/gcffmt.c: New options -strcat and -stradj
* tests/stradj.at: New test case.
* tests/strcat.at: New test case.
|
|
|
|
Port of a3f25ce2 from master.
* include/grecs/table.h (GRECS_CONST): New flag.
* src/tree.c (grecs_string_convert): For string types, free the
old value prior to assigning the new one, unless the GRECS_CONST
flag is set. In any case, clear the GRECS_CONST flag after
assigning new value.
|
|
Use _ptr_t suffix for typedefs that define pointers.
|
|
* Makefile.am (SUBDIRS): Add include
* am/grecs.m4 (GRECS_INCLUDES): Update
(GRECS_COND_BUILD_INSTALL)
(GRECS_COND_BUILD_SHARED)
(GRECS_COND_BUILD_STATIC): New conditions.
Build include/Makefile and include/grecs/Makefile.
* configure.ac: Use src/grecs-gram.y as a source
validity marker
* include/Makefile.a: New file.
* src/grecs.hin: Remove. Split into include/*. See below.
* include/grecs.h: New file.
* include/grecs/.gitignore: New file.
* include/grecs/Makefile.am: New file.
* include/grecs/doc.h: New file.
* include/grecs/error.h: New file.
* include/grecs/format.h: New file.
* include/grecs/lex.h: New file.
* include/grecs/list.h: New file.
* include/grecs/mem.h: New file.
* include/grecs/node.h: New file.
* include/grecs/parser.h: New file.
* include/grecs/preproc.h: New file.
* include/grecs/sockaddr.h: New file.
* include/grecs/symtab.h: New file.
* include/grecs/table.h: New file.
* include/grecs/tree.h: New file.
* include/grecs/txtacc.h: New file.
* include/grecs/types.h.in: New file.
* include/grecs/util.h: New file.
* include/grecs/value.h: New file.
* include/grecs/version.h: New file.
* src/grecs-locus.h: Move to ...
* include/grecs/locus.h: ... here
* src/grecsopt.h: Move to ...
* include/grecs/opt.h: ... here
* src/json.h: Move to ...
* include/grecs/json.h: ... here
* src/wordsplit.h: Move to ...
* include/wordsplit.h: ... here
* src/Make-inst.am (include_HEADERS): Remove.
* src/Make-shared.am (grecsinclude_HEADERS)
(noinst_HEADERS): Remove.
* src/Make-static.am (noinst_HEADERS): Remove.
* src/Make.am: Remove header-related stuff
* src/bind-gram.y: Fix includes.
* src/bind-lex.l: Likewise.
* src/cidr.c: Likewise.
* src/dhcpd-gram.y: Likewise.
* src/dhcpd-lex.l: Likewise.
* src/diag.c: Likewise.
* src/format.c: Likewise.
* src/grecs-gram.y: Likewise.
* src/grecs-lex.l: Likewise.
* src/json-gram.y: Likewise.
* src/json-lex.l: Likewise.
* src/jsonfmt.c: Likewise.
* src/lookup.c: Likewise.
* src/meta1-gram.y: Likewise.
* src/meta1-lex.l: Likewise.
* src/opthelp.c: Likewise.
* src/preproc.c: Likewise.
* src/sockaddr.c: Likewise.
* src/txtacc.c: Likewise.
* src/version.c: Likewise.
* tests/gcfenum.c: Likewise.
* tests/gcffmt.c: Likewise.
* tests/gcfpeek.c: Likewise.
* tests/gcfset.c: Likewise.
* tests/gcfver.c: Likewise.
* tests/json.c: Likewise.
|