2 * UCW Library -- Conversions of Strings to Numbers
4 * (c) 2010 Daniel Fiala <danfiala@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
11 #include "ucw/string.h"
12 #include "ucw/chartype.h"
13 #include "ucw/strtonum.h"
15 static uns detect_base(const char **pp, const uns flags)
17 if ((flags & STN_BASES0) && **pp == '0')
61 static const char *str_to_num_init(const char **pp, const uns flags, uns *sign, uns *base)
65 const char *err = NULL;
70 if (flags & (STN_SIGNS))
72 if (*p == '-' && (flags & STN_MINUS))
77 else if (*p == '+' && (flags & STN_PLUS))
81 *base = detect_base(&p, flags) ? : flags & STN_DBASES_MASK;
87 static inline uns get_digit(const uns c)
93 const int a = c & 0xDF;
102 #define STN_SUFFIX uns
103 #include "ucw/strtonum-gen.h"
105 #define STN_TYPE uintmax_t
106 #define STN_SUFFIX uintmax
107 #include "ucw/strtonum-gen.h"