Merge branch 'os-test-fixes' into 'master'

os-test fixes

See merge request redox-os/relibc!825
This commit is contained in:
Jeremy Soller
2025-12-24 20:52:45 -07:00
2 changed files with 22 additions and 11 deletions
+2
View File
@@ -784,7 +784,9 @@ pub unsafe extern "C" fn ftell_locked(stream: &mut FILE) -> off_t {
return -1;
}
// Adjust for read buffer, ungetc, and write buffer
pos - (stream.read_size - stream.read_pos) as off_t - stream.unget.len() as off_t
+ stream.writer.pending() as off_t
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/flockfile.html>.
+20 -11
View File
@@ -444,12 +444,15 @@ fn fmt_float_normal<W: Write>(
}
/// Write ±infinity or ±NaN representation for any floating-point style
fn fmt_float_nonfinite<W: Write>(w: &mut W, float: c_double, case: FmtCase) -> io::Result<()> {
if float.is_sign_negative() {
w.write_all(&[b'-'])?;
}
let nonfinite_str = match float.classify() {
fn fmt_float_nonfinite<W: Write>(
w: &mut W,
float: c_double,
case: FmtCase,
left: bool,
pad_space: usize,
pad_zero: usize,
) -> io::Result<()> {
let string = match float.classify() {
FpCategory::Infinite => match case {
FmtCase::Lower => INF_STR_LOWER,
FmtCase::Upper => INF_STR_UPPER,
@@ -460,11 +463,17 @@ fn fmt_float_nonfinite<W: Write>(w: &mut W, float: c_double, case: FmtCase) -> i
},
_ => {
// This function should only be called with infinite or NaN value.
panic!("this should not be possible")
panic!("fmt_float_nonfinite called with finite float")
}
};
w.write_all(nonfinite_str.as_bytes())?;
// Infinity is always padded with spaces, rather than zeroes
pad(w, !left, b' ', string.len()..pad_space + pad_zero)?;
if float.is_sign_negative() {
w.write_all(&[b'-'])?;
}
w.write_all(string.as_bytes())?;
pad(w, left, b' ', string.len()..pad_space + pad_zero)?;
Ok(())
}
@@ -851,7 +860,7 @@ pub(crate) unsafe fn inner_printf<T: c_str::Kind>(
w, fmt, false, precision, float, exp, left, pad_space, pad_zero,
)?;
} else {
fmt_float_nonfinite(w, float, fmtcase.unwrap())?;
fmt_float_nonfinite(w, float, fmtcase.unwrap(), left, pad_space, pad_zero)?;
}
}
FmtKind::Decimal => {
@@ -864,7 +873,7 @@ pub(crate) unsafe fn inner_printf<T: c_str::Kind>(
fmt_float_normal(w, false, precision, float, left, pad_space, pad_zero)?;
} else {
fmt_float_nonfinite(w, float, fmtcase.unwrap())?;
fmt_float_nonfinite(w, float, fmtcase.unwrap(), left, pad_space, pad_zero)?;
}
}
FmtKind::AnyNotation => {
@@ -896,7 +905,7 @@ pub(crate) unsafe fn inner_printf<T: c_str::Kind>(
fmt_float_normal(w, true, precision, float, left, pad_space, pad_zero)?;
}
} else {
fmt_float_nonfinite(w, float, fmtcase.unwrap())?;
fmt_float_nonfinite(w, float, fmtcase.unwrap(), left, pad_space, pad_zero)?;
}
}
FmtKind::String => {