This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
glibc-2.3.6/libio/tst_putwc.c
- From: Pedro Izecksohn <izecksohn at yahoo dot com>
- To: libc-alpha at sourceware dot org
- Date: Thu, 24 Aug 2006 13:16:36 -0700 (PDT)
- Subject: glibc-2.3.6/libio/tst_putwc.c
The existing test does not show a bug. So I wrote a test that fails on
Linux (derived from Debian with libc6 2.3.6-15) on i686. My test succeeds on
other platforms.
If you accept it, I may modify it to conform to glibc tests standard.
Also, if you accept me, I could write a fputwc replacement.
/**
To be included in glibc, could this test be licensed under GPL or must be
LGPL?
By: Pedro Izecksohn , izecksohn@yahoo.com
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <wchar.h>
#define begin 0xa1
#define after_end 0x100
#define n_ops (after_end-begin)
int main (void) {
char * filename = "fputwc_test.temp";
FILE * file;
wchar_t c;
wchar_t wa [n_ops];
int i;
file = fopen (filename, "w");
if (!file) {perror ("creating"); return EXIT_FAILURE;}
for (c=begin; c<after_end; c++) {
if (fputwc (c, file)==WEOF) {
int err = errno;
fprintf (stderr, "fputwc (%u, %p) returned WEOF because %s.\n", c, file,
strerror (err));
return EXIT_FAILURE;
}
}
if (fclose (file)) {perror ("first fclose"); return EXIT_FAILURE;}
file = fopen (filename, "r");
if (!file) {perror ("re-opening"); return EXIT_FAILURE;}
// Could remove here, but tester would not be able to inspect file.
i = fread (wa, sizeof (wchar_t), n_ops, file);
if (i!=n_ops) {
fprintf (stderr, "fread returned 0x%x.\n", i);
if (ferror (file)) perror (NULL);
return EXIT_FAILURE;
}
for (i=0; i<n_ops; i++) {
if (wa[i]!=(wchar_t)(begin+i)) {
fprintf (stderr, "i == 0x%x\twa[i] == 0x%x\t(begin+i) == 0x%x", i, wa[i],
(begin+i));
return EXIT_FAILURE;
}
}
if (fclose (file)) {perror ("second fclose"); return EXIT_FAILURE;}
if (remove (filename)) {fprintf (stderr, "Could not remove %s\n", filename);
return EXIT_FAILURE;}
return EXIT_SUCCESS;
}
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com