add descriptions and pick a better function name
This commit is contained in:
+13
-13
@@ -423,13 +423,13 @@ unsafe fn find_env(search: *const c_char) -> Option<(usize, *mut c_char)> {
|
||||
let mut search = search;
|
||||
loop {
|
||||
let end_of_query =
|
||||
unsafe { *search } == 0 || unsafe { *search } == ByteLiteral::cast_unchecked(b'=');
|
||||
unsafe { *search } == 0 || unsafe { *search } == ByteLiteral::cast_cchar(b'=');
|
||||
if unsafe { *item } == 0 {
|
||||
//TODO: environ has an item without value, is this a problem?
|
||||
break;
|
||||
}
|
||||
if unsafe { *item } == ByteLiteral::cast_unchecked(b'=') || end_of_query {
|
||||
if unsafe { *item } == ByteLiteral::cast_unchecked(b'=') && end_of_query {
|
||||
if unsafe { *item } == ByteLiteral::cast_cchar(b'=') || end_of_query {
|
||||
if unsafe { *item } == ByteLiteral::cast_cchar(b'=') && end_of_query {
|
||||
// Both keys env here
|
||||
return Some((i, unsafe { item.add(1) }));
|
||||
} else {
|
||||
@@ -477,7 +477,7 @@ pub unsafe extern "C" fn getsubopt(
|
||||
let mut found_comma = false;
|
||||
|
||||
while unsafe { *cursor } != 0 {
|
||||
if unsafe { *cursor } == ByteLiteral::cast_unchecked(b',') {
|
||||
if unsafe { *cursor } == ByteLiteral::cast_cchar(b',') {
|
||||
unsafe { *cursor = 0 };
|
||||
unsafe { *optionp = cursor.add(1) };
|
||||
found_comma = true;
|
||||
@@ -498,7 +498,7 @@ pub unsafe extern "C" fn getsubopt(
|
||||
if unsafe { strncmp(start, token, token_len) } == 0 {
|
||||
let suffix_char = unsafe { *start.add(token_len) };
|
||||
|
||||
if suffix_char == ByteLiteral::cast_unchecked(b'=') {
|
||||
if suffix_char == ByteLiteral::cast_cchar(b'=') {
|
||||
unsafe { *valuep = start.add(token_len + 1) };
|
||||
return i as c_int;
|
||||
} else if suffix_char == 0 {
|
||||
@@ -756,7 +756,7 @@ where
|
||||
}
|
||||
|
||||
for i in (len - suffix_len - 6)..(len - suffix_len) {
|
||||
if unsafe { *name.offset(i as isize) } != ByteLiteral::cast_unchecked(b'X') {
|
||||
if unsafe { *name.offset(i as isize) } != ByteLiteral::cast_cchar(b'X') {
|
||||
platform::ERRNO.set(errno::EINVAL);
|
||||
return None;
|
||||
}
|
||||
@@ -1260,7 +1260,7 @@ unsafe fn copy_kv(
|
||||
value_len: usize,
|
||||
) {
|
||||
unsafe { core::ptr::copy_nonoverlapping(key, existing, key_len) };
|
||||
unsafe { core::ptr::write(existing.add(key_len), ByteLiteral::cast_unchecked(b'=')) };
|
||||
unsafe { core::ptr::write(existing.add(key_len), ByteLiteral::cast_cchar(b'=')) };
|
||||
unsafe { core::ptr::copy_nonoverlapping(value, existing.add(key_len + 1), value_len) };
|
||||
unsafe { core::ptr::write(existing.add(key_len + 1 + value_len), 0) };
|
||||
}
|
||||
@@ -1367,8 +1367,8 @@ pub unsafe extern "C" fn srandom(seed: c_uint) {
|
||||
pub fn is_positive(ch: c_char) -> Option<(bool, isize)> {
|
||||
match ch {
|
||||
0 => None,
|
||||
ch if ch == ByteLiteral::cast_unchecked(b'+') => Some((true, 1)),
|
||||
ch if ch == ByteLiteral::cast_unchecked(b'-') => Some((false, 1)),
|
||||
ch if ch == ByteLiteral::cast_cchar(b'+') => Some((true, 1)),
|
||||
ch if ch == ByteLiteral::cast_cchar(b'-') => Some((false, 1)),
|
||||
_ => Some((true, 0)),
|
||||
}
|
||||
}
|
||||
@@ -1393,7 +1393,7 @@ pub unsafe fn detect_base(s: *const c_char) -> Option<(c_int, isize)> {
|
||||
}
|
||||
|
||||
pub unsafe fn convert_octal(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
|
||||
if unsafe { *s } != 0 && unsafe { *s } == ByteLiteral::cast_unchecked(b'0') {
|
||||
if unsafe { *s } != 0 && unsafe { *s } == ByteLiteral::cast_cchar(b'0') {
|
||||
if let Some((val, idx, overflow)) = unsafe { convert_integer(s.offset(1), 8) } {
|
||||
Some((val, idx + 1, overflow))
|
||||
} else {
|
||||
@@ -1406,10 +1406,10 @@ pub unsafe fn convert_octal(s: *const c_char) -> Option<(c_ulong, isize, bool)>
|
||||
}
|
||||
|
||||
pub unsafe fn convert_hex(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
|
||||
if (unsafe { *s } != 0 && unsafe { *s } == ByteLiteral::cast_unchecked(b'0'))
|
||||
if (unsafe { *s } != 0 && unsafe { *s } == ByteLiteral::cast_cchar(b'0'))
|
||||
&& (unsafe { *s.offset(1) } != 0
|
||||
&& (unsafe { *s.offset(1) } == ByteLiteral::cast_unchecked(b'x')
|
||||
|| unsafe { *s.offset(1) } == ByteLiteral::cast_unchecked(b'X')))
|
||||
&& (unsafe { *s.offset(1) } == ByteLiteral::cast_cchar(b'x')
|
||||
|| unsafe { *s.offset(1) } == ByteLiteral::cast_cchar(b'X')))
|
||||
{
|
||||
unsafe { convert_integer(s.offset(2), 16) }
|
||||
.map(|(val, idx, overflow)| (val, idx + 2, overflow))
|
||||
|
||||
Reference in New Issue
Block a user