mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
Update.
* libio/ioungetwc.c (ungetwc): Orient stream first. * libio/Makefile (tests): Add tst-ungetwc1. * libio/tst-ungetwc1.c: New file.
This commit is contained in:
@ -1,5 +1,9 @@
|
|||||||
2001-08-08 Ulrich Drepper <drepper@redhat.com>
|
2001-08-08 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* libio/ioungetwc.c (ungetwc): Orient stream first.
|
||||||
|
* libio/Makefile (tests): Add tst-ungetwc1.
|
||||||
|
* libio/tst-ungetwc1.c: New file.
|
||||||
|
|
||||||
* libio/wfileops.c (_IO_wfile_underflow): Remove incorrect test
|
* libio/wfileops.c (_IO_wfile_underflow): Remove incorrect test
|
||||||
for possible conversion using __codecvt_do_in.
|
for possible conversion using __codecvt_do_in.
|
||||||
* libio/Makefile (tests): Add tst-fgetws.
|
* libio/Makefile (tests): Add tst-fgetws.
|
||||||
|
@ -48,7 +48,7 @@ routines := \
|
|||||||
|
|
||||||
tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc \
|
tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc \
|
||||||
tst_wprintf2 tst-widetext test-fmemopen tst-ext tst-fopenloc \
|
tst_wprintf2 tst-widetext test-fmemopen tst-ext tst-fopenloc \
|
||||||
tst-fgetws
|
tst-fgetws tst-ungetwc1
|
||||||
test-srcs = test-freopen
|
test-srcs = test-freopen
|
||||||
|
|
||||||
all: # Make this the default target; it will be defined in Rules.
|
all: # Make this the default target; it will be defined in Rules.
|
||||||
@ -83,7 +83,8 @@ tst_wprintf2-ARGS = "Some Text"
|
|||||||
tst-widetext-ENV = LOCPATH=$(common-objpfx)localedata LANGUAGE=C
|
tst-widetext-ENV = LOCPATH=$(common-objpfx)localedata LANGUAGE=C
|
||||||
tst-fopenloc-ENV = LOCPATH=$(common-objpfx)localedata \
|
tst-fopenloc-ENV = LOCPATH=$(common-objpfx)localedata \
|
||||||
MALLOC_TRACE=$(objpfx)tst-fopenloc.mtrace
|
MALLOC_TRACE=$(objpfx)tst-fopenloc.mtrace
|
||||||
tst-fgetws-ENV = LOCPATH=$(common-objpfx)localedata LANGUAGE=C
|
tst-fgetws-ENV = LOCPATH=$(common-objpfx)localedata
|
||||||
|
tst-ungetwc1-ENV = LOCPATH=$(common-objpfx)localedata
|
||||||
|
|
||||||
generated = tst-fopenloc.mtrace tst-fopenloc.check
|
generated = tst-fopenloc.mtrace tst-fopenloc.check
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1993, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
|
/* Copyright (C) 1993, 1996-1999, 2001 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -35,11 +35,13 @@ ungetwc (c, fp)
|
|||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
CHECK_FILE (fp, WEOF);
|
CHECK_FILE (fp, WEOF);
|
||||||
if (c == WEOF)
|
|
||||||
return WEOF;
|
|
||||||
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
|
_IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
|
||||||
_IO_flockfile (fp);
|
_IO_flockfile (fp);
|
||||||
result = _IO_sputbackwc (fp, c);
|
_IO_fwide (fp, 1);
|
||||||
|
if (c == WEOF)
|
||||||
|
result = WEOF;
|
||||||
|
else
|
||||||
|
result = _IO_sputbackwc (fp, c);
|
||||||
_IO_funlockfile (fp);
|
_IO_funlockfile (fp);
|
||||||
_IO_cleanup_region_end (0);
|
_IO_cleanup_region_end (0);
|
||||||
return result;
|
return result;
|
||||||
|
81
libio/tst-ungetwc1.c
Normal file
81
libio/tst-ungetwc1.c
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
/* Taken from the Li18nux base test suite. */
|
||||||
|
|
||||||
|
#define _XOPEN_SOURCE 500
|
||||||
|
#include <locale.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main (void)
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
char *str ="abcdef";
|
||||||
|
wint_t ret, wc, ungetone = 0x00E4; /* 0x00E4 means `a umlaut'. */
|
||||||
|
char fname[] = "/tmp/tst-ungetwc1.out.XXXXXX";
|
||||||
|
int fd;
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
puts ("This program runs on de_DE.UTF-8 locale.");
|
||||||
|
if (setlocale (LC_ALL, "de_DE.UTF-8") == NULL)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "Err: Cannot run on the de_DE.UTF-8 locale");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
fd = mkstemp (fname);
|
||||||
|
if (fd == -1)
|
||||||
|
{
|
||||||
|
printf ("cannot open temp file: %m\n");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write some characters to `testfile'. */
|
||||||
|
if ((fp = fdopen (fd, "w")) == NULL)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "Cannot open 'testfile'.");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
fputs (str, fp);
|
||||||
|
fclose (fp);
|
||||||
|
|
||||||
|
/* Open `testfile'. */
|
||||||
|
if ((fp = fopen (fname, "r")) == NULL)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "Cannot open 'testfile'.");
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unget a character. */
|
||||||
|
ret = ungetwc (ungetone, fp);
|
||||||
|
printf ("Unget a character (0x%04x)\n", (unsigned int) ungetone);
|
||||||
|
fflush (stdout);
|
||||||
|
if (ret == WEOF)
|
||||||
|
{
|
||||||
|
puts ("ungetwc() returns NULL.");
|
||||||
|
exit (EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reget a character. */
|
||||||
|
wc = getwc (fp);
|
||||||
|
printf ("Reget a character (0x%04x)\n", (unsigned int) wc);
|
||||||
|
fflush (stdout);
|
||||||
|
if (wc == ungetone)
|
||||||
|
{
|
||||||
|
puts ("The ungotten character is equal to the regotten character.");
|
||||||
|
fflush (stdout);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
puts ("The ungotten character is not equal to the regotten character.");
|
||||||
|
printf ("ungotten one: %04x, regetone: %04x", ungetone, wc);
|
||||||
|
fflush (stdout);
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
fclose (fp);
|
||||||
|
|
||||||
|
unlink (fname);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
Reference in New Issue
Block a user