This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
[PATCH] New function to test localized digits
- From: Hamed Malek <hamed at bamdad dot org>
- To: libc-alpha <libc-alpha at sources dot redhat dot com>
- Date: Tue, 08 Jun 2004 18:03:37 +0430
- Subject: [PATCH] New function to test localized digits
- Organization: Sharif FarsiWeb, Inc.
Hi,
I think this is the third time I send this patch.
This checks both integer and float localized numbers.
The patch is attached.
Hamed
--- glibc-2.3.3-200405070341/stdio-common/tst-printf.c.orig 2004-06-08 17:38:30.445222640 +0430
+++ glibc-2.3.3-200405070341/stdio-common/tst-printf.c 2004-06-08 17:44:17.259498856 +0430
@@ -28,10 +28,12 @@
#endif
#include <float.h>
+#include <locale.h>
static void rfg1 (void);
static void rfg2 (void);
static void rfg3 (void);
+static void rfg4 (void);
static void
@@ -278,6 +280,7 @@
rfg1 ();
rfg2 ();
rfg3 ();
+ rfg4 ();
{
char bytes[7];
@@ -382,3 +385,29 @@
" 12345 1234 11145401322 321.765432 3.217654e+02 5 test-string");
}
+
+static void
+rfg4 (void)
+{
+ char buf[100];
+ char persian_int[100];
+ char persian_float[100];
+ int i = 12345;
+ float f = 1234.56;
+
+ setlocale (LC_ALL, "fa_IR.UTF-8");
+
+ sprintf(persian_int, "%lc%lc%lc%lc%lc%lc", 0x06f1, 0x06f2, 0x066c, 0x06f3, 0x06f4, 0x06f5);
+ sprintf(persian_float, "%lc%lc%lc%lc%lc%lc%lc%lc", 0x06f1, 0x066c, 0x06f2, 0x06f3, 0x06f4, 0x066b, 0x06f5, 0x06f6);
+
+ sprintf(buf, "%I'd", i);
+ if (strcmp (buf, persian_int) != 0)
+ printf ("got: '%s', expected: '%s'\n", buf, persian_int);
+
+ sprintf(buf, "%I'.2f", f);
+ if (strcmp (buf, persian_float) != 0)
+ printf ("got: '%s', expected: '%s'\n", buf, persian_float);
+
+ setlocale (LC_ALL, "");
+}
+