mirror of
git://git.gnu.org.ua/wordsplit.git
synced 2025-04-26 08:39:54 +03:00
Fix handling of empty words when WRDSF_RETURN_DELIMS or WRDSO_MAXWORDS are in effect
* README: Update. * wordsplit.3: Document changes. * wordsplit.at: Test backward compatibility quirk. * wordsplit.c: Make sure NULL and DELIM nodes are protected from expansions. (wordsplit_finish): Ensure the output array produced with WRDSF_RETURN_DELIMS is consistent with that produced without this flag. Provide new option, WRDSO_RETDELNOTEMPTY, to request old buggy behavior. * wordsplit.h (WRDSO_RETDELNOTEMPTY): New option. * wsp.c: New tests.
This commit is contained in:
parent
0e1a09c4c7
commit
8f3eb3433e
6 changed files with 138 additions and 55 deletions
47
wordsplit.at
47
wordsplit.at
|
@ -1,5 +1,5 @@
|
|||
# Test suite for wordsplit -*- Autotest -*-
|
||||
# Copyright (C) 2014-2023 Sergey Poznyakoff
|
||||
# Copyright (C) 2014-2025 Sergey Poznyakoff
|
||||
#
|
||||
# Wordsplit is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
@ -496,6 +496,24 @@ TOTAL: 9
|
|||
TESTWSP([custom, with returned & squeezed delimiters],[],
|
||||
[-delim : -nows -trimnl -return_delims -nosqueeze_delims],
|
||||
[semicolon: separated::list: of :words],
|
||||
[NF: 11
|
||||
0: semicolon
|
||||
1: :
|
||||
2: " separated"
|
||||
3: :
|
||||
4: ""
|
||||
5: :
|
||||
6: list
|
||||
7: :
|
||||
8: " of "
|
||||
9: :
|
||||
10: words
|
||||
TOTAL: 11
|
||||
])
|
||||
|
||||
TESTWSP([custom, with returned & squeezed delimiters (compat)],[],
|
||||
[-delim : -nows -trimnl -return_delims -retdelnotempty -nosqueeze_delims],
|
||||
[semicolon: separated::list: of :words],
|
||||
[NF: 10
|
||||
0: semicolon
|
||||
1: :
|
||||
|
@ -510,6 +528,17 @@ TESTWSP([custom, with returned & squeezed delimiters],[],
|
|||
TOTAL: 10
|
||||
])
|
||||
|
||||
TESTWSP([with maxwords limit],[],
|
||||
[-nodefault -delim : -trimnl -maxwords 4],
|
||||
[foo::baz:qux],
|
||||
[NF: 4
|
||||
0: foo
|
||||
1: ""
|
||||
2: baz
|
||||
3: qux
|
||||
TOTAL: 4
|
||||
])
|
||||
|
||||
WSPGROUP(wsp-sed)
|
||||
|
||||
TESTWSP([sed expressions],[],[-sed],
|
||||
|
@ -922,6 +951,21 @@ TESTWSP([maxwords return_delims -squeeze_delims],[],
|
|||
[NF: 8
|
||||
0: foo
|
||||
1: :
|
||||
2: ""
|
||||
3: :
|
||||
4: ""
|
||||
5: :
|
||||
6: bar
|
||||
7: -:baz:qux-
|
||||
TOTAL: 8
|
||||
])
|
||||
|
||||
TESTWSP([maxwords return_delims -squeeze_delims (compat)],[],
|
||||
[-trimnl -maxwords 8 -return_delims -retdelnotempty -nosqueeze_delims -delim :-],
|
||||
[foo:::bar-:baz:qux-],
|
||||
[NF: 8
|
||||
0: foo
|
||||
1: :
|
||||
2: :
|
||||
3: :
|
||||
4: bar
|
||||
|
@ -1161,7 +1205,6 @@ TESTWSP([alternate value],[wsp-alt wsp-alt03],
|
|||
TOTAL: 2
|
||||
])
|
||||
|
||||
|
||||
m4_popdef([TESTWSP])
|
||||
m4_popdef([wspnum])
|
||||
m4_popdef([wspid])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue