aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2019-06-05 16:34:43 +0300
committerSergey Poznyakoff <gray@gnu.org>2019-06-05 16:34:43 +0300
commitb4fefca05266f3d21cb92ee091d2e26203420bb9 (patch)
tree851369a1c4cb6f1126effda726ea2d6d537fad58
parent6c37c44ee006b3ed9957e5f3664c7063f319d565 (diff)
downloadwordsplit-b4fefca05266f3d21cb92ee091d2e26203420bb9.tar.gz
wordsplit-b4fefca05266f3d21cb92ee091d2e26203420bb9.tar.bz2
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.
-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,
int rc;
size_t start;
+ /* Initialize error context early */
+ wsp->ws_errctx = NULL;
if (!command)
{
if (!(flags & WRDSF_INCREMENTAL))
@@ -2796,6 +2798,10 @@ wordsplit_clearerr (struct wordsplit *ws)
void
wordsplit_free (struct wordsplit *ws)
{
+ if (ws->ws_errno == WRDSE_USAGE)
+ /* Usage error: the structure is not properly initialized and there's
+ nothing to free. */
+ return;
wordsplit_clearerr (ws);
wordsplit_free_nodes (ws);
wordsplit_free_words (ws);

Return to:

Send suggestions and report system problems to the System administrator.