diff options
Diffstat (limited to 'helpers')
-rw-r--r-- | helpers/ChangeLog | 13 | ||||
-rwxr-xr-x | helpers/quoteconvert2.sh | 49 | ||||
-rw-r--r-- | helpers/scanfmt.c | 22 | ||||
-rw-r--r-- | helpers/tryfmt.c | 23 |
4 files changed, 107 insertions, 0 deletions
diff --git a/helpers/ChangeLog b/helpers/ChangeLog index 91d43464..17624c3f 100644 --- a/helpers/ChangeLog +++ b/helpers/ChangeLog @@ -1,3 +1,16 @@ +2014-04-08 Arnold D. Robbins <arnold@skeeve.com> + + * 4.1.1: Release tar ball made. + +2014-03-10 Arnold D. Robbins <arnold@skeeve.com> + + * quoteconvert2.sh: Use .UTF-8 locales per request from + Michal Jaegermann. + +2014-03-08 Arnold D. Robbins <arnold@skeeve.com> + + * quoteconvert2.sh, tryfmt.c, scanfmt.c: New files. + 2013-12-21 Arnold D. Robbins <arnold@skeeve.com> * testdfa.c: Fix some bugs and compiler warnings. 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 diff --git a/helpers/scanfmt.c b/helpers/scanfmt.c new file mode 100644 index 00000000..2d7bd73a --- /dev/null +++ b/helpers/scanfmt.c @@ -0,0 +1,22 @@ +/* + * Test out ' flag in different locales. + * Michal Jaegermann + * March, 2014 + */ + +#include <stdio.h> +#include <locale.h> +#include <stdlib.h> +int +main(int argc, char **argv) +{ + double t; + + if (argc == 1) + return 1; + + setlocale(LC_ALL, getenv("LC_ALL")); + sscanf(argv[1], "%lf", &t); + printf("%.2f\n", t); + return 0; +} diff --git a/helpers/tryfmt.c b/helpers/tryfmt.c new file mode 100644 index 00000000..8166d3f1 --- /dev/null +++ b/helpers/tryfmt.c @@ -0,0 +1,23 @@ +/* + * Test out ' flag in different locales. + * Michal Jaegermann + * March, 2014 + */ + +#include <locale.h> +#include <stdio.h> +#include <stdlib.h> +int +main(int argc, char **argv) +{ + const char *fmt; + if (argc == 1) + fmt = "%'.2f"; + else + fmt = argv[1]; + + setlocale(LC_ALL, getenv("LC_ALL")); + printf(fmt, 12456789.01); + printf("\n"); + return 0; +} |