Back to index

glibc  2.9
tst-setvbuf1.c
Go to the documentation of this file.
00001 /* Dereived from the test case in BZ #2337.  */
00002 #include <errno.h>
00003 #include <error.h>
00004 #include <fcntl.h>
00005 #include <locale.h>
00006 #include <stdio.h>
00007 #include <stdlib.h>
00008 #include <string.h>
00009 #include <unistd.h>
00010 #include <wchar.h>
00011 
00012 
00013 static char buf[512] __attribute__ ((aligned (4096)));
00014 
00015 
00016 static int
00017 do_test (void)
00018 {
00019   setlocale (LC_ALL, "de_DE.UTF-8");
00020 
00021   FILE *fp = fdopen (dup (STDOUT_FILENO), "a");
00022   if (fp == NULL)
00023     error (EXIT_FAILURE, errno, "fdopen(,\"a\")");
00024 
00025   setvbuf (fp, buf, _IOFBF, sizeof (buf));
00026 
00027   /* fwprintf to unbuffered stream.   */
00028   fwprintf (fp, L"hello.\n");
00029 
00030   fclose (fp);
00031 
00032   /* touch my buffer */
00033   buf[45] = 'a';
00034 
00035   return 0;
00036 }
00037 
00038 #define TEST_FUNCTION do_test ()
00039 #include "../test-skeleton.c"