libbb: move nuke_str() from passwd into libbb
[oweals/busybox.git] / libbb / xatonum.c
index 0d487dd9be2dce33fbc458da46f70cde59ccf760..6f4e023bbc166de84cadcc6e0bc38afdc8ff325d 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Copyright (C) 2003  Manuel Novoa III  <mjn3@codepoet.org>
  *
- * Licensed under GPLv2, see file LICENSE in this tarball for details.
+ * Licensed under GPLv2, see file LICENSE in this source tree.
  */
 
 #include "libbb.h"
 #define XSTR_TYPE_MIN LLONG_MIN
 #define XSTR_STRTOU strtoull
 #include "xatonum_template.c"
-#undef type
-#undef xstrtou
-#undef xstrto
-#undef xatou
-#undef xato
-#undef XSTR_UTYPE_MAX
-#undef XSTR_TYPE_MAX
-#undef XSTR_TYPE_MIN
-#undef XSTR_STRTOU
 
 #if ULONG_MAX != ULLONG_MAX
 #define type long
 #define XSTR_TYPE_MIN LONG_MIN
 #define XSTR_STRTOU strtoul
 #include "xatonum_template.c"
-#undef type
-#undef xstrtou
-#undef xstrto
-#undef xatou
-#undef xato
-#undef XSTR_UTYPE_MAX
-#undef XSTR_TYPE_MAX
-#undef XSTR_TYPE_MIN
-#undef XSTR_STRTOU
 #endif
 
 #if UINT_MAX != ULONG_MAX
-extern inline unsigned bb_strtoui(const char *str, char **end, int b)
+static ALWAYS_INLINE
+unsigned bb_strtoui(const char *str, char **end, int b)
 {
        unsigned long v = strtoul(str, end, b);
        if (v > UINT_MAX) {
@@ -72,30 +55,23 @@ extern inline unsigned bb_strtoui(const char *str, char **end, int b)
 /* libc has no strtoui, so we need to create/use our own */
 #define XSTR_STRTOU bb_strtoui
 #include "xatonum_template.c"
-#undef type
-#undef xstrtou
-#undef xstrto
-#undef xatou
-#undef xato
-#undef XSTR_UTYPE_MAX
-#undef XSTR_TYPE_MAX
-#undef XSTR_TYPE_MIN
-#undef XSTR_STRTOU
 #endif
 
 /* A few special cases */
 
-int xatoi_u(const char *numstr)
+int FAST_FUNC xatoi_positive(const char *numstr)
 {
        return xatou_range(numstr, 0, INT_MAX);
 }
 
-uint32_t xatou32(const char *numstr)
-{
-       return xatoul_range(numstr, 0, 0xffffffff);
-}
-
-uint16_t xatou16(const char *numstr)
+uint16_t FAST_FUNC xatou16(const char *numstr)
 {
        return xatou_range(numstr, 0, 0xffff);
 }
+
+const struct suffix_mult bkm_suffixes[] = {
+       { "b", 512 },
+       { "k", 1024 },
+       { "m", 1024*1024 },
+       { "", 0 }
+};