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) (side-by-side diff)
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
@@ -236,30 +236,30 @@ wordsplit_init (struct wordsplit *wsp, const char *input, size_t len,
if (!(wsp->ws_flags & WRDSF_OPTIONS))
wsp->ws_options = 0;
if (wsp->ws_flags & WRDSF_ESCAPE)
{
- if (!wsp->ws_escape[0])
- wsp->ws_escape[0] = "";
- if (!wsp->ws_escape[1])
- wsp->ws_escape[1] = "";
+ if (!wsp->ws_escape[WRDSX_WORD])
+ wsp->ws_escape[WRDSX_WORD] = "";
+ if (!wsp->ws_escape[WRDSX_QUOTE])
+ wsp->ws_escape[WRDSX_QUOTE] = "";
}
else
{
if (wsp->ws_flags & WRDSF_CESCAPES)
{
- wsp->ws_escape[0] = wordsplit_c_escape_tab;
- wsp->ws_escape[1] = wordsplit_c_escape_tab;
+ wsp->ws_escape[WRDSX_WORD] = wordsplit_c_escape_tab;
+ wsp->ws_escape[WRDSX_QUOTE] = wordsplit_c_escape_tab;
wsp->ws_options |= WRDSO_OESC_QUOTE | WRDSO_OESC_WORD
| WRDSO_XESC_QUOTE | WRDSO_XESC_WORD;
}
else
{
- wsp->ws_escape[0] = "";
- wsp->ws_escape[1] = "\\\\\"\"";
+ wsp->ws_escape[WRDSX_WORD] = "";
+ wsp->ws_escape[WRDSX_QUOTE] = "\\\\\"\"";
wsp->ws_options |= WRDSO_BSKEEP_QUOTE;
}
}
wsp->ws_endp = 0;
diff --git a/src/wordsplit.h b/src/wordsplit.h
index e7df8bb..53503a4 100644
--- a/src/wordsplit.h
+++ b/src/wordsplit.h
@@ -206,12 +206,16 @@ struct wordsplit
#define WRDSO_XESC_QUOTE 0x00000400
#define WRDSO_BSKEEP WRDSO_BSKEEP_WORD
#define WRDSO_OESC WRDSO_OESC_WORD
#define WRDSO_XESC WRDSO_XESC_WORD
+/* Indices into ws_escape */
+#define WRDSX_WORD 0
+#define WRDSX_QUOTE 1
+
/* Set escape option F in WS for words (Q==0) or quoted strings (Q==1) */
#define WRDSO_ESC_SET(ws,q,f) ((ws)->ws_options |= ((f) << 4*(q)))
/* Test WS for escape option F for words (Q==0) or quoted strings (Q==1) */
#define WRDSO_ESC_TEST(ws,q,f) ((ws)->ws_options & ((f) << 4*(q)))
#define WRDSE_OK 0

Return to:

Send suggestions and report system problems to the System administrator.