summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2015-10-28 05:45:17 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2015-12-17 13:26:56 (GMT)
commitd51a70af75b14720a1756d90ec53132596aa3ebf (patch) (unidiff)
treefc4ad5f29e4bd481713ae652caa4e37f6e5cdff6
parenta1760108b8a85e4bcb1704737fb5beb7dd14755f (diff)
downloadgrecs-d51a70af75b14720a1756d90ec53132596aa3ebf.tar.gz
grecs-d51a70af75b14720a1756d90ec53132596aa3ebf.tar.bz2
Minor improvement in wordsplit.
* src/wordsplit.h (WRDSX_WORD, WRDSX_QUOTE): New defines. * src/wordsplit.c: Use them when initializing ws_escape.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/wordsplit.c16
-rw-r--r--src/wordsplit.h4
2 files changed, 12 insertions, 8 deletions
diff --git a/src/wordsplit.c b/src/wordsplit.c
index 355373e..86d4f4b 100644
--- a/src/wordsplit.c
+++ b/src/wordsplit.c
@@ -239,24 +239,24 @@ wordsplit_init (struct wordsplit *wsp, const char *input, size_t len,
239 239
240 if (wsp->ws_flags & WRDSF_ESCAPE) 240 if (wsp->ws_flags & WRDSF_ESCAPE)
241 { 241 {
242 if (!wsp->ws_escape[0]) 242 if (!wsp->ws_escape[WRDSX_WORD])
243 wsp->ws_escape[0] = ""; 243 wsp->ws_escape[WRDSX_WORD] = "";
244 if (!wsp->ws_escape[1]) 244 if (!wsp->ws_escape[WRDSX_QUOTE])
245 wsp->ws_escape[1] = ""; 245 wsp->ws_escape[WRDSX_QUOTE] = "";
246 } 246 }
247 else 247 else
248 { 248 {
249 if (wsp->ws_flags & WRDSF_CESCAPES) 249 if (wsp->ws_flags & WRDSF_CESCAPES)
250 { 250 {
251 wsp->ws_escape[0] = wordsplit_c_escape_tab; 251 wsp->ws_escape[WRDSX_WORD] = wordsplit_c_escape_tab;
252 wsp->ws_escape[1] = wordsplit_c_escape_tab; 252 wsp->ws_escape[WRDSX_QUOTE] = wordsplit_c_escape_tab;
253 wsp->ws_options |= WRDSO_OESC_QUOTE | WRDSO_OESC_WORD 253 wsp->ws_options |= WRDSO_OESC_QUOTE | WRDSO_OESC_WORD
254 | WRDSO_XESC_QUOTE | WRDSO_XESC_WORD; 254 | WRDSO_XESC_QUOTE | WRDSO_XESC_WORD;
255 } 255 }
256 else 256 else
257 { 257 {
258 wsp->ws_escape[0] = ""; 258 wsp->ws_escape[WRDSX_WORD] = "";
259 wsp->ws_escape[1] = "\\\\\"\""; 259 wsp->ws_escape[WRDSX_QUOTE] = "\\\\\"\"";
260 wsp->ws_options |= WRDSO_BSKEEP_QUOTE; 260 wsp->ws_options |= WRDSO_BSKEEP_QUOTE;
261 } 261 }
262 } 262 }
diff --git a/src/wordsplit.h b/src/wordsplit.h
index e7df8bb..53503a4 100644
--- a/src/wordsplit.h
+++ b/src/wordsplit.h
@@ -209,6 +209,10 @@ struct wordsplit
209#define WRDSO_OESC WRDSO_OESC_WORD 209#define WRDSO_OESC WRDSO_OESC_WORD
210#define WRDSO_XESC WRDSO_XESC_WORD 210#define WRDSO_XESC WRDSO_XESC_WORD
211 211
212/* Indices into ws_escape */
213#define WRDSX_WORD 0
214#define WRDSX_QUOTE 1
215
212/* Set escape option F in WS for words (Q==0) or quoted strings (Q==1) */ 216/* Set escape option F in WS for words (Q==0) or quoted strings (Q==1) */
213#define WRDSO_ESC_SET(ws,q,f) ((ws)->ws_options |= ((f) << 4*(q))) 217#define WRDSO_ESC_SET(ws,q,f) ((ws)->ws_options |= ((f) << 4*(q)))
214/* Test WS for escape option F for words (Q==0) or quoted strings (Q==1) */ 218/* Test WS for escape option F for words (Q==0) or quoted strings (Q==1) */

Return to:

Send suggestions and report system problems to the System administrator.