mirror of
https://github.com/chatmail/core.git
synced 2026-05-05 14:26:30 +03:00
* Start replacing int with bool where possible (#18) * Continue replacing int with bool where possible (#18) * Continue replacing int with bool where possible (#18) * Run fmt
This commit is contained in:
@@ -158,9 +158,9 @@ unsafe fn dc_simplify_simplify_plain_text(
|
||||
l = l_last;
|
||||
while l >= l_first {
|
||||
line = carray_get(lines, l as libc::c_uint) as *mut libc::c_char;
|
||||
if 0 != is_plain_quote(line) {
|
||||
if is_plain_quote(line) {
|
||||
l_lastQuotedLine = l
|
||||
} else if 0 == is_empty_line(line) {
|
||||
} else if !is_empty_line(line) {
|
||||
break;
|
||||
}
|
||||
l -= 1
|
||||
@@ -169,14 +169,13 @@ unsafe fn dc_simplify_simplify_plain_text(
|
||||
l_last = l_lastQuotedLine - 1i32;
|
||||
(*simplify).is_cut_at_end = 1i32;
|
||||
if l_last > 0i32 {
|
||||
if 0 != is_empty_line(carray_get(lines, l_last as libc::c_uint) as *mut libc::c_char)
|
||||
{
|
||||
if is_empty_line(carray_get(lines, l_last as libc::c_uint) as *mut libc::c_char) {
|
||||
l_last -= 1
|
||||
}
|
||||
}
|
||||
if l_last > 0i32 {
|
||||
line = carray_get(lines, l_last as libc::c_uint) as *mut libc::c_char;
|
||||
if 0 != is_quoted_headline(line) {
|
||||
if is_quoted_headline(line) {
|
||||
l_last -= 1
|
||||
}
|
||||
}
|
||||
@@ -188,12 +187,10 @@ unsafe fn dc_simplify_simplify_plain_text(
|
||||
l = l_first;
|
||||
while l <= l_last {
|
||||
line = carray_get(lines, l as libc::c_uint) as *mut libc::c_char;
|
||||
if 0 != is_plain_quote(line) {
|
||||
if is_plain_quote(line) {
|
||||
l_lastQuotedLine_0 = l
|
||||
} else if 0 == is_empty_line(line) {
|
||||
if 0 != is_quoted_headline(line)
|
||||
&& 0 == hasQuotedHeadline
|
||||
&& l_lastQuotedLine_0 == -1i32
|
||||
} else if !is_empty_line(line) {
|
||||
if is_quoted_headline(line) && 0 == hasQuotedHeadline && l_lastQuotedLine_0 == -1i32
|
||||
{
|
||||
hasQuotedHeadline = 1i32
|
||||
} else {
|
||||
@@ -225,7 +222,7 @@ unsafe fn dc_simplify_simplify_plain_text(
|
||||
l = l_first;
|
||||
while l <= l_last {
|
||||
line = carray_get(lines, l as libc::c_uint) as *mut libc::c_char;
|
||||
if 0 != is_empty_line(line) {
|
||||
if is_empty_line(line) {
|
||||
pending_linebreaks += 1
|
||||
} else {
|
||||
if 0 != content_lines_added {
|
||||
@@ -256,42 +253,39 @@ unsafe fn dc_simplify_simplify_plain_text(
|
||||
/* ******************************************************************************
|
||||
* Tools
|
||||
******************************************************************************/
|
||||
// TODO should return bool /rtn
|
||||
unsafe fn is_empty_line(buf: *const libc::c_char) -> libc::c_int {
|
||||
unsafe fn is_empty_line(buf: *const libc::c_char) -> bool {
|
||||
/* force unsigned - otherwise the `> ' '` comparison will fail */
|
||||
let mut p1: *const libc::c_uchar = buf as *const libc::c_uchar;
|
||||
while 0 != *p1 {
|
||||
if *p1 as libc::c_int > ' ' as i32 {
|
||||
return 0i32;
|
||||
return false;
|
||||
}
|
||||
p1 = p1.offset(1isize)
|
||||
}
|
||||
|
||||
1
|
||||
true
|
||||
}
|
||||
|
||||
// TODO should return bool /rtn
|
||||
unsafe fn is_quoted_headline(buf: *const libc::c_char) -> libc::c_int {
|
||||
unsafe fn is_quoted_headline(buf: *const libc::c_char) -> bool {
|
||||
/* This function may be called for the line _directly_ before a quote.
|
||||
The function checks if the line contains sth. like "On 01.02.2016, xy@z wrote:" in various languages.
|
||||
- Currently, we simply check if the last character is a ':'.
|
||||
- Checking for the existance of an email address may fail (headlines may show the user's name instead of the address) */
|
||||
let buf_len: libc::c_int = strlen(buf) as libc::c_int;
|
||||
if buf_len > 80i32 {
|
||||
return 0i32;
|
||||
return false;
|
||||
}
|
||||
if buf_len > 0i32 && *buf.offset((buf_len - 1i32) as isize) as libc::c_int == ':' as i32 {
|
||||
return 1i32;
|
||||
return true;
|
||||
}
|
||||
|
||||
0
|
||||
false
|
||||
}
|
||||
|
||||
// TODO should return bool /rtn
|
||||
unsafe fn is_plain_quote(buf: *const libc::c_char) -> libc::c_int {
|
||||
unsafe fn is_plain_quote(buf: *const libc::c_char) -> bool {
|
||||
if *buf.offset(0isize) as libc::c_int == '>' as i32 {
|
||||
return 1i32;
|
||||
return true;
|
||||
}
|
||||
|
||||
0
|
||||
false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user