This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch for printf's "%If"


On Wed, 2004-01-14 at 08:03, Ulrich Drepper wrote:

> This isn't really a test.  We should also have code where the output is
> compared with the expected result.  And this should be done in a locale
> which is actually providing the information.

OK, I changed it. Currently,  The only locale which uses its own
outdigits is Persian. So I set the locale to fa_IR to test I18n flag.
It checks 'd' and 'f'. But if you think we need more like 'e' or 'g' let
me know.
The patch is attached.

Hamed

--- ../../work/glibc-2.3.2-200310271512/stdio-common/tst-printf.c	2004-01-12 18:34:50.000000000 +0330
+++ tst-printf.c	2004-01-18 13:00:21.000000000 +0330
@@ -28,10 +28,13 @@
 #endif
 
 #include <float.h>
+#include <locale.h>
+#include <langinfo.h>
 
 static void rfg1 (void);
 static void rfg2 (void);
 static void rfg3 (void);
+static void rfg4 (void);
 
 
 static void
@@ -278,6 +281,7 @@
   rfg1 ();
   rfg2 ();
   rfg3 ();
+  rfg4 ();
 
   {
     char bytes[7];
@@ -381,3 +385,28 @@
     printf ("got: '%s', expected: '%s'\n", buf,
 	    "   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 = 123;
+  float f = 12.34;
+
+  setlocale (LC_ALL, "fa_IR.utf-8");
+
+  sprintf(persian_int, "%lc%lc%lc", 0x06f1, 0x06f2, 0x06f3);
+  sprintf(persian_float, "%lc%lc%s%lc%lc", 0x06f1, 0x06f2, nl_langinfo(RADIXCHAR) ,0x06f3, 0x06f4);
+
+  sprintf(buf, "%Id", 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, "");
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]