Mercurial > hg > octave-shane > gnulib-hg
annotate lib/xstrtol.h @ 1393:942e099ca5e1
(__ZLONG_MAX): Remove.
author | Jim Meyering <jim@meyering.net> |
---|---|
date | Mon, 29 Jun 1998 15:24:15 +0000 |
parents | 8de2d981b46f |
children | 891c8561137d |
rev | line source |
---|---|
764 | 1 #ifndef XSTRTOL_H_ |
2 # define XSTRTOL_H_ 1 | |
366 | 3 |
760 | 4 # if STRING_TO_UNSIGNED |
5 # define __xstrtol xstrtoul | |
6 # define __strtol strtoul | |
7 # define __unsigned unsigned | |
8 # else | |
9 # define __xstrtol xstrtol | |
10 # define __strtol strtol | |
11 # define __unsigned /* empty */ | |
12 # endif | |
366 | 13 |
1170 | 14 # ifndef PARAMS |
15 # if defined PROTOTYPES || (defined __STDC__ && __STDC__) | |
16 # define PARAMS(Args) Args | |
17 # else | |
18 # define PARAMS(Args) () | |
19 # endif | |
760 | 20 # endif |
366 | 21 |
1170 | 22 # ifndef _STRTOL_ERROR |
366 | 23 enum strtol_error |
24 { | |
25 LONGINT_OK, LONGINT_INVALID, LONGINT_INVALID_SUFFIX_CHAR, LONGINT_OVERFLOW | |
26 }; | |
27 typedef enum strtol_error strtol_error; | |
1170 | 28 # endif |
366 | 29 |
30 strtol_error | |
742
cddc2692eef4
Define and use macro, PARAMS, not __P.
Jim Meyering <jim@meyering.net>
parents:
400
diff
changeset
|
31 __xstrtol PARAMS ((const char *s, char **ptr, int base, |
cddc2692eef4
Define and use macro, PARAMS, not __P.
Jim Meyering <jim@meyering.net>
parents:
400
diff
changeset
|
32 __unsigned long int *val, const char *valid_suffixes)); |
366 | 33 |
1170 | 34 # undef _STRTOL_ERROR |
760 | 35 # define _STRTOL_ERROR(Exit_code, Str, Argument_type_string, Err) \ |
366 | 36 do \ |
37 { \ | |
759 | 38 switch ((Err)) \ |
366 | 39 { \ |
40 case LONGINT_OK: \ | |
41 abort (); \ | |
42 \ | |
43 case LONGINT_INVALID: \ | |
759 | 44 error ((Exit_code), 0, "invalid %s `%s'", \ |
45 (Argument_type_string), (Str)); \ | |
366 | 46 break; \ |
47 \ | |
48 case LONGINT_INVALID_SUFFIX_CHAR: \ | |
759 | 49 error ((Exit_code), 0, "invalid character following %s `%s'", \ |
50 (Argument_type_string), (Str)); \ | |
366 | 51 break; \ |
52 \ | |
53 case LONGINT_OVERFLOW: \ | |
400 | 54 /* FIXME: make this message dependent on STRING_TO_UNSIGNED */\ |
759 | 55 error ((Exit_code), 0, "%s `%s' larger than maximum long int",\ |
56 (Argument_type_string), (Str)); \ | |
366 | 57 break; \ |
58 } \ | |
59 } \ | |
60 while (0) | |
61 | |
760 | 62 # define STRTOL_FATAL_ERROR(Str, Argument_type_string, Err) \ |
759 | 63 _STRTOL_ERROR (2, Str, Argument_type_string, Err) |
373 | 64 |
760 | 65 # define STRTOL_FAIL_WARN(Str, Argument_type_string, Err) \ |
759 | 66 _STRTOL_ERROR (0, Str, Argument_type_string, Err) |
373 | 67 |
764 | 68 #endif /* not XSTRTOL_H_ */ |