|
@@ -498,7 +498,7 @@ pub unsafe extern "C" fn strtod(s: *const c_char, endptr: *mut *mut c_char) -> c
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-fn is_positive(ch: c_char) -> Option<(bool, isize)> {
|
|
|
+pub fn is_positive(ch: c_char) -> Option<(bool, isize)> {
|
|
|
match ch {
|
|
|
0 => None,
|
|
|
ch if ch == b'+' as c_char => Some((true, 1)),
|
|
@@ -507,7 +507,7 @@ fn is_positive(ch: c_char) -> Option<(bool, isize)> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-fn detect_base(s: *const c_char) -> Option<(c_int, isize)> {
|
|
|
+pub fn detect_base(s: *const c_char) -> Option<(c_int, isize)> {
|
|
|
let first = unsafe { *s } as u8;
|
|
|
match first {
|
|
|
0 => None,
|
|
@@ -526,7 +526,7 @@ fn detect_base(s: *const c_char) -> Option<(c_int, isize)> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-unsafe fn convert_octal(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
|
|
|
+pub unsafe fn convert_octal(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
|
|
|
if *s != 0 && *s == b'0' as c_char {
|
|
|
if let Some((val, idx, overflow)) = convert_integer(s.offset(1), 8) {
|
|
|
Some((val, idx + 1, overflow))
|
|
@@ -539,7 +539,7 @@ unsafe fn convert_octal(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-unsafe fn convert_hex(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
|
|
|
+pub unsafe fn convert_hex(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
|
|
|
if (*s != 0 && *s == b'0' as c_char)
|
|
|
&& (*s.offset(1) != 0 && (*s.offset(1) == b'x' as c_char || *s.offset(1) == b'X' as c_char))
|
|
|
{
|
|
@@ -549,7 +549,7 @@ unsafe fn convert_hex(s: *const c_char) -> Option<(c_ulong, isize, bool)> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-fn convert_integer(s: *const c_char, base: c_int) -> Option<(c_ulong, isize, bool)> {
|
|
|
+pub fn convert_integer(s: *const c_char, base: c_int) -> Option<(c_ulong, isize, bool)> {
|
|
|
// -1 means the character is invalid
|
|
|
#[cfg_attr(rustfmt, rustfmt_skip)]
|
|
|
const LOOKUP_TABLE: [c_long; 256] = [
|
|
@@ -603,6 +603,7 @@ fn convert_integer(s: *const c_char, base: c_int) -> Option<(c_ulong, isize, boo
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+#[macro_export]
|
|
|
macro_rules! strto_impl {
|
|
|
(
|
|
|
$rettype:ty,
|