From 6e271c42e889ae07f81152c0fe4d79c3c74a645a Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 5 Nov 2024 19:19:25 +0100 Subject: [PATCH] Fix compilation on Windows --- bzip2.rs | 44 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/bzip2.rs b/bzip2.rs index 5efb35ff4..e91c9bcdd 100644 --- a/bzip2.rs +++ b/bzip2.rs @@ -1412,52 +1412,44 @@ unsafe extern "C" fn mySignalCatcher(_: IntNative) { } unsafe fn mySIGSEGVorSIGBUScatcher(_: IntNative) { let mut msg: *const libc::c_char = std::ptr::null::(); - if opMode == 1 as libc::c_int { + if opMode == 1 { msg = b": Caught a SIGSEGV or SIGBUS whilst compressing.\n\n Possible causes are (most likely first):\n (1) This computer has unreliable memory or cache hardware\n (a surprisingly common problem; try a different machine.)\n (2) A bug in the compiler used to create this executable\n (unlikely, if you didn't compile bzip2 yourself.)\n (3) A real bug in bzip2 -- I hope this should never be the case.\n The user's manual, Section 4.3, has more info on (1) and (2).\n \n If you suspect this is a bug in bzip2, or are unsure about (1)\n or (2), report it at: https://gitlab.com/bzip2/bzip2/-/issues\n Section 4.3 of the user's manual describes the info a useful\n bug report should have. If the manual is available on your\n system, please try and read it before mailing me. If you don't\n have the manual or can't be bothered to read it, mail me anyway.\n\n\0" as *const u8 as *const libc::c_char; } else { msg = b": Caught a SIGSEGV or SIGBUS whilst decompressing.\n\n Possible causes are (most likely first):\n (1) The compressed data is corrupted, and bzip2's usual checks\n failed to detect this. Try bzip2 -tvv my_file.bz2.\n (2) This computer has unreliable memory or cache hardware\n (a surprisingly common problem; try a different machine.)\n (3) A bug in the compiler used to create this executable\n (unlikely, if you didn't compile bzip2 yourself.)\n (4) A real bug in bzip2 -- I hope this should never be the case.\n The user's manual, Section 4.3, has more info on (2) and (3).\n \n If you suspect this is a bug in bzip2, or are unsure about (2)\n or (3), report it at: https://gitlab.com/bzip2/bzip2/-/issues\n Section 4.3 of the user's manual describes the info a useful\n bug report should have. If the manual is available on your\n system, please try and read it before mailing me. If you don't\n have the manual or can't be bothered to read it, mail me anyway.\n\n\0" as *const u8 as *const libc::c_char; } + write(2, b"\n" as *const u8 as *const libc::c_void, 1); + write(2, progName as *const libc::c_void, strlen(progName) as _); + write(2, msg as *const libc::c_void, strlen(msg) as _); + msg = b"\tInput file = \0" as *const u8 as *const libc::c_char; write( 2 as libc::c_int, - b"\n\0" as *const u8 as *const libc::c_char as *const libc::c_void, - 1 as libc::c_int as size_t, - ); - write( - 2 as libc::c_int, - progName as *const libc::c_void, - strlen(progName), + msg as *const libc::c_void, + strlen(msg) as _, ); - write(2 as libc::c_int, msg as *const libc::c_void, strlen(msg)); - msg = b"\tInput file = \0" as *const u8 as *const libc::c_char; - write(2 as libc::c_int, msg as *const libc::c_void, strlen(msg)); write( - 2 as libc::c_int, + 2, inName.as_mut_ptr() as *const libc::c_void, - strlen(inName.as_mut_ptr()), + strlen(inName.as_mut_ptr()) as _, ); write( - 2 as libc::c_int, + 2, b"\n\0" as *const u8 as *const libc::c_char as *const libc::c_void, - 1 as libc::c_int as size_t, + 1, ); msg = b"\tOutput file = \0" as *const u8 as *const libc::c_char; - write(2 as libc::c_int, msg as *const libc::c_void, strlen(msg)); + write(2, msg as *const libc::c_void, strlen(msg) as _); write( - 2 as libc::c_int, + 2, outName.as_mut_ptr() as *const libc::c_void, - strlen(outName.as_mut_ptr()), - ); - write( - 2 as libc::c_int, - b"\n\0" as *const u8 as *const libc::c_char as *const libc::c_void, - 1 as libc::c_int as size_t, + strlen(outName.as_mut_ptr()) as _, ); - if opMode == 1 as libc::c_int { - setExit(3 as libc::c_int); + write(2, b"\n" as *const u8 as *const libc::c_void, 1); + if opMode == 1 { + setExit(3); } else { - setExit(2 as libc::c_int); + setExit(2); } _exit(exitValue); }