aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2018-02-20 16:42:25 +0200
committerSergey Poznyakoff <gray@gnu.org>2018-02-20 16:46:31 +0200
commitdae43f323db9578e656e3a6c53440e2365421af7 (patch)
tree6e1cec4e17f3ee0132a1819e6c5a05d5170e18f0
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.
-rw-r--r--doc/wordsplit.35
-rw-r--r--include/wordsplit.h4
-rw-r--r--src/wordsplit.c11
3 files changed, 13 insertions, 7 deletions
diff --git a/doc/wordsplit.3 b/doc/wordsplit.3
index 067ea5e..a391b81 100644
--- a/doc/wordsplit.3
+++ b/doc/wordsplit.3
@@ -14,7 +14,7 @@
14.\" You should have received a copy of the GNU General Public License 14.\" You should have received a copy of the GNU General Public License
15.\" along with Grecs. If not, see <http://www.gnu.org/licenses/>. 15.\" along with Grecs. If not, see <http://www.gnu.org/licenses/>.
16.\" 16.\"
17.TH WORDSPLIT 3 "December 3, 2014" "GRECS" "Grecs User Reference" 17.TH WORDSPLIT 3 "February 20, 2018" "GRECS" "Grecs User Reference"
18.SH NAME 18.SH NAME
19wordsplit \- split string into words 19wordsplit \- split string into words
20.SH SYNOPSIS 20.SH SYNOPSIS
@@ -181,7 +181,8 @@ elements in the array:
181.IR ws_env [ n ] 181.IR ws_env [ n ]
182containing the variable name, and 182containing the variable name, and
183.IR ws_env [ "n+1" ] 183.IR ws_env [ "n+1" ]
184containing its value. 184containing its value. If the latter is \fBNULL\fR, the corresponding
185variable is undefined.
185.PP 186.PP
186More sophisticated variable tables can be implemented using 187More sophisticated variable tables can be implemented using
187callback function. The \fIws_getvar\fR member should be set to point 188callback function. The \fIws_getvar\fR member should be set to point
diff --git a/include/wordsplit.h b/include/wordsplit.h
index eed88bc..d8cd461 100644
--- a/include/wordsplit.h
+++ b/include/wordsplit.h
@@ -81,8 +81,8 @@ struct wordsplit
81 void *clos); 81 void *clos);
82 /* [Input] (!WRDSF_NOCMD) Returns in the memory 82 /* [Input] (!WRDSF_NOCMD) Returns in the memory
83 location pointed to by RET the expansion of 83 location pointed to by RET the expansion of
84 the command CMD (LEN bytes nong). If WRDSF_ARGV 84 the command CMD (LEN bytes long). If WRDSO_ARGV
85 flag is set, ARGV contains CMD split out to 85 option is set, ARGV contains CMD split out to
86 words. Otherwise ARGV is NULL. 86 words. Otherwise ARGV is NULL.
87 87
88 See ws_getvar for a discussion of possible 88 See ws_getvar for a discussion of possible
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,
1034 rc = wordsplit_find_env (wsp, str, i, &vptr); 1034 rc = wordsplit_find_env (wsp, str, i, &vptr);
1035 if (rc == WRDSE_OK) 1035 if (rc == WRDSE_OK)
1036 { 1036 {
1037 value = strdup (vptr); 1037 if (vptr)
1038 if (!value) 1038 {
1039 rc = WRDSE_NOSPACE; 1039 value = strdup (vptr);
1040 if (!value)
1041 rc = WRDSE_NOSPACE;
1042 }
1043 else
1044 rc = WRDSE_UNDEF;
1040 } 1045 }
1041 else if (wsp->ws_flags & WRDSF_GETVAR) 1046 else if (wsp->ws_flags & WRDSF_GETVAR)
1042 rc = wsp->ws_getvar (&value, str, i, wsp->ws_closure); 1047 rc = wsp->ws_getvar (&value, str, i, wsp->ws_closure);

Return to:

Send suggestions and report system problems to the System administrator.