Add comma after e.g. in comment.
[coreutils.git] / lib / xstrtol.h
blobfd0c97f6325819ffb92d53a634eff87de80e506b
1 #ifndef _xstrtol_h_
2 #define _xstrtol_h_ 1
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
16 #undef __P
17 #if defined (__STDC__) && __STDC__
18 #define __P(x) x
19 #else
20 #define __P(x) ()
21 #endif
23 enum strtol_error
25 LONGINT_OK, LONGINT_INVALID, LONGINT_INVALID_SUFFIX_CHAR, LONGINT_OVERFLOW
27 typedef enum strtol_error strtol_error;
29 strtol_error
30 __xstrtol __P ((const char *s, char **ptr, int base,
31 __unsigned long int *val, const char *valid_suffixes));
33 #define _STRTOL_ERROR(exit_code, str, argument_type_string, err) \
34 do \
35 { \
36 switch ((err)) \
37 { \
38 case LONGINT_OK: \
39 abort (); \
41 case LONGINT_INVALID: \
42 error ((exit_code), 0, "invalid %s `%s'", \
43 (argument_type_string), (str)); \
44 break; \
46 case LONGINT_INVALID_SUFFIX_CHAR: \
47 error ((exit_code), 0, "invalid character following %s `%s'", \
48 (argument_type_string), (str)); \
49 break; \
51 case LONGINT_OVERFLOW: \
52 /* FIXME: make this message dependent on STRING_TO_UNSIGNED */\
53 error ((exit_code), 0, "%s `%s' larger than maximum long int",\
54 (argument_type_string), (str)); \
55 break; \
56 } \
57 } \
58 while (0)
60 #define STRTOL_FATAL_ERROR(str, argument_type_string, err) \
61 _STRTOL_ERROR (2, str, argument_type_string, err)
63 #define STRTOL_FAIL_WARN(str, argument_type_string, err) \
64 _STRTOL_ERROR (0, str, argument_type_string, err)
66 #endif /* _xstrtol_h_ */