Support nightly 2026-05-24
This commit is contained in:
+18
-34
@@ -1406,12 +1406,8 @@ pub unsafe extern "C" fn vfprintf(file: *mut FILE, format: *const c_char, ap: va
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/fprintf.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn fprintf(
|
||||
file: *mut FILE,
|
||||
format: *const c_char,
|
||||
mut __valist: ...
|
||||
) -> c_int {
|
||||
unsafe { vfprintf(file, format, __valist.as_va_list()) }
|
||||
pub unsafe extern "C" fn fprintf(file: *mut FILE, format: *const c_char, __valist: ...) -> c_int {
|
||||
unsafe { vfprintf(file, format, __valist) }
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/vdprintf.html>.
|
||||
@@ -1428,8 +1424,8 @@ pub unsafe extern "C" fn vdprintf(fd: c_int, format: *const c_char, ap: va_list)
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/dprintf.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn dprintf(fd: c_int, format: *const c_char, mut __valist: ...) -> c_int {
|
||||
unsafe { vdprintf(fd, format, __valist.as_va_list()) }
|
||||
pub unsafe extern "C" fn dprintf(fd: c_int, format: *const c_char, __valist: ...) -> c_int {
|
||||
unsafe { vdprintf(fd, format, __valist) }
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/vfprintf.html>.
|
||||
@@ -1440,8 +1436,8 @@ pub unsafe extern "C" fn vprintf(format: *const c_char, ap: va_list) -> c_int {
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/fprintf.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn printf(format: *const c_char, mut __valist: ...) -> c_int {
|
||||
unsafe { vfprintf(&raw mut *stdout, format, __valist.as_va_list()) }
|
||||
pub unsafe extern "C" fn printf(format: *const c_char, __valist: ...) -> c_int {
|
||||
unsafe { vfprintf(&raw mut *stdout, format, __valist) }
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/vfprintf.html>.
|
||||
@@ -1464,9 +1460,9 @@ pub unsafe extern "C" fn vasprintf(
|
||||
pub unsafe extern "C" fn asprintf(
|
||||
strp: *mut *mut c_char,
|
||||
format: *const c_char,
|
||||
mut __valist: ...
|
||||
__valist: ...
|
||||
) -> c_int {
|
||||
unsafe { vasprintf(strp, format, __valist.as_va_list()) }
|
||||
unsafe { vasprintf(strp, format, __valist) }
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/vfprintf.html>.
|
||||
@@ -1492,13 +1488,13 @@ pub unsafe extern "C" fn snprintf(
|
||||
s: *mut c_char,
|
||||
n: size_t,
|
||||
format: *const c_char,
|
||||
mut __valist: ...
|
||||
__valist: ...
|
||||
) -> c_int {
|
||||
unsafe {
|
||||
printf::printf(
|
||||
&mut platform::StringWriter(s, n),
|
||||
CStr::from_ptr(format),
|
||||
__valist.as_va_list(),
|
||||
__valist,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1517,16 +1513,12 @@ pub unsafe extern "C" fn vsprintf(s: *mut c_char, format: *const c_char, ap: va_
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/fprintf.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn sprintf(
|
||||
s: *mut c_char,
|
||||
format: *const c_char,
|
||||
mut __valist: ...
|
||||
) -> c_int {
|
||||
pub unsafe extern "C" fn sprintf(s: *mut c_char, format: *const c_char, __valist: ...) -> c_int {
|
||||
unsafe {
|
||||
printf::printf(
|
||||
&mut platform::UnsafeStringWriter(s.cast::<u8>()),
|
||||
CStr::from_ptr(format),
|
||||
__valist.as_va_list(),
|
||||
__valist,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1549,12 +1541,8 @@ pub unsafe extern "C" fn vfscanf(file: *mut FILE, format: *const c_char, ap: va_
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/fscanf.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn fscanf(
|
||||
file: *mut FILE,
|
||||
format: *const c_char,
|
||||
mut __valist: ...
|
||||
) -> c_int {
|
||||
unsafe { vfscanf(file, format, __valist.as_va_list()) }
|
||||
pub unsafe extern "C" fn fscanf(file: *mut FILE, format: *const c_char, __valist: ...) -> c_int {
|
||||
unsafe { vfscanf(file, format, __valist) }
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/vfscanf.html>.
|
||||
@@ -1565,8 +1553,8 @@ pub unsafe extern "C" fn vscanf(format: *const c_char, ap: va_list) -> c_int {
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/fscanf.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn scanf(format: *const c_char, mut __valist: ...) -> c_int {
|
||||
unsafe { vfscanf(&raw mut *stdin, format, __valist.as_va_list()) }
|
||||
pub unsafe extern "C" fn scanf(format: *const c_char, __valist: ...) -> c_int {
|
||||
unsafe { vfscanf(&raw mut *stdin, format, __valist) }
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/vfscanf.html>.
|
||||
@@ -1581,15 +1569,11 @@ pub unsafe extern "C" fn vsscanf(s: *const c_char, format: *const c_char, ap: va
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/fscanf.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn sscanf(
|
||||
s: *const c_char,
|
||||
format: *const c_char,
|
||||
mut __valist: ...
|
||||
) -> c_int {
|
||||
pub unsafe extern "C" fn sscanf(s: *const c_char, format: *const c_char, __valist: ...) -> c_int {
|
||||
unsafe {
|
||||
let format = CStr::from_ptr(format);
|
||||
let s = CStr::from_ptr(s);
|
||||
scanf::scanf(s.into(), format.into(), __valist.as_va_list())
|
||||
scanf::scanf(s.into(), format.into(), __valist)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-14
@@ -127,36 +127,36 @@ impl VaArg {
|
||||
(FmtKind::Percent, _) => panic!("Can't call arg_from on %"),
|
||||
|
||||
(FmtKind::Char, IntKind::Long) | (FmtKind::Char, IntKind::LongLong) => {
|
||||
VaArg::wint_t(unsafe { ap.arg::<wint_t>() })
|
||||
VaArg::wint_t(unsafe { ap.next_arg::<wint_t>() })
|
||||
}
|
||||
|
||||
(FmtKind::Char, _)
|
||||
| (FmtKind::Unsigned, IntKind::Byte)
|
||||
| (FmtKind::Signed, IntKind::Byte) => {
|
||||
// c_int is passed but truncated to c_char
|
||||
VaArg::c_char(unsafe { ap.arg::<c_int>() } as c_char)
|
||||
VaArg::c_char(unsafe { ap.next_arg::<c_int>() } as c_char)
|
||||
}
|
||||
(FmtKind::Unsigned, IntKind::Short) | (FmtKind::Signed, IntKind::Short) => {
|
||||
// c_int is passed but truncated to c_short
|
||||
VaArg::c_short(unsafe { ap.arg::<c_int>() } as c_short)
|
||||
VaArg::c_short(unsafe { ap.next_arg::<c_int>() } as c_short)
|
||||
}
|
||||
(FmtKind::Unsigned, IntKind::Int) | (FmtKind::Signed, IntKind::Int) => {
|
||||
VaArg::c_int(unsafe { ap.arg::<c_int>() })
|
||||
VaArg::c_int(unsafe { ap.next_arg::<c_int>() })
|
||||
}
|
||||
(FmtKind::Unsigned, IntKind::Long) | (FmtKind::Signed, IntKind::Long) => {
|
||||
VaArg::c_long(unsafe { ap.arg::<c_long>() })
|
||||
VaArg::c_long(unsafe { ap.next_arg::<c_long>() })
|
||||
}
|
||||
(FmtKind::Unsigned, IntKind::LongLong) | (FmtKind::Signed, IntKind::LongLong) => {
|
||||
VaArg::c_longlong(unsafe { ap.arg::<c_longlong>() })
|
||||
VaArg::c_longlong(unsafe { ap.next_arg::<c_longlong>() })
|
||||
}
|
||||
(FmtKind::Unsigned, IntKind::IntMax) | (FmtKind::Signed, IntKind::IntMax) => {
|
||||
VaArg::intmax_t(unsafe { ap.arg::<intmax_t>() })
|
||||
VaArg::intmax_t(unsafe { ap.next_arg::<intmax_t>() })
|
||||
}
|
||||
(FmtKind::Unsigned, IntKind::PtrDiff) | (FmtKind::Signed, IntKind::PtrDiff) => {
|
||||
VaArg::ptrdiff_t(unsafe { ap.arg::<ptrdiff_t>() })
|
||||
VaArg::ptrdiff_t(unsafe { ap.next_arg::<ptrdiff_t>() })
|
||||
}
|
||||
(FmtKind::Unsigned, IntKind::Size) | (FmtKind::Signed, IntKind::Size) => {
|
||||
VaArg::ssize_t(unsafe { ap.arg::<ssize_t>() })
|
||||
VaArg::ssize_t(unsafe { ap.next_arg::<ssize_t>() })
|
||||
}
|
||||
|
||||
(FmtKind::AnyNotation, IntKind::LongLong)
|
||||
@@ -165,11 +165,11 @@ impl VaArg {
|
||||
VaArg::c_longdouble(unsafe { VaArg::extract_longdouble(ap) })
|
||||
}
|
||||
(FmtKind::AnyNotation, _) | (FmtKind::Decimal, _) | (FmtKind::Scientific, _) => {
|
||||
VaArg::c_double(unsafe { ap.arg::<c_double>() })
|
||||
VaArg::c_double(unsafe { ap.next_arg::<c_double>() })
|
||||
}
|
||||
|
||||
(FmtKind::GetWritten, _) | (FmtKind::Pointer, _) | (FmtKind::String, _) => {
|
||||
VaArg::pointer(unsafe { ap.arg::<*const c_void>() })
|
||||
VaArg::pointer(unsafe { ap.next_arg::<*const c_void>() })
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -348,13 +348,13 @@ impl VaListCache {
|
||||
// point. Reaching here means there are unused gaps in the
|
||||
// arguments. Ultimately we'll have to settle down with
|
||||
// defaulting to c_int.
|
||||
self.args.push(VaArg::c_int(unsafe { ap.arg::<c_int>() }))
|
||||
self.args.push(VaArg::c_int(unsafe { ap.next_arg::<c_int>() }))
|
||||
}
|
||||
|
||||
// Add the value to the cache
|
||||
self.args.push(match default {
|
||||
Some((fmtkind, intkind)) => unsafe { VaArg::arg_from(fmtkind, intkind, ap) },
|
||||
None => VaArg::c_int(unsafe { ap.arg::<c_int>() }),
|
||||
None => VaArg::c_int(unsafe { ap.next_arg::<c_int>() }),
|
||||
});
|
||||
|
||||
// Return the value
|
||||
@@ -776,7 +776,7 @@ pub(crate) unsafe fn inner_printf<T: c_str::Kind>(
|
||||
match num {
|
||||
Number::Next => varargs
|
||||
.args
|
||||
.push(VaArg::c_int(unsafe { ap.arg::<c_int>() })),
|
||||
.push(VaArg::c_int(unsafe { ap.next_arg::<c_int>() })),
|
||||
Number::Index(i) => {
|
||||
positional.insert(i - 1, (FmtKind::Signed, IntKind::Int));
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ pub unsafe fn inner_scanf<T: Kind>(
|
||||
n.parse::<$type>().map_err(|_| 0)?
|
||||
};
|
||||
if !ignore {
|
||||
unsafe { *ap.arg::<*mut $type>() = n };
|
||||
unsafe { *ap.next_arg::<*mut $type>() = n };
|
||||
matched += 1;
|
||||
}
|
||||
}};
|
||||
@@ -268,7 +268,7 @@ pub unsafe fn inner_scanf<T: Kind>(
|
||||
$type::from_str_radix(&n, radix).map_err(|_| 0)?
|
||||
};
|
||||
if !ignore {
|
||||
unsafe { *ap.arg::<*mut $final>() = n as $final };
|
||||
unsafe { *ap.next_arg::<*mut $final>() = n as $final };
|
||||
matched += 1;
|
||||
}
|
||||
}};
|
||||
@@ -350,7 +350,7 @@ pub unsafe fn inner_scanf<T: Kind>(
|
||||
}
|
||||
|
||||
let mut ptr: Option<*mut $type> =
|
||||
if ignore { None } else { Some(ap.arg()) };
|
||||
if ignore { None } else { Some(ap.next_arg()) };
|
||||
|
||||
while width.map(|w| w > 0).unwrap_or(true) && !character.is_whitespace()
|
||||
{
|
||||
@@ -395,7 +395,7 @@ pub unsafe fn inner_scanf<T: Kind>(
|
||||
let ptr: Option<*mut $type> = if ignore {
|
||||
None
|
||||
} else {
|
||||
Some(unsafe { ap.arg() })
|
||||
Some(unsafe { ap.next_arg() })
|
||||
};
|
||||
|
||||
for i in 0..width.unwrap_or(1) {
|
||||
@@ -460,7 +460,7 @@ pub unsafe fn inner_scanf<T: Kind>(
|
||||
let mut ptr: Option<*mut c_char> = if ignore {
|
||||
None
|
||||
} else {
|
||||
Some(unsafe { ap.arg() })
|
||||
Some(unsafe { ap.next_arg() })
|
||||
};
|
||||
|
||||
// While we haven't used up all the width, and it matches
|
||||
@@ -490,7 +490,7 @@ pub unsafe fn inner_scanf<T: Kind>(
|
||||
}
|
||||
'n' => {
|
||||
if !ignore {
|
||||
unsafe { *ap.arg::<*mut c_int>() = count as c_int };
|
||||
unsafe { *ap.next_arg::<*mut c_int>() = count as c_int };
|
||||
}
|
||||
}
|
||||
_ => return Err(-1),
|
||||
|
||||
Reference in New Issue
Block a user