sunfishcode / c-ward

An implementation of libc written in Rust
Other
187 stars 11 forks source link

`strverscmp` orders "00" before "000" #103

Closed sunfishcode closed 8 months ago

sunfishcode commented 8 months ago

According to the strverscmp documentation, 000 is ordered before 00, which means that strverscmp("000", "00") should return a negative value, however it currently returns a positive value.

Specifically, running this:

fn main() {
    extern "C" {
        fn strverscmp(a: *const libc::c_char, b: *const libc::c_char) -> libc::c_int;
    }
    unsafe {
        dbg!(strverscmp("000\0".as_ptr().cast(), "00\0".as_ptr().cast()));
    }
}

prints the value 48.

@KGrewal1

sunfishcode commented 8 months ago

This is now fixed by #104.