diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2014-03-08 22:13:53 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2014-03-08 22:13:53 +0200 |
commit | 23e7f1057b1abdebb25fc7d2f11ee3f5360976a4 (patch) | |
tree | cdd91edb34458798d5c0a65cd4c476b01fbf76ec /helpers/quoteconvert2.sh | |
parent | 586bb71fdbeb5041263a3e48392d79c5931df3c4 (diff) | |
parent | c972e253abc34f8bd02f6ade74e7999a2b6d8a08 (diff) | |
download | egawk-23e7f1057b1abdebb25fc7d2f11ee3f5360976a4.tar.gz egawk-23e7f1057b1abdebb25fc7d2f11ee3f5360976a4.tar.bz2 egawk-23e7f1057b1abdebb25fc7d2f11ee3f5360976a4.zip |
Merge branch 'gawk-4.1-stable'
Diffstat (limited to 'helpers/quoteconvert2.sh')
-rwxr-xr-x | helpers/quoteconvert2.sh | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/helpers/quoteconvert2.sh b/helpers/quoteconvert2.sh new file mode 100755 index 00000000..e33a4d05 --- /dev/null +++ b/helpers/quoteconvert2.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +# quoteconvert2.sh --- test locale dependent output of numbers +# Michal Jaegermann, michal@harddata.com, 2014/Mar/1 + +#AWK="../gawk" +SCRIPT=`basename $0` + +if [ "$AWK" = "" ] +then + echo $0: You must set AWK >&2 + exit 1 +fi + +# The last entry on this list represents "a locale with a typo". + +llist=" +C +en_US +en_US.utf8 +de_DE +de_DE.utf8 +fr_FR +fr_FR.utf8 +pt_PT +pt_PT.utf8 +pt_BR +pt_BR.utf8 +ru_RU +ru_RU.utf8 +pl_PX +" + +error=0 +for lc in $llist ; do + wanted=`LC_ALL=$lc locale -c LC_NUMERIC 2>/dev/null | \ + $AWK 'NR == 2 { decimal_point = $0 } + NR == 3 { thousands_sep = $0 } + END { printf("123%s456%s789%s15\n", + thousands_sep, thousands_sep, decimal_point)}'` + got=`LC_ALL=$lc $AWK "BEGIN {printf(\"%'.2f\n\",123456789.15)}"` + if [ "$wanted" != "$got" ] ; then + echo "$lc - unexpected output $got instead of $wanted" + error=1 + fi +done + +[ "$error" = 0 ] && echo ok || echo bummer +exit $error |