From 0ecb606cb6cf65de1d9fc8a919bceb4be476c602 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 12 Jul 2007 18:26:36 +0000 Subject: 2.5-18.1 --- libio/Makefile | 12 ++- libio/Versions | 3 + libio/bits/libio-ldbl.h | 25 +++++ libio/bits/stdio-ldbl.h | 74 +++++++++++++++ libio/bits/stdio.h | 12 ++- libio/bits/stdio2.h | 69 ++++++++++++-- libio/bug-memstream1.c | 133 ++++++++++++++++++++++++++ libio/bug-wmemstream1.c | 136 +++++++++++++++++++++++++++ libio/fileops.c | 39 ++++---- libio/fmemopen.c | 30 ++++-- libio/fputwc.c | 4 +- libio/fputwc_u.c | 4 +- libio/fwprintf.c | 6 +- libio/fwscanf.c | 6 +- libio/genops.c | 72 +++++++++++++- libio/getwc_u.c | 4 +- libio/iofclose.c | 4 +- libio/iofgets.c | 10 +- libio/iofgets_u.c | 10 +- libio/iofgetws.c | 10 +- libio/iofgetws_u.c | 10 +- libio/iofopncook.c | 34 ++++++- libio/iofwide.c | 75 ++++++++++----- libio/iogetdelim.c | 10 +- libio/iogetline.c | 56 +++++------ libio/iogetwline.c | 4 +- libio/ioungetwc.c | 4 +- libio/iovdprintf.c | 10 +- libio/iovsprintf.c | 14 +-- libio/iovsscanf.c | 9 +- libio/iovswscanf.c | 11 +-- libio/libc_fatal.c | 31 +++++++ libio/libio.h | 57 +++++++----- libio/libioP.h | 242 +++++++++++++++++++++--------------------------- libio/memstream.c | 15 +-- libio/obprintf.c | 12 +-- libio/oldfileops.c | 13 ++- libio/oldiofclose.c | 4 +- libio/stdio.h | 66 +++++++------ libio/strfile.h | 13 ++- libio/strops.c | 125 ++++++++++++++++--------- libio/swprintf.c | 6 +- libio/swscanf.c | 7 +- libio/tst-fopenloc2.c | 116 +++++++++++++++++++++++ libio/tst-memstream1.c | 89 ++++++++++++++++++ libio/tst-memstream2.c | 104 +++++++++++++++++++++ libio/tst-setvbuf1.c | 39 ++++++++ libio/tst-wmemstream1.c | 7 ++ libio/tst-wmemstream2.c | 7 ++ libio/vasprintf.c | 9 +- libio/vscanf.c | 7 +- libio/vsnprintf.c | 9 +- libio/vswprintf.c | 19 +--- libio/vwprintf.c | 9 +- libio/vwscanf.c | 7 +- libio/wfiledoalloc.c | 32 ++----- libio/wfileops.c | 4 +- libio/wgenops.c | 12 +-- libio/wmemstream.c | 150 ++++++++++++++++++++++++++++++ libio/wprintf.c | 7 +- libio/wscanf.c | 7 +- libio/wstrops.c | 142 +++++++++++++++++++--------- 62 files changed, 1739 insertions(+), 528 deletions(-) create mode 100644 libio/bits/libio-ldbl.h create mode 100644 libio/bits/stdio-ldbl.h create mode 100644 libio/bug-memstream1.c create mode 100644 libio/bug-wmemstream1.c create mode 100644 libio/libc_fatal.c create mode 100644 libio/tst-fopenloc2.c create mode 100644 libio/tst-memstream1.c create mode 100644 libio/tst-memstream2.c create mode 100644 libio/tst-setvbuf1.c create mode 100644 libio/tst-wmemstream1.c create mode 100644 libio/tst-wmemstream2.c create mode 100644 libio/wmemstream.c (limited to 'libio') diff --git a/libio/Makefile b/libio/Makefile index a97623f14a..553fbda74a 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -1,4 +1,4 @@ -# Copyright (C) 1995-2002, 2003, 2004 Free Software Foundation, Inc. +# Copyright (C) 1995-2002,2003,2004,2006 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -22,7 +22,7 @@ subdir := libio headers := stdio.h libio.h _G_config.h bits/stdio.h bits/stdio-lock.h \ - bits/sys_errlist.h bits/stdio2.h + bits/sys_errlist.h bits/stdio2.h bits/stdio-ldbl.h bits/libio-ldbl.h routines := \ filedoalloc iofclose iofdopen iofflush iofgetpos iofgets iofopen \ @@ -35,7 +35,7 @@ routines := \ iofputws iofputws_u iogetwline iowpadn ioungetwc putwc putwc_u \ putwchar putwchar_u putchar putchar_u fwprintf swprintf vwprintf \ wprintf wscanf fwscanf vwscanf vswprintf iovswscanf swscanf wgenops \ - wstrops wfileops iofwide fwide \ + wstrops wfileops iofwide fwide wmemstream \ \ clearerr feof ferror fileno fputc freopen fseek getc getchar \ memstream pclose putc putchar rewind setbuf setlinebuf vasprintf \ @@ -54,7 +54,11 @@ tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc \ tst-freopen bug-rewind bug-rewind2 bug-ungetc bug-fseek \ tst-mmap-eofsync tst-mmap-fflushsync bug-mmap-fflush \ tst-mmap2-eofsync tst-mmap-offend bug-fopena+ bug-wfflush \ - bug-ungetc2 bug-ftell bug-ungetc3 bug-ungetc4 + bug-ungetc2 bug-ftell bug-ungetc3 bug-ungetc4 tst-fopenloc2 \ + tst-memstream1 tst-memstream2 \ + tst-wmemstream1 tst-wmemstream2 \ + bug-memstream1 bug-wmemstream1 \ + tst-setvbuf1 test-srcs = test-freopen all: # Make this the default target; it will be defined in Rules. diff --git a/libio/Versions b/libio/Versions index c870494872..e7a96daca5 100644 --- a/libio/Versions +++ b/libio/Versions @@ -145,6 +145,9 @@ libc { # w* wprintf; wscanf; } + GLIBC_2.4 { + open_wmemstream; + } GLIBC_PRIVATE { # Used by NPTL and librt __libc_fatal; diff --git a/libio/bits/libio-ldbl.h b/libio/bits/libio-ldbl.h new file mode 100644 index 0000000000..8674bcb0b8 --- /dev/null +++ b/libio/bits/libio-ldbl.h @@ -0,0 +1,25 @@ +/* -mlong-double-64 compatibility mode for libio functions. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _IO_STDIO_H +# error "Never include directly; use instead." +#endif + +__LDBL_REDIR_DECL (_IO_vfscanf) +__LDBL_REDIR_DECL (_IO_vfprintf) diff --git a/libio/bits/stdio-ldbl.h b/libio/bits/stdio-ldbl.h new file mode 100644 index 0000000000..7a4291225e --- /dev/null +++ b/libio/bits/stdio-ldbl.h @@ -0,0 +1,74 @@ +/* -mlong-double-64 compatibility mode for stdio functions. + Copyright (C) 2006 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _STDIO_H +# error "Never include directly; use instead." +#endif + +__BEGIN_NAMESPACE_STD +__LDBL_REDIR_DECL (fprintf) +__LDBL_REDIR_DECL (printf) +__LDBL_REDIR_DECL (sprintf) +__LDBL_REDIR_DECL (vfprintf) +__LDBL_REDIR_DECL (vprintf) +__LDBL_REDIR_DECL (vsprintf) +__LDBL_REDIR_DECL (fscanf) +__LDBL_REDIR_DECL (scanf) +__LDBL_REDIR_DECL (sscanf) +__END_NAMESPACE_STD + +#if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98 +__BEGIN_NAMESPACE_C99 +__LDBL_REDIR_DECL (snprintf) +__LDBL_REDIR_DECL (vsnprintf) +__END_NAMESPACE_C99 +#endif + +#ifdef __USE_ISOC99 +__BEGIN_NAMESPACE_C99 +__LDBL_REDIR_DECL (vfscanf) +__LDBL_REDIR_DECL (vsscanf) +__LDBL_REDIR_DECL (vscanf) +__END_NAMESPACE_C99 +#endif + +#ifdef __USE_GNU +__LDBL_REDIR_DECL (vdprintf) +__LDBL_REDIR_DECL (dprintf) +__LDBL_REDIR_DECL (vasprintf) +__LDBL_REDIR_DECL (__asprintf) +__LDBL_REDIR_DECL (asprintf) +__LDBL_REDIR_DECL (obstack_printf) +__LDBL_REDIR_DECL (obstack_vprintf) +#endif + +#if __USE_FORTIFY_LEVEL > 0 && !defined __cplusplus +__LDBL_REDIR_DECL (__sprintf_chk) +__LDBL_REDIR_DECL (__vsprintf_chk) +# if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98 +__LDBL_REDIR_DECL (__snprintf_chk) +__LDBL_REDIR_DECL (__vsnprintf_chk) +# endif +# if __USE_FORTIFY_LEVEL > 1 +__LDBL_REDIR_DECL (__fprintf_chk) +__LDBL_REDIR_DECL (__printf_chk) +__LDBL_REDIR_DECL (__vfprintf_chk) +__LDBL_REDIR_DECL (__vprintf_chk) +# endif +#endif diff --git a/libio/bits/stdio.h b/libio/bits/stdio.h index 9e951ad8e4..2d44fad1f5 100644 --- a/libio/bits/stdio.h +++ b/libio/bits/stdio.h @@ -1,5 +1,5 @@ /* Optimizing macros and inline functions for stdio functions. - Copyright (C) 1998, 2000, 2001, 2004 Free Software Foundation, Inc. + Copyright (C) 1998, 2000, 2001, 2004, 2007 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -44,6 +44,16 @@ getchar (void) } +# ifdef __USE_MISC +/* Faster version when locking is not necessary. */ +__STDIO_INLINE int +fgetc_unlocked (FILE *__fp) +{ + return _IO_getc_unlocked (__fp); +} +# endif /* misc */ + + # if defined __USE_POSIX || defined __USE_MISC /* This is defined in POSIX.1:1996. */ __STDIO_INLINE int diff --git a/libio/bits/stdio2.h b/libio/bits/stdio2.h index acf07ea91b..f1d745c699 100644 --- a/libio/bits/stdio2.h +++ b/libio/bits/stdio2.h @@ -1,5 +1,5 @@ /* Checking macros for stdio functions. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -49,7 +49,7 @@ extern int __vsnprintf_chk (char *__restrict __s, size_t __n, int __flag, __builtin___vsnprintf_chk (str, len, __USE_FORTIFY_LEVEL - 1, __bos (str), \ fmt, ap) -#endif +#endif #if __USE_FORTIFY_LEVEL > 1 @@ -61,18 +61,67 @@ extern int __vfprintf_chk (FILE *__restrict __stream, int __flag, extern int __vprintf_chk (int __flag, __const char *__restrict __format, _G_va_list __ap); -# define printf(...) \ +# if __GNUC_PREREQ (4, 0) +# define printf(...) \ __printf_chk (__USE_FORTIFY_LEVEL - 1, __VA_ARGS__) -# define fprintf(stream, ...) \ +# define fprintf(stream, ...) \ __fprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) -# define vprintf(format, ap) \ +# define vprintf(format, ap) \ __vprintf_chk (__USE_FORTIFY_LEVEL - 1, format, ap) -# define vfprintf(stream, format, ap) \ +# define vfprintf(stream, format, ap) \ __vfprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, format, ap) +# else +# define printf(...) \ + __builtin___printf_chk (__USE_FORTIFY_LEVEL - 1, __VA_ARGS__) +# define fprintf(stream, ...) \ + __builtin___fprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) +# define vprintf(format, ap) \ + __builtin___vprintf_chk (__USE_FORTIFY_LEVEL - 1, format, ap) +# define vfprintf(stream, format, ap) \ + __builtin___vfprintf_chk (stream, __USE_FORTIFY_LEVEL - 1, format, ap) +# endif #endif -extern char *__gets_chk (char *__str, size_t); -#define gets(__str) \ - ((__bos (__str) == (size_t) -1) \ - ? (gets) (__str) : __gets_chk (__str, __bos (__str))) +extern char *__gets_chk (char *__str, size_t) __wur; +extern char *__REDIRECT (__gets_alias, (char *__str), gets) __wur; + +extern __always_inline __wur char * +gets (char *__str) +{ + if (__bos (__str) != (size_t) -1) + return __gets_chk (__str, __bos (__str)); + return __gets_alias (__str); +} + +extern char *__fgets_chk (char *__restrict __s, size_t __size, int __n, + FILE *__restrict __stream) __wur; +extern char *__REDIRECT (__fgets_alias, + (char *__restrict __s, int __n, + FILE *__restrict __stream), fgets) __wur; + +extern __always_inline __wur char * +fgets (char *__restrict __s, int __n, FILE *__restrict __stream) +{ + if (__bos (__s) != (size_t) -1 + && (!__builtin_constant_p (__n) || (size_t) __n > __bos (__s))) + return __fgets_chk (__s, __bos (__s), __n, __stream); + return __fgets_alias (__s, __n, __stream); +} + +#ifdef __USE_GNU +extern char *__fgets_unlocked_chk (char *__restrict __s, size_t __size, + int __n, FILE *__restrict __stream) __wur; +extern char *__REDIRECT (__fgets_unlocked_alias, + (char *__restrict __s, int __n, + FILE *__restrict __stream), fgets_unlocked) __wur; + +extern __always_inline __wur char * +fgets_unlocked (char *__restrict __s, int __n, FILE *__restrict __stream) +{ + if (__bos (__s) != (size_t) -1 + && (!__builtin_constant_p (__n) || (size_t) __n > __bos (__s))) + return __fgets_unlocked_chk (__s, __bos (__s), __n, __stream); + return __fgets_unlocked_alias (__s, __n, __stream); +} +#endif diff --git a/libio/bug-memstream1.c b/libio/bug-memstream1.c new file mode 100644 index 0000000000..8af36fee2d --- /dev/null +++ b/libio/bug-memstream1.c @@ -0,0 +1,133 @@ +#include +#include + + +static int +do_test (void) +{ + size_t size; + char *buf; + FILE *fp = open_memstream (&buf, &size); + if (fp == NULL) + { + puts ("open_memstream failed"); + return 1; + } + + off64_t off = ftello64 (fp); + if (off != 0) + { + puts ("initial position wrong"); + return 1; + } + + if (fseek (fp, 32768, SEEK_SET) != 0) + { + puts ("fseek failed"); + return 1; + } + + if (fputs ("foo", fp) == EOF) + { + puts ("fputs failed"); + return 1; + } + + if (fclose (fp) == EOF) + { + puts ("fclose failed"); + return 1; + } + + if (size != 32768 + 3) + { + printf ("expected size %d, got %zu\n", 32768 + 3, size); + return 1; + } + + for (int i = 0; i < 32768; ++i) + if (buf[i] != '\0') + { + printf ("byte at offset %d is %#hhx\n", i, buf[i]); + return 1; + } + + if (memcmp (buf + 32768, "foo", 3) != 0) + { + puts ("written string incorrect"); + return 1; + } + + /* Mark the buffer. */ + memset (buf, 'A', size); + free (buf); + + /* Try again, this time with write mode enabled before the seek. */ + fp = open_memstream (&buf, &size); + if (fp == NULL) + { + puts ("2nd open_memstream failed"); + return 1; + } + + off = ftello64 (fp); + if (off != 0) + { + puts ("2nd initial position wrong"); + return 1; + } + + if (fputs ("bar", fp) == EOF) + { + puts ("2nd fputs failed"); + return 1; + } + + if (fseek (fp, 32768, SEEK_SET) != 0) + { + puts ("2nd fseek failed"); + return 1; + } + + if (fputs ("foo", fp) == EOF) + { + puts ("3rd fputs failed"); + return 1; + } + + if (fclose (fp) == EOF) + { + puts ("2nd fclose failed"); + return 1; + } + + if (size != 32768 + 3) + { + printf ("2nd expected size %d, got %zu\n", 32768 + 3, size); + return 1; + } + + if (memcmp (buf, "bar", 3) != 0) + { + puts ("initial string incorrect in 2nd try"); + return 1; + } + + for (int i = 3; i < 32768; ++i) + if (buf[i] != '\0') + { + printf ("byte at offset %d is %#hhx in 2nd try\n", i, buf[i]); + return 1; + } + + if (memcmp (buf + 32768, "foo", 3) != 0) + { + puts ("written string incorrect in 2nd try"); + return 1; + } + + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/libio/bug-wmemstream1.c b/libio/bug-wmemstream1.c new file mode 100644 index 0000000000..22d67f71e9 --- /dev/null +++ b/libio/bug-wmemstream1.c @@ -0,0 +1,136 @@ +#include +#include +#include + + +static int +do_test (void) +{ + size_t size; + wchar_t *buf; + FILE *fp = open_wmemstream (&buf, &size); + if (fp == NULL) + { + puts ("open_wmemstream failed"); + return 1; + } + + off64_t off = ftello64 (fp); + if (off != 0) + { + puts ("initial position wrong"); + return 1; + } + + if (fseek (fp, 32768, SEEK_SET) != 0) + { + puts ("fseek failed"); + return 1; + } + + if (fputws (L"foo", fp) == EOF) + { + puts ("fputws failed"); + return 1; + } + + if (fclose (fp) == EOF) + { + puts ("fclose failed"); + return 1; + } + + if (size != 32768 + 3) + { + printf ("expected size %d, got %zu\n", 32768 + 3, size); + return 1; + } + + for (int i = 0; i < 32768; ++i) + if (buf[i] != L'\0') + { + printf ("wide character at offset %d is %#x\n", + i, (unsigned int) buf[i]); + return 1; + } + + if (wmemcmp (buf + 32768, L"foo", 3) != 0) + { + puts ("written string incorrect"); + return 1; + } + + /* Mark the buffer. */ + wmemset (buf, L'A', size); + free (buf); + + /* Try again, this time with write mode enabled before the seek. */ + fp = open_wmemstream (&buf, &size); + if (fp == NULL) + { + puts ("2nd open_wmemstream failed"); + return 1; + } + + off = ftello64 (fp); + if (off != 0) + { + puts ("2nd initial position wrong"); + return 1; + } + + if (fputws (L"bar", fp) == EOF) + { + puts ("2nd fputws failed"); + return 1; + } + + if (fseek (fp, 32768, SEEK_SET) != 0) + { + puts ("2nd fseek failed"); + return 1; + } + + if (fputws (L"foo", fp) == EOF) + { + puts ("3rd fputws failed"); + return 1; + } + + if (fclose (fp) == EOF) + { + puts ("2nd fclose failed"); + return 1; + } + + if (size != 32768 + 3) + { + printf ("2nd expected size %d, got %zu\n", 32768 + 3, size); + return 1; + } + + if (wmemcmp (buf, L"bar", 3) != 0) + { + puts ("initial string incorrect in 2nd try"); + return 1; + } + + for (int i = 3; i < 32768; ++i) + if (buf[i] != L'\0') + { + printf ("wide character at offset %d is %#x in 2nd try\n", + i, (unsigned int) buf[i]); + return 1; + } + + if (wmemcmp (buf + 32768, L"foo", 3) != 0) + { + puts ("written string incorrect in 2nd try"); + return 1; + } + + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/libio/fileops.c b/libio/fileops.c index 19151cf188..886b3729c3 100644 --- a/libio/fileops.c +++ b/libio/fileops.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1993, 1995, 1997-2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1995, 1997-2005, 2006, 2007 + Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Per Bothner . @@ -174,14 +175,8 @@ _IO_new_file_close_it (fp) close_status = _IO_SYSCLOSE (fp); /* Free buffer. */ - if (fp->_mode <= 0) - { - INTUSE(_IO_setb) (fp, NULL, NULL, 0); - _IO_setg (fp, NULL, NULL, NULL); - _IO_setp (fp, NULL, NULL); - } #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T - else + if (fp->_mode > 0) { if (_IO_have_wbackup (fp)) INTUSE(_IO_free_wbackup_area) (fp); @@ -190,6 +185,9 @@ _IO_new_file_close_it (fp) _IO_wsetp (fp, NULL, NULL); } #endif + INTUSE(_IO_setb) (fp, NULL, NULL, 0); + _IO_setg (fp, NULL, NULL, NULL); + _IO_setp (fp, NULL, NULL); INTUSE(_IO_un_link) ((struct _IO_FILE_plus *) fp); fp->_flags = _IO_MAGIC|CLOSED_FILEBUF_FLAGS; @@ -399,6 +397,9 @@ _IO_new_file_fopen (fp, filename, mode, is32not64) /* And now the transliteration. */ cc->__cd_out.__cd.__data[0].__trans = &__libio_translit; + /* From now on use the wide character callback functions. */ + ((struct _IO_FILE_plus *) fp)->vtable = fp->_wide_data->_wide_vtable; + /* Set the mode now. */ result->_mode = 1; } @@ -472,7 +473,7 @@ _IO_file_setbuf_mmap (fp, p, len) return result; } -static _IO_size_t new_do_write (_IO_FILE *, const char *, _IO_size_t) __THROW; +static _IO_size_t new_do_write (_IO_FILE *, const char *, _IO_size_t); /* Write TO_DO bytes from DATA to FP. Then mark FP as having empty buffers. */ @@ -826,10 +827,10 @@ _IO_new_file_overflow (f, ch) return EOF; } /* If currently reading or no buffer allocated. */ - if ((f->_flags & _IO_CURRENTLY_PUTTING) == 0 || f->_IO_write_base == 0) + if ((f->_flags & _IO_CURRENTLY_PUTTING) == 0 || f->_IO_write_base == NULL) { /* Allocate a buffer if needed. */ - if (f->_IO_write_base == 0) + if (f->_IO_write_base == NULL) { INTUSE(_IO_doallocbuf) (f); _IO_setg (f, f->_IO_buf_base, f->_IO_buf_base, f->_IO_buf_base); @@ -1281,7 +1282,7 @@ _IO_new_file_xsputn (f, data, n) register const char *s = (const char *) data; _IO_size_t to_do = n; int must_flush = 0; - _IO_size_t count; + _IO_size_t count = 0; if (n <= 0) return 0; @@ -1290,7 +1291,6 @@ _IO_new_file_xsputn (f, data, n) (or the filebuf is unbuffered), use sys_write directly. */ /* First figure out how much space is available in the buffer. */ - count = f->_IO_write_end - f->_IO_write_ptr; /* Space available. */ if ((f->_flags & _IO_LINE_BUF) && (f->_flags & _IO_CURRENTLY_PUTTING)) { count = f->_IO_buf_end - f->_IO_write_ptr; @@ -1308,6 +1308,9 @@ _IO_new_file_xsputn (f, data, n) } } } + else if (f->_IO_write_end > f->_IO_write_ptr) + count = f->_IO_write_end - f->_IO_write_ptr; /* Space available. */ + /* Then fill the buffer. */ if (count > 0) { @@ -1338,7 +1341,9 @@ _IO_new_file_xsputn (f, data, n) _IO_size_t block_size, do_write; /* Next flush the (full) buffer. */ if (_IO_OVERFLOW (f, EOF) == EOF) - return n - to_do; + /* If nothing else has to be written we must not signal the + caller that everything has been written. */ + return to_do == 0 ? EOF : n - to_do; /* Try to maintain alignment: write a whole number of blocks. dont_write is what gets left over. */ @@ -1464,8 +1469,7 @@ _IO_file_xsgetn (fp, data, n) } INTDEF(_IO_file_xsgetn) -static _IO_size_t _IO_file_xsgetn_mmap (_IO_FILE *, void *, _IO_size_t) - __THROW; +static _IO_size_t _IO_file_xsgetn_mmap (_IO_FILE *, void *, _IO_size_t); static _IO_size_t _IO_file_xsgetn_mmap (fp, data, n) _IO_FILE *fp; @@ -1524,8 +1528,7 @@ _IO_file_xsgetn_mmap (fp, data, n) return s - (char *) data; } -static _IO_size_t _IO_file_xsgetn_maybe_mmap (_IO_FILE *, void *, _IO_size_t) - __THROW; +static _IO_size_t _IO_file_xsgetn_maybe_mmap (_IO_FILE *, void *, _IO_size_t); static _IO_size_t _IO_file_xsgetn_maybe_mmap (fp, data, n) _IO_FILE *fp; diff --git a/libio/fmemopen.c b/libio/fmemopen.c index ab6ffdd678..f3b280092c 100644 --- a/libio/fmemopen.c +++ b/libio/fmemopen.c @@ -1,5 +1,5 @@ /* Fmemopen implementation. - Copyright (C) 2000, 2002 Free Software Foundation, Inc. + Copyright (C) 2000, 2002, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Hanno Mueller, kontakt@hanno.de, 2000. @@ -27,8 +27,6 @@ * but couldn't find it in libio. The following snippet of code is an * attempt to implement what glibc's documentation describes. * - * No, it isn't really tested yet. :-) - * * * * I already see some potential problems: @@ -73,6 +71,7 @@ #include #include #include +#include #include #include #include "libioP.h" @@ -128,7 +127,7 @@ fmemopen_write (void *cookie, const char *b, size_t s) if ((size_t) (c->pos + addnullc) == c->size) { __set_errno (ENOSPC); - return -1; + return 0; } s = c->size - c->pos - addnullc; } @@ -166,7 +165,7 @@ fmemopen_seek (void *cookie, _IO_off64_t *p, int w) break; case SEEK_END: - np = c->size - *p; + np = c->maxpos - *p; break; default: @@ -176,9 +175,9 @@ fmemopen_seek (void *cookie, _IO_off64_t *p, int w) if (np < 0 || (size_t) np > c->size) return -1; - c->pos = np; + *p = c->pos = np; - return np; + return 0; } @@ -203,6 +202,13 @@ fmemopen (void *buf, size_t len, const char *mode) cookie_io_functions_t iof; fmemopen_cookie_t *c; + if (__builtin_expect (len == 0, 0)) + { + einval: + __set_errno (EINVAL); + return NULL; + } + c = (fmemopen_cookie_t *) malloc (sizeof (fmemopen_cookie_t)); if (c == NULL) return NULL; @@ -220,7 +226,15 @@ fmemopen (void *buf, size_t len, const char *mode) c->buffer[0] = '\0'; } else - c->buffer = buf; + { + if (__builtin_expect ((uintptr_t) len > -(uintptr_t) buf, 0)) + { + free (c); + goto einval; + } + + c->buffer = buf; + } c->size = len; diff --git a/libio/fputwc.c b/libio/fputwc.c index 8c749435a0..42cf9d716c 100644 --- a/libio/fputwc.c +++ b/libio/fputwc.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993,1996,1997,1998,1999,2003 Free Software Foundation, Inc. +/* Copyright (C) 1993,1996,1997,1998,1999,2003, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -33,7 +33,7 @@ fputwc (wc, fp) wchar_t wc; _IO_FILE *fp; { - int result; + wint_t result; CHECK_FILE (fp, EOF); _IO_acquire_lock (fp); if (_IO_fwide (fp, 1) < 0) diff --git a/libio/fputwc_u.c b/libio/fputwc_u.c index 93cbcab3d3..0478410cca 100644 --- a/libio/fputwc_u.c +++ b/libio/fputwc_u.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1996, 1997, 1999 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1996, 1997, 1999, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -35,7 +35,7 @@ fputwc_unlocked (wc, fp) wchar_t wc; _IO_FILE *fp; { - CHECK_FILE (fp, EOF); + CHECK_FILE (fp, WEOF); if (_IO_fwide (fp, 1) < 0) return WEOF; return _IO_putwc_unlocked (wc, fp); diff --git a/libio/fwprintf.c b/libio/fwprintf.c index cadeda04ab..9d9111d7c6 100644 --- a/libio/fwprintf.c +++ b/libio/fwprintf.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1991, 1997, 1999, 2000, 2001 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1997, 1999, 2000, 2001, 2006 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,6 +17,7 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include #include #include #include @@ -35,4 +37,4 @@ __fwprintf (FILE *stream, const wchar_t *format, ...) return done; } -weak_alias (__fwprintf, fwprintf) +ldbl_weak_alias (__fwprintf, fwprintf) diff --git a/libio/fwscanf.c b/libio/fwscanf.c index 411e1825c0..17296fa3d6 100644 --- a/libio/fwscanf.c +++ b/libio/fwscanf.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1997, 1999, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1997, 1999, 2000, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,6 +16,7 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include #include #include #include @@ -23,7 +24,7 @@ /* Read formatted input from STREAM according to the format string FORMAT. */ /* VARARGS2 */ int -fwscanf (FILE *stream, const wchar_t *format, ...) +__fwscanf (FILE *stream, const wchar_t *format, ...) { va_list arg; int done; @@ -34,3 +35,4 @@ fwscanf (FILE *stream, const wchar_t *format, ...) return done; } +ldbl_strong_alias (__fwscanf, fwscanf) diff --git a/libio/genops.c b/libio/genops.c index 741ed77f86..8d62da7781 100644 --- a/libio/genops.c +++ b/libio/genops.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1993,1995,1997-2002, 2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1993,1995,1997-2002, 2003, 2004, 2006 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -32,6 +33,10 @@ #include #endif #include +#include +#ifdef _LIBC +#include +#endif #ifdef _IO_MTSAFE_IO static _IO_lock_t list_all_lock = _IO_lock_initializer; @@ -362,7 +367,7 @@ __uflow (fp) #endif if (fp->_mode == 0) - _IO_fwide (fp, -11); + _IO_fwide (fp, -1); if (_IO_in_put_mode (fp)) if (INTUSE(_IO_switch_to_get_mode) (fp) == EOF) return EOF; @@ -657,6 +662,7 @@ _IO_no_init (fp, flags, orientation, wd, jmp) fp->_wide_data->_wide_vtable = jmp; } #endif + fp->_freeres_list = NULL; } int @@ -914,10 +920,27 @@ INTDEF(_IO_flush_all_linebuffered) weak_alias (_IO_flush_all_linebuffered, _flushlbf) #endif + +/* The following is a bit tricky. In general, we want to unbuffer the + streams so that all output which follows is seen. If we are not + looking for memory leaks it does not make much sense to free the + actual buffer because this will happen anyway once the program + terminated. If we do want to look for memory leaks we have to free + the buffers. Whether something is freed is determined by the + function sin the libc_freeres section. Those are called as part of + the atexit routine, just like _IO_cleanup. The problem is we do + not know whether the freeres code is called first or _IO_cleanup. + if the former is the case, we set the DEALLOC_BUFFER variable to + true and _IO_unbuffer_write will take care of the rest. If + _IO_unbuffer_write is called first we add the streams to a list + which the freeres function later can walk through. */ static void _IO_unbuffer_write (void); +static bool dealloc_buffers; +static _IO_FILE *freeres_list; + static void -_IO_unbuffer_write () +_IO_unbuffer_write (void) { struct _IO_FILE *fp; for (fp = (_IO_FILE *) INTUSE(_IO_list_all); fp; fp = fp->_chain) @@ -927,7 +950,32 @@ _IO_unbuffer_write () || (fp->_flags & _IO_IS_APPENDING)) /* Iff stream is un-orientated, it wasn't used. */ && fp->_mode != 0) - _IO_SETBUF (fp, NULL, 0); + { + int cnt; +#define MAXTRIES 2 + for (cnt = 0; cnt < MAXTRIES; ++cnt) + if (_IO_lock_trylock (*fp->_lock) == 0) + break; + else + /* Give the other thread time to finish up its use of the + stream. */ + __sched_yield (); + + if (! dealloc_buffers && !(fp->_flags & _IO_USER_BUF)) + { + fp->_flags |= _IO_USER_BUF; + + fp->_freeres_list = freeres_list; + freeres_list = fp; + fp->_freeres_buf = fp->_IO_buf_base; + fp->_freeres_size = _IO_blen (fp); + } + + _IO_SETBUF (fp, NULL, 0); + + if (cnt < MAXTRIES) + _IO_lock_unlock (*fp->_lock); + } /* Make sure that never again the wide char functions can be used. */ @@ -935,11 +983,25 @@ _IO_unbuffer_write () } } + +libc_freeres_fn (buffer_free) +{ + dealloc_buffers = true; + + while (freeres_list != NULL) + { + FREE_BUF (freeres_list->_freeres_buf, freeres_list->_freeres_size); + + freeres_list = freeres_list->_freeres_list; + } +} + + int _IO_cleanup () { /* We do *not* want locking. Some threads might use streams but - that is there problem, we flush them underneath them. */ + that is their problem, we flush them underneath them. */ int result = _IO_flush_all_lockp (0); /* We currently don't have a reliable mechanism for making sure that diff --git a/libio/getwc_u.c b/libio/getwc_u.c index bdad3c8bf3..229343cc61 100644 --- a/libio/getwc_u.c +++ b/libio/getwc_u.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993,1995,1996,1997,1999,2000 Free Software Foundation, Inc. +/* Copyright (C) 1993,1995,1996,1997,1999,2000, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -33,7 +33,7 @@ wint_t __getwc_unlocked (FILE *fp) { - CHECK_FILE (fp, EOF); + CHECK_FILE (fp, WEOF); return _IO_getwc_unlocked (fp); } diff --git a/libio/iofclose.c b/libio/iofclose.c index a372ae2b24..aa2ba40064 100644 --- a/libio/iofclose.c +++ b/libio/iofclose.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993,1995,1997-2003,2004 Free Software Foundation, Inc. +/* Copyright (C) 1993,1995,1997-2004,2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -62,8 +62,8 @@ _IO_new_fclose (fp) status = INTUSE(_IO_file_close_it) (fp); else status = fp->_flags & _IO_ERR_SEEN ? -1 : 0; - _IO_FINISH (fp); _IO_release_lock (fp); + _IO_FINISH (fp); if (fp->_mode > 0) { #if _LIBC diff --git a/libio/iofgets.c b/libio/iofgets.c index 879cc975a3..601b1746a1 100644 --- a/libio/iofgets.c +++ b/libio/iofgets.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1995, 1996, 1997, 1998, 1999, 2002, 2003 +/* Copyright (C) 1993, 1995, 1996, 1997, 1998, 1999, 2002, 2003, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -41,6 +41,14 @@ _IO_fgets (buf, n, fp) CHECK_FILE (fp, NULL); if (n <= 0) return NULL; + if (__builtin_expect (n == 1, 0)) + { + /* Another irregular case: since we have to store a NUL byte and + there is only room for exactly one byte, we don't have to + read anything. */ + buf[0] = '\0'; + return buf; + } _IO_acquire_lock (fp); /* This is very tricky since a file descriptor may be in the non-blocking mode. The error flag doesn't mean much in this diff --git a/libio/iofgets_u.c b/libio/iofgets_u.c index ded2a7c83c..4fb5b1c0fd 100644 --- a/libio/iofgets_u.c +++ b/libio/iofgets_u.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993,1995,1996,1997,1998,2002 Free Software Foundation, Inc. +/* Copyright (C) 1993,1995-1998,2002,2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -40,6 +40,14 @@ fgets_unlocked (buf, n, fp) CHECK_FILE (fp, NULL); if (n <= 0) return NULL; + if (__builtin_expect (n == 1, 0)) + { + /* Another irregular case: since we have to store a NUL byte and + there is only room for exactly one byte, we don't have to + read anything. */ + buf[0] = '\0'; + return buf; + } /* This is very tricky since a file descriptor may be in the non-blocking mode. The error flag doesn't mean much in this case. We return an error only when there is a new error. */ diff --git a/libio/iofgetws.c b/libio/iofgetws.c index 654c051a28..775391137a 100644 --- a/libio/iofgetws.c +++ b/libio/iofgetws.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1995, 1996, 1997, 1998, 1999, 2001 +/* Copyright (C) 1993, 1995, 1996, 1997, 1998, 1999, 2001, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -41,6 +41,14 @@ fgetws (buf, n, fp) CHECK_FILE (fp, NULL); if (n <= 0) return NULL; + if (__builtin_expect (n == 1, 0)) + { + /* Another irregular case: since we have to store a NUL byte and + there is only room for exactly one byte, we don't have to + read anything. */ + buf[0] = L'\0'; + return buf; + } _IO_acquire_lock (fp); /* This is very tricky since a file descriptor may be in the non-blocking mode. The error flag doesn't mean much in this diff --git a/libio/iofgetws_u.c b/libio/iofgetws_u.c index 1253564566..9fb8a5cac1 100644 --- a/libio/iofgetws_u.c +++ b/libio/iofgetws_u.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 95, 96, 97, 98, 99 Free Software Foundation, Inc. +/* Copyright (C) 1993, 95, 96, 97, 98, 99, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -40,6 +40,14 @@ fgetws_unlocked (buf, n, fp) CHECK_FILE (fp, NULL); if (n <= 0) return NULL; + if (__builtin_expect (n == 1, 0)) + { + /* Another irregular case: since we have to store a NUL byte and + there is only room for exactly one byte, we don't have to + read anything. */ + buf[0] = L'\0'; + return buf; + } /* This is very tricky since a file descriptor may be in the non-blocking mode. The error flag doesn't mean much in this case. We return an error only when there is a new error. */ diff --git a/libio/iofopncook.c b/libio/iofopncook.c index 321eb67b8d..976ff5093a 100644 --- a/libio/iofopncook.c +++ b/libio/iofopncook.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1993,95,97,99,2000,2002,2004 Free Software Foundation, Inc. +/* Copyright (C) 1993,95,97,99,2000,2002,2004, 2005 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -36,6 +37,8 @@ static _IO_ssize_t _IO_cookie_read (register _IO_FILE* fp, void* buf, static _IO_ssize_t _IO_cookie_write (register _IO_FILE* fp, const void* buf, _IO_ssize_t size); static _IO_off64_t _IO_cookie_seek (_IO_FILE *fp, _IO_off64_t offset, int dir); +static _IO_off64_t _IO_cookie_seekoff (_IO_FILE *fp, _IO_off64_t offset, + int dir, int mode); static int _IO_cookie_close (_IO_FILE* fp); static _IO_ssize_t @@ -61,9 +64,16 @@ _IO_cookie_write (fp, buf, size) struct _IO_cookie_file *cfile = (struct _IO_cookie_file *) fp; if (cfile->__io_functions.write == NULL) - return -1; + { + fp->_flags |= _IO_ERR_SEEN; + return 0; + } + + _IO_ssize_t n = cfile->__io_functions.write (cfile->__cookie, buf, size); + if (n < size) + fp->_flags |= _IO_ERR_SEEN; - return cfile->__io_functions.write (cfile->__cookie, buf, size); + return n; } static _IO_off64_t @@ -94,6 +104,20 @@ _IO_cookie_close (fp) } +static _IO_off64_t +_IO_cookie_seekoff (fp, offset, dir, mode) + _IO_FILE *fp; + _IO_off64_t offset; + int dir; + int mode; +{ + /* We must force the fileops code to always use seek to determine + the position. */ + fp->_offset = _IO_pos_BAD; + return INTUSE(_IO_file_seekoff) (fp, offset, dir, mode); +} + + static const struct _IO_jump_t _IO_cookie_jumps = { JUMP_INIT_DUMMY, JUMP_INIT(finish, INTUSE(_IO_file_finish)), @@ -103,7 +127,7 @@ static const struct _IO_jump_t _IO_cookie_jumps = { JUMP_INIT(pbackfail, INTUSE(_IO_default_pbackfail)), JUMP_INIT(xsputn, INTUSE(_IO_file_xsputn)), JUMP_INIT(xsgetn, INTUSE(_IO_default_xsgetn)), - JUMP_INIT(seekoff, INTUSE(_IO_file_seekoff)), + JUMP_INIT(seekoff, _IO_cookie_seekoff), JUMP_INIT(seekpos, _IO_default_seekpos), JUMP_INIT(setbuf, INTUSE(_IO_file_setbuf)), JUMP_INIT(sync, INTUSE(_IO_file_sync)), @@ -223,7 +247,7 @@ static const struct _IO_jump_t _IO_old_cookie_jumps = { JUMP_INIT(pbackfail, INTUSE(_IO_default_pbackfail)), JUMP_INIT(xsputn, INTUSE(_IO_file_xsputn)), JUMP_INIT(xsgetn, INTUSE(_IO_default_xsgetn)), - JUMP_INIT(seekoff, INTUSE(_IO_file_seekoff)), + JUMP_INIT(seekoff, _IO_cookie_seekoff), JUMP_INIT(seekpos, _IO_default_seekpos), JUMP_INIT(setbuf, INTUSE(_IO_file_setbuf)), JUMP_INIT(sync, INTUSE(_IO_file_sync)), diff --git a/libio/iofwide.c b/libio/iofwide.c index 03124219ad..a9936687dd 100644 --- a/libio/iofwide.c +++ b/libio/iofwide.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. +/* Copyright (C) 1999-2003, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -40,6 +40,7 @@ # include # include # include +# include #endif @@ -68,7 +69,7 @@ static int do_always_noconv (struct _IO_codecvt *codecvt); /* The functions used in `codecvt' for libio are always the same. */ -struct _IO_codecvt __libio_codecvt = +const struct _IO_codecvt __libio_codecvt = { .__codecvt_destr = NULL, /* Destructor, never used. */ .__codecvt_do_out = do_out, @@ -82,7 +83,7 @@ struct _IO_codecvt __libio_codecvt = #ifdef _LIBC -struct __gconv_trans_data __libio_translit attribute_hidden = +const struct __gconv_trans_data __libio_translit attribute_hidden = { .__trans_fct = __gconv_transliterate }; @@ -126,12 +127,11 @@ _IO_fwide (fp, mode) selected locale for LC_CTYPE. */ #ifdef _LIBC { - struct gconv_fcts fcts; - /* Clear the state. We start all over again. */ memset (&fp->_wide_data->_IO_state, '\0', sizeof (__mbstate_t)); memset (&fp->_wide_data->_IO_last_state, '\0', sizeof (__mbstate_t)); + struct gconv_fcts fcts; __wcsmbs_clone_conv (&fcts); assert (fcts.towc_nsteps == 1); assert (fcts.tomb_nsteps == 1); @@ -159,7 +159,8 @@ _IO_fwide (fp, mode) cc->__cd_out.__cd.__data[0].__statep = &fp->_wide_data->_IO_state; /* And now the transliteration. */ - cc->__cd_out.__cd.__data[0].__trans = &__libio_translit; + cc->__cd_out.__cd.__data[0].__trans + = (struct __gconv_trans_data *) &__libio_translit; } #else # ifdef _GLIBCPP_USE_WCHAR_T @@ -228,17 +229,23 @@ do_out (struct _IO_codecvt *codecvt, __mbstate_t *statep, size_t dummy; const unsigned char *from_start_copy = (unsigned char *) from_start; - codecvt->__cd_out.__cd.__data[0].__outbuf = to_start; - codecvt->__cd_out.__cd.__data[0].__outbufend = to_end; + codecvt->__cd_out.__cd.__data[0].__outbuf = (unsigned char *) to_start; + codecvt->__cd_out.__cd.__data[0].__outbufend = (unsigned char *) to_end; codecvt->__cd_out.__cd.__data[0].__statep = statep; - status = DL_CALL_FCT (gs->__fct, + __gconv_fct fct = gs->__fct; +#ifdef PTR_DEMANGLE + if (gs->__shlib_handle != NULL) + PTR_DEMANGLE (fct); +#endif + + status = DL_CALL_FCT (fct, (gs, codecvt->__cd_out.__cd.__data, &from_start_copy, (const unsigned char *) from_end, NULL, &dummy, 0, 0)); *from_stop = (wchar_t *) from_start_copy; - *to_stop = codecvt->__cd_out.__cd.__data[0].__outbuf; + *to_stop = (char *) codecvt->__cd_out.__cd.__data[0].__outbuf; switch (status) { @@ -294,15 +301,21 @@ do_unshift (struct _IO_codecvt *codecvt, __mbstate_t *statep, int status; size_t dummy; - codecvt->__cd_out.__cd.__data[0].__outbuf = to_start; - codecvt->__cd_out.__cd.__data[0].__outbufend = to_end; + codecvt->__cd_out.__cd.__data[0].__outbuf = (unsigned char *) to_start; + codecvt->__cd_out.__cd.__data[0].__outbufend = (unsigned char *) to_end; codecvt->__cd_out.__cd.__data[0].__statep = statep; - status = DL_CALL_FCT (gs->__fct, + __gconv_fct fct = gs->__fct; +#ifdef PTR_DEMANGLE + if (gs->__shlib_handle != NULL) + PTR_DEMANGLE (fct); +#endif + + status = DL_CALL_FCT (fct, (gs, codecvt->__cd_out.__cd.__data, NULL, NULL, NULL, &dummy, 1, 0)); - *to_stop = codecvt->__cd_out.__cd.__data[0].__outbuf; + *to_stop = (char *) codecvt->__cd_out.__cd.__data[0].__outbuf; switch (status) { @@ -357,15 +370,22 @@ do_in (struct _IO_codecvt *codecvt, __mbstate_t *statep, size_t dummy; const unsigned char *from_start_copy = (unsigned char *) from_start; - codecvt->__cd_in.__cd.__data[0].__outbuf = (char *) to_start; - codecvt->__cd_in.__cd.__data[0].__outbufend = (char *) to_end; + codecvt->__cd_in.__cd.__data[0].__outbuf = (unsigned char *) to_start; + codecvt->__cd_in.__cd.__data[0].__outbufend = (unsigned char *) to_end; codecvt->__cd_in.__cd.__data[0].__statep = statep; - status = DL_CALL_FCT (gs->__fct, + __gconv_fct fct = gs->__fct; +#ifdef PTR_DEMANGLE + if (gs->__shlib_handle != NULL) + PTR_DEMANGLE (fct); +#endif + + status = DL_CALL_FCT (fct, (gs, codecvt->__cd_in.__cd.__data, &from_start_copy, - from_end, NULL, &dummy, 0, 0)); + (const unsigned char *) from_end, NULL, + &dummy, 0, 0)); - *from_stop = from_start_copy; + *from_stop = (const char *) from_start_copy; *to_stop = (wchar_t *) codecvt->__cd_in.__cd.__data[0].__outbuf; switch (status) @@ -454,13 +474,20 @@ do_length (struct _IO_codecvt *codecvt, __mbstate_t *statep, int status; size_t dummy; - codecvt->__cd_in.__cd.__data[0].__outbuf = (char *) to_buf; - codecvt->__cd_in.__cd.__data[0].__outbufend = (char *) &to_buf[max]; + codecvt->__cd_in.__cd.__data[0].__outbuf = (unsigned char *) to_buf; + codecvt->__cd_in.__cd.__data[0].__outbufend = (unsigned char *) &to_buf[max]; codecvt->__cd_in.__cd.__data[0].__statep = statep; - status = DL_CALL_FCT (gs->__fct, - (gs, codecvt->__cd_in.__cd.__data, &cp, from_end, - NULL, &dummy, 0, 0)); + __gconv_fct fct = gs->__fct; +#ifdef PTR_DEMANGLE + if (gs->__shlib_handle != NULL) + PTR_DEMANGLE (fct); +#endif + + status = DL_CALL_FCT (fct, + (gs, codecvt->__cd_in.__cd.__data, &cp, + (const unsigned char *) from_end, NULL, + &dummy, 0, 0)); result = cp - (const unsigned char *) from_start; #else diff --git a/libio/iogetdelim.c b/libio/iogetdelim.c index 3d0c976f9c..a362bf978a 100644 --- a/libio/iogetdelim.c +++ b/libio/iogetdelim.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1994,1996,1997,1998,2001,2003 Free Software Foundation, Inc. +/* Copyright (C) 1994,1996-1998,2001,2003,2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -45,7 +45,7 @@ _IO_getdelim (lineptr, n, delimiter, fp) int delimiter; _IO_FILE *fp; { - int result; + _IO_ssize_t result; _IO_ssize_t cur_len = 0; _IO_ssize_t len; @@ -91,6 +91,12 @@ _IO_getdelim (lineptr, n, delimiter, fp) t = (char *) memchr ((void *) fp->_IO_read_ptr, delimiter, len); if (t != NULL) len = (t - fp->_IO_read_ptr) + 1; + if (__builtin_expect (cur_len + len + 1 < 0, 0)) + { + __set_errno (EOVERFLOW); + result = -1; + goto unlock_return; + } /* Make enough space for len+1 (for final NUL) bytes. */ needed = cur_len + len + 1; if (needed > *n) diff --git a/libio/iogetline.c b/libio/iogetline.c index eca38cf773..022a444f77 100644 --- a/libio/iogetline.c +++ b/libio/iogetline.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1993,1997,1998,2000,2001,2002 Free Software Foundation, Inc. +/* Copyright (C) 1993,1997,1998,2000,2001,2002,2005 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -73,7 +74,8 @@ _IO_getline_info (fp, buf, n, delim, extract_delim, eof) int c = __uflow (fp); if (c == EOF) { - if (eof) *eof = c; + if (eof) + *eof = c; break; } if (c == delim) @@ -89,31 +91,31 @@ _IO_getline_info (fp, buf, n, delim, extract_delim, eof) *ptr++ = c; n--; } - else - { - char *t; - if ((_IO_size_t) len >= n) - len = n; - t = (char *) memchr ((void *) fp->_IO_read_ptr, delim, len); - if (t != NULL) - { - _IO_size_t old_len = ptr-buf; - len = t - fp->_IO_read_ptr; - if (extract_delim >= 0) - { - ++t; - if (extract_delim > 0) - ++len; - } - memcpy ((void *) ptr, (void *) fp->_IO_read_ptr, len); - fp->_IO_read_ptr = t; - return old_len + len; - } - memcpy ((void *) ptr, (void *) fp->_IO_read_ptr, len); - fp->_IO_read_ptr += len; - ptr += len; - n -= len; - } + else + { + char *t; + if ((_IO_size_t) len >= n) + len = n; + t = (char *) memchr ((void *) fp->_IO_read_ptr, delim, len); + if (t != NULL) + { + _IO_size_t old_len = ptr-buf; + len = t - fp->_IO_read_ptr; + if (extract_delim >= 0) + { + ++t; + if (extract_delim > 0) + ++len; + } + memcpy ((void *) ptr, (void *) fp->_IO_read_ptr, len); + fp->_IO_read_ptr = t; + return old_len + len; + } + memcpy ((void *) ptr, (void *) fp->_IO_read_ptr, len); + fp->_IO_read_ptr += len; + ptr += len; + n -= len; + } } return ptr - buf; } diff --git a/libio/iogetwline.c b/libio/iogetwline.c index e529b7d832..45db478423 100644 --- a/libio/iogetwline.c +++ b/libio/iogetwline.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993,1997,1998,1999,2000,2002 Free Software Foundation, Inc. +/* Copyright (C) 1993,1997-2000,2002,2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -87,9 +87,9 @@ _IO_getwline_info (fp, buf, n, delim, extract_delim, eof) *ptr++ = wc; else if (extract_delim < 0) INTUSE(_IO_sputbackc) (fp, wc); - return ptr - buf; if (extract_delim > 0) ++len; + return ptr - buf; } *ptr++ = wc; n--; diff --git a/libio/ioungetwc.c b/libio/ioungetwc.c index 00d3e965b5..f7b6866617 100644 --- a/libio/ioungetwc.c +++ b/libio/ioungetwc.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1996, 1997, 1998, 1999, 2001, 2002, 2003 +/* Copyright (C) 1993, 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -34,7 +34,7 @@ ungetwc (c, fp) wint_t c; _IO_FILE *fp; { - int result; + wint_t result; CHECK_FILE (fp, WEOF); _IO_acquire_lock (fp); _IO_fwide (fp, 1); diff --git a/libio/iovdprintf.c b/libio/iovdprintf.c index e81d870ca7..edab849a44 100644 --- a/libio/iovdprintf.c +++ b/libio/iovdprintf.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1995,1997-2000,2001,2002,2003 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1997-2000, 2001, 2002, 2003, 2006 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -25,7 +26,7 @@ This exception applies to code released by its copyright holders in files containing the exception. */ -#include "libioP.h" +#include #include int @@ -63,7 +64,4 @@ _IO_vdprintf (d, format, arg) return done; } - -#ifdef weak_alias -weak_alias (_IO_vdprintf, vdprintf) -#endif +ldbl_weak_alias (_IO_vdprintf, vdprintf) diff --git a/libio/iovsprintf.c b/libio/iovsprintf.c index b26a99b271..7fcd0a156e 100644 --- a/libio/iovsprintf.c +++ b/libio/iovsprintf.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1997-2003 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1997-2003, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -29,10 +29,7 @@ #include "strfile.h" int -_IO_vsprintf (string, format, args) - char *string; - const char *format; - _IO_va_list args; +__IO_vsprintf (char *string, const char *format, _IO_va_list args) { _IO_strfile sf; int ret; @@ -47,8 +44,7 @@ _IO_vsprintf (string, format, args) _IO_putc_unlocked ('\0', (_IO_FILE *) &sf._sbf); return ret; } -INTDEF(_IO_vsprintf) +INTDEF2(__IO_vsprintf, _IO_vsprintf) -#ifdef weak_alias -weak_alias (_IO_vsprintf, vsprintf) -#endif +ldbl_strong_alias (__IO_vsprintf, _IO_vsprintf) +ldbl_weak_alias (__IO_vsprintf, vsprintf) diff --git a/libio/iovsscanf.c b/libio/iovsscanf.c index 1a965c2d92..10e4b0a9ac 100644 --- a/libio/iovsscanf.c +++ b/libio/iovsscanf.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1997-2003 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1997-2003, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -45,8 +45,5 @@ _IO_vsscanf (string, format, args) ret = INTUSE(_IO_vfscanf) ((_IO_FILE *) &sf._sbf, format, args, NULL); return ret; } - -#ifdef weak_alias -weak_alias (_IO_vsscanf, __vsscanf) -weak_alias (_IO_vsscanf, vsscanf) -#endif +ldbl_weak_alias (_IO_vsscanf, __vsscanf) +ldbl_weak_alias (_IO_vsscanf, vsscanf) diff --git a/libio/iovswscanf.c b/libio/iovswscanf.c index 1bbddd442f..182d8da410 100644 --- a/libio/iovswscanf.c +++ b/libio/iovswscanf.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1993, 1997-2000, 2001, 2002 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1997-2000, 2001, 2002, 2006 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -30,10 +31,7 @@ #include int -vswscanf (string, format, args) - const wchar_t *string; - const wchar_t *format; - _IO_va_list args; +__vswscanf (const wchar_t *string, const wchar_t *format, _IO_va_list args) { int ret; _IO_strfile sf; @@ -47,4 +45,5 @@ vswscanf (string, format, args) ret = _IO_vfwscanf ((_IO_FILE *) &sf._sbf, format, args, NULL); return ret; } -libc_hidden_def (vswscanf) +ldbl_hidden_def (__vswscanf, vswscanf) +ldbl_strong_alias (__vswscanf, vswscanf) diff --git a/libio/libc_fatal.c b/libio/libc_fatal.c new file mode 100644 index 0000000000..be23849829 --- /dev/null +++ b/libio/libc_fatal.c @@ -0,0 +1,31 @@ +/* Copyright (C) 1993, 1995, 1997, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + +/* Abort with an error message. */ +void +__libc_fatal (message) + const char *message; +{ + /* This function should write MESSAGE out in the most reliable way. + It is called in situations like internal stdio lossage. */ + + abort (); +} +libc_hidden_def (__libc_fatal) diff --git a/libio/libio.h b/libio/libio.h index 3b6facdddb..9df08614ee 100644 --- a/libio/libio.h +++ b/libio/libio.h @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-1995, 1997-2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1991-1995,1997-2005,2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Per Bothner . @@ -142,6 +142,7 @@ #ifdef _LIBC # define _IO_FLAGS2_FORTIFY 4 #endif +#define _IO_FLAGS2_USER_WBUF 8 /* These are "formatting flags" matching the iostream fmtflags enum values. */ #define _IO_SKIPWS 01 @@ -317,13 +318,19 @@ struct _IO_FILE_complete /* Wide character stream stuff. */ struct _IO_codecvt *_codecvt; struct _IO_wide_data *_wide_data; + struct _IO_FILE *_freeres_list; + void *_freeres_buf; + size_t _freeres_size; # else void *__pad1; void *__pad2; + void *__pad3; + void *__pad4; + size_t __pad5; # endif int _mode; /* Make sure we don't get into trouble again. */ - char _unused2[15 * sizeof (int) - 2 * sizeof (void *)]; + char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)]; #endif }; @@ -403,15 +410,15 @@ extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write, extern "C" { #endif -extern int __underflow (_IO_FILE *) __THROW; -extern int __uflow (_IO_FILE *) __THROW; -extern int __overflow (_IO_FILE *, int) __THROW; -extern _IO_wint_t __wunderflow (_IO_FILE *) __THROW; -extern _IO_wint_t __wuflow (_IO_FILE *) __THROW; -extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t) __THROW; +extern int __underflow (_IO_FILE *); +extern int __uflow (_IO_FILE *); +extern int __overflow (_IO_FILE *, int); +extern _IO_wint_t __wunderflow (_IO_FILE *); +extern _IO_wint_t __wuflow (_IO_FILE *); +extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t); #if __GNUC__ >= 3 -# define _IO_BE(expr, res) __builtin_expect (expr, res) +# define _IO_BE(expr, res) __builtin_expect ((expr), res) #else # define _IO_BE(expr, res) (expr) #endif @@ -441,12 +448,12 @@ extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t) __THROW; #define _IO_feof_unlocked(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0) #define _IO_ferror_unlocked(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0) -extern int _IO_getc (_IO_FILE *__fp) __THROW; -extern int _IO_putc (int __c, _IO_FILE *__fp) __THROW; +extern int _IO_getc (_IO_FILE *__fp); +extern int _IO_putc (int __c, _IO_FILE *__fp); extern int _IO_feof (_IO_FILE *__fp) __THROW; extern int _IO_ferror (_IO_FILE *__fp) __THROW; -extern int _IO_peekc_locked (_IO_FILE *__fp) __THROW; +extern int _IO_peekc_locked (_IO_FILE *__fp); /* This one is for Emacs. */ #define _IO_PENDING_OUTPUT_COUNT(_fp) \ @@ -472,20 +479,20 @@ extern int _IO_ftrylockfile (_IO_FILE *) __THROW; #endif /* !_IO_MTSAFE_IO */ extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict, - _IO_va_list, int *__restrict) __THROW; + _IO_va_list, int *__restrict); extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict, - _IO_va_list) __THROW; -extern _IO_ssize_t _IO_padn (_IO_FILE *, int, _IO_ssize_t) __THROW; -extern _IO_size_t _IO_sgetn (_IO_FILE *, void *, _IO_size_t) __THROW; + _IO_va_list); +extern _IO_ssize_t _IO_padn (_IO_FILE *, int, _IO_ssize_t); +extern _IO_size_t _IO_sgetn (_IO_FILE *, void *, _IO_size_t); -extern _IO_off64_t _IO_seekoff (_IO_FILE *, _IO_off64_t, int, int) __THROW; -extern _IO_off64_t _IO_seekpos (_IO_FILE *, _IO_off64_t, int) __THROW; +extern _IO_off64_t _IO_seekoff (_IO_FILE *, _IO_off64_t, int, int); +extern _IO_off64_t _IO_seekpos (_IO_FILE *, _IO_off64_t, int); extern void _IO_free_backup_area (_IO_FILE *) __THROW; #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T -extern _IO_wint_t _IO_getwc (_IO_FILE *__fp) __THROW; -extern _IO_wint_t _IO_putwc (wchar_t __wc, _IO_FILE *__fp) __THROW; +extern _IO_wint_t _IO_getwc (_IO_FILE *__fp); +extern _IO_wint_t _IO_putwc (wchar_t __wc, _IO_FILE *__fp); extern int _IO_fwide (_IO_FILE *__fp, int __mode) __THROW; # if __GNUC__ >= 2 /* While compiling glibc we have to handle compatibility with very old @@ -521,13 +528,17 @@ weak_extern (_IO_stdin_used); # endif extern int _IO_vfwscanf (_IO_FILE * __restrict, const wchar_t * __restrict, - _IO_va_list, int *__restrict) __THROW; + _IO_va_list, int *__restrict); extern int _IO_vfwprintf (_IO_FILE *__restrict, const wchar_t *__restrict, - _IO_va_list) __THROW; -extern _IO_ssize_t _IO_wpadn (_IO_FILE *, wint_t, _IO_ssize_t) __THROW; + _IO_va_list); +extern _IO_ssize_t _IO_wpadn (_IO_FILE *, wint_t, _IO_ssize_t); extern void _IO_free_wbackup_area (_IO_FILE *) __THROW; #endif +#ifdef __LDBL_COMPAT +# include +#endif + #ifdef __cplusplus } #endif diff --git a/libio/libioP.h b/libio/libioP.h index 319b0fd5f3..a574b40f77 100644 --- a/libio/libioP.h +++ b/libio/libioP.h @@ -1,4 +1,5 @@ -/* Copyright (C) 1993, 1997-2003, 2004 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1997-2003,2004,2005,2006,2007 + Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -35,6 +36,8 @@ /*# include */ #endif +#include + #include "iolibio.h" /* Control of exported symbols. Used in glibc. By default we don't @@ -377,7 +380,7 @@ typedef struct _IO_FILE *_IO_ITER; extern void _IO_switch_to_main_get_area (_IO_FILE *) __THROW; extern void _IO_switch_to_backup_area (_IO_FILE *) __THROW; -extern int _IO_switch_to_get_mode (_IO_FILE *) __THROW; +extern int _IO_switch_to_get_mode (_IO_FILE *); extern void _IO_init (_IO_FILE *, int) __THROW; extern int _IO_sputbackc (_IO_FILE *, int) __THROW; extern int _IO_sungetc (_IO_FILE *) __THROW; @@ -391,7 +394,7 @@ extern unsigned _IO_adjust_column (unsigned, const char *, int) __THROW; extern void _IO_switch_to_main_wget_area (_IO_FILE *) __THROW; extern void _IO_switch_to_wbackup_area (_IO_FILE *) __THROW; -extern int _IO_switch_to_wget_mode (_IO_FILE *) __THROW; +extern int _IO_switch_to_wget_mode (_IO_FILE *); extern void _IO_wsetb (_IO_FILE *, wchar_t *, wchar_t *, int) __THROW; extern wint_t _IO_sputbackwc (_IO_FILE *, wint_t) __THROW; extern wint_t _IO_sungetwc (_IO_FILE *) __THROW; @@ -401,8 +404,8 @@ extern unsigned _IO_adjust_wcolumn (unsigned, const wchar_t *, int) __THROW; /* Marker-related function. */ -extern void _IO_init_marker (struct _IO_marker *, _IO_FILE *) __THROW; -extern void _IO_init_wmarker (struct _IO_marker *, _IO_FILE *) __THROW; +extern void _IO_init_marker (struct _IO_marker *, _IO_FILE *); +extern void _IO_init_wmarker (struct _IO_marker *, _IO_FILE *); extern void _IO_remove_marker (struct _IO_marker *) __THROW; extern int _IO_marker_difference (struct _IO_marker *, struct _IO_marker *) __THROW; @@ -431,22 +434,22 @@ libc_hidden_proto (_IO_list_resetlock) /* Default jumptable functions. */ extern int _IO_default_underflow (_IO_FILE *) __THROW; -extern int _IO_default_uflow (_IO_FILE *) __THROW; -extern wint_t _IO_wdefault_uflow (_IO_FILE *) __THROW; +extern int _IO_default_uflow (_IO_FILE *); +extern wint_t _IO_wdefault_uflow (_IO_FILE *); extern int _IO_default_doallocate (_IO_FILE *) __THROW; extern int _IO_wdefault_doallocate (_IO_FILE *) __THROW; extern void _IO_default_finish (_IO_FILE *, int) __THROW; extern void _IO_wdefault_finish (_IO_FILE *, int) __THROW; extern int _IO_default_pbackfail (_IO_FILE *, int) __THROW; extern wint_t _IO_wdefault_pbackfail (_IO_FILE *, wint_t) __THROW; -extern _IO_FILE* _IO_default_setbuf (_IO_FILE *, char *, _IO_ssize_t) __THROW; +extern _IO_FILE* _IO_default_setbuf (_IO_FILE *, char *, _IO_ssize_t); extern _IO_size_t _IO_default_xsputn (_IO_FILE *, const void *, _IO_size_t); extern _IO_size_t _IO_wdefault_xsputn (_IO_FILE *, const void *, _IO_size_t); extern _IO_size_t _IO_default_xsgetn (_IO_FILE *, void *, _IO_size_t); extern _IO_size_t _IO_wdefault_xsgetn (_IO_FILE *, void *, _IO_size_t); extern _IO_off64_t _IO_default_seekoff (_IO_FILE *, _IO_off64_t, int, int) __THROW; -extern _IO_off64_t _IO_default_seekpos (_IO_FILE *, _IO_off64_t, int) __THROW; +extern _IO_off64_t _IO_default_seekpos (_IO_FILE *, _IO_off64_t, int); extern _IO_ssize_t _IO_default_write (_IO_FILE *, const void *, _IO_ssize_t); extern _IO_ssize_t _IO_default_read (_IO_FILE *, void *, _IO_ssize_t); extern int _IO_default_stat (_IO_FILE *, void *) __THROW; @@ -469,23 +472,23 @@ extern const struct _IO_jump_t _IO_streambuf_jumps; extern const struct _IO_jump_t _IO_old_proc_jumps attribute_hidden; extern const struct _IO_jump_t _IO_str_jumps attribute_hidden; extern const struct _IO_jump_t _IO_wstr_jumps attribute_hidden; -extern struct _IO_codecvt __libio_codecvt attribute_hidden; -extern int _IO_do_write (_IO_FILE *, const char *, _IO_size_t) __THROW; -extern int _IO_new_do_write (_IO_FILE *, const char *, _IO_size_t) __THROW; -extern int _IO_old_do_write (_IO_FILE *, const char *, _IO_size_t) __THROW; -extern int _IO_wdo_write (_IO_FILE *, const wchar_t *, _IO_size_t) __THROW; -extern int _IO_flush_all_lockp (int) __THROW; -extern int _IO_flush_all (void) __THROW; -extern int _IO_cleanup (void) __THROW; -extern void _IO_flush_all_linebuffered (void) __THROW; -extern int _IO_new_fgetpos (_IO_FILE *, _IO_fpos_t *) __THROW; -extern int _IO_old_fgetpos (_IO_FILE *, _IO_fpos_t *) __THROW; -extern int _IO_new_fsetpos (_IO_FILE *, const _IO_fpos_t *) __THROW; -extern int _IO_old_fsetpos (_IO_FILE *, const _IO_fpos_t *) __THROW; -extern int _IO_new_fgetpos64 (_IO_FILE *, _IO_fpos64_t *) __THROW; -extern int _IO_old_fgetpos64 (_IO_FILE *, _IO_fpos64_t *) __THROW; -extern int _IO_new_fsetpos64 (_IO_FILE *, const _IO_fpos64_t *) __THROW; -extern int _IO_old_fsetpos64 (_IO_FILE *, const _IO_fpos64_t *) __THROW; +extern const struct _IO_codecvt __libio_codecvt attribute_hidden; +extern int _IO_do_write (_IO_FILE *, const char *, _IO_size_t); +extern int _IO_new_do_write (_IO_FILE *, const char *, _IO_size_t); +extern int _IO_old_do_write (_IO_FILE *, const char *, _IO_size_t); +extern int _IO_wdo_write (_IO_FILE *, const wchar_t *, _IO_size_t); +extern int _IO_flush_all_lockp (int); +extern int _IO_flush_all (void); +extern int _IO_cleanup (void); +extern void _IO_flush_all_linebuffered (void); +exte