~ubuntu-branches/ubuntu/gutsy/findutils/gutsy-proposed

« back to all changes in this revision

Viewing changes to gnulib/lib/strtoimax.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Metzler
  • Date: 2005-07-04 11:37:37 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050704113737-ll89ui8be35r0pir
Tags: 4.2.22-2
* Remove locatedb on purge. (Closes: #315343)
* revert regex-syntax back to emacs-re. (Closes: #315136) Future versions
  will allow to select this by commandline parameter.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Convert string representation of a number into an intmax_t value.
2
 
   Copyright 1999, 2001, 2002 Free Software Foundation, Inc.
 
2
 
 
3
   Copyright (C) 1999, 2001, 2002, 2003, 2004 Free Software
 
4
   Foundation, Inc.
3
5
 
4
6
   This program is free software; you can redistribute it and/or modify
5
7
   it under the terms of the GNU General Public License as published by
13
15
 
14
16
   You should have received a copy of the GNU General Public License
15
17
   along with this program; if not, write to the Free Software Foundation,
16
 
   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
18
   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
17
19
 
18
20
/* Written by Paul Eggert. */
19
21
 
23
25
 
24
26
#if HAVE_INTTYPES_H
25
27
# include <inttypes.h>
26
 
#else
27
 
# if HAVE_STDINT_H
28
 
#  include <stdint.h>
29
 
# endif
30
 
#endif
31
 
 
32
 
#if HAVE_STDLIB_H
33
 
# include <stdlib.h>
34
 
#endif
35
 
 
36
 
#ifndef PARAMS
37
 
# if defined PROTOTYPES || defined __STDC__
38
 
#  define PARAMS(Args) Args
39
 
# else
40
 
#  define PARAMS(Args) ()
41
 
# endif
42
 
#endif
 
28
#endif
 
29
#if HAVE_STDINT_H
 
30
# include <stdint.h>
 
31
#endif
 
32
 
 
33
#include <stdlib.h>
43
34
 
44
35
/* Verify a requirement at compile-time (unlike assert, which is runtime).  */
45
36
#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
46
37
 
47
38
#ifdef UNSIGNED
48
 
# ifndef HAVE_DECL_STRTOUL
49
 
"this configure-time declaration test was not run"
50
 
# endif
51
 
# if !HAVE_DECL_STRTOUL
52
 
unsigned long strtoul PARAMS ((char const *, char **, int));
53
 
# endif
54
39
# ifndef HAVE_DECL_STRTOULL
55
40
"this configure-time declaration test was not run"
56
41
# endif
57
42
# if !HAVE_DECL_STRTOULL && HAVE_UNSIGNED_LONG_LONG
58
 
unsigned long long strtoull PARAMS ((char const *, char **, int));
 
43
unsigned long long strtoull (char const *, char **, int);
59
44
# endif
60
45
 
61
46
#else
62
47
 
63
 
# ifndef HAVE_DECL_STRTOL
64
 
"this configure-time declaration test was not run"
65
 
# endif
66
 
# if !HAVE_DECL_STRTOL
67
 
long strtol PARAMS ((char const *, char **, int));
68
 
# endif
69
48
# ifndef HAVE_DECL_STRTOLL
70
49
"this configure-time declaration test was not run"
71
50
# endif
72
51
# if !HAVE_DECL_STRTOLL && HAVE_UNSIGNED_LONG_LONG
73
 
long long strtoll PARAMS ((char const *, char **, int));
 
52
long long strtoll (char const *, char **, int);
74
53
# endif
75
54
#endif
76
55
 
90
69
{
91
70
#if HAVE_LONG_LONG
92
71
  verify (size_is_that_of_long_or_long_long,
93
 
          (sizeof (INT) == sizeof (long)
94
 
           || sizeof (INT) == sizeof (long long)));
 
72
          (sizeof (INT) == sizeof (long int)
 
73
           || sizeof (INT) == sizeof (long long int)));
95
74
 
96
 
  if (sizeof (INT) != sizeof (long))
 
75
  if (sizeof (INT) != sizeof (long int))
97
76
    return strtoll (ptr, endptr, base);
98
77
#else
99
78
  verify (size_is_that_of_long,
100
 
          sizeof (INT) == sizeof (long));
 
79
          sizeof (INT) == sizeof (long int));
101
80
#endif
102
81
 
103
82
  return strtol (ptr, endptr, base);