aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2022-05-03 13:15:49 +0200
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2022-05-03 13:15:49 +0200
commit59f55a21193ec7461205f4bb95303b69f3f7ce1c (patch)
treed175982cbdc238ce28bbe59501fe5882962cdf28 /src/main.cpp
parent8bac82320fbba53a440bf42b117c702e726db093 (diff)
Make `big_int_from_string` return an error if not an integer.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 86c1544a4..8bd6fc618 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -961,19 +961,10 @@ bool parse_build_flags(Array<String> args) {
bad_flags = true;
break;
}
- // NOTE(Jeroen): We can't rely on `value.value_integer` here, because words will be returned as `0`.
- // Meaning that -opt:speed will coerce to opt:0. That's not what the user intended.
- // Instead we'll just compare 0..3 directly.
- if (param == "0") {
- build_context.optimization_level = 0;
- } else if (param == "1") {
- build_context.optimization_level = 1;
- } else if (param == "2") {
- build_context.optimization_level = 2;
- } else if (param == "3") {
- build_context.optimization_level = 3;
- } else {
- gb_printf_err("Invalid optimization level for -o:<integer>, got %.*s\n", LIT(param));
+
+ build_context.optimization_level = cast(i32)big_int_to_i64(&value.value_integer);
+ if (build_context.optimization_level < 0 || build_context.optimization_level > 3) {
+ gb_printf_err("Invalid optimization level for -o:<integer>, got %d\n", build_context.optimization_level);
gb_printf_err("Valid optimization levels:\n");
gb_printf_err("\t0\n");
gb_printf_err("\t1\n");