mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-18 03:12:10 +00:00
Also restore codepage on trap.
This commit is contained in:
@@ -945,5 +945,25 @@ default_assertion_contextless_failure_proc :: proc "contextless" (prefix, messag
|
||||
print_byte('\n')
|
||||
}
|
||||
}
|
||||
when ODIN_CODEPAGE_MAGIC {
|
||||
SetConsoleOutputCP(old_console_codepage)
|
||||
}
|
||||
trap()
|
||||
}
|
||||
|
||||
ODIN_CODEPAGE_MAGIC :: ODIN_OS == .Windows && #config(ODIN_CODEPAGE_MAGIC, !ODIN_BEDROCK)
|
||||
|
||||
when ODIN_CODEPAGE_MAGIC {
|
||||
@(private)
|
||||
old_console_codepage: u32
|
||||
|
||||
@(private)
|
||||
UTF_8 :: 65001
|
||||
}
|
||||
|
||||
foreign import kernel32 "system:Kernel32.lib"
|
||||
@(default_calling_convention="system")
|
||||
foreign kernel32 {
|
||||
GetConsoleOutputCP :: proc() -> u32 ---
|
||||
SetConsoleOutputCP :: proc(codepage: u32) -> b32 ---
|
||||
}
|
||||
@@ -5,16 +5,6 @@ package runtime
|
||||
|
||||
import "base:intrinsics"
|
||||
|
||||
ODIN_CODEPAGE_MAGIC :: #config(ODIN_CODEPAGE_MAGIC, !ODIN_BEDROCK)
|
||||
|
||||
when ODIN_CODEPAGE_MAGIC {
|
||||
@(private="file")
|
||||
old_console_codepage: u32
|
||||
|
||||
@(private="file")
|
||||
UTF_8 :: 65001
|
||||
}
|
||||
|
||||
when ODIN_BUILD_MODE == .Dynamic {
|
||||
@(link_name="DllMain", linkage="strong", require)
|
||||
DllMain :: proc "system" (hinstDLL: rawptr, fdwReason: u32, lpReserved: rawptr) -> b32 {
|
||||
@@ -90,11 +80,4 @@ when ODIN_BUILD_MODE == .Dynamic {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreign import kernel32 "system:Kernel32.lib"
|
||||
@(default_calling_convention="system")
|
||||
foreign kernel32 {
|
||||
GetConsoleOutputCP :: proc() -> u32 ---
|
||||
SetConsoleOutputCP :: proc(codepage: u32) -> b32 ---
|
||||
}
|
||||
@@ -11,8 +11,9 @@ foreign kernel32 {
|
||||
|
||||
windows_trap_array_bounds :: proc "contextless" () -> ! {
|
||||
EXCEPTION_ARRAY_BOUNDS_EXCEEDED :: 0xC000008C
|
||||
|
||||
|
||||
when ODIN_CODEPAGE_MAGIC {
|
||||
SetConsoleOutputCP(old_console_codepage)
|
||||
}
|
||||
RaiseException(EXCEPTION_ARRAY_BOUNDS_EXCEEDED, 0, 0, nil)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,9 @@ windows_trap_array_bounds :: proc "contextless" () -> ! {
|
||||
foreign kernel32 {
|
||||
RaiseException :: proc "system" (dwExceptionCode, dwExceptionFlags, nNumberOfArguments: DWORD, lpArguments: ^ULONG_PTR) -> ! ---
|
||||
}
|
||||
|
||||
when ODIN_CODEPAGE_MAGIC {
|
||||
SetConsoleOutputCP(old_console_codepage)
|
||||
}
|
||||
RaiseException(EXCEPTION_ARRAY_BOUNDS_EXCEEDED, 0, 0, nil)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user