~ubuntu-branches/ubuntu/utopic/eglibc/utopic

« back to all changes in this revision

Viewing changes to libio/wgenops.c

  • Committer: Package Import Robot
  • Author(s): Adam Conrad
  • Date: 2012-10-26 05:14:58 UTC
  • mfrom: (1.5.1) (4.4.22 experimental)
  • Revision ID: package-import@ubuntu.com-20121026051458-oryotr4i03ob5pab
Tags: 2.16-0ubuntu1
* Merge with unreleased 2.16 in Debian experimental, remaining changes:
  - Drop the Breaks line from libc6, which refers to a Debian transition
  - Remove the libc6 recommends on libc6-i686, which we don't build
  - Enable libc6{,-dev}-armel on armhf and libc6{-dev}-armhf on armel
  - Ship update-locale and validlocale in /usr/sbin in libc-bin
  - Don't build locales or locales-all in Ubuntu, we rely on langpacks
  - Heavily mangle the way we do service restarting on major upgrades
  - Use different MIN_KERNEL_SUPPORTED versions than Debian, due to
    buildd needs.  This should be universally bumped to 3.2.0 once all
    our buildds (including the PPA guests) are running precise kernels
  - Build i386 variants as -march=i686, build amd64 with -O3, and build
    ppc64 variants (both 64-bit and 32-bit) with -O3 -fno-tree-vectorize
  - Re-enable unsubmitted-ldconfig-cache-abi.diff and rebuild the cache
    on upgrades from previous versions that used a different constant
  - debian/patches/any/local-CVE-2012-3406.diff: switch to malloc when
    array grows too large to handle via alloca extension (CVE-2012-3406)
  - Build generic i386/i686 flavour with -mno-tls-direct-seg-refs
* Changes added/dropped with this merge while reducing our delta:
  - Stop building glibc docs from the eglibc source, and instead make
    the glibc-docs stub have a hard dependency on glibc-doc-reference
  - Remove outdated conflicts against ancient versions of ia32-libs
  - Drop the tzdata dependency from libc6, it's in required and minimal
  - Use gcc-4.7/g++-4.7 by default on all our supported architectures
  - Save our historical changelog as changelog.ubuntu in the source
  - Drop nscd's libaudit build-dep for now, as libaudit is in universe
  - Drop the unnecessary Breaks from libc6 to locales and locales-all
  - Ship xen's ld.so.conf.d snippet as /etc/ld.so.conf.d/libc6-xen.conf
* Disable hard failures on the test suite for the first upload to raring

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 1993,1995,1997-2002,2004,2006 Free Software Foundation, Inc.
 
1
/* Copyright (C) 1993-2012 Free Software Foundation, Inc.
2
2
   This file is part of the GNU C Library.
3
3
   Written by Ulrich Drepper <drepper@cygnus.com>.
4
4
   Based on the single byte version by Per Bothner <bothner@cygnus.com>.
14
14
   Lesser General Public License for more details.
15
15
 
16
16
   You should have received a copy of the GNU Lesser General Public
17
 
   License along with the GNU C Library; if not, write to the Free
18
 
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19
 
   02111-1307 USA.
 
17
   License along with the GNU C Library; if not, see
 
18
   <http://www.gnu.org/licenses/>.
20
19
 
21
20
   As a special exception, if you link the code in this file with
22
21
   files compiled with a GNU compiler to produce an executable,
30
29
/* Generic or default I/O operations. */
31
30
 
32
31
#include "libioP.h"
33
 
#ifdef __STDC__
34
32
#include <stdlib.h>
35
 
#endif
36
33
#include <string.h>
37
34
#include <wchar.h>
38
35
 
50
47
 
51
48
/* Return minimum _pos markers
52
49
   Assumes the current get area is the main get area. */
53
 
_IO_ssize_t _IO_least_wmarker (_IO_FILE *fp, wchar_t *end_p) __THROW;
54
 
 
55
50
_IO_ssize_t
56
51
_IO_least_wmarker (fp, end_p)
57
52
     _IO_FILE *fp;
64
59
      least_so_far = mark->_pos;
65
60
  return least_so_far;
66
61
}
67
 
INTDEF(_IO_least_wmarker)
 
62
libc_hidden_def (_IO_least_wmarker)
68
63
 
69
64
/* Switch current get area from backup buffer to (start of) main get area. */
70
65
void
84
79
  /* Set _IO_read_ptr. */
85
80
  fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_base;
86
81
}
87
 
INTDEF(_IO_switch_to_main_wget_area)
 
82
libc_hidden_def (_IO_switch_to_main_wget_area)
88
83
 
89
84
 
90
85
/* Switch current get area from main get area to (end of) backup area. */
105
100
  /* Set _IO_read_ptr.  */
106
101
  fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_end;
107
102
}
108
 
