]> mj.ucw.cz Git - libucw.git/commitdiff
Strtonum: Support u32 and s32
authorMartin Mares <mj@ucw.cz>
Sun, 29 Jun 2014 11:43:05 +0000 (13:43 +0200)
committerMartin Mares <mj@ucw.cz>
Sun, 29 Jun 2014 11:43:05 +0000 (13:43 +0200)
I got tired of parsing to uint and then checking range.

maint/libucw.abi
ucw/strtonum.c
ucw/strtonum.h

index 7c469ebd6003ba7234d5a55e1287a01d2b35610d..21141179c98384469ceb7c9dda6bda160fdad2f9 100644 (file)
@@ -499,6 +499,8 @@ str_hier_suffix
 str_to_uintmax
 str_to_uint
 str_to_uns
+str_to_u32
+str_to_u64
 # ucw/table.h
 table_init
 table_cleanup
index 77858b19a375ff53e9b25118513e103d1edc0e49..e8fa486445e0868175c24bd3ef34e8f91412e93a 100644 (file)
@@ -102,6 +102,10 @@ static inline uint get_digit(const uint c)
 #define STN_SUFFIX uint
 #include <ucw/strtonum-gen.h>
 
+#define STN_TYPE u32
+#define STN_SUFFIX u32
+#include <ucw/strtonum-gen.h>
+
 #define STN_TYPE u64
 #define STN_SUFFIX u64
 #include <ucw/strtonum-gen.h>
index d5631f68171b829feb8804496b27b3269cf87f5f..ae25ff5d9a46c4aeb9ea5f9b01cee51076ddeeaf 100644 (file)
@@ -11,6 +11,8 @@
 #define _STRTONUM_H
 
 #ifdef CONFIG_UCW_CLEAN_ABI
+#define str_to_u32 ucw_str_to_u32
+#define str_to_u64 ucw_str_to_u64
 #define str_to_uint ucw_str_to_uint
 #define str_to_uintmax ucw_str_to_uintmax
 #define str_to_uns ucw_str_to_uns
@@ -52,6 +54,9 @@ static inline const char *str_to_##suffix(type *num, const char *str, const char
 STN_DECLARE_CONVERTOR(uint, uint);
 STN_SIGNED_CONVERTOR(int, int, uint)
 
+STN_DECLARE_CONVERTOR(u32, u32);
+STN_SIGNED_CONVERTOR(s32, s32, u32)
+
 STN_DECLARE_CONVERTOR(u64, u64);
 STN_SIGNED_CONVERTOR(s64, s64, u64)