csvm: Permit all whitespace (including tabs)

While tabs aren't desirable, users that are not developers will be modifying
these files, and so we need to be permissive in what we want to
accept.  That doesn't mean that we need to forego occasional formatting, though.
master
Mike Gerwitz 2019-04-08 15:16:58 -04:00
parent 6f5796238a
commit 4c61dfb1cc
2 changed files with 19 additions and 2 deletions

View File

@ -162,7 +162,7 @@ function parseline( i, m, j, me, orig )
BEGIN {
# we're parsing CSVs
FS = " *, *"
FS = "[[:space:]]*,[[:space:]]*"
OFS = ","
has_directives = 0

View File

@ -120,6 +120,22 @@ $bar_baz-quux,$foo'
run-test "$input" "$expected"
}
# same as above but with whitespace
test-whitespace-including-tabs-ok()
{
declare -r input='header, line
:foo=1
:bar_baz-quux=2
$foo, 1
$bar_baz-quux, $foo'
declare -r expected='header,line
1,1
2,1'
run-test "$input" "$expected"
}
test-range-delim()
{
@ -305,6 +321,7 @@ test-comment \
&& test-var-zero-ref \
&& test-directive-stripped \
&& test-no-sort \
&& test-whitespace-including-tabs-ok \
&& test-fail-multi-directive \
&& test-fail-unknown-var-ref \
&& test-fail-non-numeric-range \
@ -315,7 +332,7 @@ test-comment \
}
# safety check
test "$testsum" -eq 15 || {
test "$testsum" -eq 16 || {
echo 'error: did not run all csvm2csv tests!' >&2
exit 1
}