diff options
-rw-r--r-- | src/wordsplit.c | 39 | ||||
-rw-r--r-- | tests/wordsplit.at | 13 |
2 files changed, 36 insertions, 16 deletions
diff --git a/src/wordsplit.c b/src/wordsplit.c index f94015a..e979f27 100644 --- a/src/wordsplit.c +++ b/src/wordsplit.c | |||
@@ -807,21 +807,31 @@ wordsplit_finish (struct wordsplit *wsp) | |||
807 | 807 | ||
808 | if (n == 0 && (wsp->ws_flags & WRDSF_INCREMENTAL)) | 808 | if (n == 0) |
809 | { | 809 | { |
810 | /* The loop above have eliminated all nodes. Restart the | 810 | /* The loop above have eliminated all nodes. */ |
811 | processing, if there's any input left. */ | 811 | if (wsp->ws_flags & WRDSF_INCREMENTAL) |
812 | if (wsp->ws_endp < wsp->ws_len) | ||
813 | { | 812 | { |
814 | int rc; | 813 | /* Restart the processing, if there's any input left. */ |
815 | if (wsp->ws_flags & WRDSF_SHOWDBG) | 814 | if (wsp->ws_endp < wsp->ws_len) |
816 | wsp->ws_debug (_("Restarting")); | 815 | { |
817 | rc = wordsplit_process_list (wsp, skip_delim (wsp)); | 816 | int rc; |
818 | if (rc) | 817 | if (wsp->ws_flags & WRDSF_SHOWDBG) |
819 | return rc; | 818 | wsp->ws_debug (_("Restarting")); |
819 | rc = wordsplit_process_list (wsp, skip_delim (wsp)); | ||
820 | if (rc) | ||
821 | return rc; | ||
822 | } | ||
823 | else | ||
824 | { | ||
825 | wsp->ws_error = WRDSE_EOF; | ||
826 | return WRDSE_EOF; | ||
827 | } | ||
828 | goto again; | ||
820 | } | 829 | } |
821 | else | 830 | |
831 | if (wsp->ws_flags & WRDSF_NOSPLIT) | ||
822 | { | 832 | { |
823 | wsp->ws_error = WRDSE_EOF; | 833 | if (wordsplit_add_segm (wsp, 0, 0, _WSNF_EMPTYOK)) |
824 | return WRDSE_EOF; | 834 | return wsp->ws_errno; |
835 | n = 1; | ||
825 | } | 836 | } |
826 | goto again; | ||
827 | } | 837 | } |
@@ -2414,2 +2424,3 @@ wordsplit_process_list (struct wordsplit *wsp, size_t start) | |||
2414 | } | 2424 | } |
2425 | |||
2415 | return wsp->ws_errno; | 2426 | return wsp->ws_errno; |
diff --git a/tests/wordsplit.at b/tests/wordsplit.at index 631d939..e3af703 100644 --- a/tests/wordsplit.at +++ b/tests/wordsplit.at | |||
@@ -264,3 +264,3 @@ TOTAL: 2 | |||
264 | 264 | ||
265 | TESTWSP([nosplit with expansion],[wsp-var-nosplit],[nosplit], | 265 | TESTWSP([nosplit with variable expansion],[wsp-var-nosplit],[nosplit], |
266 | [a $FOO test], | 266 | [a $FOO test], |
@@ -273,3 +273,3 @@ TOTAL: 1 | |||
273 | 273 | ||
274 | TESTWSP([nosplit without expansion],[],[nosplit novar], | 274 | TESTWSP([nosplit without variable expansion],[],[nosplit novar], |
275 | [a $FOO test], | 275 | [a $FOO test], |
@@ -282,2 +282,11 @@ TOTAL: 1 | |||
282 | 282 | ||
283 | TESTWSP([nosplit: empty expansion],[],[nosplit trimnl], | ||
284 | [$FOO], | ||
285 | [NF: 1 | ||
286 | 0: "" | ||
287 | TOTAL: 1 | ||
288 | ], | ||
289 | [], | ||
290 | [FOO=""]) | ||
291 | |||
283 | TESTWSP([default value (defined)],[],[], | 292 | TESTWSP([default value (defined)],[],[], |