Convert 113 more function definitions to prototype style (files with assertions).
[glibc.git] / libio / wgenops.c
blobe038f2c8bf638486a299e435c3f7c93c8e64a4ab
1 /* Copyright (C) 1993-2015 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 (fp, end_p)
473 _IO_FILE *fp;
474 wchar_t *end_p;
476 /* Append [_IO_read_base..end_p] to backup area. */
477 _IO_ssize_t least_mark = _IO_least_wmarker (fp, end_p);
478 /* needed_size is how much space we need in the backup area. */
479 _IO_size_t needed_size = ((end_p - fp->_wide_data->_IO_read_base)
480 - least_mark);
481 /* FIXME: Dubious arithmetic if pointers are NULL */
482 _IO_size_t current_Bsize = (fp->_wide_data->_IO_save_end
483 - fp->_wide_data->_IO_save_base);
484 _IO_size_t avail; /* Extra space available for future expansion. */
485 _IO_ssize_t delta;
486 struct _IO_marker *mark;
487 if (needed_size > current_Bsize)
489 wchar_t *new_buffer;
490 avail = 100;
491 new_buffer = (wchar_t *) malloc ((avail + needed_size)
492 * sizeof (wchar_t));
493 if (new_buffer == NULL)
494 return EOF; /* FIXME */
495 if (least_mark < 0)
497 #ifdef _LIBC
498 __wmempcpy (__wmempcpy (new_buffer + avail,
499 fp->_wide_data->_IO_save_end + least_mark,
500 -least_mark),
501 fp->_wide_data->_IO_read_base,
502 end_p - fp->_wide_data->_IO_read_base);
503 #else
504 memcpy (new_buffer + avail,
505 fp->_wide_data->_IO_save_end + least_mark,
506 -least_mark * sizeof (wchar_t));
507 memcpy (new_buffer + avail - least_mark,
508 fp->_wide_data->_IO_read_base,
509 (end_p - fp->_wide_data->_IO_read_base) * sizeof (wchar_t));
510 #endif
512 else
514 #ifdef _LIBC
515 __wmemcpy (new_buffer + avail,
516 fp->_wide_data->_IO_read_base + least_mark,
517 needed_size);
518 #else
519 memcpy (new_buffer + avail,
520 fp->_wide_data->_IO_read_base + least_mark,
521 needed_size * sizeof (wchar_t));
522 #endif
524 free (fp->_wide_data->_IO_save_base);
525 fp->_wide_data->_IO_save_base = new_buffer;
526 fp->_wide_data->_IO_save_end = new_buffer + avail + needed_size;
528 else
530 avail = current_Bsize - needed_size;
531 if (least_mark < 0)
533 #ifdef _LIBC
534 __wmemmove (fp->_wide_data->_IO_save_base + avail,
535 fp->_wide_data->_IO_save_end + least_mark,
536 -least_mark);
537 __wmemcpy (fp->_wide_data->_IO_save_base + avail - least_mark,
538 fp->_wide_data->_IO_read_base,
539 end_p - fp->_wide_data->_IO_read_base);
540 #else
541 memmove (fp->_wide_data->_IO_save_base + avail,
542 fp->_wide_data->_IO_save_end + least_mark,
543 -least_mark * sizeof (wchar_t));
544 memcpy (fp->_wide_data->_IO_save_base + avail - least_mark,
545 fp->_wide_data->_IO_read_base,
546 (end_p - fp->_wide_data->_IO_read_base) * sizeof (wchar_t));
547 #endif
549 else if (needed_size > 0)
550 #ifdef _LIBC
551 __wmemcpy (fp->_wide_data->_IO_save_base + avail,
552 fp->_wide_data->_IO_read_base + least_mark,
553 needed_size);
554 #else
555 memcpy (fp->_wide_data->_IO_save_base + avail,
556 fp->_wide_data->_IO_read_base + least_mark,
557 needed_size * sizeof (wchar_t));
558 #endif
560 fp->_wide_data->_IO_backup_base = fp->_wide_data->_IO_save_base + avail;
561 /* Adjust all the streammarkers. */
562 delta = end_p - fp->_wide_data->_IO_read_base;
563 for (mark = fp->_markers; mark != NULL; mark = mark->_next)
564 mark->_pos -= delta;
565 return 0;
568 wint_t
569 _IO_sputbackwc (_IO_FILE *fp, wint_t c)
571 wint_t result;
573 if (fp->_wide_data->_IO_read_ptr > fp->_wide_data->_IO_read_base
574 && (wchar_t)fp->_wide_data->_IO_read_ptr[-1] == (wchar_t) c)
576 fp->_wide_data->_IO_read_ptr--;
577 result = c;
579 else
580 result = _IO_PBACKFAIL (fp, c);
582 if (result != WEOF)
583 fp->_flags &= ~_IO_EOF_SEEN;
585 return result;
587 libc_hidden_def (_IO_sputbackwc)
589 wint_t
590 _IO_sungetwc (_IO_FILE *fp)
592 wint_t result;
594 if (fp->_wide_data->_IO_read_ptr > fp->_wide_data->_IO_read_base)
596 fp->_wide_data->_IO_read_ptr--;
597 result = *fp->_wide_data->_IO_read_ptr;
599 else
600 result = _IO_PBACKFAIL (fp, EOF);
602 if (result != WEOF)
603 fp->_flags &= ~_IO_EOF_SEEN;
605 return result;
609 unsigned
610 _IO_adjust_wcolumn (unsigned start, const wchar_t *line, int count)
612 const wchar_t *ptr = line + count;
613 while (ptr > line)
614 if (*--ptr == L'\n')
615 return line + count - ptr - 1;
616 return start + count;
619 void
620 _IO_init_wmarker (struct _IO_marker *marker, _IO_FILE *fp)
622 marker->_sbuf = fp;
623 if (_IO_in_put_mode (fp))
624 _IO_switch_to_wget_mode (fp);
625 if (_IO_in_backup (fp))
626 marker->_pos = fp->_wide_data->_IO_read_ptr - fp->_wide_data->_IO_read_end;
627 else
628 marker->_pos = (fp->_wide_data->_IO_read_ptr
629 - fp->_wide_data->_IO_read_base);
631 /* Should perhaps sort the chain? */
632 marker->_next = fp->_markers;
633 fp->_markers = marker;
636 #define BAD_DELTA EOF
638 /* Return difference between MARK and current position of MARK's stream. */
640 _IO_wmarker_delta (struct _IO_marker *mark)
642 int cur_pos;
643 if (mark->_sbuf == NULL)
644 return BAD_DELTA;
645 if (_IO_in_backup (mark->_sbuf))
646 cur_pos = (mark->_sbuf->_wide_data->_IO_read_ptr
647 - mark->_sbuf->_wide_data->_IO_read_end);
648 else
649 cur_pos = (mark->_sbuf->_wide_data->_IO_read_ptr
650 - mark->_sbuf->_wide_data->_IO_read_base);
651 return mark->_pos - cur_pos;
655 _IO_seekwmark (_IO_FILE *fp, struct _IO_marker *mark, int delta)
657 if (mark->_sbuf != fp)
658 return EOF;
659 if (mark->_pos >= 0)
661 if (_IO_in_backup (fp))
662 _IO_switch_to_main_wget_area (fp);
663 fp->_wide_data->_IO_read_ptr = (fp->_wide_data->_IO_read_base
664 + mark->_pos);
666 else
668 if (!_IO_in_backup (fp))
669 _IO_switch_to_wbackup_area (fp);
670 fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_end + mark->_pos;
672 return 0;
675 void
676 _IO_unsave_wmarkers (_IO_FILE *fp)
678 struct _IO_marker *mark = fp->_markers;
679 if (mark)
681 #ifdef TODO
682 streampos offset = seekoff (0, ios::cur, ios::in);
683 if (offset != EOF)
685 offset += eGptr () - Gbase ();
686 for ( ; mark != NULL; mark = mark->_next)
687 mark->set_streampos (mark->_pos + offset);
689 else
691 for ( ; mark != NULL; mark = mark->_next)
692 mark->set_streampos (EOF);
694 #endif
695 fp->_markers = 0;
698 if (_IO_have_backup (fp))
699 _IO_free_wbackup_area (fp);