diff options
Diffstat (limited to 'libio')
80 files changed, 4568 insertions, 199 deletions
diff --git a/libio/Makefile b/libio/Makefile index 948556e15c..6fcde40814 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -25,11 +25,16 @@ headers := stdio.h libio.h _G_config.h bits/stdio.h routines := \ filedoalloc iofclose iofdopen iofflush iofgetpos iofgets iofopen \ - iofopncook iofputs iofread iofsetpos ioftell \ + iofopncook iofputs iofread iofsetpos ioftell wfiledoalloc \ iofwrite iogetdelim iogetline iogets iopadn iopopen ioputs \ ioseekoff ioseekpos iosetbuffer iosetvbuf iosprintf ioungetc \ iovsprintf iovsscanf \ iofgetpos64 iofopen64 iofsetpos64 \ + oldiofgetpos oldiofgetpos64 oldiofsetpos oldiofsetpos64 \ + fputwc fputwc_u getwc getwc_u getwchar getwchar_u iofgetws iofgetws_u \ + iofputws iofputws_u iogetwline iowpadn ioungetwc putwc putwc_u \ + putchar putchar_u swprintf vwprintf wprintf wscanf fwscanf vwscanf \ + vswprintf iovswscanf swscanf wgenops wstrops wfileops iofwide \ \ clearerr feof ferror fileno fputc freopen fseek getc getchar \ memstream pclose putc putchar rewind setbuf setlinebuf vasprintf \ @@ -38,6 +43,8 @@ routines := \ \ libc_fatal +tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf + all: # Make this the default target; it will be defined in Rules. include ../Makeconfig diff --git a/libio/Versions b/libio/Versions index 61b767a2d3..c7a5f668a1 100644 --- a/libio/Versions +++ b/libio/Versions @@ -100,4 +100,31 @@ libc { # p* pclose; popen; } + GLIBC_2.2 { + # functions used in libstdc++ + _IO_fgetpos; _IO_fgetpos64; _IO_fsetpos; _IO_fsetpos64; + + # f* + fgetpos; fgetpos64; fgetwc; fgetwc_unlocked; fgetws; fgetws_unlocked; + fputwc; fputwc_unlocked; fputws; fputws_unlocked; fsetpos; fsetpos64; + fwide; fwprintf; fwscanf; + + # g* + getwc; getwc_unlocked; getwchar; getwchar_unlocked; + + # p* + putwc; putwc_unlocked; putwchar; putwchar_unlocked; + + # s* + swprintf; swscanf; + + # u* + ungetwc; + + # v* + vfwprintf; vswprintf; vwprintf; vfwscanf; vswscanf; vwscanf; + + # w* + wprintf; wscanf; + } } diff --git a/libio/fileops.c b/libio/fileops.c index f5ec0e2b9e..8d480ad08b 100644 --- a/libio/fileops.c +++ b/libio/fileops.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1993, 1995, 1997, 1998 Free Software Foundation, Inc. +/* Copyright (C) 1993, 1995, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU IO Library. Written by Per Bothner <bothner@cygnus.com>. @@ -136,9 +136,18 @@ _IO_new_file_close_it (fp) close_status = _IO_SYSCLOSE (fp); /* Free buffer. */ - _IO_setb (fp, NULL, NULL, 0); - _IO_setg (fp, NULL, NULL, NULL); - _IO_setp (fp, NULL, NULL); + if (fp->_mode <= 0) + { + _IO_setb (fp, NULL, NULL, 0); + _IO_setg (fp, NULL, NULL, NULL); + _IO_setp (fp, NULL, NULL); + } + else + { + _IO_wsetb (fp, NULL, NULL, 0); + _IO_wsetg (fp, NULL, NULL, NULL); + _IO_wsetp (fp, NULL, NULL); + } _IO_un_link (fp); fp->_flags = _IO_MAGIC|CLOSED_FILEBUF_FLAGS; @@ -277,14 +286,14 @@ _IO_new_file_setbuf (fp, p, len) char *p; _IO_ssize_t len; { - if (_IO_default_setbuf (fp, p, len) == NULL) - return NULL; + if (_IO_default_setbuf (fp, p, len) == NULL) + return NULL; - fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end - = fp->_IO_buf_base; - _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base); + fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end + = fp->_IO_buf_base; + _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base); - return fp; + return fp; } static int new_do_write __P ((_IO_FILE *, const char *, _IO_size_t)); @@ -319,7 +328,7 @@ new_do_write (fp, data, to_do) fp->_offset = _IO_pos_BAD; else if (fp->_IO_read_end != fp->_IO_write_base) { - _IO_fpos64_t new_pos + _IO_off64_t new_pos = _IO_SYSSEEK (fp, fp->_IO_write_base - fp->_IO_read_end, 1); if (new_pos == _IO_pos_BAD) return 0; @@ -330,7 +339,8 @@ new_do_write (fp, data, to_do) fp->_cur_column = _IO_adjust_column (fp->_cur_column - 1, data, count) + 1; _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base); fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_buf_base; - fp->_IO_write_end = ((fp->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED)) + fp->_IO_write_end = (fp->_mode < 0 + && (fp->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED)) ? fp->_IO_buf_base : fp->_IO_buf_end); return count; } @@ -410,7 +420,7 @@ _IO_new_file_overflow (f, ch) return EOF; } /* If currently reading or no buffer allocated. */ - if ((f->_flags & _IO_CURRENTLY_PUTTING) == 0) + if ((f->_flags & _IO_CURRENTLY_PUTTING) == 0 || f->_IO_write_base == 0) { /* Allocate a buffer if needed. */ if (f->_IO_write_base == 0) @@ -433,18 +443,20 @@ _IO_new_file_overflow (f, ch) f->_IO_read_base = f->_IO_read_ptr = f->_IO_read_end; f->_flags |= _IO_CURRENTLY_PUTTING; - if (f->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED)) + if (f->_mode < 0 && f->_flags & (_IO_LINE_BUF+_IO_UNBUFFERED)) f->_IO_write_end = f->_IO_write_ptr; } if (ch == EOF) - return _IO_do_flush (f); + return _IO_new_do_write(f, f->_IO_write_base, + f->_IO_write_ptr - f->_IO_write_base); |
