summaryrefslogtreecommitdiffabout
AgeCommit message (Collapse)AuthorFiles
2019-07-24Incorporate wordsplit v1.0-9-g7eaa3c4HEADmasterSergey Poznyakoff3
2019-07-16Fix in GRECS_SETUP macroSergey Poznyakoff2
* am/grecs.m4: Quote the use of $DEFAULT_PREPROCESSOR as argument to expr. * tests/Makefile.am: Fix LDADD
2019-07-10BugfixesSergey Poznyakoff3
* src/.gitignore: Remove grecs.h * tests/Makefile.am: Fix AM_CPPFLAGS
2019-07-10Distribute only needed parts of wordsplitSergey Poznyakoff2
* Makefile.am (WORDSPLIT_SRC) (WORDSPLIT_TEST,WORDSPLIT_DOC): New variables. (EXTRA_DIST): Add WORDSPLIT_SRC (unconditionally) and @GRECS_EXTRA_DIST@ (gets set depending on whether docs and testsuite is required). * am/grecs.m4: Set GRECS_EXTRA_DIST to $(WORDSPLIT_TEST) if testsuite is required. Append to it $(WORDSPLIT_DOC) if documentation is required as well.
2019-07-10Add a missing includeSergey Poznyakoff1
2019-07-10Import wordsplit as a submoduleSergey Poznyakoff18
* .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.
2019-06-24getopt.m4: add macro to insert a CPP directive in all diversionsSergey Poznyakoff1
* build-aux/getopt.m4 (CPP): New macro
2019-06-13wordsplit: configurable order of lookups if both WRDSF_ENV and WRDSF_GETVAR ↵Sergey Poznyakoff2
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.
2019-06-13BugfixSergey Poznyakoff1
* lib/wordsplit.c (_wsplt_store_errctx): Fix typo in the error message. (wsplt_assign_var): Fix a +1 offset of the ws_envidx field.
2019-06-06BugfixSergey Poznyakoff1
* src/assert.c (grecs_assert_node_value_type): Fix return value.
2019-06-06Fix previous commitSergey Poznyakoff1
* src/tree.c (find_keyword): Fix precedence in the conditional.
2019-06-05Fix syntax checking of compound vs. scalar statements. Add assertion functions.Sergey Poznyakoff8
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.
2019-06-05Minor fix in location printerSergey Poznyakoff1
* src/diag.c (grecs_asprint_locus): Handle the case where beg equals end.
2019-06-05wordsplit: special handling for WRDSE_USAGE.Sergey Poznyakoff1
* src/wordsplit.c (wordsplit_run): Initialize ws_errctx early. This ensures that wordsplit_strerror gets correct data after WRDSE_USAGE. (wordsplit_free): Return immediately if errno was WRDSE_USAGE.
2019-05-16Minor fix.Sergey Poznyakoff1
* src/wordsplit.c (_wsplt_seterr_sub): Propagate error context.
2019-05-15wordsplit: introduce error contextSergey Poznyakoff3
* 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.
2019-05-15BugfixSergey Poznyakoff1
* src/wordsplit.c (wordsplit_finish): Fix typo. (wsplt_assign_param): Use _wsplt_seterr
2019-05-14Fix behaviour of $* and $@ in quoted contextSergey Poznyakoff3
2019-05-14wordsplit: whitespace cleanupSergey Poznyakoff2
2019-05-14wordsplit: implement $* and $@Sergey Poznyakoff2
2019-05-14wordsplit: rewrite positional parameters implementationSergey Poznyakoff4
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.
2019-05-13wordsplit: optionally disable splitting of unexpandable variable and command ↵Sergey Poznyakoff4
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.
2019-05-13wordsplit: return single empty string on empty input in WRDSF_NOSPLIT modeSergey Poznyakoff2
* src/wordsplit.c (wordsplit_finish): Make sure at one non-null argument is always returned in WRDSF_NOSPLIT mode. * tests/wordsplit.at: Add new test.
2019-04-20Improve variable handling in wordsplit.Sergey Poznyakoff2
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).
2019-02-18New substitution variable for linking with host project librariesSergey Poznyakoff2
New variable GRECS_HOST_PROJECT_LDADD complements GRECS_HOST_PROJECT_INCLUDES. It provides a way to link test binaries with host project libraries. This may be useful if config.h redefines missing or defective library functions to their replacements, which are provided in third-party libraries, such as e.g. gnulib, * am/grecs.m4 (GRECS_HOST_PROJECT_LDADD): New substitution variable. * tests/Makefile.am (LDADD): Add GRECS_HOST_PROJECT_LDADD.
2018-12-07Revise getopt.m4Sergey Poznyakoff1
2018-11-15Update wordsplit docsSergey Poznyakoff1
2018-11-15Port mailutils commit 2c2e3c50d6Sergey Poznyakoff4
* 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.
2018-11-15Fix a wordsplit testcase.Sergey Poznyakoff1
* tests/wordsplit.at (append + dooffs + env): Disable environment.
2018-07-31Minor fixes in wordsplitSergey Poznyakoff1
* src/wordsplit.c (find_closing_paren): paren is char const * (wsplt_unquote_char, wsplt_quote_char): mark as static (exptab) <descr>: mark as const.
2018-06-04json: improve parser reentrabilitySergey Poznyakoff5
* 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.
2018-05-22Minor fixSergey Poznyakoff1
* src/wordsplit.c (wordsplit_run): Return consistent error code.
2018-05-22New feature: maxwordsSergey Poznyakoff5
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.
2018-05-21Minor fixesSergey Poznyakoff2
* README.submodule: Fix the description. * include/wordsplit.h: Fix typo.
2018-03-15Minor fixSergey Poznyakoff1
2018-02-20Minor improvement in wordsplitSergey Poznyakoff3
* src/wordsplit.c (expvar): Gracefully handle NULL values in ENV_KV environment. * src/wordsplit.h: Fix typo in a comment. * doc/wordsplit.3: Update.
2017-11-10Pull fixes to wordsplit from mailutilsSergey Poznyakoff4
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.
2017-11-10Fix 5938aedc.Sergey Poznyakoff1
* src/tree.c (grecs_node_unlink): Partially revert 5938aedc. (node_merge_block): Fix prev link.
2017-08-15Fix typo in sockaddr.hSergey Poznyakoff1
* include/grecs/sockaddr.h (grecs_sockaddr_str): New proto.
2017-08-14Fix grecs_node_unlink function; implement grecs_sockaddr_str.Sergey Poznyakoff3
* 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.
2016-11-21BugfixesSergey Poznyakoff2
* src/jsonfmt.c (json_format_obj): Use grecs_symtab_count and grecs_symtab_foreach. * src/wordsplit.c: Always pass format strings as first argument to wsp->ws_error.
2016-08-25symtabs: allow to modify the list during iteration over it.Sergey Poznyakoff4
* 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.
2016-08-05Minor fixSergey Poznyakoff1
* build-aux/getopt.m4: Only define lastoptlab if necessary
2016-08-05New operator to stop option processingSergey Poznyakoff1
* build-aux/getopt.m4 (LASTOPT): New macro. Stops further option processing.
2016-07-29Start Automake conditionals on column one.Sergey Poznyakoff2
2016-07-16Complement 529fed25Sergey Poznyakoff2
* tests/gcfpeek.c: New options: -strcat -stradj * tests/locus02.at: Use these.
2016-07-16Disable adjacent string concatenation.Sergey Poznyakoff9
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.
2016-07-04Remove leftover includesSergey Poznyakoff1
* build-aux/getopt.m4: Include grecs/opt.h
2016-07-04Update copyright yearsSergey Poznyakoff1
2016-07-04Fix prototypes.Sergey Poznyakoff1

Return to:

Send suggestions and report system problems to the System administrator.