~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to lib/strtol.c

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Convert string representation of a number into an integer value.
2
2
 
3
 
   Copyright (C) 1991-1992, 1994-1999, 2003, 2005-2007, 2009-2011 Free Software
 
3
   Copyright (C) 1991-1992, 1994-1999, 2003, 2005-2007, 2009-2012 Free Software
4
4
   Foundation, Inc.
5
5
 
6
6
   NOTE: The canonical source of this file is maintained with the GNU C
40
40
# include "../locale/localeinfo.h"
41
41
#endif
42
42
 
43
 
/* Nonzero if we are defining `strtoul' or `strtoull', operating on
 
43
/* Nonzero if we are defining 'strtoul' or 'strtoull', operating on
44
44
   unsigned integers.  */
45
45
#ifndef UNSIGNED
46
46
# define UNSIGNED 0
110
110
# endif
111
111
#endif
112
112
 
113
 
/* If QUAD is defined, we are defining `strtoll' or `strtoull',
114
 
   operating on `long long int's.  */
 
113
/* If QUAD is defined, we are defining 'strtoll' or 'strtoull',
 
114
   operating on 'long long int's.  */
115
115
#ifdef QUAD
116
116
# define LONG long long
117
117
# define STRTOL_LONG_MIN LLONG_MIN
227
227
 
228
228
 
229
229
 
230
 
/* Convert NPTR to an `unsigned long int' or `long int' in base BASE.
 
230
/* Convert NPTR to an 'unsigned long int' or 'long int' in base BASE.
231
231
   If BASE is 0 the base is determined by the presence of a leading
232
232
   zero, indicating octal or a leading "0x" or "0X", indicating hexadecimal.
233
233
   If BASE is < 2 or > 36, it is reset to 10.
380
380
 
381
381
#if !UNSIGNED
382
382
  /* Check for a value that is within the range of
383
 
     `unsigned LONG int', but outside the range of `LONG int'.  */
 
383
     'unsigned LONG int', but outside the range of 'LONG int'.  */
384
384
  if (overflow == 0
385
385
      && i > (negative
386
386
              ? -((unsigned LONG int) (STRTOL_LONG_MIN + 1)) + 1
405
405
  /* We must handle a special case here: the base is 0 or 16 and the
406
406
     first two characters are '0' and 'x', but the rest are no
407
407
     hexadecimal digits.  This is no error case.  We return 0 and
408
 
     ENDPTR points to the `x`.  */
 
408
     ENDPTR points to the 'x'.  */
409
409
  if (endptr != NULL)
410
410
    {
411
411
      if (save - nptr >= 2 && TOUPPER (save[-1]) == L_('X')