:: commit 10bd26962a30378d0bbce110089177e139edcc8c

mintsuki <mintsuki@protonmail.com> — 2020-11-05 00:17

parents: d7ec93d01d

blib: Make strtoui break on first non numeric digit

diff --git a/limine.bin b/limine.bin
index f74b6242..bcc5e41d 100644
Binary files a/limine.bin and b/limine.bin differ
diff --git a/stage2/lib/blib.c b/stage2/lib/blib.c
index d593c15f..9ed4d9c4 100644
--- a/stage2/lib/blib.c
+++ b/stage2/lib/blib.c
@@ -70,7 +70,11 @@ uint64_t strtoui(const char *s, size_t limit, int base) {
     uint64_t n = 0;
     if (!limit)
         limit = strlen(s);
-    for (size_t i = 0; i < limit; i++)
-        n = n * base + digit_to_int(s[i]);
+    for (size_t i = 0; i < limit; i++) {
+        int d = digit_to_int(s[i]);
+        if (d == -1)
+            break;
+        n = n * base + d;
+    }
     return n;
 }
tab: 248 wrap: offon