Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@rtspecialty.com>2019-04-08 15:16:58 -0400
committerMike Gerwitz <mike.gerwitz@rtspecialty.com>2019-04-08 15:17:00 -0400
commit4c61dfb1cc85eeaa232ec810b260d3b0169e0829 (patch)
treef4d58286b0eb7281525b69d4c5fa880e33a4edbf /build-aux
parent6f5796238a2102b2fb05cc15422abcbe7bf228de (diff)
downloadtame-4c61dfb1cc85eeaa232ec810b260d3b0169e0829.tar.gz
tame-4c61dfb1cc85eeaa232ec810b260d3b0169e0829.tar.bz2
tame-4c61dfb1cc85eeaa232ec810b260d3b0169e0829.zip
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.
Diffstat (limited to 'build-aux')
-rwxr-xr-xbuild-aux/csvm-expand2
-rwxr-xr-xbuild-aux/test/test-csvm2csv19
2 files changed, 19 insertions, 2 deletions
diff --git a/build-aux/csvm-expand b/build-aux/csvm-expand
index e53e5b3..74a71e9 100755
--- a/build-aux/csvm-expand
+++ b/build-aux/csvm-expand
@@ -162,7 +162,7 @@ function parseline( i, m, j, me, orig )
BEGIN {
# we're parsing CSVs
- FS = " *, *"
+ FS = "[[:space:]]*,[[:space:]]*"
OFS = ","
has_directives = 0
diff --git a/build-aux/test/test-csvm2csv b/build-aux/test/test-csvm2csv
index 04e6337..3e9bded 100755
--- a/build-aux/test/test-csvm2csv
+++ b/build-aux/test/test-csvm2csv
@@ -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
}