gccxml_gem 0.9.3-x86-darwin-11
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +84 -0
- data/bin/gccxml +0 -0
- data/bin/gccxml_cc1plus +0 -0
- data/gccxml.rb +57 -0
- data/share/doc/gccxml-0.9/Copyright.txt +55 -0
- data/share/doc/gccxml-0.9/gccxml.html +168 -0
- data/share/doc/gccxml-0.9/gccxml.txt +293 -0
- data/share/gccxml-0.9/GCC/2.95/algorithm +76 -0
- data/share/gccxml-0.9/GCC/2.95/bitset +17 -0
- data/share/gccxml-0.9/GCC/2.95/cctype +24 -0
- data/share/gccxml-0.9/GCC/2.95/clocale +14 -0
- data/share/gccxml-0.9/GCC/2.95/cmath +33 -0
- data/share/gccxml-0.9/GCC/2.95/complex +38 -0
- data/share/gccxml-0.9/GCC/2.95/csetjmp +13 -0
- data/share/gccxml-0.9/GCC/2.95/csignal +14 -0
- data/share/gccxml-0.9/GCC/2.95/cstdarg +12 -0
- data/share/gccxml-0.9/GCC/2.95/cstddef +13 -0
- data/share/gccxml-0.9/GCC/2.95/cstdio +55 -0
- data/share/gccxml-0.9/GCC/2.95/cstdlib +66 -0
- data/share/gccxml-0.9/GCC/2.95/cstring +34 -0
- data/share/gccxml-0.9/GCC/2.95/ctime +24 -0
- data/share/gccxml-0.9/GCC/2.95/cwchar +65 -0
- data/share/gccxml-0.9/GCC/2.95/cwctype +31 -0
- data/share/gccxml-0.9/GCC/2.95/deque +19 -0
- data/share/gccxml-0.9/GCC/2.95/exception +20 -0
- data/share/gccxml-0.9/GCC/2.95/fstream +23 -0
- data/share/gccxml-0.9/GCC/2.95/functional +64 -0
- data/share/gccxml-0.9/GCC/2.95/gccxml_bitset +1066 -0
- data/share/gccxml-0.9/GCC/2.95/iomanip +20 -0
- data/share/gccxml-0.9/GCC/2.95/iosfwd +20 -0
- data/share/gccxml-0.9/GCC/2.95/iostream +27 -0
- data/share/gccxml-0.9/GCC/2.95/iterator +39 -0
- data/share/gccxml-0.9/GCC/2.95/list +19 -0
- data/share/gccxml-0.9/GCC/2.95/map +20 -0
- data/share/gccxml-0.9/GCC/2.95/memory +21 -0
- data/share/gccxml-0.9/GCC/2.95/new +13 -0
- data/share/gccxml-0.9/GCC/2.95/numeric +15 -0
- data/share/gccxml-0.9/GCC/2.95/pthread.h +16 -0
- data/share/gccxml-0.9/GCC/2.95/queue +20 -0
- data/share/gccxml-0.9/GCC/2.95/set +20 -0
- data/share/gccxml-0.9/GCC/2.95/sstream +24 -0
- data/share/gccxml-0.9/GCC/2.95/stack +19 -0
- data/share/gccxml-0.9/GCC/2.95/std/bastring.cc +524 -0
- data/share/gccxml-0.9/GCC/2.95/std/complext.h +397 -0
- data/share/gccxml-0.9/GCC/2.95/std/dcomplex.h +92 -0
- data/share/gccxml-0.9/GCC/2.95/std/fcomplex.h +88 -0
- data/share/gccxml-0.9/GCC/2.95/std/gslice_array.h +170 -0
- data/share/gccxml-0.9/GCC/2.95/std/indirect_array.h +157 -0
- data/share/gccxml-0.9/GCC/2.95/std/ldcomplex.h +96 -0
- data/share/gccxml-0.9/GCC/2.95/std/mask_array.h +154 -0
- data/share/gccxml-0.9/GCC/2.95/std/slice_array.h +156 -0
- data/share/gccxml-0.9/GCC/2.95/std/std_valarray.h +728 -0
- data/share/gccxml-0.9/GCC/2.95/std/straits.h +162 -0
- data/share/gccxml-0.9/GCC/2.95/std/valarray_meta.h +1035 -0
- data/share/gccxml-0.9/GCC/2.95/stdexcept +17 -0
- data/share/gccxml-0.9/GCC/2.95/stl_alloc.h +1057 -0
- data/share/gccxml-0.9/GCC/2.95/stl_bvector.h +836 -0
- data/share/gccxml-0.9/GCC/2.95/stl_deque.h +1699 -0
- data/share/gccxml-0.9/GCC/2.95/stl_list.h +843 -0
- data/share/gccxml-0.9/GCC/2.95/stl_tree.h +1331 -0
- data/share/gccxml-0.9/GCC/2.95/stl_vector.h +828 -0
- data/share/gccxml-0.9/GCC/2.95/string +26 -0
- data/share/gccxml-0.9/GCC/2.95/strstream +23 -0
- data/share/gccxml-0.9/GCC/2.95/typeinfo +11 -0
- data/share/gccxml-0.9/GCC/2.95/utility +25 -0
- data/share/gccxml-0.9/GCC/2.95/valarray +52 -0
- data/share/gccxml-0.9/GCC/2.95/vector +19 -0
- data/share/gccxml-0.9/GCC/2.96/sstream +305 -0
- data/share/gccxml-0.9/GCC/3.0/pthread.h +16 -0
- data/share/gccxml-0.9/GCC/3.1/pthread.h +16 -0
- data/share/gccxml-0.9/GCC/3.2/bits/fstream.tcc +500 -0
- data/share/gccxml-0.9/GCC/3.2/bits/gthr-default.h +585 -0
- data/share/gccxml-0.9/GCC/3.2/bits/istream.tcc +1207 -0
- data/share/gccxml-0.9/GCC/3.2/bits/locale_facets.h +1810 -0
- data/share/gccxml-0.9/GCC/3.2/bits/locale_facets.tcc +2397 -0
- data/share/gccxml-0.9/GCC/3.2/bits/messages_members.h +108 -0
- data/share/gccxml-0.9/GCC/3.2/bits/ostream.tcc +713 -0
- data/share/gccxml-0.9/GCC/3.2/bits/sstream.tcc +241 -0
- data/share/gccxml-0.9/GCC/3.2/bits/stl_deque.h +1682 -0
- data/share/gccxml-0.9/GCC/3.2/bits/stl_list.h +989 -0
- data/share/gccxml-0.9/GCC/3.2/bits/stl_tree.h +1462 -0
- data/share/gccxml-0.9/GCC/3.2/bits/stl_vector.h +1085 -0
- data/share/gccxml-0.9/GCC/3.2/bits/valarray_meta.h +1063 -0
- data/share/gccxml-0.9/GCC/3.2/fstream +579 -0
- data/share/gccxml-0.9/GCC/3.2/pthread.h +16 -0
- data/share/gccxml-0.9/GCC/3.2/sstream +384 -0
- data/share/gccxml-0.9/GCC/3.3/bits/fstream.tcc +530 -0
- data/share/gccxml-0.9/GCC/3.3/bits/list.tcc +378 -0
- data/share/gccxml-0.9/GCC/3.3/bits/locale_facets.h +2050 -0
- data/share/gccxml-0.9/GCC/3.3/bits/messages_members.h +108 -0
- data/share/gccxml-0.9/GCC/3.3/bits/sstream.tcc +243 -0
- data/share/gccxml-0.9/GCC/3.3/bits/stl_deque.h +1603 -0
- data/share/gccxml-0.9/GCC/3.3/bits/stl_list.h +1167 -0
- data/share/gccxml-0.9/GCC/3.3/bits/stl_tree.h +1462 -0
- data/share/gccxml-0.9/GCC/3.3/bits/stl_vector.h +992 -0
- data/share/gccxml-0.9/GCC/3.3/bits/valarray_meta.h +1135 -0
- data/share/gccxml-0.9/GCC/3.3/fstream +842 -0
- data/share/gccxml-0.9/GCC/3.3/gccxml_builtins.h +22 -0
- data/share/gccxml-0.9/GCC/3.3/sstream +638 -0
- data/share/gccxml-0.9/GCC/3.4/bits/gthr-default.h +669 -0
- data/share/gccxml-0.9/GCC/3.4/gccxml_builtins.h +91 -0
- data/share/gccxml-0.9/GCC/4.0/emmintrin.h +5 -0
- data/share/gccxml-0.9/GCC/4.0/gccxml_apple_emmintrin.h +1037 -0
- data/share/gccxml-0.9/GCC/4.0/gccxml_apple_mmintrin.h +669 -0
- data/share/gccxml-0.9/GCC/4.0/gccxml_apple_xmmintrin.h +870 -0
- data/share/gccxml-0.9/GCC/4.0/gccxml_builtins.h +128 -0
- data/share/gccxml-0.9/GCC/4.0/gccxml_gnu_emmintrin.h +977 -0
- data/share/gccxml-0.9/GCC/4.0/gccxml_gnu_mmintrin.h +636 -0
- data/share/gccxml-0.9/GCC/4.0/gccxml_gnu_xmmintrin.h +833 -0
- data/share/gccxml-0.9/GCC/4.0/mmintrin.h +5 -0
- data/share/gccxml-0.9/GCC/4.0/xmmintrin.h +5 -0
- data/share/gccxml-0.9/GCC/4.1/bits/gthr-default.h +622 -0
- data/share/gccxml-0.9/GCC/4.1/emmintrin.h +5 -0
- data/share/gccxml-0.9/GCC/4.1/gccxml_apple_emmintrin.h +1509 -0
- data/share/gccxml-0.9/GCC/4.1/gccxml_apple_mmintrin.h +942 -0
- data/share/gccxml-0.9/GCC/4.1/gccxml_apple_xmmintrin.h +1192 -0
- data/share/gccxml-0.9/GCC/4.1/gccxml_builtins.h +131 -0
- data/share/gccxml-0.9/GCC/4.1/gccxml_gnu_emmintrin.h +1004 -0
- data/share/gccxml-0.9/GCC/4.1/gccxml_gnu_mmintrin.h +637 -0
- data/share/gccxml-0.9/GCC/4.1/gccxml_gnu_xmmintrin.h +834 -0
- data/share/gccxml-0.9/GCC/4.1/mmintrin.h +5 -0
- data/share/gccxml-0.9/GCC/4.1/xmmintrin.h +5 -0
- data/share/gccxml-0.9/GCC/4.2/emmintrin.h +5 -0
- data/share/gccxml-0.9/GCC/4.2/gccxml_apple_emmintrin.h +1509 -0
- data/share/gccxml-0.9/GCC/4.2/gccxml_apple_mmintrin.h +942 -0
- data/share/gccxml-0.9/GCC/4.2/gccxml_apple_xmmintrin.h +1192 -0
- data/share/gccxml-0.9/GCC/4.2/gccxml_builtins.h +131 -0
- data/share/gccxml-0.9/GCC/4.2/gccxml_gnu_emmintrin.h +1013 -0
- data/share/gccxml-0.9/GCC/4.2/gccxml_gnu_mmintrin.h +663 -0
- data/share/gccxml-0.9/GCC/4.2/gccxml_gnu_xmmintrin.h +860 -0
- data/share/gccxml-0.9/GCC/4.2/mmintrin.h +5 -0
- data/share/gccxml-0.9/GCC/4.2/xmmintrin.h +5 -0
- data/share/gccxml-0.9/GCC/4.3/emmintrin.h +1043 -0
- data/share/gccxml-0.9/GCC/4.3/gccxml_builtins.h +183 -0
- data/share/gccxml-0.9/GCC/4.3/mmintrin.h +663 -0
- data/share/gccxml-0.9/GCC/4.3/xmmintrin.h +867 -0
- data/share/gccxml-0.9/GCC/4.4/bits/c++config.h +1431 -0
- data/share/gccxml-0.9/GCC/4.4/emmintrin.h +1041 -0
- data/share/gccxml-0.9/GCC/4.4/gccxml_builtins.h +153 -0
- data/share/gccxml-0.9/GCC/4.4/mmintrin.h +662 -0
- data/share/gccxml-0.9/GCC/4.4/xmmintrin.h +864 -0
- data/share/gccxml-0.9/GCC/4.5/gccxml_builtins.h +154 -0
- data/share/gccxml-0.9/GCC/4.5/iomanip +349 -0
- data/share/gccxml-0.9/GCC/COPYING.RUNTIME +73 -0
- data/share/gccxml-0.9/GCC/COPYING3 +674 -0
- data/share/gccxml-0.9/IBM/8.0/adapt_headers.sh +34 -0
- data/share/gccxml-0.9/IBM/8.0/stdlib.h.patch +27 -0
- data/share/gccxml-0.9/IBM/8.0/xstring.patch +19 -0
- data/share/gccxml-0.9/IBM/README +8 -0
- data/share/gccxml-0.9/IBM/find_flags +51 -0
- data/share/gccxml-0.9/IBM/find_flags_common +48 -0
- data/share/gccxml-0.9/Intel/find_flags +56 -0
- data/share/gccxml-0.9/Intel/pthread.h +16 -0
- data/share/gccxml-0.9/MIPSpro/7.3/exception +9 -0
- data/share/gccxml-0.9/MIPSpro/7.3/gccxml_mpro_internals.h +21 -0
- data/share/gccxml-0.9/MIPSpro/7.3/iomanip +161 -0
- data/share/gccxml-0.9/MIPSpro/7.3/ostream +9 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stddef.h +9 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stl_config.h +9 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stl_locale.h +17 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stl_monetary.h +14 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stl_numeric_facets.h +13 -0
- data/share/gccxml-0.9/MIPSpro/7.3/stl_threads.h +11 -0
- data/share/gccxml-0.9/MIPSpro/7.3/string +18 -0
- data/share/gccxml-0.9/MIPSpro/find_flags +70 -0
- data/share/gccxml-0.9/MIPSpro/mipspro_defs.cxx +63 -0
- data/share/gccxml-0.9/Sun/5.8/Cstd.patch +156 -0
- data/share/gccxml-0.9/Sun/5.8/adapt_headers.sh +32 -0
- data/share/gccxml-0.9/Sun/5.8/std-5.10.patch +22 -0
- data/share/gccxml-0.9/Sun/README +8 -0
- data/share/gccxml-0.9/Sun/find_flags +51 -0
- data/share/gccxml-0.9/Sun/find_flags_common +42 -0
- data/share/gccxml-0.9/gccxml_config +2 -0
- data/share/gccxml-0.9/gccxml_identify_compiler.cc +13 -0
- data/share/man/man1/gccxml.1 +246 -0
- metadata +243 -0
@@ -0,0 +1,500 @@
|
|
1
|
+
// File based streams -*- C++ -*-
|
2
|
+
|
3
|
+
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
|
4
|
+
// Free Software Foundation, Inc.
|
5
|
+
//
|
6
|
+
// This file is part of the GNU ISO C++ Library. This library is free
|
7
|
+
// software; you can redistribute it and/or modify it under the
|
8
|
+
// terms of the GNU General Public License as published by the
|
9
|
+
// Free Software Foundation; either version 2, or (at your option)
|
10
|
+
// any later version.
|
11
|
+
|
12
|
+
// This library is distributed in the hope that it will be useful,
|
13
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
// GNU General Public License for more details.
|
16
|
+
|
17
|
+
// You should have received a copy of the GNU General Public License along
|
18
|
+
// with this library; see the file COPYING. If not, write to the Free
|
19
|
+
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
20
|
+
// USA.
|
21
|
+
|
22
|
+
// As a special exception, you may use this file as part of a free software
|
23
|
+
// library without restriction. Specifically, if other files instantiate
|
24
|
+
// templates or use macros or inline functions from this file, or you compile
|
25
|
+
// this file and link it with other files to produce an executable, this
|
26
|
+
// file does not by itself cause the resulting executable to be covered by
|
27
|
+
// the GNU General Public License. This exception does not however
|
28
|
+
// invalidate any other reasons why the executable file might be covered by
|
29
|
+
// the GNU General Public License.
|
30
|
+
|
31
|
+
//
|
32
|
+
// ISO C++ 14882: 27.8 File-based streams
|
33
|
+
//
|
34
|
+
|
35
|
+
#ifndef _CPP_BITS_FSTREAM_TCC
|
36
|
+
#define _CPP_BITS_FSTREAM_TCC 1
|
37
|
+
|
38
|
+
#pragma GCC system_header
|
39
|
+
|
40
|
+
namespace std
|
41
|
+
{
|
42
|
+
template<typename _CharT, typename _Traits>
|
43
|
+
void
|
44
|
+
basic_filebuf<_CharT, _Traits>::
|
45
|
+
_M_allocate_internal_buffer()
|
46
|
+
{
|
47
|
+
if (!this->_M_buf && this->_M_buf_size_opt)
|
48
|
+
{
|
49
|
+
this->_M_buf_size = this->_M_buf_size_opt;
|
50
|
+
|
51
|
+
// Allocate internal buffer.
|
52
|
+
this->_M_buf = new char_type[this->_M_buf_size];
|
53
|
+
this->_M_buf_allocated = true;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
// Both close and setbuf need to deallocate internal buffers, if it exists.
|
58
|
+
template<typename _CharT, typename _Traits>
|
59
|
+
void
|
60
|
+
basic_filebuf<_CharT, _Traits>::
|
61
|
+
_M_destroy_internal_buffer()
|
62
|
+
{
|
63
|
+
if (this->_M_buf_allocated)
|
64
|
+
{
|
65
|
+
delete [] this->_M_buf;
|
66
|
+
this->_M_buf = NULL;
|
67
|
+
this->_M_buf_allocated = false;
|
68
|
+
this->setg(NULL, NULL, NULL);
|
69
|
+
this->setp(NULL, NULL);
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
template<typename _CharT, typename _Traits>
|
74
|
+
basic_filebuf<_CharT, _Traits>::
|
75
|
+
basic_filebuf() : __streambuf_type(), _M_file(&_M_lock),
|
76
|
+
_M_state_cur(__state_type()), _M_state_beg(__state_type()),
|
77
|
+
_M_buf_allocated(false), _M_last_overflowed(false)
|
78
|
+
{ this->_M_buf_unified = true; }
|
79
|
+
|
80
|
+
template<typename _CharT, typename _Traits>
|
81
|
+
typename basic_filebuf<_CharT, _Traits>::__filebuf_type*
|
82
|
+
basic_filebuf<_CharT, _Traits>::
|
83
|
+
open(const char* __s, ios_base::openmode __mode)
|
84
|
+
{
|
85
|
+
__filebuf_type *__ret = NULL;
|
86
|
+
if (!this->is_open())
|
87
|
+
{
|
88
|
+
_M_file.open(__s, __mode);
|
89
|
+
if (this->is_open())
|
90
|
+
{
|
91
|
+
_M_allocate_internal_buffer();
|
92
|
+
this->_M_mode = __mode;
|
93
|
+
_M_set_indeterminate();
|
94
|
+
|
95
|
+
if ((__mode & ios_base::ate)
|
96
|
+
&& this->seekoff(0, ios_base::end, __mode) < 0)
|
97
|
+
{
|
98
|
+
// 27.8.1.3,4
|
99
|
+
this->close();
|
100
|
+
return __ret;
|
101
|
+
}
|
102
|
+
|
103
|
+
__ret = this;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
return __ret;
|
107
|
+
}
|
108
|
+
|
109
|
+
template<typename _CharT, typename _Traits>
|
110
|
+
typename basic_filebuf<_CharT, _Traits>::__filebuf_type*
|
111
|
+
basic_filebuf<_CharT, _Traits>::
|
112
|
+
close()
|
113
|
+
{
|
114
|
+
__filebuf_type *__ret = NULL;
|
115
|
+
if (this->is_open())
|
116
|
+
{
|
117
|
+
const int_type __eof = traits_type::eof();
|
118
|
+
bool __testput = this->_M_out_cur && this->_M_out_beg < this->_M_out_end;
|
119
|
+
if (__testput
|
120
|
+
&& traits_type::eq_int_type(_M_really_overflow(__eof), __eof))
|
121
|
+
return __ret;
|
122
|
+
|
123
|
+
// NB: Do this here so that re-opened filebufs will be cool...
|
124
|
+
this->_M_mode = ios_base::openmode(0);
|
125
|
+
this->_M_destroy_internal_buffer();
|
126
|
+
this->_M_pback_destroy();
|
127
|
+
|
128
|
+
#if 0
|
129
|
+
// XXX not done
|
130
|
+
if (_M_last_overflowed)
|
131
|
+
{
|
132
|
+
_M_output_unshift();
|
133
|
+
_M_really_overflow(__eof);
|
134
|
+
}
|
135
|
+
#endif
|
136
|
+
|
137
|
+
if (_M_file.close())
|
138
|
+
__ret = this;
|
139
|
+
}
|
140
|
+
|
141
|
+
_M_last_overflowed = false;
|
142
|
+
return __ret;
|
143
|
+
}
|
144
|
+
|
145
|
+
template<typename _CharT, typename _Traits>
|
146
|
+
streamsize
|
147
|
+
basic_filebuf<_CharT, _Traits>::
|
148
|
+
showmanyc()
|
149
|
+
{
|
150
|
+
streamsize __ret = -1;
|
151
|
+
bool __testin = this->_M_mode & ios_base::in;
|
152
|
+
|
153
|
+
if (__testin && this->is_open())
|
154
|
+
__ret = this->_M_in_end - this->_M_in_cur;
|
155
|
+
this->_M_last_overflowed = false;
|
156
|
+
return __ret;
|
157
|
+
}
|
158
|
+
|
159
|
+
template<typename _CharT, typename _Traits>
|
160
|
+
typename basic_filebuf<_CharT, _Traits>::int_type
|
161
|
+
basic_filebuf<_CharT, _Traits>::
|
162
|
+
pbackfail(int_type __i)
|
163
|
+
{
|
164
|
+
int_type __ret = traits_type::eof();
|
165
|
+
bool __testin = this->_M_mode & ios_base::in;
|
166
|
+
|
167
|
+
if (__testin)
|
168
|
+
{
|
169
|
+
bool __testpb = this->_M_in_beg < this->_M_in_cur;
|
170
|
+
char_type __c = traits_type::to_char_type(__i);
|
171
|
+
bool __testeof = traits_type::eq_int_type(__i, __ret);
|
172
|
+
|
173
|
+
if (__testpb)
|
174
|
+
{
|
175
|
+
bool __testout = this->_M_mode & ios_base::out;
|
176
|
+
bool __testeq = traits_type::eq(__c, this->gptr()[-1]);
|
177
|
+
|
178
|
+
// Try to put back __c into input sequence in one of three ways.
|
179
|
+
// Order these tests done in is unspecified by the standard.
|
180
|
+
if (!__testeof && __testeq)
|
181
|
+
{
|
182
|
+
--this->_M_in_cur;
|
183
|
+
if (__testout)
|
184
|
+
--this->_M_out_cur;
|
185
|
+
__ret = __i;
|
186
|
+
}
|
187
|
+
else if (__testeof)
|
188
|
+
{
|
189
|
+
--this->_M_in_cur;
|
190
|
+
if (__testout)
|
191
|
+
--this->_M_out_cur;
|
192
|
+
__ret = traits_type::not_eof(__i);
|
193
|
+
}
|
194
|
+
else if (!__testeof)
|
195
|
+
{
|
196
|
+
--this->_M_in_cur;
|
197
|
+
if (__testout)
|
198
|
+
--this->_M_out_cur;
|
199
|
+
this->_M_pback_create();
|
200
|
+
*this->_M_in_cur = __c;
|
201
|
+
__ret = __i;
|
202
|
+
}
|
203
|
+
}
|
204
|
+
else
|
205
|
+
{
|
206
|
+
// At the beginning of the buffer, need to make a
|
207
|
+
// putback position available.
|
208
|
+
this->seekoff(-1, ios_base::cur);
|
209
|
+
this->underflow();
|
210
|
+
if (!__testeof)
|
211
|
+
{
|
212
|
+
if (!traits_type::eq(__c, *this->_M_in_cur))
|
213
|
+
{
|
214
|
+
this->_M_pback_create();
|
215
|
+
*this->_M_in_cur = __c;
|
216
|
+
}
|
217
|
+
__ret = __i;
|
218
|
+
}
|
219
|
+
else
|
220
|
+
__ret = traits_type::not_eof(__i);
|
221
|
+
}
|
222
|
+
}
|
223
|
+
this->_M_last_overflowed = false;
|
224
|
+
return __ret;
|
225
|
+
}
|
226
|
+
|
227
|
+
template<typename _CharT, typename _Traits>
|
228
|
+
typename basic_filebuf<_CharT, _Traits>::int_type
|
229
|
+
basic_filebuf<_CharT, _Traits>::
|
230
|
+
overflow(int_type __c)
|
231
|
+
{
|
232
|
+
int_type __ret = traits_type::eof();
|
233
|
+
bool __testput = this->_M_out_cur && this->_M_out_cur < this->_M_buf + this->_M_buf_size;
|
234
|
+
bool __testout = this->_M_mode & ios_base::out;
|
235
|
+
|
236
|
+
if (__testout)
|
237
|
+
{
|
238
|
+
if (__testput)
|
239
|
+
{
|
240
|
+
*this->_M_out_cur = traits_type::to_char_type(__c);
|
241
|
+
this->_M_out_cur_move(1);
|
242
|
+
__ret = traits_type::not_eof(__c);
|
243
|
+
}
|
244
|
+
else
|
245
|
+
__ret = this->_M_really_overflow(__c);
|
246
|
+
}
|
247
|
+
|
248
|
+
this->_M_last_overflowed = false; // Set in this->_M_really_overflow, below.
|
249
|
+
return __ret;
|
250
|
+
}
|
251
|
+
|
252
|
+
template<typename _CharT, typename _Traits>
|
253
|
+
void
|
254
|
+
basic_filebuf<_CharT, _Traits>::
|
255
|
+
_M_convert_to_external(_CharT* __ibuf, streamsize __ilen,
|
256
|
+
streamsize& __elen, streamsize& __plen)
|
257
|
+
{
|
258
|
+
const locale __loc = this->getloc();
|
259
|
+
const __codecvt_type& __cvt = use_facet<__codecvt_type>(__loc);
|
260
|
+
|
261
|
+
if (__cvt.always_noconv() && __ilen)
|
262
|
+
{
|
263
|
+
__elen += _M_file.xsputn(reinterpret_cast<char*>(__ibuf), __ilen);
|
264
|
+
__plen += __ilen;
|
265
|
+
}
|
266
|
+
else
|
267
|
+
{
|
268
|
+
// Worst-case number of external bytes needed.
|
269
|
+
int __ext_multiplier = __cvt.encoding();
|
270
|
+
if (__ext_multiplier == -1 || __ext_multiplier == 0)
|
271
|
+
__ext_multiplier = sizeof(char_type);
|
272
|
+
streamsize __blen = __ilen * __ext_multiplier;
|
273
|
+
char* __buf = static_cast<char*>(__builtin_alloca(__blen));
|
274
|
+
char* __bend;
|
275
|
+
const char_type* __iend;
|
276
|
+
__res_type __r = __cvt.out(_M_state_cur, __ibuf, __ibuf + __ilen,
|
277
|
+
__iend, __buf, __buf + __blen, __bend);
|
278
|
+
|
279
|
+
if (__r == codecvt_base::ok || __r == codecvt_base::partial)
|
280
|
+
__blen = __bend - __buf;
|
281
|
+
// Similarly to the always_noconv case above.
|
282
|
+
else if (__r == codecvt_base::noconv)
|
283
|
+
{
|
284
|
+
__buf = reinterpret_cast<char*>(__ibuf);
|
285
|
+
__blen = __ilen;
|
286
|
+
}
|
287
|
+
// Result == error
|
288
|
+
else
|
289
|
+
__blen = 0;
|
290
|
+
|
291
|
+
if (__blen)
|
292
|
+
{
|
293
|
+
__elen += _M_file.xsputn(__buf, __blen);
|
294
|
+
__plen += __blen;
|
295
|
+
}
|
296
|
+
|
297
|
+
// Try once more for partial conversions.
|
298
|
+
if (__r == codecvt_base::partial)
|
299
|
+
{
|
300
|
+
const char_type* __iresume = __iend;
|
301
|
+
streamsize __rlen = this->_M_out_end - __iend;
|
302
|
+
__r = __cvt.out(this->_M_state_cur, __iresume, __iresume + __rlen,
|
303
|
+
__iend, __buf, __buf + __blen, __bend);
|
304
|
+
if (__r != codecvt_base::error)
|
305
|
+
__rlen = __bend - __buf;
|
306
|
+
else
|
307
|
+
__rlen = 0;
|
308
|
+
if (__rlen)
|
309
|
+
{
|
310
|
+
__elen += _M_file.xsputn(__buf, __rlen);
|
311
|
+
__plen += __rlen;
|
312
|
+
}
|
313
|
+
}
|
314
|
+
}
|
315
|
+
}
|
316
|
+
|
317
|
+
template<typename _CharT, typename _Traits>
|
318
|
+
typename basic_filebuf<_CharT, _Traits>::int_type
|
319
|
+
basic_filebuf<_CharT, _Traits>::
|
320
|
+
_M_really_overflow(int_type __c)
|
321
|
+
{
|
322
|
+
int_type __ret = traits_type::eof();
|
323
|
+
bool __testput = this->_M_out_cur && this->_M_out_beg < this->_M_out_end;
|
324
|
+
bool __testunbuffered = this->_M_file.is_open() && !this->_M_buf_size_opt;
|
325
|
+
|
326
|
+
if (__testput || __testunbuffered)
|
327
|
+
{
|
328
|
+
// Sizes of external and pending output.
|
329
|
+
streamsize __elen = 0;
|
330
|
+
streamsize __plen = 0;
|
331
|
+
|
332
|
+
// Need to restore current position. The position of the external
|
333
|
+
// byte sequence (_M_file) corresponds to _M_filepos, and we need
|
334
|
+
// to move it to _M_out_beg for the write.
|
335
|
+
if (this->_M_filepos && this->_M_filepos != this->_M_out_beg)
|
336
|
+
{
|
337
|
+
off_type __off = this->_M_out_beg - this->_M_filepos;
|
338
|
+
this->_M_file.seekoff(__off, ios_base::cur);
|
339
|
+
}
|
340
|
+
|
341
|
+
// Convert internal buffer to external representation, output.
|
342
|
+
// NB: In the unbuffered case, no internal buffer exists.
|
343
|
+
if (!__testunbuffered)
|
344
|
+
_M_convert_to_external(this->_M_out_beg, this->_M_out_end - this->_M_out_beg,
|
345
|
+
__elen, __plen);
|
346
|
+
|
347
|
+
// Convert pending sequence to external representation, output.
|
348
|
+
// If eof, then just attempt sync.
|
349
|
+
if (!traits_type::eq_int_type(__c, traits_type::eof()))
|
350
|
+
{
|
351
|
+
char_type __pending = traits_type::to_char_type(__c);
|
352
|
+
_M_convert_to_external(&__pending, 1, __elen, __plen);
|
353
|
+
|
354
|
+
// User code must flush when switching modes (thus don't sync).
|
355
|
+
if (__elen == __plen)
|
356
|
+
{
|
357
|
+
_M_set_indeterminate();
|
358
|
+
__ret = traits_type::not_eof(__c);
|
359
|
+
}
|
360
|
+
}
|
361
|
+
else if (!_M_file.sync())
|
362
|
+
{
|
363
|
+
_M_set_indeterminate();
|
364
|
+
__ret = traits_type::not_eof(__c);
|
365
|
+
}
|
366
|
+
}
|
367
|
+
_M_last_overflowed = true;
|
368
|
+
return __ret;
|
369
|
+
}
|
370
|
+
|
371
|
+
template<typename _CharT, typename _Traits>
|
372
|
+
typename basic_filebuf<_CharT, _Traits>::__streambuf_type*
|
373
|
+
basic_filebuf<_CharT, _Traits>::
|
374
|
+
setbuf(char_type* __s, streamsize __n)
|
375
|
+
{
|
376
|
+
if (!this->is_open() && __s == 0 && __n == 0)
|
377
|
+
this->_M_buf_size_opt = 0;
|
378
|
+
else if (__s && __n)
|
379
|
+
{
|
380
|
+
// This is implementation-defined behavior, and assumes
|
381
|
+
// that an external char_type array of length (__s + __n)
|
382
|
+
// exists and has been pre-allocated. If this is not the
|
383
|
+
// case, things will quickly blow up.
|
384
|
+
// Step 1: Destroy the current internal array.
|
385
|
+
_M_destroy_internal_buffer();
|
386
|
+
|
387
|
+
// Step 2: Use the external array.
|
388
|
+
this->_M_buf = __s;
|
389
|
+
this->_M_buf_size_opt = this->_M_buf_size = __n;
|
390
|
+
_M_set_indeterminate();
|
391
|
+
}
|
392
|
+
_M_last_overflowed = false;
|
393
|
+
return this;
|
394
|
+
}
|
395
|
+
|
396
|
+
template<typename _CharT, typename _Traits>
|
397
|
+
typename basic_filebuf<_CharT, _Traits>::pos_type
|
398
|
+
basic_filebuf<_CharT, _Traits>::
|
399
|
+
seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode)
|
400
|
+
{
|
401
|
+
pos_type __ret = pos_type(off_type(-1));
|
402
|
+
bool __testin = (ios_base::in & this->_M_mode & __mode) != 0;
|
403
|
+
bool __testout = (ios_base::out & this->_M_mode & __mode) != 0;
|
404
|
+
|
405
|
+
// Should probably do has_facet checks here.
|
406
|
+
int __width = use_facet<__codecvt_type>(this->_M_buf_locale).encoding();
|
407
|
+
if (__width < 0)
|
408
|
+
__width = 0;
|
409
|
+
bool __testfail = __off != 0 && __width <= 0;
|
410
|
+
|
411
|
+
if (this->is_open() && !__testfail && (__testin || __testout))
|
412
|
+
{
|
413
|
+
// Ditch any pback buffers to avoid confusion.
|
414
|
+
this->_M_pback_destroy();
|
415
|
+
|
416
|
+
if (__way != ios_base::cur || __off != 0)
|
417
|
+
{
|
418
|
+
off_type __computed_off = __width * __off;
|
419
|
+
|
420
|
+
bool __testget = this->_M_in_cur && this->_M_in_beg < this->_M_in_end;
|
421
|
+
bool __testput = this->_M_out_cur && this->_M_out_beg < this->_M_out_end;
|
422
|
+
// Sync the internal and external streams.
|
423
|
+
// out
|
424
|
+
if (__testput || this->_M_last_overflowed)
|
425
|
+
{
|
426
|
+
// Part one: update the output sequence.
|
427
|
+
this->sync();
|
428
|
+
// Part two: output unshift sequence.
|
429
|
+
this->_M_output_unshift();
|
430
|
+
}
|
431
|
+
//in
|
432
|
+
else if (__testget && __way == ios_base::cur)
|
433
|
+
__computed_off += this->_M_in_cur - this->_M_filepos;
|
434
|
+
|
435
|
+
__ret = this->_M_file.seekoff(__computed_off, __way, __mode);
|
436
|
+
this->_M_set_indeterminate();
|
437
|
+
}
|
438
|
+
// NB: Need to do this in case this->_M_file in indeterminate
|
439
|
+
// state, ie _M_file._offset == -1
|
440
|
+
else
|
441
|
+
{
|
442
|
+
__ret = _M_file.seekoff(__off, ios_base::cur, __mode);
|
443
|
+
__ret += max(this->_M_out_cur, this->_M_in_cur) - this->_M_filepos;
|
444
|
+
}
|
445
|
+
}
|
446
|
+
this->_M_last_overflowed = false;
|
447
|
+
return __ret;
|
448
|
+
}
|
449
|
+
|
450
|
+
template<typename _CharT, typename _Traits>
|
451
|
+
typename basic_filebuf<_CharT, _Traits>::pos_type
|
452
|
+
basic_filebuf<_CharT, _Traits>::
|
453
|
+
seekpos(pos_type __pos, ios_base::openmode __mode)
|
454
|
+
{
|
455
|
+
#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
|
456
|
+
// 171. Strange seekpos() semantics due to joint position
|
457
|
+
return this->seekoff(off_type(__pos), ios_base::beg, __mode);
|
458
|
+
#endif
|
459
|
+
}
|
460
|
+
|
461
|
+
template<typename _CharT, typename _Traits>
|
462
|
+
void
|
463
|
+
basic_filebuf<_CharT, _Traits>::
|
464
|
+
_M_output_unshift()
|
465
|
+
{ }
|
466
|
+
|
467
|
+
template<typename _CharT, typename _Traits>
|
468
|
+
void
|
469
|
+
basic_filebuf<_CharT, _Traits>::
|
470
|
+
imbue(const locale& __loc)
|
471
|
+
{
|
472
|
+
bool __testbeg = this->gptr() == this->eback() && this->pptr() == this->pbase();
|
473
|
+
|
474
|
+
if (__testbeg && this->_M_buf_locale != __loc)
|
475
|
+
this->_M_buf_locale = __loc;
|
476
|
+
|
477
|
+
// NB this may require the reconversion of previously
|
478
|
+
// converted chars. This in turn may cause the reconstruction
|
479
|
+
// of the original file. YIKES!!
|
480
|
+
// XXX The part in the above comment is not done.
|
481
|
+
this->_M_last_overflowed = false;
|
482
|
+
}
|
483
|
+
|
484
|
+
// Inhibit implicit instantiations for required instantiations,
|
485
|
+
// which are defined via explicit instantiations elsewhere.
|
486
|
+
// NB: This syntax is a GNU extension.
|
487
|
+
extern template class basic_filebuf<char>;
|
488
|
+
extern template class basic_ifstream<char>;
|
489
|
+
extern template class basic_ofstream<char>;
|
490
|
+
extern template class basic_fstream<char>;
|
491
|
+
|
492
|
+
#ifdef _GLIBCPP_USE_WCHAR_T
|
493
|
+
extern template class basic_filebuf<wchar_t>;
|
494
|
+
extern template class basic_ifstream<wchar_t>;
|
495
|
+
extern template class basic_ofstream<wchar_t>;
|
496
|
+
extern template class basic_fstream<wchar_t>;
|
497
|
+
#endif
|
498
|
+
} // namespace std
|
499
|
+
|
500
|
+
#endif
|