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
parent
6f5796238a
commit
4c61dfb1cc
|
@ -162,7 +162,7 @@ function parseline( i, m, j, me, orig )
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
# we're parsing CSVs
|
# we're parsing CSVs
|
||||||
FS = " *, *"
|
FS = "[[:space:]]*,[[:space:]]*"
|
||||||
OFS = ","
|
OFS = ","
|
||||||
|
|
||||||
has_directives = 0
|
has_directives = 0
|
||||||
|
|
|
@ -120,6 +120,22 @@ $bar_baz-quux,$foo'
|
||||||
run-test "$input" "$expected"
|
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()
|
test-range-delim()
|
||||||
{
|
{
|
||||||
|
@ -305,6 +321,7 @@ test-comment \
|
||||||
&& test-var-zero-ref \
|
&& test-var-zero-ref \
|
||||||
&& test-directive-stripped \
|
&& test-directive-stripped \
|
||||||
&& test-no-sort \
|
&& test-no-sort \
|
||||||
|
&& test-whitespace-including-tabs-ok \
|
||||||
&& test-fail-multi-directive \
|
&& test-fail-multi-directive \
|
||||||
&& test-fail-unknown-var-ref \
|
&& test-fail-unknown-var-ref \
|
||||||
&& test-fail-non-numeric-range \
|
&& test-fail-non-numeric-range \
|
||||||
|
@ -315,7 +332,7 @@ test-comment \
|
||||||
}
|
}
|
||||||
|
|
||||||
# safety check
|
# safety check
|
||||||
test "$testsum" -eq 15 || {
|
test "$testsum" -eq 16 || {
|
||||||
echo 'error: did not run all csvm2csv tests!' >&2
|
echo 'error: did not run all csvm2csv tests!' >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue