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