aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-07-19 16:17:23 +0100
committergingerBill <bill@gingerbill.org>2022-07-19 16:17:23 +0100
commit3db3047f47ddda7f99dc7c481e368cff68db4aaf (patch)
tree81ff1f8579781d987a9c470545f0a01c06bfe772
parent7420fbd95b1130e3b2e7eaf52c56302a6e1f3b31 (diff)
Minor improvements
-rw-r--r--core/os/env_windows.odin30
-rw-r--r--src/check_type.cpp4
2 files changed, 18 insertions, 16 deletions
diff --git a/core/os/env_windows.odin b/core/os/env_windows.odin
index 9a33a0611..6e14127ed 100644
--- a/core/os/env_windows.odin
+++ b/core/os/env_windows.odin
@@ -11,24 +11,24 @@ lookup_env :: proc(key: string, allocator := context.allocator) -> (value: strin
return
}
wkey := win32.utf8_to_wstring(key)
- b := make([dynamic]u16, 100, context.temp_allocator)
- for {
- n := win32.GetEnvironmentVariableW(wkey, raw_data(b), u32(len(b)))
- if n == 0 {
- err := win32.GetLastError()
- if err == u32(ERROR_ENVVAR_NOT_FOUND) {
- return "", false
- }
+ n := win32.GetEnvironmentVariableW(wkey, nil, 0)
+ if n == 0 {
+ err := win32.GetLastError()
+ if err == u32(ERROR_ENVVAR_NOT_FOUND) {
+ return "", false
}
-
- if n <= u32(len(b)) {
- value, _ = win32.utf16_to_utf8(b[:n], allocator)
- found = true
- return
+ }
+ b := make([dynamic]u16, n, context.temp_allocator)
+ n = win32.GetEnvironmentVariableW(wkey, raw_data(b), u32(len(b)))
+ if n == 0 {
+ err := win32.GetLastError()
+ if err == u32(ERROR_ENVVAR_NOT_FOUND) {
+ return "", false
}
-
- resize(&b, len(b)*2)
}
+ value, _ = win32.utf16_to_utf8(b[:n], allocator)
+ found = true
+ return
}
diff --git a/src/check_type.cpp b/src/check_type.cpp
index cd4b43fab..741385e29 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -1345,7 +1345,9 @@ ParameterValue handle_parameter_value(CheckerContext *ctx, Type *in_type, Type *
param_value.kind = ParameterValue_Constant;
param_value.value = o.value;
} else {
- error(expr, "Default parameter must be a constant, %d", o.mode);
+ gbString s = expr_to_string(o.expr);
+ error(expr, "Default parameter must be a constant, got %s", s);
+ gb_string_free(s);
}
}
} else {