Back to index

glibc  2.9
bug14.c
Go to the documentation of this file.
00001 /* Test case by Al Viro <aviro@redhat.com>.  */
00002 #include <locale.h>
00003 #include <wchar.h>
00004 #include <stdio.h>
00005 #include <stdlib.h>
00006 
00007 /* MB_CUR_MAX multibyte ones (6 UTF+0080, in this case) */
00008 static const char string[] = "\
00009 \xc2\x80\xc2\x80\xc2\x80\xc2\x80\xc2\x80\xc2\x80";
00010 
00011 int
00012 main (void)
00013 {
00014   if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
00015     {
00016       puts ("cannot set locale");
00017       exit (1);
00018     }
00019 
00020   wchar_t s[7];
00021   int n = sscanf (string, "%l[\x80\xc2]", s);
00022   if (n != 1)
00023     {
00024       printf ("return values %d != 1\n", n);
00025       exit (1);
00026     }
00027 
00028   return 0;
00029 }