INTDEF(_IO_switch_to_wbackup_area)
 
103
libc_hidden_def (_IO_switch_to_wbackup_area)
109
104
 
110
105
 
111
106
void
124
119
  else
125
120
    f->_flags2 |= _IO_FLAGS2_USER_WBUF;
126
121
}
127
 
INTDEF(_IO_wsetb)
 
122
libc_hidden_def (_IO_wsetb)
128
123
 
129
124
 
130
125
wint_t
164
159
              fp->_wide_data->_IO_backup_base = fp->_wide_data->_IO_save_end;
165
160
            }
166
161
          fp->_wide_data->_IO_read_base = fp->_wide_data->_IO_read_ptr;
167
 
          INTUSE(_IO_switch_to_wbackup_area) (fp);
 
162
          _IO_switch_to_wbackup_area (fp);
168
163
        }
169
164
      else if (fp->_wide_data->_IO_read_ptr <= fp->_wide_data->_IO_read_base)
170
165
        {
189
184
    }
190
185
  return c;
191
186
}
192
 
INTDEF(_IO_wdefault_pbackfail)
 
187
libc_hidden_def (_IO_wdefault_pbackfail)
193
188
 
194
189
 
195
190
void
219
214
    _IO_lock_fini (*fp->_lock);
220
215
#endif
221
216
 
222
 
  INTUSE(_IO_un_link) ((struct _IO_FILE_plus *) fp);
 
217
  _IO_un_link ((struct _IO_FILE_plus *) fp);
223
218
}
224
 
INTDEF(_IO_wdefault_finish)
 
219
libc_hidden_def (_IO_wdefault_finish)
225
220
 
226
221
 
227
222
wint_t
234
229
    return WEOF;
235
230
  return *fp->_wide_data->_IO_read_ptr++;
236
231
}
237
 
INTDEF(_IO_wdefault_uflow)
 
232
libc_hidden_def (_IO_wdefault_uflow)
238
233
 
239
234
 
240
235
wint_t
259
254
  if (fp->_mode == 0)
260
255
    _IO_fwide (fp, 1);
261
256
  if (_IO_in_put_mode (fp))
262
 
    if (INTUSE(_IO_switch_to_wget_mode) (fp) == EOF)
 
257
    if (_IO_switch_to_wget_mode (fp) == EOF)
263
258
      return WEOF;
264
259
  if (fp->_wide_data->_IO_read_ptr < fp->_wide_data->_IO_read_end)
265
260
    return *fp->_wide_data->_IO_read_ptr++;
266
261
  if (_IO_in_backup (fp))
267
262
    {
268
 
      INTUSE(_IO_switch_to_main_wget_area) (fp);
 
263
      _IO_switch_to_main_wget_area (fp);
269
264
      if (fp->_wide_data->_IO_read_ptr < fp->_wide_data->_IO_read_end)
270
265
        return *fp->_wide_data->_IO_read_ptr++;
271
266
    }
275
270
        return WEOF;
276
271
    }
277
272
  else if (_IO_have_wbackup (fp))
278
 
    INTUSE(_IO_free_wbackup_area) (fp);
 
273
    _IO_free_wbackup_area (fp);
279
274
  return _IO_UFLOW (fp);
280
275
}
281
276
libc_hidden_def (__wuflow)
290
285
  if (fp->_mode == 0)
291
286
    _IO_fwide (fp, 1);
292
287
  if (_IO_in_put_mode (fp))
293
 
    if (INTUSE(_IO_switch_to_wget_mode) (fp) == EOF)
 
288
    if (_IO_switch_to_wget_mode (fp) == EOF)
294
289
      return WEOF;
295
290
  if (fp->_wide_data->_IO_read_ptr < fp->_wide_data->_IO_read_end)
296
291
    return *fp->_wide_data->_IO_read_ptr;
297
292
  if (_IO_in_backup (fp))
298
293
    {
299
 
      INTUSE(_IO_switch_to_main_wget_area) (fp);
 
294
      _IO_switch_to_main_wget_area (fp);
300
295
      if (fp->_wide_data->_IO_read_ptr < fp->_wide_data->_IO_read_end)
301
296
        return *fp->_wide_data->_IO_read_ptr;
302
297
    }
306
301
        return WEOF;
307
302
    }
308
303
  else if (_IO_have_backup (fp))
309
 
    INTUSE(_IO_free_wbackup_area) (fp);
 
304
    _IO_free_wbackup_area (fp);
310
305
  return _IO_UNDERFLOW (fp);
311
306
}
312
307
libc_hidden_def (__wunderflow)
360
355
    }
361
356
  return n - more;
362
357
}
363
 
INTDEF(_IO_wdefault_xsputn)
 
358
libc_hidden_def (_IO_wdefault_xsputn)
364
359
 
365
360
 
