Skip to content

Commit

Permalink
Fix for systems with unsigned char
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Nov 5, 2024
1 parent a869950 commit 3e36f1b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
17 changes: 9 additions & 8 deletions bzip2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
#![allow(unused_assignments)]
#![allow(unused_mut)]

use std::ffi::CStr;
use std::ffi::{c_char, CStr};
use std::mem::zeroed;
use std::ptr;

use libbzip2_rs_sys::bzlib::{
BZ2_bzRead, BZ2_bzReadClose, BZ2_bzReadGetUnused, BZ2_bzReadOpen, BZ2_bzWrite,
Expand Down Expand Up @@ -33,7 +34,7 @@ struct UInt64 {
#[derive(Copy, Clone)]
#[repr(C)]
struct zzzz {
name: *mut i8,
name: *mut c_char,
link: *mut zzzz,
}
type Cell = zzzz;
Expand All @@ -52,12 +53,12 @@ static mut exitValue: i32 = 0;
static mut opMode: i32 = 0;
static mut srcMode: i32 = 0;
static mut longestFileName: i32 = 0;
static mut inName: [i8; 1034] = [0; 1034];
static mut outName: [i8; 1034] = [0; 1034];
static mut tmpName: [i8; 1034] = [0; 1034];
static mut progName: *mut i8 = 0 as *const i8 as *mut i8;
static mut progNameReally: [i8; 1034] = [0; 1034];
static mut outputHandleJustInCase: *mut FILE = 0 as *const FILE as *mut FILE;
static mut inName: [c_char; 1034] = [0; 1034];
static mut outName: [c_char; 1034] = [0; 1034];
static mut tmpName: [c_char; 1034] = [0; 1034];
static mut progName: *mut c_char = ptr::null_mut();
static mut progNameReally: [c_char; 1034] = [0; 1034];
static mut outputHandleJustInCase: *mut FILE = ptr::null_mut();
static mut workFactor: i32 = 0;
unsafe fn uInt64_from_UInt32s(mut n: *mut UInt64, mut lo32: u32, mut hi32: u32) {
(*n).b[7 as libc::c_int as usize] =
Expand Down
8 changes: 4 additions & 4 deletions bzlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,7 @@ pub unsafe extern "C" fn BZ2_bzWrite(
(*bzf).strm.next_in = buf as *mut libc::c_char;
loop {
(*bzf).strm.avail_out = 5000 as libc::c_int as libc::c_uint;
(*bzf).strm.next_out = ((*bzf).buf).as_mut_ptr();
(*bzf).strm.next_out = ((*bzf).buf).as_mut_ptr().cast::<c_char>();
ret = BZ2_bzCompress(&mut (*bzf).strm, 0 as libc::c_int);
if ret != 1 as libc::c_int {
if !bzerror.is_null() {
Expand Down Expand Up @@ -1902,7 +1902,7 @@ pub unsafe extern "C" fn BZ2_bzWriteClose64(
if abandon == 0 && (*bzf).lastErr == 0 as libc::c_int {
loop {
(*bzf).strm.avail_out = 5000 as libc::c_int as libc::c_uint;
(*bzf).strm.next_out = ((*bzf).buf).as_mut_ptr();
(*bzf).strm.next_out = ((*bzf).buf).as_mut_ptr().cast::<c_char>();
ret = BZ2_bzCompress(&mut (*bzf).strm, 2 as libc::c_int);
if ret != 3 as libc::c_int && ret != 4 as libc::c_int {
if !bzerror.is_null() {
Expand Down Expand Up @@ -2052,7 +2052,7 @@ pub unsafe extern "C" fn BZ2_bzReadOpen(
return std::ptr::null_mut::<libc::c_void>();
}
(*bzf).strm.avail_in = (*bzf).bufN as libc::c_uint;
(*bzf).strm.next_in = ((*bzf).buf).as_mut_ptr();
(*bzf).strm.next_in = ((*bzf).buf).as_mut_ptr().cast::<c_char>();
(*bzf).initialisedOk = true;
bzf as *mut libc::c_void
}
Expand Down Expand Up @@ -2162,7 +2162,7 @@ pub unsafe extern "C" fn BZ2_bzRead(
}
(*bzf).bufN = n;
(*bzf).strm.avail_in = (*bzf).bufN as libc::c_uint;
(*bzf).strm.next_in = ((*bzf).buf).as_mut_ptr();
(*bzf).strm.next_in = ((*bzf).buf).as_mut_ptr().cast::<c_char>();
}
ret = BZ2_bzDecompress(&mut (*bzf).strm);
if ret != 0 as libc::c_int && ret != 4 as libc::c_int {
Expand Down

0 comments on commit 3e36f1b

Please sign in to comment.