aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-05-13 15:20:24 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-05-13 15:20:24 +0300
commit65f41a742e025487f8ec7f2e7ca2a3af3283fc96 (patch)
treecef728d35f7683f7721659a58fdb2aa1f61387bc /src
parent07930c5ee74b8d2645fc55465833ab84e2f4444a (diff)
downloadgrecs-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.c6
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
@@ -2060,3 +2060,4 @@ scan_word (struct wordsplit *wsp, size_t start, int consume_all)
{
- if (!(wsp->ws_flags & WRDSF_NOVAR)
+ if ((!(wsp->ws_flags & WRDSF_NOVAR)
+ || (wsp->ws_options & WRDSO_NOVARSPLIT))
&& command[i+1] == '{'
@@ -2064,3 +2065,4 @@ scan_word (struct wordsplit *wsp, size_t start, int consume_all)
continue;
- if (!(wsp->ws_flags & WRDSF_NOCMD)
+ if ((!(wsp->ws_flags & WRDSF_NOCMD)
+ || (wsp->ws_options & WRDSO_NOCMDSPLIT))
&& command[i+1] == '('

Return to:

Send suggestions and report system problems to the System administrator.