libbb: move nuke_str() from passwd into libbb
[oweals/busybox.git] / libbb / xatonum_template.c
index 2360ae88a345998d4a6f90c2c603d7babebfed5e..e0471983c98f3849a7eca3fc0c8783a9cbbe2a13 100644 (file)
@@ -1,3 +1,7 @@
+/*
+ *
+ * Licensed under GPLv2, see file LICENSE in this source tree.
+ */
 /*
 You need to define the following (example):
 
@@ -21,9 +25,8 @@ unsigned type FAST_FUNC xstrtou(_range_sfx)(const char *numstr, int base,
        int old_errno;
        char *e;
 
-       /* Disallow '-' and any leading whitespace. Make sure we get the
-        * actual isspace function rather than a macro implementaion. */
-       if (*numstr == '-' || *numstr == '+' || (isspace)(*numstr))
+       /* Disallow '-' and any leading whitespace. */
+       if (*numstr == '-' || *numstr == '+' || isspace(*numstr))
                goto inval;
 
        /* Since this is a lib function, we're not allowed to reset errno to 0.
@@ -38,7 +41,7 @@ unsigned type FAST_FUNC xstrtou(_range_sfx)(const char *numstr, int base,
        if (errno || numstr == e)
                goto inval; /* error / no digits / illegal trailing chars */
 
-       errno = old_errno;      /* Ok.  So restore errno. */
+       errno = old_errno;  /* Ok.  So restore errno. */
 
        /* Do optional suffix parsing.  Allow 'empty' suffix tables.
         * Note that we also allow nul suffixes with associated multipliers,
@@ -56,7 +59,7 @@ unsigned type FAST_FUNC xstrtou(_range_sfx)(const char *numstr, int base,
        }
 
        /* Note: trailing space is an error.
-          It would be easy enough to allow though if desired. */
+        * It would be easy enough to allow though if desired. */
        if (*e)
                goto inval;
  chk_range:
@@ -153,6 +156,11 @@ type FAST_FUNC xstrto(_range)(const char *numstr, int base, type lower, type upp
        return xstrto(_range_sfx)(numstr, base, lower, upper, NULL);
 }
 
+type FAST_FUNC xstrto()(const char *numstr, int base)
+{
+       return xstrto(_range_sfx)(numstr, base, XSTR_TYPE_MIN, XSTR_TYPE_MAX, NULL);
+}
+
 type FAST_FUNC xato(_range_sfx)(const char *numstr,
                type lower,
                type upper,