summaryrefslogtreecommitdiffabout
path: root/src
authorSergey Poznyakoff <gray@gnu.org>2018-02-20 14:42:25 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2018-02-20 14:46:31 (GMT)
commitdae43f323db9578e656e3a6c53440e2365421af7 (patch) (side-by-side diff)
tree6e1cec4e17f3ee0132a1819e6c5a05d5170e18f0 /src
parent3299cf1ccb1c596969fcfd91253e10d5482eacf9 (diff)
downloadgrecs-dae43f323db9578e656e3a6c53440e2365421af7.tar.gz
grecs-dae43f323db9578e656e3a6c53440e2365421af7.tar.bz2
Minor improvement in wordsplit
* src/wordsplit.c (expvar): Gracefully handle NULL values in ENV_KV environment. * src/wordsplit.h: Fix typo in a comment. * doc/wordsplit.3: Update.
Diffstat (limited to 'src') (more/less context) (ignore whitespace changes)
-rw-r--r--src/wordsplit.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/wordsplit.c b/src/wordsplit.c
index 4884a22..5cd8daa 100644
--- a/src/wordsplit.c
+++ b/src/wordsplit.c
@@ -1034,9 +1034,14 @@ expvar (struct wordsplit *wsp, const char *str, size_t len,
rc = wordsplit_find_env (wsp, str, i, &vptr);
if (rc == WRDSE_OK)
{
- value = strdup (vptr);
- if (!value)
- rc = WRDSE_NOSPACE;
+ if (vptr)
+ {
+ value = strdup (vptr);
+ if (!value)
+ rc = WRDSE_NOSPACE;
+ }
+ else
+ rc = WRDSE_UNDEF;
}
else if (wsp->ws_flags & WRDSF_GETVAR)
rc = wsp->ws_getvar (&value, str, i, wsp->ws_closure);

Return to:

Send suggestions and report system problems to the System administrator.