Mercurial > hg > octave-kai > gnulib-hg
annotate lib/xstrtol.h @ 17249:e542fd46ad6f
maint: update all copyright year number ranges
Run "make update-copyright". Compare to commit 1602f0a from last year.
Signed-off-by: Eric Blake <eblake@redhat.com>
author | Eric Blake <eblake@redhat.com> |
---|---|
date | Tue, 01 Jan 2013 00:50:58 +0000 |
parents | 2e351049200b |
children |
rev | line source |
---|---|
3412
0053a9244567
* lib/xstrtol.h: Add copyright notice.
Jim Meyering <jim@meyering.net>
parents:
3379
diff
changeset
|
1 /* A more useful interface to strtol. |
4397
c6450308f123
Assume C89, so PARAMS isn't needed.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
2 |
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
17061
diff
changeset
|
3 Copyright (C) 1995-1996, 1998-1999, 2001-2004, 2006-2013 Free Software |
12518
b5e42ef33b49
update nearly all FSF copyright year lists to include 2009
Jim Meyering <meyering@redhat.com>
parents:
12421
diff
changeset
|
4 Foundation, Inc. |
3412
0053a9244567
* lib/xstrtol.h: Add copyright notice.
Jim Meyering <jim@meyering.net>
parents:
3379
diff
changeset
|
5 |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9143
diff
changeset
|
6 This program is free software: you can redistribute it and/or modify |
3412
0053a9244567
* lib/xstrtol.h: Add copyright notice.
Jim Meyering <jim@meyering.net>
parents:
3379
diff
changeset
|
7 it under the terms of the GNU General Public License as published by |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9143
diff
changeset
|
8 the Free Software Foundation; either version 3 of the License, or |
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9143
diff
changeset
|
9 (at your option) any later version. |
3412
0053a9244567
* lib/xstrtol.h: Add copyright notice.
Jim Meyering <jim@meyering.net>
parents:
3379
diff
changeset
|
10 |
0053a9244567
* lib/xstrtol.h: Add copyright notice.
Jim Meyering <jim@meyering.net>
parents:
3379
diff
changeset
|
11 This program is distributed in the hope that it will be useful, |
0053a9244567
* lib/xstrtol.h: Add copyright notice.
Jim Meyering <jim@meyering.net>
parents:
3379
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
0053a9244567
* lib/xstrtol.h: Add copyright notice.
Jim Meyering <jim@meyering.net>
parents:
3379
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
0053a9244567
* lib/xstrtol.h: Add copyright notice.
Jim Meyering <jim@meyering.net>
parents:
3379
diff
changeset
|
14 GNU General Public License for more details. |
0053a9244567
* lib/xstrtol.h: Add copyright notice.
Jim Meyering <jim@meyering.net>
parents:
3379
diff
changeset
|
15 |
0053a9244567
* lib/xstrtol.h: Add copyright notice.
Jim Meyering <jim@meyering.net>
parents:
3379
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
9309
bbbbbf4cd1c5
Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents:
9143
diff
changeset
|
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
3412
0053a9244567
* lib/xstrtol.h: Add copyright notice.
Jim Meyering <jim@meyering.net>
parents:
3379
diff
changeset
|
18 |
764 | 19 #ifndef XSTRTOL_H_ |
20 # define XSTRTOL_H_ 1 | |
366 | 21 |
9143
4290c9101f09
* NEWS: In xstrtol, remove STRTOL_FATAL_ERROR and add xstrtol_fatal.
Paul Eggert <eggert@cs.ucla.edu>
parents:
9141
diff
changeset
|
22 # include <getopt.h> |
7162
19c2e5121b2f
Add and change modules to make it easier for coreutils to use
Paul Eggert <eggert@cs.ucla.edu>
parents:
5848
diff
changeset
|
23 # include <inttypes.h> |
366 | 24 |
1170 | 25 # ifndef _STRTOL_ERROR |
366 | 26 enum strtol_error |
27 { | |
4788
33e8f958b651
Handle invalid suffixes and overflow independently, so that
Paul Eggert <eggert@cs.ucla.edu>
parents:
4397
diff
changeset
|
28 LONGINT_OK = 0, |
33e8f958b651
Handle invalid suffixes and overflow independently, so that
Paul Eggert <eggert@cs.ucla.edu>
parents:
4397
diff
changeset
|
29 |
33e8f958b651
Handle invalid suffixes and overflow independently, so that
Paul Eggert <eggert@cs.ucla.edu>
parents:
4397
diff
changeset
|
30 /* These two values can be ORed together, to indicate that both |
33e8f958b651
Handle invalid suffixes and overflow independently, so that
Paul Eggert <eggert@cs.ucla.edu>
parents:
4397
diff
changeset
|
31 errors occurred. */ |
33e8f958b651
Handle invalid suffixes and overflow independently, so that
Paul Eggert <eggert@cs.ucla.edu>
parents:
4397
diff
changeset
|
32 LONGINT_OVERFLOW = 1, |
33e8f958b651
Handle invalid suffixes and overflow independently, so that
Paul Eggert <eggert@cs.ucla.edu>
parents:
4397
diff
changeset
|
33 LONGINT_INVALID_SUFFIX_CHAR = 2, |
33e8f958b651
Handle invalid suffixes and overflow independently, so that
Paul Eggert <eggert@cs.ucla.edu>
parents:
4397
diff
changeset
|
34 |
33e8f958b651
Handle invalid suffixes and overflow independently, so that
Paul Eggert <eggert@cs.ucla.edu>
parents:
4397
diff
changeset
|
35 LONGINT_INVALID_SUFFIX_CHAR_WITH_OVERFLOW = (LONGINT_INVALID_SUFFIX_CHAR |
12421
e8d2c6fc33ad
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
9613
diff
changeset
|
36 | LONGINT_OVERFLOW), |
4788
33e8f958b651
Handle invalid suffixes and overflow independently, so that
Paul Eggert <eggert@cs.ucla.edu>
parents:
4397
diff
changeset
|
37 LONGINT_INVALID = 4 |
366 | 38 }; |
39 typedef enum strtol_error strtol_error; | |
1170 | 40 # endif |
366 | 41 |
1782
891c8561137d
(__xstrtol, __strtol, __unsigned): Remove macro decls.
Jim Meyering <jim@meyering.net>
parents:
1393
diff
changeset
|
42 # define _DECLARE_XSTRTOL(name, type) \ |
4397
c6450308f123
Assume C89, so PARAMS isn't needed.
Paul Eggert <eggert@cs.ucla.edu>
parents:
4132
diff
changeset
|
43 strtol_error name (const char *, char **, int, type *, const char *); |
1782
891c8561137d
(__xstrtol, __strtol, __unsigned): Remove macro decls.
Jim Meyering <jim@meyering.net>
parents:
1393
diff
changeset
|
44 _DECLARE_XSTRTOL (xstrtol, long int) |
891c8561137d
(__xstrtol, __strtol, __unsigned): Remove macro decls.
Jim Meyering <jim@meyering.net>
parents:
1393
diff
changeset
|
45 _DECLARE_XSTRTOL (xstrtoul, unsigned long int) |
3379 | 46 _DECLARE_XSTRTOL (xstrtoimax, intmax_t) |
1782
891c8561137d
(__xstrtol, __strtol, __unsigned): Remove macro decls.
Jim Meyering <jim@meyering.net>
parents:
1393
diff
changeset
|
47 _DECLARE_XSTRTOL (xstrtoumax, uintmax_t) |
366 | 48 |
12814 | 49 #if HAVE_LONG_LONG_INT |
50 _DECLARE_XSTRTOL (xstrtoll, long long int) | |
51 _DECLARE_XSTRTOL (xstrtoull, unsigned long long int) | |
52 #endif | |
53 | |
9143
4290c9101f09
* NEWS: In xstrtol, remove STRTOL_FATAL_ERROR and add xstrtol_fatal.
Paul Eggert <eggert@cs.ucla.edu>
parents:
9141
diff
changeset
|
54 /* Report an error for an invalid integer in an option argument. |
4290c9101f09
* NEWS: In xstrtol, remove STRTOL_FATAL_ERROR and add xstrtol_fatal.
Paul Eggert <eggert@cs.ucla.edu>
parents:
9141
diff
changeset
|
55 |
4290c9101f09
* NEWS: In xstrtol, remove STRTOL_FATAL_ERROR and add xstrtol_fatal.
Paul Eggert <eggert@cs.ucla.edu>
parents:
9141
diff
changeset
|
56 ERR is the error code returned by one of the xstrto* functions. |
366 | 57 |
9143
4290c9101f09
* NEWS: In xstrtol, remove STRTOL_FATAL_ERROR and add xstrtol_fatal.
Paul Eggert <eggert@cs.ucla.edu>
parents:
9141
diff
changeset
|
58 Use OPT_IDX to decide whether to print the short option string "C" |
4290c9101f09
* NEWS: In xstrtol, remove STRTOL_FATAL_ERROR and add xstrtol_fatal.
Paul Eggert <eggert@cs.ucla.edu>
parents:
9141
diff
changeset
|
59 or "-C" or a long option string derived from LONG_OPTION. OPT_IDX |
4290c9101f09
* NEWS: In xstrtol, remove STRTOL_FATAL_ERROR and add xstrtol_fatal.
Paul Eggert <eggert@cs.ucla.edu>
parents:
9141
diff
changeset
|
60 is -2 if the short option "C" was used, without any leading "-"; it |
4290c9101f09
* NEWS: In xstrtol, remove STRTOL_FATAL_ERROR and add xstrtol_fatal.
Paul Eggert <eggert@cs.ucla.edu>
parents:
9141
diff
changeset
|
61 is -1 if the short option "-C" was used; otherwise it is an index |
4290c9101f09
* NEWS: In xstrtol, remove STRTOL_FATAL_ERROR and add xstrtol_fatal.
Paul Eggert <eggert@cs.ucla.edu>
parents:
9141
diff
changeset
|
62 into LONG_OPTIONS, which should have a name preceded by two '-' |
4290c9101f09
* NEWS: In xstrtol, remove STRTOL_FATAL_ERROR and add xstrtol_fatal.
Paul Eggert <eggert@cs.ucla.edu>
parents:
9141
diff
changeset
|
63 characters. |
4290c9101f09
* NEWS: In xstrtol, remove STRTOL_FATAL_ERROR and add xstrtol_fatal.
Paul Eggert <eggert@cs.ucla.edu>
parents:
9141
diff
changeset
|
64 |
4290c9101f09
* NEWS: In xstrtol, remove STRTOL_FATAL_ERROR and add xstrtol_fatal.
Paul Eggert <eggert@cs.ucla.edu>
parents:
9141
diff
changeset
|
65 ARG is the option-argument containing the integer. |
4290c9101f09
* NEWS: In xstrtol, remove STRTOL_FATAL_ERROR and add xstrtol_fatal.
Paul Eggert <eggert@cs.ucla.edu>
parents:
9141
diff
changeset
|
66 |
4290c9101f09
* NEWS: In xstrtol, remove STRTOL_FATAL_ERROR and add xstrtol_fatal.
Paul Eggert <eggert@cs.ucla.edu>
parents:
9141
diff
changeset
|
67 After reporting an error, exit with a failure status. */ |
4290c9101f09
* NEWS: In xstrtol, remove STRTOL_FATAL_ERROR and add xstrtol_fatal.
Paul Eggert <eggert@cs.ucla.edu>
parents:
9141
diff
changeset
|
68 |
17061
2e351049200b
xstrtol.h: avoid "_Noreturn is not at beginning of declaration" warning
Jim Meyering <meyering@redhat.com>
parents:
16201
diff
changeset
|
69 _Noreturn void xstrtol_fatal (enum strtol_error, |
15412
7f0f3e1ac6fd
stdnoreturn, stdnoreturn-tests: remove modules
Paul Eggert <eggert@cs.ucla.edu>
parents:
15407
diff
changeset
|
70 int, char, struct option const *, |
7f0f3e1ac6fd
stdnoreturn, stdnoreturn-tests: remove modules
Paul Eggert <eggert@cs.ucla.edu>
parents:
15407
diff
changeset
|
71 char const *); |
373 | 72 |
764 | 73 #endif /* not XSTRTOL_H_ */ |