mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
Remove goto/current_block logic with OK_TO_CONTINUE. Keeps identation
This commit is contained in:
committed by
Floris Bruynooghe
parent
164a8fe39a
commit
9fb9fb0fc1
@@ -264,7 +264,7 @@ pub unsafe fn dc_unify_lineends(buf: *mut libc::c_char) {
|
|||||||
|
|
||||||
/* replace bad UTF-8 characters by sequences of `_` (to avoid problems in filenames, we do not use eg. `?`) the function is useful if strings are unexpectingly encoded eg. as ISO-8859-1 */
|
/* replace bad UTF-8 characters by sequences of `_` (to avoid problems in filenames, we do not use eg. `?`) the function is useful if strings are unexpectingly encoded eg. as ISO-8859-1 */
|
||||||
pub unsafe fn dc_replace_bad_utf8_chars(buf: *mut libc::c_char) {
|
pub unsafe fn dc_replace_bad_utf8_chars(buf: *mut libc::c_char) {
|
||||||
let current_block: u64;
|
let mut OK_TO_CONTINUE = true;
|
||||||
if buf.is_null() {
|
if buf.is_null() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -280,7 +280,6 @@ pub unsafe fn dc_replace_bad_utf8_chars(buf: *mut libc::c_char) {
|
|||||||
ix = p1len;
|
ix = p1len;
|
||||||
's_36: loop {
|
's_36: loop {
|
||||||
if !(i < ix) {
|
if !(i < ix) {
|
||||||
current_block = 13550086250199790493;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
c = *p1.offset(i as isize) as libc::c_int;
|
c = *p1.offset(i as isize) as libc::c_int;
|
||||||
@@ -293,7 +292,7 @@ pub unsafe fn dc_replace_bad_utf8_chars(buf: *mut libc::c_char) {
|
|||||||
&& *p1.offset((i + 1i32) as isize) as libc::c_int & 0xa0i32 == 0xa0i32
|
&& *p1.offset((i + 1i32) as isize) as libc::c_int & 0xa0i32 == 0xa0i32
|
||||||
{
|
{
|
||||||
/* U+d800 to U+dfff */
|
/* U+d800 to U+dfff */
|
||||||
current_block = 2775201239069267972;
|
OK_TO_CONTINUE = false;
|
||||||
break;
|
break;
|
||||||
} else if c & 0xf0i32 == 0xe0i32 {
|
} else if c & 0xf0i32 == 0xe0i32 {
|
||||||
n = 2i32
|
n = 2i32
|
||||||
@@ -302,7 +301,7 @@ pub unsafe fn dc_replace_bad_utf8_chars(buf: *mut libc::c_char) {
|
|||||||
} else {
|
} else {
|
||||||
//else if ((c & 0xFC) == 0xF8) { n=4; } /* 111110bb - not valid in https://tools.ietf.org/html/rfc3629 */
|
//else if ((c & 0xFC) == 0xF8) { n=4; } /* 111110bb - not valid in https://tools.ietf.org/html/rfc3629 */
|
||||||
//else if ((c & 0xFE) == 0xFC) { n=5; } /* 1111110b - not valid in https://tools.ietf.org/html/rfc3629 */
|
//else if ((c & 0xFE) == 0xFC) { n=5; } /* 1111110b - not valid in https://tools.ietf.org/html/rfc3629 */
|
||||||
current_block = 2775201239069267972;
|
OK_TO_CONTINUE = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
j = 0i32;
|
j = 0i32;
|
||||||
@@ -310,16 +309,14 @@ pub unsafe fn dc_replace_bad_utf8_chars(buf: *mut libc::c_char) {
|
|||||||
/* n bytes matching 10bbbbbb follow ? */
|
/* n bytes matching 10bbbbbb follow ? */
|
||||||
i += 1;
|
i += 1;
|
||||||
if i == ix || *p1.offset(i as isize) as libc::c_int & 0xc0i32 != 0x80i32 {
|
if i == ix || *p1.offset(i as isize) as libc::c_int & 0xc0i32 != 0x80i32 {
|
||||||
current_block = 2775201239069267972;
|
OK_TO_CONTINUE = false;
|
||||||
break 's_36;
|
break 's_36;
|
||||||
}
|
}
|
||||||
j += 1
|
j += 1
|
||||||
}
|
}
|
||||||
i += 1
|
i += 1
|
||||||
}
|
}
|
||||||
match current_block {
|
if OK_TO_CONTINUE == false {
|
||||||
13550086250199790493 => return,
|
|
||||||
_ => {
|
|
||||||
while 0 != *p1 {
|
while 0 != *p1 {
|
||||||
if *p1 as libc::c_int > 0x7fi32 {
|
if *p1 as libc::c_int > 0x7fi32 {
|
||||||
*p1 = '_' as i32 as libc::c_uchar
|
*p1 = '_' as i32 as libc::c_uchar
|
||||||
@@ -327,8 +324,7 @@ pub unsafe fn dc_replace_bad_utf8_chars(buf: *mut libc::c_char) {
|
|||||||
p1 = p1.offset(1isize)
|
p1 = p1.offset(1isize)
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_utf8_strlen(s: *const libc::c_char) -> size_t {
|
pub unsafe fn dc_utf8_strlen(s: *const libc::c_char) -> size_t {
|
||||||
|
|||||||
Reference in New Issue
Block a user