366
361
_IO_size_t
407
402
    }
408
403
  return n - more;
409
404
}
410
 
INTDEF(_IO_wdefault_xsgetn)
 
405
libc_hidden_def (_IO_wdefault_xsgetn)
411
406
 
412
407
 
413
408
void
419
414
  if (!(fp->_flags & _IO_UNBUFFERED))
420
415
    if ((wint_t)_IO_WDOALLOCATE (fp) != WEOF)
421
416
      return;
422
 
  INTUSE(_IO_wsetb) (fp, fp->_wide_data->_shortbuf,
 
417
  _IO_wsetb (fp, fp->_wide_data->_shortbuf,
423
418
                     fp->_wide_data->_shortbuf + 1, 0);
424
419
}
425
 
INTDEF(_IO_wdoallocbuf)
 
420
libc_hidden_def (_IO_wdoallocbuf)
426
421
 
427
422
 
428
423
int
432
427
  wchar_t *buf;
433
428
 
434
429
  ALLOC_WBUF (buf, _IO_BUFSIZ, EOF);
435
 
  INTUSE(_IO_wsetb) (fp, buf, buf + _IO_BUFSIZ, 1);
 
430
  _IO_wsetb (fp, buf, buf + _IO_BUFSIZ, 1);
436
431
  return 1;
437
432
}
438
 
INTDEF(_IO_wdefault_doallocate)
 
433
libc_hidden_def (_IO_wdefault_doallocate)
439
434
 
440
435
 
441
436
int
461
456
  fp->_flags &= ~_IO_CURRENTLY_PUTTING;
462
457
  return 0;
463
458
}
464
 
INTDEF(_IO_switch_to_wget_mode)
 
459
libc_hidden_def (_IO_switch_to_wget_mode)
465
460
 
466
461
void
467
462
_IO_free_wbackup_area (fp)
468
463
     _IO_FILE *fp;
469
464
{
470
465
  if (_IO_in_backup (fp))
471
 
    INTUSE(_IO_switch_to_main_wget_area) (fp);  /* Just in case. */
 
466
    _IO_switch_to_main_wget_area (fp);  /* Just in case. */
472
467
  free (fp->_wide_data->_IO_save_base);
473
468
  fp->_wide_data->_IO_save_base = NULL;
474
469
  fp->_wide_data->_IO_save_end = NULL;
475
470
  fp->_wide_data->_IO_backup_base = NULL;
476
471
}
477
 
INTDEF(_IO_free_wbackup_area)
 
472
libc_hidden_def (_IO_free_wbackup_area)
478
473
 
479
474
#if 0
480
475
int
506
501
     wchar_t *end_p;
507
502
{
508
503
  /* Append [_IO_read_base..end_p] to backup area. */
509
 
  _IO_ssize_t least_mark = INTUSE(_IO_least_wmarker) (fp, end_p);
 
504
  _IO_ssize_t least_mark = _IO_least_wmarker (fp, end_p);
510
505
  /* needed_size is how much space we need in the backup area. */
511
506
  _IO_size_t needed_size = ((end_p - fp->_wide_data->_IO_read_base)
512
507
                            - least_mark);
618
613
 
619
614
  return result;
620
615
}
621
 
INTDEF(_IO_sputbackwc)
 
616
libc_hidden_def (_IO_sputbackwc)
622
617
 
623
618
wint_t
624
619
_IO_sungetwc (fp)
661
656
{
662
657
  marker->_sbuf = fp;
663
658
  if (_IO_in_put_mode (fp))
664
 
    INTUSE(_IO_switch_to_wget_mode) (fp);
 
659
    _IO_switch_to_wget_mode (fp);
665
660
  if (_IO_in_backup (fp))
666
661
    marker->_pos = fp->_wide_data->_IO_read_ptr - fp->_wide_data->_IO_read_end;
667
662
  else
703
698
 if (mark->_pos >= 0)
704
699
    {
705
700
      if (_IO_in_backup (fp))
706
 
        INTUSE(_IO_switch_to_main_wget_area) (fp);
 
701
        _IO_switch_to_main_wget_area (fp);
707
702
      fp->_wide_data->_IO_read_ptr = (fp->_wide_data->_IO_read_base
708
703
                                      + mark->_pos);
709
704
    }
710
705
  else
711
706
    {
712
707
      if (!_IO_in_backup (fp))
713
 
        INTUSE(_IO_switch_to_wbackup_area) (fp);
 
708
        _IO_switch_to_wbackup_area (fp);
714
709
      fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_end + mark->_pos;
715
710
    }
716
711
  return 0;
741
736
    }
742
737
 
743
738
  if (_IO_have_backup (fp))
744
 
    INTUSE(_IO_free_wbackup_area) (fp);
 
739
    _IO_free_wbackup_area (fp);
745
740
}