Fix SH4 FP_ILOGB0 (bug 20859).
[glibc.git] / libio / wgenops.c
blob9f524aaf2d49faa2c78a83d4dc770a8f4a186d36
1 /* Copyright (C) 1993-2016 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Written by Ulrich Drepper <drepper@cygnus.com>.
4 Based on the single byte version by Per Bothner <bothner@cygnus.com>.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>.
20 As a special exception, if you link the code in this file with
21 files compiled with a GNU compiler to produce an executable,
22 that does not cause the resulting executable to be covered by
23 the GNU Lesser General Public License. This exception does not
24 however invalidate any other reasons why the executable file
25 might be covered by the GNU Lesser General Public License.
26 This exception applies to code released by its copyright holders
27 in files containing the exception. */
29 /* Generic or default I/O operations. */
31 #include "libioP.h"
32 #include <stdlib.h>
33 #include <string.h>
34 #include <wchar.h>
37 #ifndef _LIBC
38 # define __wmemcpy(dst, src, n) wmemcpy (dst, src, n)
39 #endif
42 static int save_for_wbackup (_IO_FILE *fp, wchar_t *end_p) __THROW
43 #ifdef _LIBC
44 internal_function
45 #endif
48 /* Return minimum _pos markers
49 Assumes the current get area is the main get area. */
50 _IO_ssize_t
51 _IO_least_wmarker (_IO_FILE *fp, wchar_t *end_p)
53 _IO_ssize_t least_so_far = end_p - fp->_wide_data->_IO_read_base;
54 struct _IO_marker *mark;
55 for (mark = fp->_markers; mark != NULL; mark = mark->_next)
56 if (mark->_pos < least_so_far)
57 least_so_far = mark->_pos;
58 return least_so_far;
60 libc_hidden_def (_IO_least_wmarker)
62 /* Switch current get area from backup buffer to (start of) main get area. */
63 void
64 _IO_switch_to_main_wget_area (_IO_FILE *fp)
66 wchar_t *tmp;
67 fp->_flags &= ~_IO_IN_BACKUP;
68 /* Swap _IO_read_end and _IO_save_end. */
69 tmp = fp->_wide_data->_IO_read_end;
70 fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_save_end;
71 fp->_wide_data->_IO_save_end= tmp;
72 /* Swap _IO_read_base and _IO_save_base. */
73 tmp = fp->_wide_data->_IO_read_base;
74 fp->_wide_data->_IO_read_base = fp->_wide_data->_IO_save_base;
75 fp->_wide_data->_IO_save_base = tmp;
76 /* Set _IO_read_ptr. */
77 fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_base;
79 libc_hidden_def (_IO_switch_to_main_wget_area)
82 /* Switch current get area from main get area to (end of) backup area. */
83 void
84 _IO_switch_to_wbackup_area (_IO_FILE *fp)
86 wchar_t *tmp;
87 fp->_flags |= _IO_IN_BACKUP;
88 /* Swap _IO_read_end and _IO_save_end. */
89 tmp = fp->_wide_data->_IO_read_end;
90 fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_save_end;
91 fp->_wide_data->_IO_save_end = tmp;
92 /* Swap _IO_read_base and _IO_save_base. */
93 tmp = fp->_wide_data->_IO_read_base;
94 fp->_wide_data->_IO_read_base = fp->_wide_data->_IO_save_base;
95 fp->_wide_data->_IO_save_base = tmp;
96 /* Set _IO_read_ptr. */
97 fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_end;
99 libc_hidden_def (_IO_switch_to_wbackup_area)
102 void
103 _IO_wsetb (_IO_FILE *f, wchar_t *b, wchar_t *eb, int a)
105 if (f->_wide_data->_IO_buf_base && !(f->_flags2 & _IO_FLAGS2_USER_WBUF))
106 free (f->_wide_data->_IO_buf_base);
107 f->_wide_data->_IO_buf_base = b;
108 f->_wide_data->_IO_buf_end = eb;
109 if (a)
110 f->_flags2 &= ~_IO_FLAGS2_USER_WBUF;
111 else
112 f->_flags2 |= _IO_FLAGS2_USER_WBUF;
114 libc_hidden_def (_IO_wsetb)
117 wint_t
118 _IO_wdefault_pbackfail (_IO_FILE *fp, wint_t c)
120 if (fp->_wide_data->_IO_read_ptr > fp->_wide_data->_IO_read_base
121 && !_IO_in_backup (fp)
122 && (wint_t) fp->_IO_read_ptr[-1] == c)
123 --fp->_IO_read_ptr;
124 else
126 /* Need to handle a filebuf in write mode (switch to read mode). FIXME!*/
127 if (!_IO_in_backup (fp))
129 /* We need to keep the invariant that the main get area
130 logically follows the backup area. */
131 if (fp->_wide_data->_IO_read_ptr > fp->_wide_data->_IO_read_base
132 && _IO_have_wbackup (fp))
134 if (save_for_wbackup (fp, fp->_wide_data->_IO_read_ptr))
135 return WEOF;
137 else if (!_IO_have_wbackup (fp))
139 /* No backup buffer: allocate one. */
140 /* Use nshort buffer, if unused? (probably not) FIXME */
141 int backup_size = 128;
142 wchar_t *bbuf = (wchar_t *) malloc (backup_size
143 * sizeof (wchar_t));
144 if (bbuf == NULL)
145 return WEOF;
146 fp->_wide_data->_IO_save_base = bbuf;
147 fp->_wide_data->_IO_save_end = (fp->_wide_data->_IO_save_base
148 + backup_size);
149 fp->_wide_data->_IO_backup_base = fp->_wide_data->_IO_save_end;
151 fp->_wide_data->_IO_read_base = fp->_wide_data->_IO_read_ptr;
152 _IO_switch_to_wbackup_area (fp);
154 else if (fp->_wide_data->_IO_read_ptr <= fp->_wide_data->_IO_read_base)
156 /* Increase size of existing backup buffer. */
157 _IO_size_t new_size;
158 _IO_size_t old_size = (fp->_wide_data->_IO_read_end
159 - fp->_wide_data->_IO_read_base);
160 wchar_t *new_buf;
161 new_size = 2 * old_size;
162 new_buf = (wchar_t *) malloc (new_size * sizeof (wchar_t));
163 if (new_buf == NULL)
164 return WEOF;
165 __wmemcpy (new_buf + (new_size - old_size),
166 fp->_wide_data->_IO_read_base, old_size);
167 free (fp->_wide_data->_IO_read_base);
168 _IO_wsetg (fp, new_buf, new_buf + (new_size - old_size),
169 new_buf + new_size);
170 fp->_wide_data->_IO_backup_base = fp->_wide_data->_IO_read_ptr;
173 *--fp->_wide_data->_IO_read_ptr = c;
175 return c;
177 libc_hidden_def (_IO_wdefault_pbackfail)
180 void
181 _IO_wdefault_finish (_IO_FILE *fp, int dummy)
183 struct _IO_marker *mark;
184 if (fp->_wide_data->_IO_buf_base && !(fp->_flags2 & _IO_FLAGS2_USER_WBUF))
186 free (fp->_wide_data->_IO_buf_base);
187 fp->_wide_data->_IO_buf_base = fp->_wide_data->_IO_buf_end = NULL;
190 for (mark = fp->_markers; mark != NULL; mark = mark->_next)
191 mark->_sbuf = NULL;
193 if (fp->_IO_save_base)
195 free (fp->_wide_data->_IO_save_base);
196 fp->_IO_save_base = NULL;
199 #ifdef _IO_MTSAFE_IO
200 if (fp->_lock != NULL)
201 _IO_lock_fini (*fp->_lock);
202 #endif
204 _IO_un_link ((struct _IO_FILE_plus *) fp);
206 libc_hidden_def (_IO_wdefault_finish)
209 wint_t
210 _IO_wdefault_uflow (_IO_FILE *fp)
212 wint_t wch;
213 wch = _IO_UNDERFLOW (fp);
214 if (wch == WEOF)
215 return WEOF;
216 return *fp->_wide_data->_IO_read_ptr++;
218 libc_hidden_def (_IO_wdefault_uflow)
221 wint_t
222 __woverflow (_IO_FILE *f, wint_t wch)
224 if (f->_mode == 0)
225 _IO_fwide (f, 1);
226 return _IO_OVERFLOW (f, wch);
228 libc_hidden_def (__woverflow)
231 wint_t
232 __wuflow (_IO_FILE *fp)
234 if (fp->_mode < 0 || (fp->_mode == 0 && _IO_fwide (fp, 1) != 1))
235 return WEOF;
237 if (fp->_mode == 0)
238 _IO_fwide (fp, 1);
239 if (_IO_in_put_mode (fp))
240 if (_IO_switch_to_wget_mode (fp) == EOF)
241 return WEOF;
242 if (fp->_wide_data->_IO_read_ptr < fp->_wide_data->_IO_read_end)
243 return *fp->_wide_data->_IO_read_ptr++;
244 if (_IO_in_backup (fp))
246 _IO_switch_to_main_wget_area (fp);
247 if (fp->_wide_data->_IO_read_ptr < fp->_wide_data->_IO_read_end)
248 return *fp->_wide_data->_IO_read_ptr++;
250 if (_IO_have_markers (fp))
252 if (save_for_wbackup (fp, fp->_wide_data->_IO_read_end))
253 return WEOF;
255 else if (_IO_have_wbackup (fp))
256 _IO_free_wbackup_area (fp);
257 return _IO_UFLOW (fp);
259 libc_hidden_def (__wuflow)
261 wint_t
262 __wunderflow (_IO_FILE *fp)
264 if (fp->_mode < 0 || (fp->_mode == 0 && _IO_fwide (fp, 1) != 1))
265 return WEOF;
267 if (fp->_mode == 0)
268 _IO_fwide (fp, 1);
269 if (_IO_in_put_mode (fp))
270 if (_IO_switch_to_wget_mode (fp) == EOF)
271 return WEOF;
272 if (fp->_wide_data->_IO_read_ptr < fp->_wide_data->_IO_read_end)
273 return *fp->_wide_data->_IO_read_ptr;
274 if (_IO_in_backup (fp))
276 _IO_switch_to_main_wget_area (fp);
277 if (fp->_wide_data->_IO_read_ptr < fp->_wide_data->_IO_read_end)
278 return *fp->_wide_data->_IO_read_ptr;
280 if (_IO_have_markers (fp))
282 if (save_for_wbackup (fp, fp->_wide_data->_IO_read_end))
283 return WEOF;
285 else if (_IO_have_backup (fp))
286 _IO_free_wbackup_area (fp);
287 return _IO_UNDERFLOW (fp);
289 libc_hidden_def (__wunderflow)
292 _IO_size_t
293 _IO_wdefault_xsputn (_IO_FILE *f, const void *data, _IO_size_t n)
295 const wchar_t *s = (const wchar_t *) data;
296 _IO_size_t more = n;
297 if (more <= 0)
298 return 0;
299 for (;;)
301 /* Space available. */
302 _IO_ssize_t count = (f->_wide_data->_IO_write_end
303 - f->_wide_data->_IO_write_ptr);
304 if (count > 0)
306 if ((_IO_size_t) count > more)
307 count = more;
308 if (count > 20)
310 #ifdef _LIBC
311 f->_wide_data->_IO_write_ptr =
312 __wmempcpy (f->_wide_data->_IO_write_ptr, s, count);
313 #else
314 memcpy (f->_wide_data->_IO_write_ptr, s, count);
315 f->_wide_data->_IO_write_ptr += count;
316 #endif
317 s += count;
319 else if (count <= 0)
320 count = 0;
321 else
323 wchar_t *p = f->_wide_data->_IO_write_ptr;
324 _IO_ssize_t i;
325 for (i = count; --i >= 0; )
326 *p++ = *s++;
327 f->_wide_data->_IO_write_ptr = p;
329 more -= count;
331 if (more == 0 || __woverflow (f, *s++) == WEOF)
332 break;
333 more--;
335 return n - more;
337 libc_hidden_def (_IO_wdefault_xsputn)
340 _IO_size_t
341 _IO_wdefault_xsgetn (_IO_FILE *fp, void *data, _IO_size_t n)
343 _IO_size_t more = n;
344 wchar_t *s = (wchar_t*) data;
345 for (;;)
347 /* Data available. */
348 _IO_ssize_t count = (fp->_wide_data->_IO_read_end
349 - fp->_wide_data->_IO_read_ptr);
350 if (count > 0)
352 if ((_IO_size_t) count > more)
353 count = more;
354 if (count > 20)
356 #ifdef _LIBC
357 s = __wmempcpy (s, fp->_wide_data->_IO_read_ptr, count);
358 #else
359 memcpy (s, fp->_wide_data->_IO_read_ptr, count);
360 s += count;
361 #endif
362 fp->_wide_data->_IO_read_ptr += count;
364 else if (count <= 0)
365 count = 0;
366 else
368 wchar_t *p = fp->_wide_data->_IO_read_ptr;
369 int i = (int) count;
370 while (--i >= 0)
371 *s++ = *p++;
372 fp->_wide_data->_IO_read_ptr = p;
374 more -= count;
376 if (more == 0 || __wunderflow (fp) == WEOF)
377 break;
379 return n - more;
381 libc_hidden_def (_IO_wdefault_xsgetn)
384 void
385 _IO_wdoallocbuf (_IO_FILE *fp)
387 if (fp->_wide_data->_IO_buf_base)
388 return;
389 if (!(fp->_flags & _IO_UNBUFFERED))
390 if ((wint_t)_IO_WDOALLOCATE (fp) != WEOF)
391 return;
392 _IO_wsetb (fp, fp->_wide_data->_shortbuf,
393 fp->_wide_data->_shortbuf + 1, 0);
395 libc_hidden_def (_IO_wdoallocbuf)
399 _IO_wdefault_doallocate (_IO_FILE *fp)
401 wchar_t *buf;
403 buf = malloc (_IO_BUFSIZ);
404 if (__glibc_unlikely (buf == NULL))
405 return EOF;
406 _IO_wsetb (fp, buf, buf + _IO_BUFSIZ, 1);
407 return 1;
409 libc_hidden_def (_IO_wdefault_doallocate)
413 _IO_switch_to_wget_mode (_IO_FILE *fp)
415 if (fp->_wide_data->_IO_write_ptr > fp->_wide_data->_IO_write_base)
416 if ((wint_t)_IO_WOVERFLOW (fp, WEOF) == WEOF)
417 return EOF;
418 if (_IO_in_backup (fp))
419 fp->_wide_data->_IO_read_base = fp->_wide_data->_IO_backup_base;
420 else
422 fp->_wide_data->_IO_read_base = fp->_wide_data->_IO_buf_base;
423 if (fp->_wide_data->_IO_write_ptr > fp->_wide_data->_IO_read_end)
424 fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_write_ptr;
426 fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_write_ptr;
428 fp->_wide_data->_IO_write_base = fp->_wide_data->_IO_write_ptr
429 = fp->_wide_data->_IO_write_end = fp->_wide_data->_IO_read_ptr;
431 fp->_flags &= ~_IO_CURRENTLY_PUTTING;
432 return 0;
434 libc_hidden_def (_IO_switch_to_wget_mode)
436 void
437 _IO_free_wbackup_area (_IO_FILE *fp)
439 if (_IO_in_backup (fp))
440 _IO_switch_to_main_wget_area (fp); /* Just in case. */
441 free (fp->_wide_data->_IO_save_base);
442 fp->_wide_data->_IO_save_base = NULL;
443 fp->_wide_data->_IO_save_end = NULL;
444 fp->_wide_data->_IO_backup_base = NULL;
446 libc_hidden_def (_IO_free_wbackup_area)
448 #if 0
450 _IO_switch_to_wput_mode (_IO_FILE *fp)
452 fp->_wide_data->_IO_write_base = fp->_wide_data->_IO_read_ptr;
453 fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_read_ptr;
454 /* Following is wrong if line- or un-buffered? */
455 fp->_wide_data->_IO_write_end = (fp->_flags & _IO_IN_BACKUP
456 ? fp->_wide_data->_IO_read_end
457 : fp->_wide_data->_IO_buf_end);
459 fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_end;
460 fp->_wide_data->_IO_read_base = fp->_wide_data->_IO_read_end;
462 fp->_flags |= _IO_CURRENTLY_PUTTING;
463 return 0;
465 #endif
468 static int
469 #ifdef _LIBC
470 internal_function
471 #endif
472 save_for_wbackup (_IO_FILE *fp, wchar_t *end_p)
474 /* Append [_IO_read_base..end_p] to backup area. */
475 _IO_ssize_t least_mark = _IO_least_wmarker (fp, end_p);
476 /* needed_size is how much space we need in the backup area. */
477 _IO_size_t needed_size = ((end_p - fp->_wide_data->_IO_read_base)
478 - least_mark);
479 /* FIXME: Dubious arithmetic if pointers are NULL */
480 _IO_size_t current_Bsize = (fp->_wide_data->_IO_save_end
481 - fp->_wide_data->_IO_save_base);
482 _IO_size_t avail; /* Extra space available for future expansion. */
483 _IO_ssize_t delta;
484 struct _IO_marker *mark;
485 if (needed_size > current_Bsize)
487 wchar_t *new_buffer;
488 avail = 100;
489 new_buffer = (wchar_t *) malloc ((avail + needed_size)
490 * sizeof (wchar_t));
491 if (new_buffer == NULL)
492 return EOF; /* FIXME */
493 if (least_mark < 0)
495 #ifdef _LIBC
496 __wmempcpy (__wmempcpy (new_buffer + avail,
497 fp->_wide_data->_IO_save_end + least_mark,
498 -least_mark),
499 fp->_wide_data->_IO_read_base,
500 end_p - fp->_wide_data->_IO_read_base);
501 #else
502 memcpy (new_buffer + avail,
503 fp->_wide_data->_IO_save_end + least_mark,
504 -least_mark * sizeof (wchar_t));
505 memcpy (new_buffer + avail - least_mark,
506 fp->_wide_data->_IO_read_base,
507 (end_p - fp->_wide_data->_IO_read_base) * sizeof (wchar_t));
508 #endif
510 else
512 #ifdef _LIBC
513 __wmemcpy (new_buffer + avail,
514 fp->_wide_data->_IO_read_base + least_mark,
515 needed_size);
516 #else
517 memcpy (new_buffer + avail,
518 fp->_wide_data->_IO_read_base + least_mark,
519 needed_size * sizeof (wchar_t));
520 #endif
522 free (fp->_wide_data->_IO_save_base);
523 fp->_wide_data->_IO_save_base = new_buffer;
524 fp->_wide_data->_IO_save_end = new_buffer + avail + needed_size;
526 else
528 avail = current_Bsize - needed_size;
529 if (least_mark < 0)
531 #ifdef _LIBC
532 __wmemmove (fp->_wide_data->_IO_save_base + avail,
533 fp->_wide_data->_IO_save_end + least_mark,
534 -least_mark);
535 __wmemcpy (fp->_wide_data->_IO_save_base + avail - least_mark,
536 fp->_wide_data->_IO_read_base,
537 end_p - fp->_wide_data->_IO_read_base);
538 #else
539 memmove (fp->_wide_data->_IO_save_base + avail,
540 fp->_wide_data->_IO_save_end + least_mark,
541 -least_mark * sizeof (wchar_t));
542 memcpy (fp->_wide_data->_IO_save_base + avail - least_mark,
543 fp->_wide_data->_IO_read_base,
544 (end_p - fp->_wide_data->_IO_read_base) * sizeof (wchar_t));
545 #endif
547 else if (needed_size > 0)
548 #ifdef _LIBC
549 __wmemcpy (fp->_wide_data->_IO_save_base + avail,
550 fp->_wide_data->_IO_read_base + least_mark,
551 needed_size);
552 #else
553 memcpy (fp->_wide_data->_IO_save_base + avail,
554 fp->_wide_data->_IO_read_base + least_mark,
555 needed_size * sizeof (wchar_t));
556 #endif
558 fp->_wide_data->_IO_backup_base = fp->_wide_data->_IO_save_base + avail;
559 /* Adjust all the streammarkers. */
560 delta = end_p - fp->_wide_data->_IO_read_base;
561 for (mark = fp->_markers; mark != NULL; mark = mark->_next)
562 mark->_pos -= delta;
563 return 0;
566 wint_t
567 _IO_sputbackwc (_IO_FILE *fp, wint_t c)
569 wint_t result;
571 if (fp->_wide_data->_IO_read_ptr > fp->_wide_data->_IO_read_base
572 && (wchar_t)fp->_wide_data->_IO_read_ptr[-1] == (wchar_t) c)
574 fp->_wide_data->_IO_read_ptr--;
575 result = c;
577 else
578 result = _IO_PBACKFAIL (fp, c);
580 if (result != WEOF)
581 fp->_flags &= ~_IO_EOF_SEEN;
583 return result;
585 libc_hidden_def (_IO_sputbackwc)
587 wint_t
588 _IO_sungetwc (_IO_FILE *fp)
590 wint_t result;
592 if (fp->_wide_data->_IO_read_ptr > fp->_wide_data->_IO_read_base)
594 fp->_wide_data->_IO_read_ptr--;
595 result = *fp->_wide_data->_IO_read_ptr;
597 else
598 result = _IO_PBACKFAIL (fp, EOF);
600 if (result != WEOF)
601 fp->_flags &= ~_IO_EOF_SEEN;
603 return result;
607 unsigned
608 _IO_adjust_wcolumn (unsigned start, const wchar_t *line, int count)
610 const wchar_t *ptr = line + count;
611 while (ptr > line)
612 if (*--ptr == L'\n')
613 return line + count - ptr - 1;
614 return start + count;
617 void
618 _IO_init_wmarker (struct _IO_marker *marker, _IO_FILE *fp)
620 marker->_sbuf = fp;
621 if (_IO_in_put_mode (fp))
622 _IO_switch_to_wget_mode (fp);
623 if (_IO_in_backup (fp))
624 marker->_pos = fp->_wide_data->_IO_read_ptr - fp->_wide_data->_IO_read_end;
625 else
626 marker->_pos = (fp->_wide_data->_IO_read_ptr
627 - fp->_wide_data->_IO_read_base);
629 /* Should perhaps sort the chain? */
630 marker->_next = fp->_markers;
631 fp->_markers = marker;
634 #define BAD_DELTA EOF
636 /* Return difference between MARK and current position of MARK's stream. */
638 _IO_wmarker_delta (struct _IO_marker *mark)
640 int cur_pos;
641 if (mark->_sbuf == NULL)
642 return BAD_DELTA;
643 if (_IO_in_backup (mark->_sbuf))
644 cur_pos = (mark->_sbuf->_wide_data->_IO_read_ptr
645 - mark->_sbuf->_wide_data->_IO_read_end);
646 else
647 cur_pos = (mark->_sbuf->_wide_data->_IO_read_ptr
648 - mark->_sbuf->_wide_data->_IO_read_base);
649 return mark->_pos - cur_pos;
653 _IO_seekwmark (_IO_FILE *fp, struct _IO_marker *mark, int delta)
655 if (mark->_sbuf != fp)
656 return EOF;
657 if (mark->_pos >= 0)
659 if (_IO_in_backup (fp))
660 _IO_switch_to_main_wget_area (fp);
661 fp->_wide_data->_IO_read_ptr = (fp->_wide_data->_IO_read_base
662 + mark->_pos);
664 else
666 if (!_IO_in_backup (fp))
667 _IO_switch_to_wbackup_area (fp);
668 fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_end + mark->_pos;
670 return 0;
673 void
674 _IO_unsave_wmarkers (_IO_FILE *fp)
676 struct _IO_marker *mark = fp->_markers;
677 if (mark)
679 #ifdef TODO
680 streampos offset = seekoff (0, ios::cur, ios::in);
681 if (offset != EOF)
683 offset += eGptr () - Gbase ();
684 for ( ; mark != NULL; mark = mark->_next)
685 mark->set_streampos (mark->_pos + offset);
687 else
689 for ( ; mark != NULL; mark = mark->_next)
690 mark->set_streampos (EOF);
692 #endif
693 fp->_markers = 0;
696 if (_IO_have_backup (fp))
697 _IO_free_wbackup_area (fp);