fix for suffix optimization (which was in previous commit)
authorDenis Vlasenko <vda.linux@googlemail.com>
Fri, 27 Jul 2007 15:30:39 +0000 (15:30 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Fri, 27 Jul 2007 15:30:39 +0000 (15:30 -0000)
include/libbb.h
libbb/xatonum_template.c

index 780bd4566444ce6f28b74be5ace8f7def6e3fb08..ddbde1833be5758739dbb5bbac1e023ba80f72ff 100644 (file)
@@ -450,6 +450,7 @@ const char *make_human_readable_str(unsigned long long size,
 /* Put a string of hex bytes ("1b2e66fe"...), return advanced pointer */
 char *bin2hex(char *buf, const char *cp, int count);
 
+/* Last element is marked by mult == 0 */
 struct suffix_mult {
        char suffix[4];
        unsigned mult;
index bc81160568d60079870a12cd1b2033f1d404813a..205da53c8dee0ef56f5d3b15dc928b724ebb44d7 100644 (file)
@@ -45,7 +45,7 @@ unsigned type xstrtou(_range_sfx)(const char *numstr, int base,
         * Note that we also allow nul suffixes with associated multipliers,
         * to allow for scaling of the numstr by some default multiplier. */
        if (suffixes) {
-               while (suffixes->suffix) {
+               while (suffixes->mult) {
                        if (strcmp(suffixes->suffix, e) == 0) {
                                if (XSTR_UTYPE_MAX / suffixes->mult < r)
                                        goto range; /* overflow! */