Back to index

glibc  2.9
bug20.c
Go to the documentation of this file.
00001 /* BZ #5225 */
00002 #include <stdio.h>
00003 #include <string.h>
00004 #include <wchar.h>
00005 
00006 static int
00007 do_test (void)
00008 {
00009   wchar_t in[] = L"123,abc,321";
00010   /* This is the critical part for this test.  format must be in
00011      read-only memory.  */
00012   static const wchar_t format[50] = L"%d,%[^,],%d";
00013   int out_d1, out_d2;
00014   char out_s[50];
00015   printf ("in='%ls' format='%ls'\n", in, format);
00016   if (swscanf (in, format, &out_d1, out_s, &out_d2) != 3)
00017     {
00018       puts ("swscanf did not return 3");
00019       return 1;
00020     }
00021   printf ("in='%ls' format='%ls'\n", in, format);
00022   printf ("out_d1=%d out_s='%s' out_d2=%d\n", out_d1, out_s, out_d2);
00023   if (out_d1 != 123 || strcmp (out_s, "abc") != 0 || out_d2 != 321)
00024     {
00025       puts ("swscanf did not return the correct values");
00026       return 1;
00027     }
00028   return 0;
00029 }
00030 
00031 #define TEST_FUNCTION do_test ()
00032 #include "../test-skeleton.c"