* of the GNU Lesser General Public License.
*/
-/* This is not a normall header file, it is generator of a function for converting strings to integers
- * of a certain type. This file should be used only by ucw/stronum.c .
+/*
+ * This is not a normal header file, it is a generator of a function for
+ * converting strings to integers of a certain type. This file should be used
+ * by ucw/stronum.c only.
*/
#define STN_DECLARE(type, suffix) STN_DECLARE_CONVERTOR(type, suffix)
uns sign, base;
err = str_to_num_init(&p, flags, &sign, &base);
+
const char *parse_string(void)
{
const STN_TYPE max = STN_MAX;
return NULL;
}
+
if (!err)
err = parse_string();
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 resulting range
+ STN_TRUNC = 0x100, // Allow range overflow -> truncate to the allowed range
STN_DEC = 0x200, // Support decimal numbers
STN_HEX = 0x400, // Support hexadecimal numbers (0x...)
STN_BIN = 0x800, // Support binary numbers (0b...)
#define STN_DBASES_MASK 0x1F
#define STN_SIGNS (STN_MINUS | STN_PLUS)
#define STN_BASES (STN_DEC | STN_HEX | STN_BIN | STN_OCT)
-#define STN_FLAGS (STN_MINUS | STN_PLUS | STN_BASES)
-#define STN_UFLAGS (STN_FLAGS | STN_UNDERSCORE)
-#define STN_SFLAGS (STN_FLAGS | STN_SIGNED)
-#define STN_USFLAGS (STN_SFLAGS | STN_UNDERSCORE)
+#define STN_FLAGS (STN_MINUS | STN_PLUS | STN_BASES)
+#define STN_UFLAGS (STN_FLAGS | STN_UNDERSCORE)
+#define STN_SFLAGS (STN_FLAGS | STN_SIGNED)
+#define STN_USFLAGS (STN_SFLAGS | STN_UNDERSCORE)
-#define STN_DECLARE_CONVERTOR(type, suffix) \
+#define STN_DECLARE_CONVERTOR(type, suffix) \
const char *str_to_##suffix(type *num, const char *str, const char **next, const uns flags)
-#define STN_SIGNED_CONVERTOR(type, suffix, usuffix) \
+#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_DECLARE_CONVERTOR(uns, uns);