Fix toupper_table_loc not returning the correct type of ptr

This commit is contained in:
csd4ni3l
2026-04-19 18:17:05 +02:00
parent 9047b85e32
commit a79af6d365

View File

@@ -37,6 +37,8 @@ static TOUPPER_TABLE: [i32; 384] = {
table table
}; };
static mut TOUPPER_TABLE_PTR: *const i32 = core::ptr::null();
#[unsafe(no_mangle)] #[unsafe(no_mangle)]
extern "C" fn write(fd: i32, buf: *const u8, count: usize) -> isize { extern "C" fn write(fd: i32, buf: *const u8, count: usize) -> isize {
unsafe { syscall3(WRITE, fd as isize, buf as isize, count as isize) } unsafe { syscall3(WRITE, fd as isize, buf as isize, count as isize) }
@@ -624,8 +626,11 @@ unsafe extern "C" fn strrchr(s: *const u8, ch: u8) -> *const u8 {
} }
#[unsafe(no_mangle)] #[unsafe(no_mangle)]
unsafe extern "C" fn toupper(char: i32) -> i32 { unsafe extern "C" fn toupper(ch: i32) -> i32 {
(char as u8).to_ascii_uppercase() as i32 if ch == -1 {
return -1;
}
(ch as u8).to_ascii_uppercase() as i32
} }
#[unsafe(no_mangle)] #[unsafe(no_mangle)]
@@ -638,8 +643,13 @@ extern "C" fn system(cmd: *const u8) -> i32 {
0 0
} }
#[unsafe(no_mangle)] #[unsafe(no_mangle)]
extern "C" fn __ctype_toupper_loc() -> *const u8 { extern "C" fn __ctype_toupper_loc() -> *const *const i32 {
TOUPPER_TABLE.as_ptr() as *const u8 unsafe {
if TOUPPER_TABLE_PTR.is_null() {
TOUPPER_TABLE_PTR = TOUPPER_TABLE.as_ptr();
}
core::ptr::addr_of!(TOUPPER_TABLE_PTR)
}
} }
#[unsafe(no_mangle)] #[unsafe(no_mangle)]