Commit 849176f3 authored by Niels Möller's avatar Niels Möller
Browse files

(print_raw, print_nl): Use printf.

Updated testcases with comments; comments are now preserved.

Rev: nettle/testsuite/sexp-conv-test:1.2
parent a40eeeed
...@@ -4,28 +4,12 @@ if [ -z "$srcdir" ] ; then ...@@ -4,28 +4,12 @@ if [ -z "$srcdir" ] ; then
srcdir=`pwd` srcdir=`pwd`
fi fi
# echo -n is not portable
if [ "`echo -n ''`" = "" ]; then
n='-n'; c=''
elif [ "`echo '\c'`" = "" ]; then
n=''; c='\c'
else
echo >&2 'Neither echo -n nor echo \c seems to work.'
exit 1
fi
# Doesn't work if $1 contains
print_raw () { print_raw () {
echo $n "$1$c" > "$2" printf "%s" "$1" > "$2"
} }
# Using a here-document seems more robust. However, I don't know how
# to get rid of the final newline, so we can't use it exclusively.
print_nl () { print_nl () {
cat >"$2" <<EOF printf "%s\n" "$1" > "$2"
$1
EOF
} }
test_advanced () { test_advanced () {
...@@ -106,7 +90,13 @@ test_advanced '()' '()' ...@@ -106,7 +90,13 @@ test_advanced '()' '()'
test_advanced '(foo bar baz)' '(foo bar test_advanced '(foo bar baz)' '(foo bar
baz)' baz)'
test_advanced '; comment test_advanced '; comment
()' '()' ()' '; comment
()'
test_advanced '(foo ; gazonk
bar)' '(foo ; gazonk
bar)'
test_advanced '(foo[bar]foo)' '(foo [bar]foo)' test_advanced '(foo[bar]foo)' '(foo [bar]foo)'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment