source: trunk/diffutils/lib/strtol.c@ 2745

Last change on this file since 2745 was 2556, checked in by bird, 20 years ago

diffutils 2.8.1

File size: 11.2 KB
Line 
1/* Convert string representation of a number into an integer value.
2 Copyright (C) 1991, 92, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
3 NOTE: The canonical source of this file is maintained with the GNU C
4 Library. Bugs can be reported to [email protected].
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version.
10
11 This program 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
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software Foundation,
18 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19
20#if HAVE_CONFIG_H
21# include <config.h>
22#endif
23
24#ifdef _LIBC
25# define USE_NUMBER_GROUPING
26# define STDC_HEADERS
27# define HAVE_LIMITS_H
28#endif
29
30#include <ctype.h>
31#include <errno.h>
32#ifndef errno
33extern int errno;
34#endif
35#ifndef __set_errno
36# define __set_errno(Val) errno = (Val)
37#endif
38
39#ifdef HAVE_LIMITS_H
40# include <limits.h>
41#endif
42
43#ifdef STDC_HEADERS
44# include <stddef.h>
45# include <stdlib.h>
46# include <string.h>
47#else
48# ifndef NULL
49# define NULL 0
50# endif
51#endif
52
53#ifdef USE_NUMBER_GROUPING
54# include "../locale/localeinfo.h"
55#endif
56
57/* Nonzero if we are defining `strtoul' or `strtoull', operating on
58 unsigned integers. */
59#ifndef UNSIGNED
60# define UNSIGNED 0
61# define INT LONG int
62#else
63# define INT unsigned LONG int
64#endif
65
66/* Determine the name. */
67#ifdef USE_IN_EXTENDED_LOCALE_MODEL
68# if UNSIGNED
69# ifdef USE_WIDE_CHAR
70# ifdef QUAD
71# define strtol __wcstoull_l
72# else
73# define strtol __wcstoul_l
74# endif
75# else
76# ifdef QUAD
77# define strtol __strtoull_l
78# else
79# define strtol __strtoul_l
80# endif
81# endif
82# else