diff options
author | Benjamin Kosnik <bkoz@redhat.com> | 2004-02-05 05:24:18 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2004-02-05 05:24:18 +0000 |
commit | 6a734d618f8f49ea8560fae0a1808254e5a54419 (patch) | |
tree | 5134bbd68c2f1f5e6f3dd0e39597f684172ba154 /libstdc++-v3/config | |
parent | f583e45212b6c2960801fc74c34104bb9064fc95 (diff) | |
download | gcc-6a734d618f8f49ea8560fae0a1808254e5a54419.tar.gz |
basic_file_stdio.cc (__gnu_internal::fopen_mode): New function.
2004-02-04 Benjamin Kosnik <bkoz@redhat.com>
Zack Weinberg <zack@codesourcery.com>
* config/io/basic_file_stdio.cc (__gnu_internal::fopen_mode):
New function.
(__basic_file<char>::sys_open, __basic_file<char>::open): Use it.
(__basic_file<char>::_M_open_mode): Delete.
* config/io/basic_file_stdio.cc: Delete declaration of _M_open_mode.
* testsuite/27_io/basic_filebuf/close/char/9964.cc
* testsuite/27_io/basic_filebuf/open/char/9507.cc:
Correct flags to filebuf::open calls.
* config/abi/alpha-freebsd5/baseline_symbols.txt
* config/abi/alpha-linux-gnu/baseline_symbols.txt
* config/abi/hppa-linux-gnu/baseline_symbols.txt
* config/abi/i386-freebsd4/baseline_symbols.txt
* config/abi/i386-freebsd5/baseline_symbols.txt
* config/abi/i486-linux-gnu/baseline_symbols.txt
* config/abi/ia64-linux-gnu/baseline_symbols.txt
* config/abi/mips-linux-gnu/baseline_symbols.txt
* config/abi/sparc-freebsd5/baseline_symbols.txt
* config/abi/sparc-linux-gnu/baseline_symbols.txt
* config/abi/x86_64-linux-gnu/baseline_symbols.txt:
Remove entry for __basic_file<char>::_M_open_mode.
From-SVN: r77298
Diffstat (limited to 'libstdc++-v3/config')
13 files changed, 45 insertions, 79 deletions
diff --git a/libstdc++-v3/config/abi/alpha-freebsd5/baseline_symbols.txt b/libstdc++-v3/config/abi/alpha-freebsd5/baseline_symbols.txt index 6afb865077a..8c680d21e93 100644 --- a/libstdc++-v3/config/abi/alpha-freebsd5/baseline_symbols.txt +++ b/libstdc++-v3/config/abi/alpha-freebsd5/baseline_symbols.txt @@ -946,7 +946,6 @@ FUNC:_ZNSt11range_errorC2ERKSs@@GLIBCPP_3.2 FUNC:_ZNSt11range_errorD0Ev@@GLIBCPP_3.2 FUNC:_ZNSt11range_errorD1Ev@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE10sys_ungetcEi@@GLIBCPP_3.2 -FUNC:_ZNSt12__basic_fileIcE12_M_open_modeESt13_Ios_OpenmodeRiS2_Pc@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE16showmanyc_helperEv@@GLIBCPP_3.2.3 FUNC:_ZNSt12__basic_fileIcE2fdEv@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE4openEPKcSt13_Ios_Openmodei@@GLIBCPP_3.2 diff --git a/libstdc++-v3/config/abi/alpha-linux-gnu/baseline_symbols.txt b/libstdc++-v3/config/abi/alpha-linux-gnu/baseline_symbols.txt index b2df36d3bf7..b4371cc9501 100644 --- a/libstdc++-v3/config/abi/alpha-linux-gnu/baseline_symbols.txt +++ b/libstdc++-v3/config/abi/alpha-linux-gnu/baseline_symbols.txt @@ -982,7 +982,6 @@ FUNC:_ZNSt11__timepunctIwED0Ev@@GLIBCPP_3.2 FUNC:_ZNSt11__timepunctIwED1Ev@@GLIBCPP_3.2 FUNC:_ZNSt11__timepunctIwED2Ev@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE10sys_ungetcEi@@GLIBCPP_3.2 -FUNC:_ZNSt12__basic_fileIcE12_M_open_modeESt13_Ios_OpenmodeRiS2_Pc@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE2fdEv@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE4openEPKcSt13_Ios_Openmodei@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE4syncEv@@GLIBCPP_3.2 diff --git a/libstdc++-v3/config/abi/hppa-linux-gnu/baseline_symbols.txt b/libstdc++-v3/config/abi/hppa-linux-gnu/baseline_symbols.txt index 6990e640ad4..365807286be 100644 --- a/libstdc++-v3/config/abi/hppa-linux-gnu/baseline_symbols.txt +++ b/libstdc++-v3/config/abi/hppa-linux-gnu/baseline_symbols.txt @@ -946,7 +946,6 @@ FUNC:_ZNSt11range_errorC2ERKSs@@GLIBCPP_3.2 FUNC:_ZNSt11range_errorD0Ev@@GLIBCPP_3.2 FUNC:_ZNSt11range_errorD1Ev@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE10sys_ungetcEi@@GLIBCPP_3.2 -FUNC:_ZNSt12__basic_fileIcE12_M_open_modeESt13_Ios_OpenmodeRiS2_Pc@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE16showmanyc_helperEv@@GLIBCPP_3.2.3 FUNC:_ZNSt12__basic_fileIcE2fdEv@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE4openEPKcSt13_Ios_Openmodei@@GLIBCPP_3.2 diff --git a/libstdc++-v3/config/abi/i386-freebsd4/baseline_symbols.txt b/libstdc++-v3/config/abi/i386-freebsd4/baseline_symbols.txt index 5372a28e3bd..8e1f762908e 100644 --- a/libstdc++-v3/config/abi/i386-freebsd4/baseline_symbols.txt +++ b/libstdc++-v3/config/abi/i386-freebsd4/baseline_symbols.txt @@ -553,7 +553,6 @@ FUNC:_ZNSt11range_errorC2ERKSs@@GLIBCPP_3.2 FUNC:_ZNSt11range_errorD0Ev@@GLIBCPP_3.2 FUNC:_ZNSt11range_errorD1Ev@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE10sys_ungetcEi@@GLIBCPP_3.2 -FUNC:_ZNSt12__basic_fileIcE12_M_open_modeESt13_Ios_OpenmodeRiS2_Pc@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE16showmanyc_helperEv@@GLIBCPP_3.2.3 FUNC:_ZNSt12__basic_fileIcE2fdEv@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE4openEPKcSt13_Ios_Openmodei@@GLIBCPP_3.2 diff --git a/libstdc++-v3/config/abi/i386-freebsd5/baseline_symbols.txt b/libstdc++-v3/config/abi/i386-freebsd5/baseline_symbols.txt index c66b031d4b3..f58249fc847 100644 --- a/libstdc++-v3/config/abi/i386-freebsd5/baseline_symbols.txt +++ b/libstdc++-v3/config/abi/i386-freebsd5/baseline_symbols.txt @@ -946,7 +946,6 @@ FUNC:_ZNSt11range_errorC2ERKSs@@GLIBCPP_3.2 FUNC:_ZNSt11range_errorD0Ev@@GLIBCPP_3.2 FUNC:_ZNSt11range_errorD1Ev@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE10sys_ungetcEi@@GLIBCPP_3.2 -FUNC:_ZNSt12__basic_fileIcE12_M_open_modeESt13_Ios_OpenmodeRiS2_Pc@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE16showmanyc_helperEv@@GLIBCPP_3.2.3 FUNC:_ZNSt12__basic_fileIcE2fdEv@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE4openEPKcSt13_Ios_Openmodei@@GLIBCPP_3.2 diff --git a/libstdc++-v3/config/abi/i486-linux-gnu/baseline_symbols.txt b/libstdc++-v3/config/abi/i486-linux-gnu/baseline_symbols.txt index 018ef0ea4a2..ae9a71e3bdc 100644 --- a/libstdc++-v3/config/abi/i486-linux-gnu/baseline_symbols.txt +++ b/libstdc++-v3/config/abi/i486-linux-gnu/baseline_symbols.txt @@ -999,7 +999,6 @@ FUNC:_ZNSt11__timepunctIwED0Ev@@GLIBCPP_3.2 FUNC:_ZNSt11__timepunctIwED1Ev@@GLIBCPP_3.2 FUNC:_ZNSt11__timepunctIwED2Ev@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE10sys_ungetcEi@@GLIBCPP_3.2 -FUNC:_ZNSt12__basic_fileIcE12_M_open_modeESt13_Ios_OpenmodeRiS2_Pc@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE16showmanyc_helperEv@@GLIBCPP_3.2.3 FUNC:_ZNSt12__basic_fileIcE2fdEv@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE4openEPKcSt13_Ios_Openmodei@@GLIBCPP_3.2 diff --git a/libstdc++-v3/config/abi/ia64-linux-gnu/baseline_symbols.txt b/libstdc++-v3/config/abi/ia64-linux-gnu/baseline_symbols.txt index eb729d3a2a0..423b0e7eb82 100644 --- a/libstdc++-v3/config/abi/ia64-linux-gnu/baseline_symbols.txt +++ b/libstdc++-v3/config/abi/ia64-linux-gnu/baseline_symbols.txt @@ -982,7 +982,6 @@ FUNC:_ZNSt11__timepunctIwED0Ev@@GLIBCPP_3.2 FUNC:_ZNSt11__timepunctIwED1Ev@@GLIBCPP_3.2 FUNC:_ZNSt11__timepunctIwED2Ev@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE10sys_ungetcEi@@GLIBCPP_3.2 -FUNC:_ZNSt12__basic_fileIcE12_M_open_modeESt13_Ios_OpenmodeRiS2_Pc@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE2fdEv@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE4openEPKcSt13_Ios_Openmodei@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE4syncEv@@GLIBCPP_3.2 diff --git a/libstdc++-v3/config/abi/mips-linux-gnu/baseline_symbols.txt b/libstdc++-v3/config/abi/mips-linux-gnu/baseline_symbols.txt index 4d049b0701f..a8d1bdf8409 100644 --- a/libstdc++-v3/config/abi/mips-linux-gnu/baseline_symbols.txt +++ b/libstdc++-v3/config/abi/mips-linux-gnu/baseline_symbols.txt @@ -946,7 +946,6 @@ FUNC:_ZNSt11range_errorC2ERKSs@@GLIBCPP_3.2 FUNC:_ZNSt11range_errorD0Ev@@GLIBCPP_3.2 FUNC:_ZNSt11range_errorD1Ev@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE10sys_ungetcEi@@GLIBCPP_3.2 -FUNC:_ZNSt12__basic_fileIcE12_M_open_modeESt13_Ios_OpenmodeRiS2_Pc@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE16showmanyc_helperEv@@GLIBCPP_3.2.3 FUNC:_ZNSt12__basic_fileIcE2fdEv@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE4openEPKcSt13_Ios_Openmodei@@GLIBCPP_3.2 diff --git a/libstdc++-v3/config/abi/sparc-freebsd5/baseline_symbols.txt b/libstdc++-v3/config/abi/sparc-freebsd5/baseline_symbols.txt index b63c4a360a6..dbf935b9b3e 100644 --- a/libstdc++-v3/config/abi/sparc-freebsd5/baseline_symbols.txt +++ b/libstdc++-v3/config/abi/sparc-freebsd5/baseline_symbols.txt @@ -946,7 +946,6 @@ FUNC:_ZNSt11range_errorC2ERKSs@@GLIBCPP_3.2 FUNC:_ZNSt11range_errorD0Ev@@GLIBCPP_3.2 FUNC:_ZNSt11range_errorD1Ev@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE10sys_ungetcEi@@GLIBCPP_3.2 -FUNC:_ZNSt12__basic_fileIcE12_M_open_modeESt13_Ios_OpenmodeRiS2_Pc@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE16showmanyc_helperEv@@GLIBCPP_3.2.3 FUNC:_ZNSt12__basic_fileIcE2fdEv@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE4openEPKcSt13_Ios_Openmodei@@GLIBCPP_3.2 diff --git a/libstdc++-v3/config/abi/sparc-linux-gnu/baseline_symbols.txt b/libstdc++-v3/config/abi/sparc-linux-gnu/baseline_symbols.txt index 3969f4e6910..451dc1fad89 100644 --- a/libstdc++-v3/config/abi/sparc-linux-gnu/baseline_symbols.txt +++ b/libstdc++-v3/config/abi/sparc-linux-gnu/baseline_symbols.txt @@ -1005,7 +1005,6 @@ FUNC:_ZNSt11range_errorC2ERKSs@@GLIBCPP_3.2 FUNC:_ZNSt11range_errorD0Ev@@GLIBCPP_3.2 FUNC:_ZNSt11range_errorD1Ev@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE10sys_ungetcEi@@GLIBCPP_3.2 -FUNC:_ZNSt12__basic_fileIcE12_M_open_modeESt13_Ios_OpenmodeRiS2_Pc@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE16showmanyc_helperEv@@GLIBCPP_3.2.3 FUNC:_ZNSt12__basic_fileIcE2fdEv@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE4openEPKcSt13_Ios_Openmodei@@GLIBCPP_3.2 diff --git a/libstdc++-v3/config/abi/x86_64-linux-gnu/baseline_symbols.txt b/libstdc++-v3/config/abi/x86_64-linux-gnu/baseline_symbols.txt index 299af6148a8..2ad6eabca94 100644 --- a/libstdc++-v3/config/abi/x86_64-linux-gnu/baseline_symbols.txt +++ b/libstdc++-v3/config/abi/x86_64-linux-gnu/baseline_symbols.txt @@ -946,7 +946,6 @@ FUNC:_ZNSt11range_errorC2ERKSs@@GLIBCPP_3.2 FUNC:_ZNSt11range_errorD0Ev@@GLIBCPP_3.2 FUNC:_ZNSt11range_errorD1Ev@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE10sys_ungetcEi@@GLIBCPP_3.2 -FUNC:_ZNSt12__basic_fileIcE12_M_open_modeESt13_Ios_OpenmodeRiS2_Pc@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE16showmanyc_helperEv@@GLIBCPP_3.2.3 FUNC:_ZNSt12__basic_fileIcE2fdEv@@GLIBCPP_3.2 FUNC:_ZNSt12__basic_fileIcE4openEPKcSt13_Ios_Openmodei@@GLIBCPP_3.2 diff --git a/libstdc++-v3/config/io/basic_file_stdio.cc b/libstdc++-v3/config/io/basic_file_stdio.cc index 7d014e448b4..b1d55d0e02e 100644 --- a/libstdc++-v3/config/io/basic_file_stdio.cc +++ b/libstdc++-v3/config/io/basic_file_stdio.cc @@ -1,6 +1,6 @@ // Wrapper of C-language FILE struct -*- C++ -*- -// Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -70,6 +70,43 @@ #include <limits> // For <off_t>::max() and min() +namespace __gnu_internal +{ + // Map ios_base::openmode flags to a string for use in fopen(). + // Table of valid combinations as given in [lib.filebuf.members]/2. + static const char* + fopen_mode(std::ios_base::openmode mode) + { + enum + { + in = std::ios_base::in, + out = std::ios_base::out, + trunc = std::ios_base::trunc, + app = std::ios_base::app, + binary = std::ios_base::binary + }; + + switch (mode & (in|out|trunc|app|binary)) + { + case ( out ): return "w"; + case ( out |app ): return "a"; + case ( out|trunc ): return "w"; + case (in ): return "r"; + case (in|out ): return "r+"; + case (in|out|trunc ): return "w+"; + + case ( out |binary): return "wb"; + case ( out |app|binary): return "ab"; + case ( out|trunc |binary): return "wb"; + case (in |binary): return "rb"; + case (in|out |binary): return "r+b"; + case (in|out|trunc |binary): return "w+b"; + + default: return 0; // invalid + } + } +} // namespace __gnu_internal + namespace std { // Definitions for __basic_file<char>. @@ -79,53 +116,6 @@ namespace std __basic_file<char>::~__basic_file() { this->close(); } - void - __basic_file<char>::_M_open_mode(ios_base::openmode __mode, int& __p_mode, - int&, char* __c_mode) - { - bool __testb = __mode & ios_base::binary; - bool __testi = __mode & ios_base::in; - bool __testo = __mode & ios_base::out; - bool __testt = __mode & ios_base::trunc; - bool __testa = __mode & ios_base::app; - - // Set __c_mode for use in fopen. - // Set __p_mode for use in open. - if (!__testi && __testo && !__testt && !__testa) - { - strcpy(__c_mode, "w"); - __p_mode = O_WRONLY | O_CREAT; - } - if (!__testi && __testo && !__testt && __testa) - { - strcpy(__c_mode, "a"); - __p_mode = O_WRONLY | O_CREAT | O_APPEND; - } - if (!__testi && __testo && __testt && !__testa) - { - strcpy(__c_mode, "w"); - __p_mode = O_WRONLY | O_CREAT | O_TRUNC; - } - - if (__testi && !__testo && !__testt && !__testa) - { - strcpy(__c_mode, "r"); - __p_mode = O_RDONLY; - } - if (__testi && __testo && !__testt && !__testa) - { - strcpy(__c_mode, "r+"); - __p_mode = O_RDWR | O_CREAT; - } - if (__testi && __testo && __testt && !__testa) - { - strcpy(__c_mode, "w+"); - __p_mode = O_RDWR | O_CREAT | O_TRUNC; - } - if (__testb) - strcat(__c_mode, "b"); - } - __basic_file<char>* __basic_file<char>::sys_open(__c_file* __file, ios_base::openmode) { @@ -144,12 +134,9 @@ namespace std __basic_file<char>::sys_open(int __fd, ios_base::openmode __mode) { __basic_file* __ret = NULL; - int __p_mode = 0; - int __rw_mode = 0; - char __c_mode[4]; - - _M_open_mode(__mode, __p_mode, __rw_mode, __c_mode); - if (!this->is_open() && (_M_cfile = fdopen(__fd, __c_mode))) + const char* __c_mode = __gnu_internal::fopen_mode(__mode); + if (__c_mode && !this->is_open() + && (_M_cfile = fdopen(__fd, __c_mode))) { _M_cfile_created = true; if (__fd == 0) @@ -164,13 +151,8 @@ namespace std int /*__prot*/) { __basic_file* __ret = NULL; - int __p_mode = 0; - int __rw_mode = 0; - char __c_mode[4]; - - _M_open_mode(__mode, __p_mode, __rw_mode, __c_mode); - - if (!this->is_open()) + const char* __c_mode = __gnu_internal::fopen_mode(__mode); + if (__c_mode && !this->is_open()) { #ifdef _GLIBCXX_USE_LFS if ((_M_cfile = fopen64(__name, __c_mode))) @@ -309,5 +291,4 @@ namespace std #endif return 0; } - } // namespace std diff --git a/libstdc++-v3/config/io/basic_file_stdio.h b/libstdc++-v3/config/io/basic_file_stdio.h index d6a06ead739..57ff4326e6b 100644 --- a/libstdc++-v3/config/io/basic_file_stdio.h +++ b/libstdc++-v3/config/io/basic_file_stdio.h @@ -1,6 +1,6 @@ // Wrapper of C-language FILE struct -*- C++ -*- -// Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc. +// Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -62,11 +62,7 @@ namespace std public: __basic_file(__c_lock* __lock = 0); - - void - _M_open_mode(ios_base::openmode __mode, int& __p_mode, int& __rw_mode, - char* __c_mode); - + __basic_file* open(const char* __name, ios_base::openmode __mode, int __prot = 0664); |