summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2011-05-28 11:37:47 +0000
committerjilles <jilles@FreeBSD.org>2011-05-28 11:37:47 +0000
commit979af05e7725d814570e4633b10a5d49e67e987c (patch)
tree97044025b3bbee11165340fbea5bcf368dd81b10 /tools
parent36cd7cef5ee843f5238463d58cf2180183b674cd (diff)
downloadFreeBSD-src-979af05e7725d814570e4633b10a5d49e67e987c.zip
FreeBSD-src-979af05e7725d814570e4633b10a5d49e67e987c.tar.gz
printf: Allow multibyte characters for '<char> form, avoid negative codes.
Examples: LC_ALL=en_US.UTF-8 printf '%d\n' $(printf \'\\303\\244) LC_ALL=en_US.ISO8859-1 printf '%d\n' $(printf \'\\344) Both of these should print 228. Like some other shells, incomplete or invalid multibyte characters yield the value of the first byte without a warning. Note that there is no general way to go back from the character code to the character.
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/usr.bin/printf/regress.l1.out1
-rw-r--r--tools/regression/usr.bin/printf/regress.l2.out1
-rw-r--r--tools/regression/usr.bin/printf/regress.sh4
3 files changed, 5 insertions, 1 deletions
diff --git a/tools/regression/usr.bin/printf/regress.l1.out b/tools/regression/usr.bin/printf/regress.l1.out
new file mode 100644
index 0000000..9be0dc9
--- /dev/null
+++ b/tools/regression/usr.bin/printf/regress.l1.out
@@ -0,0 +1 @@
+228
diff --git a/tools/regression/usr.bin/printf/regress.l2.out b/tools/regression/usr.bin/printf/regress.l2.out
new file mode 100644
index 0000000..9be0dc9
--- /dev/null
+++ b/tools/regression/usr.bin/printf/regress.l2.out
@@ -0,0 +1 @@
+228
diff --git a/tools/regression/usr.bin/printf/regress.sh b/tools/regression/usr.bin/printf/regress.sh
index 980fc70..4ce282f 100644
--- a/tools/regression/usr.bin/printf/regress.sh
+++ b/tools/regression/usr.bin/printf/regress.sh
@@ -2,11 +2,13 @@
REGRESSION_START($1)
-echo '1..9'
+echo '1..11'
REGRESSION_TEST(`b', `printf "abc%b%b" "def\n" "\cghi"')
REGRESSION_TEST(`d', `printf "%d,%5d,%.5d,%0*d,%.*d\n" 123 123 123 5 123 5 123')
REGRESSION_TEST(`f', `printf "%f,%-8.3f,%f,%f\n" +42.25 -42.25 inf nan')
+REGRESSION_TEST(`l1', `LC_ALL=en_US.ISO8859-1 printf "%d\n" $(printf \"\\344)')
+REGRESSION_TEST(`l2', `LC_ALL=en_US.UTF-8 printf "%d\n" $(printf \"\\303\\244)')
REGRESSION_TEST(`m1', `printf "%c%%%d\0\045\n" abc \"abc')
REGRESSION_TEST(`m2', `printf "abc\n\cdef"')
REGRESSION_TEST(`m3', `printf "%%%s\n" abc def ghi jkl')
OpenPOWER on IntegriCloud