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