@@ -178,8 +178,8 @@ public:
178
178
// Get and put areas:
179
179
// 27.6.2.2.3 Get area:
180
180
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 streamsize in_avail () {
181
- if (__ninp_ < __einp_ )
182
- return static_cast <streamsize>(__einp_ - __ninp_ );
181
+ if (gptr () < egptr () )
182
+ return static_cast <streamsize>(egptr () - gptr () );
183
183
return showmanyc ();
184
184
}
185
185
@@ -190,37 +190,42 @@ public:
190
190
}
191
191
192
192
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sbumpc () {
193
- if (__ninp_ == __einp_ )
193
+ if (gptr () == egptr () )
194
194
return uflow ();
195
- return traits_type::to_int_type (*__ninp_++);
195
+ int_type __c = traits_type::to_int_type (*gptr ());
196
+ this ->gbump (1 );
197
+ return __c;
196
198
}
197
199
198
200
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sgetc () {
199
- if (__ninp_ == __einp_ )
201
+ if (gptr () == egptr () )
200
202
return underflow ();
201
- return traits_type::to_int_type (*__ninp_ );
203
+ return traits_type::to_int_type (*gptr () );
202
204
}
203
205
204
206
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 streamsize sgetn (char_type* __s, streamsize __n) { return xsgetn (__s, __n); }
205
207
206
208
// 27.6.2.2.4 Putback:
207
209
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sputbackc (char_type __c) {
208
- if (__binp_ == __ninp_ || !traits_type::eq (__c, __ninp_[- 1 ] ))
210
+ if (eback () == gptr () || !traits_type::eq (__c, *( gptr () - 1 ) ))
209
211
return pbackfail (traits_type::to_int_type (__c));
210
- return traits_type::to_int_type (*--__ninp_);
212
+ this ->gbump (-1 );
213
+ return traits_type::to_int_type (*gptr ());
211
214
}
212
215
213
216
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sungetc () {
214
- if (__binp_ == __ninp_ )
217
+ if (eback () == gptr () )
215
218
return pbackfail ();
216
- return traits_type::to_int_type (*--__ninp_);
219
+ this ->gbump (-1 );
220
+ return traits_type::to_int_type (*gptr ());
217
221
}
218
222
219
223
// 27.6.2.2.5 Put area:
220
224
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sputc (char_type __c) {
221
- if (__nout_ == __eout_ )
225
+ if (pptr () == epptr () )
222
226
return overflow (traits_type::to_int_type (__c));
223
- *__nout_++ = __c;
227
+ *pptr () = __c;
228
+ this ->pbump (1 );
224
229
return traits_type::to_int_type (__c);
225
230
}
226
231
@@ -312,17 +317,16 @@ protected:
312
317
virtual streamsize showmanyc () { return 0 ; }
313
318
314
319
virtual streamsize xsgetn (char_type* __s, streamsize __n) {
315
- const int_type __eof = traits_type::eof ();
316
320
int_type __c;
317
321
streamsize __i = 0 ;
318
322
while (__i < __n) {
319
- if (__ninp_ < __einp_ ) {
320
- const streamsize __len = std::min (static_cast <streamsize>(INT_MAX), std::min (__einp_ - __ninp_ , __n - __i));
321
- traits_type::copy (__s, __ninp_ , __len);
323
+ if (gptr () < egptr () ) {
324
+ const streamsize __len = std::min (static_cast <streamsize>(INT_MAX), std::min (egptr () - gptr () , __n - __i));
325
+ traits_type::copy (__s, gptr () , __len);
322
326
__s += __len;
323
327
__i += __len;
324
328
this ->gbump (__len);
325
- } else if ((__c = uflow ()) != __eof ) {
329
+ } else if ((__c = uflow ()) != traits_type::eof () ) {
326
330
*__s = traits_type::to_char_type (__c);
327
331
++__s;
328
332
++__i;
@@ -336,7 +340,9 @@ protected:
336
340
virtual int_type uflow () {
337
341
if (underflow () == traits_type::eof ())
338
342
return traits_type::eof ();
339
- return traits_type::to_int_type (*__ninp_++);
343
+ int_type __c = traits_type::to_int_type (*gptr ());
344
+ this ->gbump (1 );
345
+ return __c;
340
346
}
341
347
342
348
// 27.6.2.4.4 Putback:
@@ -345,17 +351,16 @@ protected:
345
351
// 27.6.2.4.5 Put area:
346
352
virtual streamsize xsputn (const char_type* __s, streamsize __n) {
347
353
streamsize __i = 0 ;
348
- int_type __eof = traits_type::eof ();
349
354
while (__i < __n) {
350
- if (__nout_ >= __eout_ ) {
351
- if (overflow (traits_type::to_int_type (*__s)) == __eof )
355
+ if (pptr () >= epptr () ) {
356
+ if (overflow (traits_type::to_int_type (*__s)) == traits_type::eof () )
352
357
break ;
353
358
++__s;
354
359
++__i;
355
360
} else {
356
- streamsize __chunk_size = std::min (__eout_ - __nout_ , __n - __i);
357
- traits_type::copy (__nout_ , __s, __chunk_size);
358
- __nout_ += __chunk_size;
361
+ streamsize __chunk_size = std::min (epptr () - pptr () , __n - __i);
362
+ traits_type::copy (pptr () , __s, __chunk_size);
363
+ __pbump ( __chunk_size) ;
359
364
__s += __chunk_size;
360
365
__i += __chunk_size;
361
366
}
0 commit comments