diff options
author | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2014-04-13 14:30:56 -0400 |
---|---|---|
committer | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2014-04-13 14:30:56 -0400 |
commit | 94e3f93395de538d73826e128281a3ea9591a5a9 (patch) | |
tree | 45257e4b024537c5e0e5a3037a99ea9765583c99 /helpers/quoteconvert2.sh | |
parent | c4300d657ba49db0b6d0f0884f41a29622edc58b (diff) | |
parent | a4b59faf911743b30f2e6e979c4f9c1ea0669ac3 (diff) | |
download | egawk-94e3f93395de538d73826e128281a3ea9591a5a9.tar.gz egawk-94e3f93395de538d73826e128281a3ea9591a5a9.tar.bz2 egawk-94e3f93395de538d73826e128281a3ea9591a5a9.zip |
Merge branch 'master' into select
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..63750a37 --- /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.UTF-8 +de_DE +de_DE.UTF-8 +fr_FR +fr_FR.UTF-8 +pt_PT +pt_PT.UTF-8 +pt_BR +pt_BR.UTF-8 +ru_RU +ru_RU.UTF-8 +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 |