diff options
author | Bernd Schmidt <bernds@redhat.com> | 2000-12-10 17:45:08 +0000 |
---|---|---|
committer | Bernd Schmidt <bernds@gcc.gnu.org> | 2000-12-10 17:45:08 +0000 |
commit | 2459d37eabcbd848e1d71d017150f873696a4a24 (patch) | |
tree | 4ef1277c74cdd5458827167d2a42442dd6d2bf84 | |
parent | ca876c54e5a15998421f926dcd9aa8fc6da3da74 (diff) | |
download | gcc-2459d37eabcbd848e1d71d017150f873696a4a24.tar.gz |
Backport patches that make libio compatible with glibc-2.2
From-SVN: r38172
-rw-r--r-- | libio/ChangeLog | 28 | ||||
-rw-r--r-- | libio/iolibio.h | 8 | ||||
-rw-r--r-- | libio/iostream.cc | 10 | ||||
-rw-r--r-- | libio/libio.h | 11 | ||||
-rw-r--r-- | libio/libioP.h | 52 | ||||
-rw-r--r-- | libio/parsestream.h | 157 | ||||
-rw-r--r-- | libio/stdstreams.cc | 154 | ||||
-rw-r--r-- | libio/streambuf.h | 4 |
8 files changed, 79 insertions, 345 deletions
diff --git a/libio/ChangeLog b/libio/ChangeLog index d78e5056a4e..ead89e4b1ea 100644 --- a/libio/ChangeLog +++ b/libio/ChangeLog @@ -1,3 +1,31 @@ +2000-12-10 Bernd Schmidt <bernds@redhat.com> + + 2000-10-16 Jakub Jelinek <jakub@redhat.com> + * iostream.cc (ostream::operator<<(double n)) [__GLIBC_MINOR__ >= 2]: + Initialize new fields wide and i18n of struct printf_info. + (ostream::operator<<(long double n)) [__GLIBC_MINOR__ >= 2]: + Likewise. + + 2000-09-23 Franz Sirl <Franz.Sirl-kernel@lauterbach.com> + * stdstreams.cc: Include <libio.h>, not "libio.h". + * iolibio.h: Likewise. + (_IO_pos_BAD): Use _IO_off_t instead of _IO_fpos_t. + * libio.h (_IO_USER_LOCK): Define. + + 1999-12-22 Jakub Jelinek <jakub@redhat.com> + * libio.h (_IO_cookie_io_functions_t): Use _IO_off_t instead of + _IO_fpos_t. + (_IO_seekoff, _IO_seekpos): Likewise. Use _IO_off64_t instead of + _IO_fpos64_t. + * libioP.h (_IO_seekoff_t, _IO_seekpos_t, _IO_seek_t): Likewise. + (_IO_seekoff, _IO_seekpos): Likewise. + (_IO_default_seekoff, _IO_default_seekpos): Likewise. + (_IO_default_seek): Likewise. + (_IO_file_seekoff, _IO_file_seek, _IO_str_seekoff): Likewise. + * streambuf.h (streampos): Typedef to _IO_off_t resp. _IO_off64_t. + * parsestream.h (class parsebuf::pos_at_line_start): Change type + to _IO_off_t. + 2000-01-28 Martin v. Löwis <loewis@informatik.hu-berlin.de> * fstream.h (ifstream::ifstream): Add ios::in to mode. diff --git a/libio/iolibio.h b/libio/iolibio.h index 083b198b448..0ebc14f7ac2 100644 --- a/libio/iolibio.h +++ b/libio/iolibio.h @@ -1,4 +1,4 @@ -#include "libio.h" +#include <libio.h> /* These emulate stdio functionality, but with a different name (_IO_ungetc instead of ungetc), and using _IO_FILE instead of FILE. */ @@ -38,7 +38,11 @@ extern int _IO_obstack_vprintf __P ((struct obstack *, const char *, _IO_va_list)); extern int _IO_obstack_printf __P ((struct obstack *, const char *, ...)); #ifndef _IO_pos_BAD -#define _IO_pos_BAD ((_IO_fpos_t)(-1)) +# if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001 +# define _IO_pos_BAD ((_IO_off64_t) -1) +# else +# define _IO_pos_BAD ((_IO_off_t) -1) +# endif #endif #define _IO_clearerr(FP) ((FP)->_flags &= ~(_IO_ERR_SEEN|_IO_EOF_SEEN)) #define _IO_fseek(__fp, __offset, __whence) \ diff --git a/libio/iostream.cc b/libio/iostream.cc index 4b75fca764d..792eaae6b4c 100644 --- a/libio/iostream.cc +++ b/libio/iostream.cc @@ -1,5 +1,5 @@ /* This is part of libio/iostream, providing -*- C++ -*- input/output. - Copyright (C) 1993, 1997 Free Software Foundation, Inc. + Copyright (C) 1993, 1997, 2000 Free Software Foundation, Inc. This file is part of the GNU IO Library. This library is free software; you can redistribute it and/or modify it under the @@ -687,6 +687,10 @@ ostream& ostream::operator<<(double n) /* extra: */ 0, #if __GLIBC_MINOR__ >= 1 /* is_char: */ 0, +#if __GLIBC_MINOR__ >= 2 + /* wide: */ 0, + /* i18n: */ 0, +#endif #endif #endif /* pad: */ fill() @@ -793,6 +797,10 @@ ostream& ostream::operator<<(long double n) /* extra: */ 0, #if __GLIBC_MINOR__ >= 1 /* is_char: */ 0, +#if __GLIBC_MINOR__ >= 2 + /* wide: */ 0, + /* i18n: */ 0, +#endif #endif #endif /* pad: */ fill() diff --git a/libio/libio.h b/libio/libio.h index b152874d1f6..c453b77bf30 100644 --- a/libio/libio.h +++ b/libio/libio.h @@ -136,6 +136,7 @@ #define _IO_IS_APPENDING 0x1000 #define _IO_IS_FILEBUF 0x2000 #define _IO_BAD_SEEN 0x4000 +#define _IO_USER_LOCK 0x8000 /* These are "formatting flags" matching the iostream fmtflags enum values. */ #define _IO_SKIPWS 01 @@ -277,7 +278,7 @@ typedef struct { _IO_ssize_t (*read) __PMT ((struct _IO_FILE *, void *, _IO_ssize_t)); _IO_ssize_t (*write) __PMT ((struct _IO_FILE *, const void *, _IO_ssize_t)); - _IO_fpos_t (*seek) __PMT ((struct _IO_FILE *, _IO_off_t, int)); + _IO_off_t (*seek) __PMT ((struct _IO_FILE *, _IO_off_t, int)); int (*close) __PMT ((struct _IO_FILE *)); } _IO_cookie_io_functions_t; @@ -348,11 +349,11 @@ extern _IO_ssize_t _IO_padn __P ((_IO_FILE *, int, _IO_ssize_t)); extern _IO_size_t _IO_sgetn __P ((_IO_FILE *, void *, _IO_size_t)); #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001 -extern _IO_fpos64_t _IO_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int)); -extern _IO_fpos64_t _IO_seekpos __P ((_IO_FILE *, _IO_fpos64_t, int)); +extern _IO_off64_t _IO_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int)); +extern _IO_off64_t _IO_seekpos __P ((_IO_FILE *, _IO_off64_t, int)); #else -extern _IO_fpos_t _IO_seekoff __P ((_IO_FILE *, _IO_off_t, int, int)); -extern _IO_fpos_t _IO_seekpos __P ((_IO_FILE *, _IO_fpos_t, int)); +extern _IO_off_t _IO_seekoff __P ((_IO_FILE *, _IO_off_t, int, int)); +extern _IO_off_t _IO_seekpos __P ((_IO_FILE *, _IO_off_t, int)); #endif extern void _IO_free_backup_area __P ((_IO_FILE *)); diff --git a/libio/libioP.h b/libio/libioP.h index 629e4fd8cf6..be70f526bbe 100644 --- a/libio/libioP.h +++ b/libio/libioP.h @@ -146,10 +146,10 @@ typedef _IO_size_t (*_IO_xsgetn_t) __PMT ((_IO_FILE *FP, void *DATA, It matches the streambuf::seekoff virtual function. It is also used for the ANSI fseek function. */ #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001 -typedef _IO_fpos64_t (*_IO_seekoff_t) __PMT ((_IO_FILE *FP, _IO_off64_t OFF, +typedef _IO_off64_t (*_IO_seekoff_t) __PMT ((_IO_FILE *FP, _IO_off64_t OFF, int DIR, int MODE)); #else -typedef _IO_fpos_t (*_IO_seekoff_t) __PMT ((_IO_FILE *FP, _IO_off_t OFF, +typedef _IO_off_t (*_IO_seekoff_t) __PMT ((_IO_FILE *FP, _IO_off_t OFF, int DIR, int MODE)); #endif #define _IO_SEEKOFF(FP, OFF, DIR, MODE) JUMP3 (__seekoff, FP, OFF, DIR, MODE) @@ -160,9 +160,9 @@ typedef _IO_fpos_t (*_IO_seekoff_t) __PMT ((_IO_FILE *FP, _IO_off_t OFF, It is also used for the ANSI fgetpos and fsetpos functions. */ /* The _IO_seek_cur and _IO_seek_end options are not allowed. */ #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001 -typedef _IO_fpos64_t (*_IO_seekpos_t) __PMT ((_IO_FILE *, _IO_fpos64_t, int)); +typedef _IO_off64_t (*_IO_seekpos_t) __PMT ((_IO_FILE *, _IO_off64_t, int)); #else -typedef _IO_fpos_t (*_IO_seekpos_t) __PMT ((_IO_FILE *, _IO_fpos_t, int)); +typedef _IO_off_t (*_IO_seekpos_t) __PMT ((_IO_FILE *, _IO_off_t, int)); #endif #define _IO_SEEKPOS(FP, POS, FLAGS) JUMP2 (__seekpos, FP, POS, FLAGS) @@ -213,9 +213,9 @@ typedef _IO_ssize_t (*_IO_write_t) __PMT ((_IO_FILE *,const void *,_IO_ssize_t)) It matches the streambuf::sys_seek virtual function, which is specific to this implementation. */ #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001 -typedef _IO_fpos64_t (*_IO_seek_t) __PMT ((_IO_FILE *, _IO_off64_t, int)); +typedef _IO_off64_t (*_IO_seek_t) __PMT ((_IO_FILE *, _IO_off64_t, int)); #else -typedef _IO_fpos_t (*_IO_seek_t) __PMT ((_IO_FILE *, _IO_off_t, int)); +typedef _IO_off_t (*_IO_seek_t) __PMT ((_IO_FILE *, _IO_off_t, int)); #endif #define _IO_SYSSEEK(FP, OFFSET, MODE) JUMP2 (__seek, FP, OFFSET, MODE) @@ -298,11 +298,11 @@ struct _IO_FILE_plus /* Generic functions */ #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001 -extern _IO_fpos64_t _IO_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int)); -extern _IO_fpos64_t _IO_seekpos __P ((_IO_FILE *, _IO_fpos64_t, int)); +extern _IO_off64_t _IO_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int)); +extern _IO_off64_t _IO_seekpos __P ((_IO_FILE *, _IO_off64_t, int)); #else -extern _IO_fpos_t _IO_seekoff __P ((_IO_FILE *, _IO_off_t, int, int)); -extern _IO_fpos_t _IO_seekpos __P ((_IO_FILE *, _IO_fpos_t, int)); +extern _IO_off_t _IO_seekoff __P ((_IO_FILE *, _IO_off_t, int, int)); +extern _IO_off_t _IO_seekpos __P ((_IO_FILE *, _IO_off_t, int)); #endif extern void _IO_switch_to_main_get_area __P ((_IO_FILE *)); @@ -340,22 +340,22 @@ extern _IO_size_t _IO_default_xsputn __P ((_IO_FILE *, const void *, _IO_size_t)); extern _IO_size_t _IO_default_xsgetn __P ((_IO_FILE *, void *, _IO_size_t)); #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001 -extern _IO_fpos64_t _IO_default_seekoff __P ((_IO_FILE *, +extern _IO_off64_t _IO_default_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int)); -extern _IO_fpos64_t _IO_default_seekpos __P ((_IO_FILE *, - _IO_fpos64_t, int)); +extern _IO_off64_t _IO_default_seekpos __P ((_IO_FILE *, + _IO_off64_t, int)); #else -extern _IO_fpos_t _IO_default_seekoff __P ((_IO_FILE *, _IO_off_t, int, int)); -extern _IO_fpos_t _IO_default_seekpos __P ((_IO_FILE *, _IO_fpos_t, int)); +extern _IO_off_t _IO_default_seekoff __P ((_IO_FILE *, _IO_off_t, int, int)); +extern _IO_off_t _IO_default_seekpos __P ((_IO_FILE *, _IO_off_t, int)); #endif extern _IO_ssize_t _IO_default_write __P ((_IO_FILE *, const void *, _IO_ssize_t)); extern _IO_ssize_t _IO_default_read __P ((_IO_FILE *, void *, _IO_ssize_t)); extern int _IO_default_stat __P ((_IO_FILE *, void *)); #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001 -extern _IO_fpos64_t _IO_default_seek __P ((_IO_FILE *, _IO_off64_t, int)); +extern _IO_off64_t _IO_default_seek __P ((_IO_FILE *, _IO_off64_t, int)); #else -extern _IO_fpos_t _IO_default_seek __P ((_IO_FILE *, _IO_off_t, int)); +extern _IO_off_t _IO_default_seek __P ((_IO_FILE *, _IO_off_t, int)); #endif extern int _IO_default_sync __P ((_IO_FILE *)); #define _IO_default_close ((_IO_close_t) _IO_default_sync) @@ -389,11 +389,11 @@ extern void _IO_flush_all_linebuffered __P ((void)); extern int _IO_file_doallocate __P ((_IO_FILE *)); extern _IO_FILE* _IO_file_setbuf __P ((_IO_FILE *, char *, _IO_ssize_t)); #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001 -extern _IO_fpos64_t _IO_file_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int)); -extern _IO_fpos64_t _IO_file_seek __P ((_IO_FILE *, _IO_off64_t, int)); +extern _IO_off64_t _IO_file_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int)); +extern _IO_off64_t _IO_file_seek __P ((_IO_FILE *, _IO_off64_t, int)); #else -extern _IO_fpos_t _IO_file_seekoff __P ((_IO_FILE *, _IO_off_t, int, int)); -extern _IO_fpos_t _IO_file_seek __P ((_IO_FILE *, _IO_off_t, int)); +extern _IO_off_t _IO_file_seekoff __P ((_IO_FILE *, _IO_off_t, int, int)); +extern _IO_off_t _IO_file_seek __P ((_IO_FILE *, _IO_off_t, int)); #endif extern _IO_size_t _IO_file_xsputn __P ((_IO_FILE *, const void *, _IO_size_t)); extern int _IO_file_stat __P ((_IO_FILE *, void *)); @@ -427,9 +427,9 @@ extern int _IO_str_underflow __P ((_IO_FILE *)); extern int _IO_str_overflow __P ((_IO_FILE *, int)); extern int _IO_str_pbackfail __P ((_IO_FILE *, int)); #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001 -extern _IO_fpos64_t _IO_str_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int)); +extern _IO_off64_t _IO_str_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int)); #else -extern _IO_fpos_t _IO_str_seekoff __P ((_IO_FILE *, _IO_off_t, int, int)); +extern _IO_off_t _IO_str_seekoff __P ((_IO_FILE *, _IO_off_t, int, int)); #endif extern void _IO_str_finish __P ((_IO_FILE *, int)); @@ -544,12 +544,12 @@ extern int _IO_vscanf __P ((const char *, _IO_va_list)); where an _IO_fpos_t is a struct. Note that _IO_off_t must be an integral type. */ -/* _IO_pos_BAD is an _IO_fpos_t value indicating error, unknown, or EOF. */ +/* _IO_pos_BAD is an _IO_off_t value indicating error, unknown, or EOF. */ #ifndef _IO_pos_BAD # if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001 -# define _IO_pos_BAD ((_IO_fpos64_t) -1) +# define _IO_pos_BAD ((_IO_off64_t) -1) # else -# define _IO_pos_BAD ((_IO_fpos_t) -1) +# define _IO_pos_BAD ((_IO_off_t) -1) # endif #endif /* _IO_pos_as_off converts an _IO_fpos_t value to an _IO_off_t value. */ diff --git a/libio/parsestream.h b/libio/parsestream.h index 326ab87a809..acb37bd0146 100644 --- a/libio/parsestream.h +++ b/libio/parsestream.h @@ -1,156 +1 @@ -/* This is part of libio/iostream, providing -*- C++ -*- input/output. -Copyright (C) 1993 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this library; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. - -Written by Per Bothner (bothner@cygnus.com). */ - -#ifndef PARSESTREAM_H -#define PARSESTREAM_H -#ifdef __GNUG__ -#pragma interface -#endif -#include "streambuf.h" - -extern "C++" { -// A parsebuf is a streambuf optimized for scanning text files. -// It keeps track of line and column numbers. -// It is guaranteed to remember the entire current line, -// as well the '\n'-s on either side of it (if they exist). -// You can arbitrarily seek (or unget) within this extended line. -// Other backward seeks are not supported. -// Normal read semantics are supported (and hence istream operators like >>). - -class parsebuf : public streambuf { - protected: - _IO_fpos_t pos_at_line_start; - long _line_length; - unsigned long __line_number; - char *buf_start; - char *buf_end; - - public: - parsebuf *chain; - - // Return column number (raw - don't handle tabs etc). - // Retult can be -1, meaning: at '\n' before current line. - virtual int tell_in_line(); - - // seek to (raw) column I in current line. - // Result is new (raw) column position - differs from I if unable to seek. - // Seek to -1 tries to seek to before previous LF. - virtual int seek_in_line(int i); - - // Note: there is no "current line" initially, until something is read. - - // Current line number, starting with 0. - // If tell_in_line()==-1, then line number of next line. - int line_number() { return __line_number; } - - // Length of current line, not counting either '\n'. - int line_length() { return _line_length; } - // Current line - not a copy, so file ops may trash it. - virtual char* current_line(); - virtual streampos seekoff(streamoff, _seek_dir, int mode=ios::in|ios::out); - virtual streambuf* setbuf(char* p, int len); - protected: - parsebuf() { chain= NULL; - __line_number = 0; pos_at_line_start = 0; _line_length = -1; } - virtual int pbackfail(int c); -}; - -// A string_parsebuf is a parsebuf whose source is a fixed string. - -class string_parsebuf : public parsebuf { - public: - int do_delete; - string_parsebuf(char *str, int len, int delete_at_close=0); - virtual int underflow(); - virtual char* current_line(); - virtual int seek_in_line(int i); - virtual int tell_in_line(); - char *left() const { return base(); } - char *right() const { return ebuf(); } -// streampos seekoff(streamoff, _seek_dir, int); -}; - -// A func_parsebuf calls a given function to get new input. -// Each call returns an entire NUL-terminated line (without the '\n'). -// That line has been allocated with malloc(), not new. -// The interface is tailored to the GNU readline library. -// Example: -// char* DoReadLine(void* arg) -// { -// char *line = readline((char*)arg); /* 'arg' is used as prompt. */ -// if line == NULL) { putc('\n', stderr); return NULL; } -// if (line[0] != '\0') add_history(line); -// return line; -// } -// char PromptBuffer[100] = "> "; -// func_parsebuf my_stream(DoReadLine, PromptBuffer); - -typedef char *(*CharReader)(void *arg); -class istream; - -class func_parsebuf : public parsebuf { - public: - void *arg; - CharReader read_func; - int backed_up_to_newline; - func_parsebuf(CharReader func, void *argm = NULL); - int underflow(); - virtual int tell_in_line(); - virtual int seek_in_line(int i); - virtual char* current_line(); -}; - -// A general_parsebuf is a parsebuf which gets its input from some -// other streambuf. It explicitly buffers up an entire line. - -class general_parsebuf : public parsebuf { - public: - streambuf *sbuf; - int delete_buf; // Delete sbuf when destroying this. - general_parsebuf(streambuf *buf, int delete_arg_buf = 0); - int underflow(); - virtual int tell_in_line(); - virtual int seek_in_line(int i); - ~general_parsebuf(); - virtual char* current_line(); -}; - -#if 0 -class parsestream : public istream { - streammarker marks[2]; - short _first; // of the two marks; either 0 or 1 - int _lineno; - int first() { return _first; } - int second() { return 1-_first; } - int line_length() { marks[second].delta(marks[first]); } - int line_length() { marks[second].delta(marks[first]); } - int seek_in_line(int i); - int tell_in_line(); - int line_number(); -}; -#endif -} // extern "C++" -#endif /*!defined(PARSESTREAM_H)*/ + _IO_off_t pos_at_line_start; diff --git a/libio/stdstreams.cc b/libio/stdstreams.cc index a5889d738e2..0d322ef67f6 100644 --- a/libio/stdstreams.cc +++ b/libio/stdstreams.cc @@ -1,153 +1 @@ -/* This is part of libio/iostream, providing -*- C++ -*- input/output. -Copyright (C) 1993 Free Software Foundation - -This file is part of the GNU IO Library. This library is free -software; you can redistribute it and/or modify it under the -terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) -any later version. - -This 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this library; see the file COPYING. If not, write to the Free -Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -As a special exception, if you link this library with files -compiled with a GNU compiler to produce an executable, this does not cause -the resulting executable to be covered by the GNU General Public License. -This exception does not however invalidate any other reasons why -the executable file might be covered by the GNU General Public License. */ - -/* Written by Per Bothner (bothner@cygnus.com). */ - -#include "libioP.h" -#include "streambuf.h" -#include <stdio.h> - -// The ANSI draft requires that operations on cin/cout/cerr can be -// mixed with operations on stdin/stdout/stderr on a character by -// character basis. This normally requires that the streambuf's -// used by cin/cout/cerr be stdiostreams. However, if the stdio -// implementation is the one that is built using this library, -// then we don't need to, since in that case stdin/stdout/stderr -// are identical to _IO_stdin/_IO_stdout/_IO_stderr. - -#include "libio.h" - -#ifdef _STDIO_USES_IOSTREAM -#define CIN_SBUF _IO_stdin_ -#define COUT_SBUF _IO_stdout_ -#define CERR_SBUF _IO_stderr_ -static int use_stdiobuf = 0; -#else -#define CIN_SBUF _IO_stdin_buf -#define COUT_SBUF _IO_stdout_buf -#define CERR_SBUF _IO_stderr_buf -static int use_stdiobuf = 1; -#endif - -#define cin CIN -#define cout COUT -#define cerr CERR -#define clog CLOG -#include "iostream.h" -#undef cin -#undef cout -#undef cerr -#undef clog - -#ifdef __GNUG__ -#define PAD 0 /* g++ allows 0-length arrays. */ -#else -#define PAD 1 -#endif -struct _fake_istream { - struct myfields { -#ifdef __GNUC__ - _ios_fields *vb; /* pointer to virtual base class ios */ - _IO_ssize_t _gcount; -#else - /* This is supposedly correct for cfront. */ - _IO_ssize_t _gcount; - void *vptr; - _ios_fields *vb; /* pointer to virtual base class ios */ -#endif - } mine; - _ios_fields base; - char filler[sizeof(struct istream)-sizeof(struct _ios_fields)+PAD]; -}; -struct _fake_ostream { - struct myfields { -#ifndef __GNUC__ - void *vptr; -#endif - _ios_fields *vb; /* pointer to virtual base class ios */ - } mine; - _ios_fields base; - char filler[sizeof(struct ostream)-sizeof(struct _ios_fields)+PAD]; -}; - - -#ifdef _IO_NEW_STREAMS -#define STD_STR(SBUF, TIE, EXTRA_FLAGS) \ - (streambuf*)&SBUF, TIE, 0, ios::skipws|ios::dec|EXTRA_FLAGS, ' ',0,0,6 -#else -#define STD_STR(SBUF, TIE, EXTRA_FLAGS) \ - (streambuf*)&SBUF, TIE, 0, ios::dont_close|ios::dec|ios::skipws|EXTRA_FLAGS, ' ',0,0,6 -#endif - -#ifdef __GNUC__ -#define OSTREAM_DEF(NAME, SBUF, TIE, EXTRA_FLAGS, ASM) \ - _fake_ostream NAME ASM = { {&NAME.base}, {STD_STR(SBUF, TIE, EXTRA_FLAGS) }}; -#define ISTREAM_DEF(NAME, SBUF, TIE, EXTRA_FLAGS) \ - _fake_istream NAME = { {&NAME.base}, {STD_STR(SBUF, TIE, EXTRA_FLAGS) }}; -#else -#define OSTREAM_DEF(NAME, SBUF, TIE, EXTRA_FLAGS) \ - _fake_ostream NAME = { {0, &NAME.base}, {STD_STR(SBUF, TIE, EXTRA_FLAGS) }}; -#define ISTREAM_DEF(NAME, SBUF, TIE, EXTRA_FLAGS) \ - _fake_istream NAME = {{0, 0, &NAME.base}, {STD_STR(SBUF, TIE, EXTRA_FLAGS)}}; -#endif - -OSTREAM_DEF(cout, COUT_SBUF, NULL, 0, ) -OSTREAM_DEF(cerr, CERR_SBUF,(ostream*)&cout, ios::unitbuf, ) -ISTREAM_DEF(cin, CIN_SBUF, (ostream*)&cout, 0) - -/* Only for (partial) compatibility with AT&T's library. */ -#if _G_CLOG_CONFLICT -OSTREAM_DEF(clog, CERR_SBUF, (ostream*)&cout, 0, __asm__ ("__IO_clog")) -#else -OSTREAM_DEF(clog, CERR_SBUF, (ostream*)&cout, 0, ) -#endif - -// Switches between using _IO_std{in,out,err} and __std{in,out,err}_buf -// for standard streams. This does not normally need to be called -// explicitly, but is provided for AT&T compatibility. - -int ios::sync_with_stdio(int new_state) -{ -#ifdef _STDIO_USES_IOSTREAM - // It is always synced. - return 0; -#else - if (new_state == use_stdiobuf) // The usual case now. - return use_stdiobuf; - if (new_state) { - cin.base._strbuf = (streambuf*)&_IO_stdin_buf; - cout.base._strbuf = (streambuf*)&_IO_stdout_buf; - cerr.base._strbuf = (streambuf*)&_IO_stderr_buf; - clog.base._strbuf = (streambuf*)&_IO_stderr_buf; - } else { - cin.base._strbuf = (streambuf*)_IO_stdin; - cout.base._strbuf = (streambuf*)_IO_stdout; - cerr.base._strbuf = (streambuf*)_IO_stderr; - clog.base._strbuf = (streambuf*)_IO_stderr; - } - int old_state = use_stdiobuf; - use_stdiobuf = new_state; - return old_state; -#endif -} +#include <libio.h> diff --git a/libio/streambuf.h b/libio/streambuf.h index 8785d96c694..193c4993827 100644 --- a/libio/streambuf.h +++ b/libio/streambuf.h @@ -72,10 +72,10 @@ class ostream; class streambuf; #if defined(_G_IO_IO_FILE_VERSION) && _G_IO_IO_FILE_VERSION == 0x20001 typedef _IO_off64_t streamoff; -typedef _IO_fpos64_t streampos; +typedef _IO_off64_t streampos; #else typedef _IO_off_t streamoff; -typedef _IO_fpos_t streampos; +typedef _IO_off_t streampos; #endif typedef _IO_ssize_t streamsize; |