aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--locale/programs/locale.c6
-rw-r--r--localedata/ChangeLog8
-rw-r--r--localedata/Makefile12
-rw-r--r--localedata/tst-numeric.c74
-rw-r--r--localedata/tst-numeric.data49
-rw-r--r--localedata/tst-numeric.sh48
7 files changed, 193 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 8f737fa856..579f2108f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2003-04-27 Ulrich Drepper <drepper@redhat.com>
+ * locale/programs/locale.c (show_info): Use '\177' instead of CHAR_MAX.
+
* Makerules ($(common-objpfx)shlib.lds): Don't use PROVIDE to
define __start_libc_freeres_ptrs and __stop___libc_freeres_ptrs.
diff --git a/locale/programs/locale.c b/locale/programs/locale.c
index 0a8d0563fb..9dc0e393a9 100644
--- a/locale/programs/locale.c
+++ b/locale/programs/locale.c
@@ -864,7 +864,7 @@ show_info (const char *name)
printf ("%s=", item->name);
if (val != NULL)
- printf ("%d", *val == CHAR_MAX ? -1 : *val);
+ printf ("%d", *val == '\177' ? -1 : *val);
putchar ('\n');
}
break;
@@ -878,12 +878,12 @@ show_info (const char *name)
while (cnt > 1)
{
- printf ("%d;", *val == CHAR_MAX ? -1 : *val);
+ printf ("%d;", *val == '\177' ? -1 : *val);
--cnt;
++val;
}
- printf ("%d\n", cnt == 0 || *val == CHAR_MAX ? -1 : *val);
+ printf ("%d\n", cnt == 0 || *val == '\177' ? -1 : *val);
}
break;
case word:
diff --git a/localedata/ChangeLog b/localedata/ChangeLog
index bdde5203fc..8322e01524 100644
--- a/localedata/ChangeLog
+++ b/localedata/ChangeLog
@@ -1,3 +1,11 @@
+2003-04-16 Petter Reinholdtsen <pere@hungry.com>
+
+ * Makefile (tests): Add LC_NUMERIC test tst-numeric.out.
+ (tst-numeric.out): Define.
+ * tst-numeric.c: New file.
+ * tst-numeric.sh: New file.
+ * tst-numeric.data: New file.
+
2003-04-21 Ulrich Drepper <drepper@redhat.com>
* locales/ar_BH: Fix spelling of Bahrain.
diff --git a/localedata/Makefile b/localedata/Makefile
index a7df29d9b1..c5e8711ca4 100644
--- a/localedata/Makefile
+++ b/localedata/Makefile
@@ -39,7 +39,7 @@ vpath %.h tests-mbwc
test-srcs := collate-test xfrm-test tst-fmon tst-rpmatch tst-trans \
tst-mbswcs1 tst-mbswcs2 tst-mbswcs3 tst-mbswcs4 tst-mbswcs5 \
- tst-ctype tst-wctype tst-langinfo
+ tst-ctype tst-wctype tst-langinfo tst-numeric
test-input := de_DE.ISO-8859-1 en_US.ISO-8859-1 da_DK.ISO-8859-1 \
hr_HR.ISO-8859-2 sv_SE.ISO-8859-1
test-input-data = $(addsuffix .in, $(basename $(test-input)))
@@ -65,6 +65,7 @@ distribute := CHECKSUMS README SUPPORTED ChangeLog \
tst-fmon.data $(test-input-data) $(ld-test-srcs) \
th_TH.in cs_CZ.in tst-mbswcs.sh tst-trans.sh tst-ctype.sh \
tst-ctype-de_DE.ISO-8859-1.in \
+ tst-numeric.sh tst-numeric.data \
$(wildcard tests-mbwc/*.[ch]) \
$(addprefix tst-fmon-locales/tstfmon_,$(fmon-tests)) \
gen-locale.sh show-ucs-data.c tst-langinfo.sh \
@@ -130,7 +131,7 @@ ifeq (no,$(cross-compiling))
LOCALES := de_DE.ISO-8859-1 de_DE.UTF-8 en_US.ANSI_X3.4-1968 \
en_US.ISO-8859-1 ja_JP.EUC-JP da_DK.ISO-8859-1 \
hr_HR.ISO-8859-2 sv_SE.ISO-8859-1 ja_JP.SJIS fr_FR.ISO-8859-1 \
- vi_VN.TCVN5712-1
+ vi_VN.TCVN5712-1 no_NO.ISO-8859-1 nn_NO.ISO-8859-1
LOCALE_SRCS := $(shell echo "$(LOCALES)"|sed 's/\([^ .]*\)[^ ]*/\1/g')
CHARMAPS := $(shell echo "$(LOCALES)" | \
sed -e 's/[^ .]*[.]\([^ ]*\)/\1/g' -e s/SJIS/SHIFT_JIS/g)
@@ -151,7 +152,7 @@ $(addsuffix .out,$(addprefix $(objpfx),$(tests))): %: \
tests: $(objpfx)sort-test.out $(objpfx)tst-fmon.out $(objpfx)tst-locale.out \
$(objpfx)tst-rpmatch.out $(objpfx)tst-trans.out \
$(objpfx)tst-mbswcs.out $(objpfx)tst-ctype.out $(objpfx)tst-wctype.out \
- $(objpfx)tst-langinfo.out
+ $(objpfx)tst-langinfo.out $(objpfx)tst-numeric.out
$(objpfx)sort-test.out: sort-test.sh $(objpfx)collate-test $(objpfx)xfrm-test \
$(test-input-data) $(addprefix $(objpfx),$(CTYPE_FILES))
@@ -162,6 +163,11 @@ $(objpfx)tst-fmon.out: tst-fmon.sh $(objpfx)tst-fmon tst-fmon.data \
$(addprefix $(objpfx),$(CTYPE_FILES))
$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' tst-fmon.data \
> $@
+$(objpfx)tst-numeric.out: tst-numeric.sh $(objpfx)tst-numeric tst-numeric.data \
+ $(objpfx)sort-test.out \
+ $(addprefix $(objpfx),$(CTYPE_FILES))
+ $(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' tst-numeric.data \
+ > $@
$(objpfx)tst-locale.out: tst-locale.sh $(common-objpfx)locale/localedef \
$(ld-test-srcs) $(addprefix $(objpfx),$(CTYPE_FILES))
$(SHELL) -e $< $(common-objpfx) '$(built-program-cmd)' > $@
diff --git a/localedata/tst-numeric.c b/localedata/tst-numeric.c
new file mode 100644
index 0000000000..86e6533f01
--- /dev/null
+++ b/localedata/tst-numeric.c
@@ -0,0 +1,74 @@
+/* Testing the implementation of LC_NUMERIC and snprintf().
+ Copyright (C) 2003 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Petter Reinholdtsen <pere@hungry.com>, 2003
+
+ Based on tst-fmon.c by Jochen Hein <jochen.hein@delphi.central.de>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdio.h>
+#include <locale.h>
+#include <string.h>
+#include <stdlib.h>
+
+/*
+ test-numeric gets called with three parameters:
+ - the locale
+ - the format-string to be used
+ - the actual number to be formatted
+ - the expected string
+ If the test passes, test-numeric terminates with returncode 0,
+ otherwise with 1
+*/
+#define EXIT_SUCCESS 0
+#define EXIT_FAILURE 1
+#define EXIT_SETLOCALE 2
+#define EXIT_SNPRINTF 3
+
+int
+main (int argc, char *argv[])
+{
+ char *s = malloc (201);
+ double val;
+
+ /* Make sure to read the value before setting of the locale, as
+ strtod() is locale-dependent. */
+ val = strtod (argv[3], NULL);
+
+ if (setlocale (LC_ALL, argv[1]) == NULL)
+ {
+ perror ("setlocale");
+ exit (EXIT_SETLOCALE);
+ }
+
+ if (snprintf (s, 200, argv[2], val) == -1)
+ {
+ perror ("snprintf");
+ exit (EXIT_SNPRINTF);
+ }
+
+ if (strcmp (s, argv[4]) != 0)
+ {
+ printf ("\
+locale: \"%s\", format: \"%s\", expected: \"%s\", got: \"%s\" => %s\n",
+ argv[1], argv[2], argv[4], s,
+ strcmp (s, argv[4]) != 0 ? "false" : "correct");
+ exit (EXIT_FAILURE);
+ }
+
+ return EXIT_SUCCESS;
+}
diff --git a/localedata/tst-numeric.data b/localedata/tst-numeric.data
new file mode 100644
index 0000000000..c586b68f93
--- /dev/null
+++ b/localedata/tst-numeric.data
@@ -0,0 +1,49 @@
+# Test data for tst-nomeric, which checks it's implementation in glibc
+# Copyright (C) 2003 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# Contributed by Petter Reinholdtsen <pere@hungry.com>, 2003
+# Based on code by Jochen Hein <jochen.hein@delphi.central.de>, 1997.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+# The format of this file is pretty simple: Each line contains a test
+# for strfmon. Fields are separated by TABs. Lines that start with a
+# '#' are comments and are ignored.
+#
+# Field Description
+# #1 locale which is to be checked
+# #2 format string which is fed into snprintf
+# #3 double value that is used for formatting
+# #4 the expected result (may contain trailing spaces!)
+#
+# First the implementation without any locale-dependent data
+C %g 1.23 1.23
+C %g -1.23 -1.23
+C %g 0 0
+C %% 0 %
+C %'g 123.45 123.45
+C %'g -123.45 -123.45
+C *%g* 1.23 *1.23*
+C %9g 1.23 1.23
+C %9g -1.23 -1.23
+#
+# check both the norwegian locales and snprintf with that data
+#
+no_NO.ISO-8859-1 %'g 123.45 123,45
+no_NO.ISO-8859-1 %'g -123.45 -123,45
+nn_NO.ISO-8859-1 %'g 123.45 123,45
+nn_NO.ISO-8859-1 %'g -123.45 -123,45
diff --git a/localedata/tst-numeric.sh b/localedata/tst-numeric.sh
new file mode 100644
index 0000000000..e6e973feba
--- /dev/null
+++ b/localedata/tst-numeric.sh
@@ -0,0 +1,48 @@
+#! /bin/sh
+# Testing the implementation of LC_NUMERIC and snprintf(3).
+# Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+# Contributed by Jochen Hein <jochen.hein@delphi.central.de>, 1997.
+#
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, write to the Free
+# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA.
+
+common_objpfx=$1
+run_program_prefix=$2
+datafile=$3
+
+# Run the tests.
+# There's a TAB for IFS
+while IFS=" " read locale format value expect; do
+ if [ -n "$format" ]; then
+ LOCPATH=${common_objpfx}localedata \
+ GCONV_PATH=${common_objpfx}/iconvdata \
+ ${run_program_prefix} ${common_objpfx}localedata/tst-numeric \
+ "$locale" "$format" "$value" "$expect"
+ if [ $? -eq 0 ]; then
+ echo "Locale: \"${locale}\" Format: \"${format}\"" \
+ "Value: \"${value}\" Expect: \"${expect}\" passed"
+ else
+ echo "Locale: \"${locale}\" Format: \"${format}\"" \
+ "Value: \"${value}\" Expect: \"${expect}\" failed"
+ fi
+ fi
+done < $datafile
+
+exit $?
+# Local Variables:
+# mode:shell-script
+# End: