summaryrefslogtreecommitdiff
path: root/localedata
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-02-19 04:40:58 +0000
committerUlrich Drepper <drepper@redhat.com>2007-02-19 04:40:58 +0000
commitecb72bd5b640497474ceae8d5e991b88c0c032e2 (patch)
tree97a7c41d486c34139416fb2b225854b0d074992d /localedata
parentac2ca0229ab39381e9e92e07f929703981f77a90 (diff)
[BZ #2211]
* stdio-common/vfscanf.c: Handle localized digits etc for floating point numbers. Patch mostly by Hamed Malek <hamed@farsiweb.info>.
Diffstat (limited to 'localedata')
-rw-r--r--localedata/ChangeLog4
-rw-r--r--localedata/Makefile6
-rw-r--r--localedata/tst-sscanf.c56
3 files changed, 63 insertions, 3 deletions
diff --git a/localedata/ChangeLog b/localedata/ChangeLog
index 9dfe469503..e1bc145ec3 100644
--- a/localedata/ChangeLog
+++ b/localedata/ChangeLog
@@ -1,5 +1,9 @@
2007-02-18 Ulrich Drepper <drepper@redhat.com>
+ * Makefile (tests): Add tst-sscanf.
+ (LOCALES): Add fa_IR.UTF-8.
+ * tst-sscanf.c: New file.
+
* da_DK.in: Adjust for unified collation.
* locales/vi_VN: Don't define HOK here as well.
diff --git a/localedata/Makefile b/localedata/Makefile
index db7094fabe..e518175b98 100644
--- a/localedata/Makefile
+++ b/localedata/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1996-2002, 2003, 2005 Free Software Foundation, Inc.
+# Copyright (C) 1996-2002, 2003, 2005, 2007 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
@@ -93,7 +93,7 @@ locale_test_suite := tst_iswalnum tst_iswalpha tst_iswcntrl \
tests = $(locale_test_suite) tst-digits tst-setlocale bug-iconv-trans \
tst-leaks tst-mbswcs6 tst-xlocale1 tst-xlocale2 bug-usesetlocale \
- tst-strfmon1
+ tst-strfmon1 tst-sscanf
ifeq (yes,$(build-shared))
ifneq (no,$(PERL))
tests: $(objpfx)mtrace-tst-leaks
@@ -133,7 +133,7 @@ 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 nb_NO.ISO-8859-1 nn_NO.ISO-8859-1 \
- tr_TR.UTF-8 cs_CZ.UTF-8 zh_TW.EUC-TW
+ tr_TR.UTF-8 cs_CZ.UTF-8 zh_TW.EUC-TW fa_IR.UTF-8
LOCALE_SRCS := $(shell echo "$(LOCALES)"|sed 's/\([^ .]*\)[^ ]*/\1/g')
CHARMAPS := $(shell echo "$(LOCALES)" | \
sed -e 's/[^ .]*[.]\([^ ]*\)/\1/g' -e s/SJIS/SHIFT_JIS/g)
diff --git a/localedata/tst-sscanf.c b/localedata/tst-sscanf.c
new file mode 100644
index 0000000000..89a77a14f8
--- /dev/null
+++ b/localedata/tst-sscanf.c
@@ -0,0 +1,56 @@
+#include <stdio.h>
+#include <locale.h>
+#include <assert.h>
+
+#define P0 "\xDB\xB0"
+#define P1 "\xDB\xB1"
+#define P2 "\xDB\xB2"
+#define P3 "\xDB\xB3"
+#define P4 "\xDB\xB4"
+#define P5 "\xDB\xB5"
+#define P6 "\xDB\xB6"
+#define P7 "\xDB\xB7"
+#define P8 "\xDB\xB8"
+#define P9 "\xDB\xB9"
+#define PD "\xd9\xab"
+#define PT "\xd9\xac"
+
+static int
+check_sscanf (const char *s, const char *format, const float n)
+{
+ float f;
+
+ if (sscanf (s, format, &f) != 1)
+ {
+ printf ("nothing found for \"%s\"\n", s);
+ return 1;
+ }
+ if (f != n)
+ {
+ printf ("got %f expected %f from \"%s\"\n", f, n, s);
+ return 1;
+ }
+ return 0;
+}
+
+static int
+do_test (void)
+{
+ if (setlocale (LC_ALL, "fa_IR") == NULL)
+ {
+ puts ("cannot set fa_IR locale");
+ return 1;
+ }
+
+ int r = check_sscanf (P3 PD P1 P4, "%I8f", 3.14);
+ r |= check_sscanf (P3 PT P1 P4 P5, "%I'f", 3145);
+ r |= check_sscanf (P3 PD P1 P4 P1 P5 P9, "%If", 3.14159);
+ r |= check_sscanf ("-" P3 PD P1 P4 P1 P5, "%If", -3.1415);
+ r |= check_sscanf ("+" PD P1 P4 P1 P5, "%If", +.1415);
+ r |= check_sscanf (P3 PD P1 P4 P1 P5 "e+" P2, "%Ie", 3.1415e+2);
+
+ return r;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"