X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fstrtonum.h;h=865dda7d3eebdeee91e3ab6dfca04a8c3c0ecbc3;hb=f1149d882df3b1bfd12a33cef49430f559c3e0ee;hp=fd7e87b196a9e10c059963e2959953700ae34412;hpb=a1fdee4766b969fd0786e3286ce878a2a1142bbd;p=libucw.git diff --git a/ucw/strtonum.h b/ucw/strtonum.h index fd7e87b1..865dda7d 100644 --- a/ucw/strtonum.h +++ b/ucw/strtonum.h @@ -10,12 +10,13 @@ #ifndef _STRTONUM_H #define _STRTONUM_H +// Set (flags & 0x1f) in the range 1 to 31 to denote the default base of the number enum str_to_num_flags { STN_SIGNED = 0x20, // The resulting range is signed STN_MINUS = 0x40, // Allow optional '-' sign STN_PLUS = 0x80, // Allow optional '+' sign STN_TRUNC = 0x100, // Allow range overflow -> truncate to the allowed range - STN_DEC = 0x200, // Support decimal numbers + STN_DEC = 0x200, // Support decimal numbers (currently no prefix) STN_HEX = 0x400, // Support hexadecimal numbers (0x...) STN_BIN = 0x800, // Support binary numbers (0b...) STN_OCT = 0x1000, // Support octal numbers (0o...) @@ -39,7 +40,7 @@ const char *str_to_##suffix(type *num, const char *str, const char **next, const #define STN_SIGNED_CONVERTOR(type, suffix, usuffix) \ static inline const char *str_to_##suffix(type *num, const char *str, const char **next, const uns flags) \ { \ - return str_to_##usuffix((void *) num, str, next, flags | STN_SIGNED); \ + return str_to_##usuffix((void *) num, str, next, flags | STN_SIGNED | STN_PLUS | STN_MINUS); \ } STN_DECLARE_CONVERTOR(uns, uns);