Skip to content

Commit

Permalink
Merge pull request tectonic-typesetting#19 from burrbull/return
Browse files Browse the repository at this point in the history
use `true` & `false`, clean `return`s in the ends of functions
  • Loading branch information
crlf0710 authored Sep 11, 2019
2 parents 875beec + 42ed2c7 commit bb79da7
Show file tree
Hide file tree
Showing 88 changed files with 2,105 additions and 2,101 deletions.
490 changes: 230 additions & 260 deletions engine/src/bibtex.rs

Large diffs are not rendered by default.

58 changes: 29 additions & 29 deletions engine/src/dpx_agl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ unsafe extern "C" fn streq_ptr(mut s1: *const i8, mut s2: *const i8) -> bool {
if !s1.is_null() && !s2.is_null() {
return strcmp(s1, s2) == 0i32;
} /* Acutesmall, Gravesmall, etc */
return 0i32 != 0;
false
}
#[inline]
unsafe extern "C" fn strstartswith(mut s: *const i8, mut prefix: *const i8) -> *const i8 {
Expand All @@ -237,7 +237,7 @@ unsafe extern "C" fn strstartswith(mut s: *const i8, mut prefix: *const i8) -> *
if strncmp(s, prefix, length) == 0i32 {
return s.offset(length as isize);
}
return 0 as *const i8;
0 as *const i8
}
static mut verbose: i32 = 0i32;
#[no_mangle]
Expand All @@ -253,7 +253,7 @@ unsafe extern "C" fn agl_new_name() -> *mut agl_name {
(*agln).n_components = 0i32;
(*agln).alternate = 0 as *mut agl_name;
(*agln).is_predef = 0i32;
return agln;
agln
}
unsafe extern "C" fn agl_release_name(mut agln: *mut agl_name) {
let mut next: *mut agl_name = 0 as *mut agl_name;
Expand Down Expand Up @@ -307,7 +307,7 @@ pub unsafe extern "C" fn agl_chop_suffix(
strcpy(name, glyphname);
*suffix = 0 as *mut i8
}
return name;
name
}
static mut modifiers: [*const i8; 21] = [
b"acute\x00" as *const u8 as *const i8,
Expand Down Expand Up @@ -362,7 +362,7 @@ unsafe extern "C" fn skip_capital(mut p: *mut *const i8, mut endptr: *const i8)
*p = (*p).offset(1);
slen = 1i32
}
return slen;
slen
}
unsafe extern "C" fn skip_modifier(mut p: *mut *const i8, mut endptr: *const i8) -> size_t {
let mut slen: size_t = 0i32 as size_t;
Expand All @@ -385,15 +385,15 @@ unsafe extern "C" fn skip_modifier(mut p: *mut *const i8, mut endptr: *const i8)
i = i.wrapping_add(1)
}
}
return slen;
slen
}
unsafe extern "C" fn is_smallcap(mut glyphname: *const i8) -> bool {
let mut len: size_t = 0;
let mut slen: size_t = 0;
let mut p: *const i8 = 0 as *const i8;
let mut endptr: *const i8 = 0 as *const i8;
if glyphname.is_null() {
return 0i32 != 0;
return false;
}
p = glyphname;
len = strlen(glyphname);
Expand All @@ -403,33 +403,33 @@ unsafe extern "C" fn is_smallcap(mut glyphname: *const i8) -> bool {
b"small\x00" as *const u8 as *const i8,
) != 0
{
return 0i32 != 0;
return false;
}
endptr = p.offset(len as isize).offset(-5);
len = (len as u64).wrapping_sub(5i32 as u64) as size_t as size_t;
slen = skip_modifier(&mut p, endptr);
if slen == len {
return 1i32 != 0;
return true;
} else {
if slen > 0i32 as u64 {
/* ??? */
return 0i32 != 0;
return false;
}
}
len = (len as u64).wrapping_sub(skip_capital(&mut p, endptr) as u64) as size_t as size_t;
if len == 0i32 as u64 {
return 1i32 != 0;
return true;
/* Asmall, AEsmall, etc */
}
while len > 0i32 as u64 {
/* allow multiple accent */
slen = skip_modifier(&mut p, endptr);
if slen == 0i32 as u64 {
return 0i32 != 0;
return false;
}
len = (len as u64).wrapping_sub(slen) as size_t as size_t
}
return 1i32 != 0;
true
}
static mut var_list: [C2RustUnnamed_0; 14] = [
{
Expand Down Expand Up @@ -806,7 +806,7 @@ pub unsafe extern "C" fn agl_suffix_to_otltag(mut suffix: *const i8) -> *const i
}
i += 1
}
return 0 as *const i8;
0 as *const i8
}
unsafe extern "C" fn agl_guess_name(mut glyphname: *const i8) -> ssize_t {
let mut i: ssize_t = 0;
Expand All @@ -830,7 +830,7 @@ unsafe extern "C" fn agl_guess_name(mut glyphname: *const i8) -> ssize_t {
}
i += 1
}
return -1i32 as ssize_t;
-1i32 as ssize_t
}
unsafe extern "C" fn agl_normalized_name(mut glyphname: *mut i8) -> *mut agl_name {
let mut agln: *mut agl_name = 0 as *mut agl_name;
Expand Down Expand Up @@ -913,7 +913,7 @@ unsafe extern "C" fn agl_normalized_name(mut glyphname: *mut i8) -> *mut agl_nam
);
*(*agln).name.offset(n as isize) = '\u{0}' as i32 as i8
}
return agln;
agln
}
static mut aglmap: ht_table = ht_table {
count: 0,
Expand Down Expand Up @@ -1119,7 +1119,7 @@ unsafe extern "C" fn agl_load_listfile(mut filename: *const i8, mut is_predef: i
if verbose != 0 {
dpx_message(b">\x00" as *const u8 as *const i8);
}
return count;
count
}
#[no_mangle]
pub unsafe extern "C" fn agl_lookup_list(mut glyphname: *const i8) -> *mut agl_name {
Expand All @@ -1132,7 +1132,7 @@ pub unsafe extern "C" fn agl_lookup_list(mut glyphname: *const i8) -> *mut agl_n
glyphname as *const libc::c_void,
strlen(glyphname) as i32,
) as *mut agl_name;
return agln;
agln
}
#[no_mangle]
pub unsafe extern "C" fn agl_name_is_unicode(mut glyphname: *const i8) -> bool {
Expand All @@ -1141,7 +1141,7 @@ pub unsafe extern "C" fn agl_name_is_unicode(mut glyphname: *const i8) -> bool {
let mut i: size_t = 0;
let mut len: size_t = 0;
if glyphname.is_null() {
return 0i32 != 0;
return false;
}
suffix = strchr(glyphname, '.' as i32);
len = if !suffix.is_null() {
Expand All @@ -1166,9 +1166,9 @@ pub unsafe extern "C" fn agl_name_is_unicode(mut glyphname: *const i8) -> bool {
!= 0
|| c as i32 >= 'A' as i32 && c as i32 <= 'F' as i32
{
return 1i32 != 0;
return true;
} else {
return 0i32 != 0;
return false;
}
} else {
if len <= 7i32 as u64 && len >= 5i32 as u64 && *glyphname.offset(0) as i32 == 'u' as i32 {
Expand All @@ -1180,14 +1180,14 @@ pub unsafe extern "C" fn agl_name_is_unicode(mut glyphname: *const i8) -> bool {
== 0
&& ((c as i32) < 'A' as i32 || c as i32 > 'F' as i32)
{
return 0i32 != 0;
return false;
}
i = i.wrapping_add(1)
}
return 1i32 != 0;
return true;
}
}
return 0i32 != 0;
false
}
#[no_mangle]
pub unsafe extern "C" fn agl_name_convert_unicode(mut glyphname: *const i8) -> i32 {
Expand Down Expand Up @@ -1246,7 +1246,7 @@ pub unsafe extern "C" fn agl_name_convert_unicode(mut glyphname: *const i8) -> i
}
ucv = -1i32
}
return ucv;
ucv
}
unsafe extern "C" fn xtol(mut start: *const i8, mut len: i32) -> i32 {
let mut v: i32 = 0i32;
Expand All @@ -1269,7 +1269,7 @@ unsafe extern "C" fn xtol(mut start: *const i8, mut len: i32) -> i32 {
}
start = start.offset(1)
}
return v;
v
}
unsafe extern "C" fn put_unicode_glyph(
mut name: *const i8,
Expand All @@ -1294,7 +1294,7 @@ unsafe extern "C" fn put_unicode_glyph(
p = p.offset(4)
}
}
return len;
len
}
#[no_mangle]
pub unsafe extern "C" fn agl_sput_UTF16BE(
Expand Down Expand Up @@ -1411,7 +1411,7 @@ pub unsafe extern "C" fn agl_sput_UTF16BE(
if !fail_count.is_null() {
*fail_count = count
}
return len;
len
}
/* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
Expand Down Expand Up @@ -1560,5 +1560,5 @@ pub unsafe extern "C" fn agl_get_unicodes(
free(name as *mut libc::c_void);
p = delim.offset(1)
}
return count;
count
}
12 changes: 6 additions & 6 deletions engine/src/dpx_bmpimage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ pub unsafe extern "C" fn check_for_bmp(mut handle: rust_input_handle_t) -> i32 {
{
return 0i32;
}
return 1i32;
1i32
}
unsafe extern "C" fn get_density(
mut xdensity: *mut f64,
Expand Down Expand Up @@ -217,7 +217,7 @@ pub unsafe extern "C" fn bmp_get_bbox(
hdr.height
}) as u32;
get_density(xdensity, ydensity, &mut hdr);
return r;
r
}
/* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
Expand Down Expand Up @@ -481,7 +481,7 @@ pub unsafe extern "C" fn bmp_include_image(
&mut info as *mut ximage_info as *mut libc::c_void,
stream,
);
return 0i32;
0i32
}
unsafe extern "C" fn read_header(mut handle: rust_input_handle_t, mut hdr: *mut hdr_info) -> i32 {
let mut buf: [u8; 142] = [0; 142];
Expand Down Expand Up @@ -599,7 +599,7 @@ unsafe extern "C" fn read_header(mut handle: rust_input_handle_t, mut hdr: *mut
return -1i32;
}
}
return 0i32;
0i32
}
unsafe extern "C" fn read_raster_rle8(
mut data_ptr: *mut u8,
Expand Down Expand Up @@ -691,7 +691,7 @@ unsafe extern "C" fn read_raster_rle8(
}
v += 1
}
return count;
count
}
unsafe extern "C" fn read_raster_rle4(
mut data_ptr: *mut u8,
Expand Down Expand Up @@ -820,6 +820,6 @@ unsafe extern "C" fn read_raster_rle4(
}
v += 1
}
return count;
count
}
/* Check for EOL and EOI marker */
Loading

0 comments on commit bb79da7

Please sign in to comment.