summaryrefslogtreecommitdiffabout
path: root/src/wordsplit.c
authorSergey Poznyakoff <gray@gnu.org>2019-06-05 13:34:43 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2019-06-05 13:34:43 (GMT)
commitb9e95e79712c1e0021e63204e0d910da2ec2692a (patch) (unidiff)
treed4d70a225257807223d944972cd3a25b9bb055a4 /src/wordsplit.c
parent1fa2dd2c6587822ff682581643499c3c3b78c9ea (diff)
downloadgrecs-b9e95e79712c1e0021e63204e0d910da2ec2692a.tar.gz
grecs-b9e95e79712c1e0021e63204e0d910da2ec2692a.tar.bz2
wordsplit: special handling for WRDSE_USAGE.
* 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.
Diffstat (limited to 'src/wordsplit.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/wordsplit.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/wordsplit.c b/src/wordsplit.c
index 48312bb..b38dde4 100644
--- a/src/wordsplit.c
+++ b/src/wordsplit.c
@@ -2686,6 +2686,8 @@ wordsplit_run (const char *command, size_t length, struct wordsplit *wsp,
2686 int rc; 2686 int rc;
2687 size_t start; 2687 size_t start;
2688 2688
2689 /* Initialize error context early */
2690 wsp->ws_errctx = NULL;
2689 if (!command) 2691 if (!command)
2690 { 2692 {
2691 if (!(flags & WRDSF_INCREMENTAL)) 2693 if (!(flags & WRDSF_INCREMENTAL))
@@ -2796,6 +2798,10 @@ wordsplit_clearerr (struct wordsplit *ws)
2796void 2798void
2797wordsplit_free (struct wordsplit *ws) 2799wordsplit_free (struct wordsplit *ws)
2798{ 2800{
2801 if (ws->ws_errno == WRDSE_USAGE)
2802 /* Usage error: the structure is not properly initialized and there's
2803 nothing to free. */
2804 return;
2799 wordsplit_clearerr (ws); 2805 wordsplit_clearerr (ws);
2800 wordsplit_free_nodes (ws); 2806 wordsplit_free_nodes (ws);
2801 wordsplit_free_words (ws); 2807 wordsplit_free_words (ws);

Return to:

Send suggestions and report system problems to the System administrator.