Renamed from strtoxmax.c, removing the old strtoimax.c.
Also, make the following further changes to make this file's
configuration more similar to that of strtol.c:
(UNSIGNED): Renamed from STRTOUXMAX_UNSIGNED. All uses changed.
(strtoumax, uintmax_t, strtoull, strtol): Remove.
(intmax_t, strtoimax, strtol, strtoll): New macros, if UNSIGNED.
(strtoimax): Renamed from strtoumax. All uses of unsigned values
changed to signed values.
And make the following changes as well:
Fix copyright notice, as 1999 was missing.
(verify): New macro.
(strtoimax): Check sizes at compile-time, not run-time.
Prefer strtol to strtoll if both work.
(main): Remove; it was not that useful and was a pain to maintain.
2001-08-31 17:37:58 +08:00
|
|
|
/* Convert string representation of a number into an intmax_t value.
|
2004-08-03 06:50:47 +08:00
|
|
|
|
|
|
|
Copyright (C) 1999, 2001, 2002, 2003, 2004 Free Software
|
|
|
|
Foundation, Inc.
|
Renamed from strtoxmax.c, removing the old strtoimax.c.
Also, make the following further changes to make this file's
configuration more similar to that of strtol.c:
(UNSIGNED): Renamed from STRTOUXMAX_UNSIGNED. All uses changed.
(strtoumax, uintmax_t, strtoull, strtol): Remove.
(intmax_t, strtoimax, strtol, strtoll): New macros, if UNSIGNED.
(strtoimax): Renamed from strtoumax. All uses of unsigned values
changed to signed values.
And make the following changes as well:
Fix copyright notice, as 1999 was missing.
(verify): New macro.
(strtoimax): Check sizes at compile-time, not run-time.
Prefer strtol to strtoll if both work.
(main): Remove; it was not that useful and was a pain to maintain.
2001-08-31 17:37:58 +08:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software Foundation,
|
2005-05-14 15:58:06 +08:00
|
|
|
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
Renamed from strtoxmax.c, removing the old strtoimax.c.
Also, make the following further changes to make this file's
configuration more similar to that of strtol.c:
(UNSIGNED): Renamed from STRTOUXMAX_UNSIGNED. All uses changed.
(strtoumax, uintmax_t, strtoull, strtol): Remove.
(intmax_t, strtoimax, strtol, strtoll): New macros, if UNSIGNED.
(strtoimax): Renamed from strtoumax. All uses of unsigned values
changed to signed values.
And make the following changes as well:
Fix copyright notice, as 1999 was missing.
(verify): New macro.
(strtoimax): Check sizes at compile-time, not run-time.
Prefer strtol to strtoll if both work.
(main): Remove; it was not that useful and was a pain to maintain.
2001-08-31 17:37:58 +08:00
|
|
|
|
|
|
|
/* Written by Paul Eggert. */
|
|
|
|
|
2005-09-22 14:05:39 +08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
Renamed from strtoxmax.c, removing the old strtoimax.c.
Also, make the following further changes to make this file's
configuration more similar to that of strtol.c:
(UNSIGNED): Renamed from STRTOUXMAX_UNSIGNED. All uses changed.
(strtoumax, uintmax_t, strtoull, strtol): Remove.
(intmax_t, strtoimax, strtol, strtoll): New macros, if UNSIGNED.
(strtoimax): Renamed from strtoumax. All uses of unsigned values
changed to signed values.
And make the following changes as well:
Fix copyright notice, as 1999 was missing.
(verify): New macro.
(strtoimax): Check sizes at compile-time, not run-time.
Prefer strtol to strtoll if both work.
(main): Remove; it was not that useful and was a pain to maintain.
2001-08-31 17:37:58 +08:00
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAVE_INTTYPES_H
|
|
|
|
# include <inttypes.h>
|
2004-08-03 06:50:29 +08:00
|
|
|
#endif
|
|
|
|
#if HAVE_STDINT_H
|
2003-06-07 06:30:28 +08:00
|
|
|
# include <stdint.h>
|
Renamed from strtoxmax.c, removing the old strtoimax.c.
Also, make the following further changes to make this file's
configuration more similar to that of strtol.c:
(UNSIGNED): Renamed from STRTOUXMAX_UNSIGNED. All uses changed.
(strtoumax, uintmax_t, strtoull, strtol): Remove.
(intmax_t, strtoimax, strtol, strtoll): New macros, if UNSIGNED.
(strtoimax): Renamed from strtoumax. All uses of unsigned values
changed to signed values.
And make the following changes as well:
Fix copyright notice, as 1999 was missing.
(verify): New macro.
(strtoimax): Check sizes at compile-time, not run-time.
Prefer strtol to strtoll if both work.
(main): Remove; it was not that useful and was a pain to maintain.
2001-08-31 17:37:58 +08:00
|
|
|
#endif
|
|
|
|
|
2003-09-14 06:01:20 +08:00
|
|
|
#include <stdlib.h>
|
Renamed from strtoxmax.c, removing the old strtoimax.c.
Also, make the following further changes to make this file's
configuration more similar to that of strtol.c:
(UNSIGNED): Renamed from STRTOUXMAX_UNSIGNED. All uses changed.
(strtoumax, uintmax_t, strtoull, strtol): Remove.
(intmax_t, strtoimax, strtol, strtoll): New macros, if UNSIGNED.
(strtoimax): Renamed from strtoumax. All uses of unsigned values
changed to signed values.
And make the following changes as well:
Fix copyright notice, as 1999 was missing.
(verify): New macro.
(strtoimax): Check sizes at compile-time, not run-time.
Prefer strtol to strtoll if both work.
(main): Remove; it was not that useful and was a pain to maintain.
2001-08-31 17:37:58 +08:00
|
|
|
|
|
|
|
/* Verify a requirement at compile-time (unlike assert, which is runtime). */
|
|
|
|
#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
|
|
|
|
|
|
|
|
#ifdef UNSIGNED
|
|
|
|
# ifndef HAVE_DECL_STRTOULL
|
|
|
|
"this configure-time declaration test was not run"
|
|
|
|
# endif
|
|
|
|
# if !HAVE_DECL_STRTOULL && HAVE_UNSIGNED_LONG_LONG
|
2003-06-18 15:57:26 +08:00
|
|
|
unsigned long long strtoull (char const *, char **, int);
|
Renamed from strtoxmax.c, removing the old strtoimax.c.
Also, make the following further changes to make this file's
configuration more similar to that of strtol.c:
(UNSIGNED): Renamed from STRTOUXMAX_UNSIGNED. All uses changed.
(strtoumax, uintmax_t, strtoull, strtol): Remove.
(intmax_t, strtoimax, strtol, strtoll): New macros, if UNSIGNED.
(strtoimax): Renamed from strtoumax. All uses of unsigned values
changed to signed values.
And make the following changes as well:
Fix copyright notice, as 1999 was missing.
(verify): New macro.
(strtoimax): Check sizes at compile-time, not run-time.
Prefer strtol to strtoll if both work.
(main): Remove; it was not that useful and was a pain to maintain.
2001-08-31 17:37:58 +08:00
|
|
|
# endif
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
# ifndef HAVE_DECL_STRTOLL
|
|
|
|
"this configure-time declaration test was not run"
|
|
|
|
# endif
|
|
|
|
# if !HAVE_DECL_STRTOLL && HAVE_UNSIGNED_LONG_LONG
|
2003-06-18 15:57:26 +08:00
|
|
|
long long strtoll (char const *, char **, int);
|
Renamed from strtoxmax.c, removing the old strtoimax.c.
Also, make the following further changes to make this file's
configuration more similar to that of strtol.c:
(UNSIGNED): Renamed from STRTOUXMAX_UNSIGNED. All uses changed.
(strtoumax, uintmax_t, strtoull, strtol): Remove.
(intmax_t, strtoimax, strtol, strtoll): New macros, if UNSIGNED.
(strtoimax): Renamed from strtoumax. All uses of unsigned values
changed to signed values.
And make the following changes as well:
Fix copyright notice, as 1999 was missing.
(verify): New macro.
(strtoimax): Check sizes at compile-time, not run-time.
Prefer strtol to strtoll if both work.
(main): Remove; it was not that useful and was a pain to maintain.
2001-08-31 17:37:58 +08:00
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef UNSIGNED
|
2001-09-17 18:24:20 +08:00
|
|
|
# undef HAVE_LONG_LONG
|
|
|
|
# define HAVE_LONG_LONG HAVE_UNSIGNED_LONG_LONG
|
Renamed from strtoxmax.c, removing the old strtoimax.c.
Also, make the following further changes to make this file's
configuration more similar to that of strtol.c:
(UNSIGNED): Renamed from STRTOUXMAX_UNSIGNED. All uses changed.
(strtoumax, uintmax_t, strtoull, strtol): Remove.
(intmax_t, strtoimax, strtol, strtoll): New macros, if UNSIGNED.
(strtoimax): Renamed from strtoumax. All uses of unsigned values
changed to signed values.
And make the following changes as well:
Fix copyright notice, as 1999 was missing.
(verify): New macro.
(strtoimax): Check sizes at compile-time, not run-time.
Prefer strtol to strtoll if both work.
(main): Remove; it was not that useful and was a pain to maintain.
2001-08-31 17:37:58 +08:00
|
|
|
# define INT uintmax_t
|
|
|
|
# define strtoimax strtoumax
|
|
|
|
# define strtol strtoul
|
|
|
|
# define strtoll strtoull
|
|
|
|
#else
|
|
|
|
# define INT intmax_t
|
|
|
|
#endif
|
|
|
|
|
|
|
|
INT
|
|
|
|
strtoimax (char const *ptr, char **endptr, int base)
|
|
|
|
{
|
2001-09-17 18:24:20 +08:00
|
|
|
#if HAVE_LONG_LONG
|
Renamed from strtoxmax.c, removing the old strtoimax.c.
Also, make the following further changes to make this file's
configuration more similar to that of strtol.c:
(UNSIGNED): Renamed from STRTOUXMAX_UNSIGNED. All uses changed.
(strtoumax, uintmax_t, strtoull, strtol): Remove.
(intmax_t, strtoimax, strtol, strtoll): New macros, if UNSIGNED.
(strtoimax): Renamed from strtoumax. All uses of unsigned values
changed to signed values.
And make the following changes as well:
Fix copyright notice, as 1999 was missing.
(verify): New macro.
(strtoimax): Check sizes at compile-time, not run-time.
Prefer strtol to strtoll if both work.
(main): Remove; it was not that useful and was a pain to maintain.
2001-08-31 17:37:58 +08:00
|
|
|
verify (size_is_that_of_long_or_long_long,
|
2004-08-03 06:50:29 +08:00
|
|
|
(sizeof (INT) == sizeof (long int)
|
|
|
|
|| sizeof (INT) == sizeof (long long int)));
|
Renamed from strtoxmax.c, removing the old strtoimax.c.
Also, make the following further changes to make this file's
configuration more similar to that of strtol.c:
(UNSIGNED): Renamed from STRTOUXMAX_UNSIGNED. All uses changed.
(strtoumax, uintmax_t, strtoull, strtol): Remove.
(intmax_t, strtoimax, strtol, strtoll): New macros, if UNSIGNED.
(strtoimax): Renamed from strtoumax. All uses of unsigned values
changed to signed values.
And make the following changes as well:
Fix copyright notice, as 1999 was missing.
(verify): New macro.
(strtoimax): Check sizes at compile-time, not run-time.
Prefer strtol to strtoll if both work.
(main): Remove; it was not that useful and was a pain to maintain.
2001-08-31 17:37:58 +08:00
|
|
|
|
2004-08-03 06:50:29 +08:00
|
|
|
if (sizeof (INT) != sizeof (long int))
|
Renamed from strtoxmax.c, removing the old strtoimax.c.
Also, make the following further changes to make this file's
configuration more similar to that of strtol.c:
(UNSIGNED): Renamed from STRTOUXMAX_UNSIGNED. All uses changed.
(strtoumax, uintmax_t, strtoull, strtol): Remove.
(intmax_t, strtoimax, strtol, strtoll): New macros, if UNSIGNED.
(strtoimax): Renamed from strtoumax. All uses of unsigned values
changed to signed values.
And make the following changes as well:
Fix copyright notice, as 1999 was missing.
(verify): New macro.
(strtoimax): Check sizes at compile-time, not run-time.
Prefer strtol to strtoll if both work.
(main): Remove; it was not that useful and was a pain to maintain.
2001-08-31 17:37:58 +08:00
|
|
|
return strtoll (ptr, endptr, base);
|
|
|
|
#else
|
|
|
|
verify (size_is_that_of_long,
|
2004-08-03 06:50:29 +08:00
|
|
|
sizeof (INT) == sizeof (long int));
|
Renamed from strtoxmax.c, removing the old strtoimax.c.
Also, make the following further changes to make this file's
configuration more similar to that of strtol.c:
(UNSIGNED): Renamed from STRTOUXMAX_UNSIGNED. All uses changed.
(strtoumax, uintmax_t, strtoull, strtol): Remove.
(intmax_t, strtoimax, strtol, strtoll): New macros, if UNSIGNED.
(strtoimax): Renamed from strtoumax. All uses of unsigned values
changed to signed values.
And make the following changes as well:
Fix copyright notice, as 1999 was missing.
(verify): New macro.
(strtoimax): Check sizes at compile-time, not run-time.
Prefer strtol to strtoll if both work.
(main): Remove; it was not that useful and was a pain to maintain.
2001-08-31 17:37:58 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return strtol (ptr, endptr, base);
|
|
|
|
}
|