diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2019-05-13 15:20:24 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2019-05-13 15:20:24 +0300 |
commit | 65f41a742e025487f8ec7f2e7ca2a3af3283fc96 (patch) | |
tree | cef728d35f7683f7721659a58fdb2aa1f61387bc /src | |
parent | 07930c5ee74b8d2645fc55465833ab84e2f4444a (diff) | |
download | grecs-65f41a742e025487f8ec7f2e7ca2a3af3283fc96.tar.gz grecs-65f41a742e025487f8ec7f2e7ca2a3af3283fc96.tar.bz2 |
wordsplit: optionally disable splitting of unexpandable variable and command 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.
Diffstat (limited to 'src')
-rw-r--r-- | src/wordsplit.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/wordsplit.c b/src/wordsplit.c index e979f27..521a1eb 100644 --- a/src/wordsplit.c +++ b/src/wordsplit.c @@ -2058,11 +2058,13 @@ scan_word (struct wordsplit *wsp, size_t start, int consume_all) if (command[i] == '$') { - if (!(wsp->ws_flags & WRDSF_NOVAR) + if ((!(wsp->ws_flags & WRDSF_NOVAR) + || (wsp->ws_options & WRDSO_NOVARSPLIT)) && command[i+1] == '{' && find_closing_paren (command, i + 2, len, &i, "{}") == 0) continue; - if (!(wsp->ws_flags & WRDSF_NOCMD) + if ((!(wsp->ws_flags & WRDSF_NOCMD) + || (wsp->ws_options & WRDSO_NOCMDSPLIT)) && command[i+1] == '(' && find_closing_paren (command, i + 2, len, &i, "()") == 0) continue; |