]> sigrok.org Git - libsigrok.git/blobdiff - src/strutil.c
strutil: accept 0b prefix when base is 2 (which is non-zero)
[libsigrok.git] / src / strutil.c
index c389a524d26598aa20a4274969cbd1bf9c76ae4b..be07662f3ec03c95eb8e0afc8b0695ba8afcc82e 100644 (file)
@@ -174,7 +174,7 @@ SR_PRIV int sr_atoul_base(const char *str, unsigned long *ret, char **end, int b
        /* Add "0b" prefix support which strtol(3) may be missing. */
        while (str && isspace(*str))
                str++;
-       if (!base && strncmp(str, "0b", strlen("0b")) == 0) {
+       if ((!base || base == 2) && strncmp(str, "0b", strlen("0b")) == 0) {
                str += strlen("0b");
                base = 2;
        }