Merge branch 'strptime-subfmt-no-clobber' into 'master'

fix(strptime): Don't clobber struct tm

See merge request redox-os/relibc!640
This commit is contained in:
Jeremy Soller
2025-04-02 18:58:10 +00:00
2 changed files with 15 additions and 22 deletions
-6
View File
@@ -89,12 +89,6 @@ pub unsafe extern "C" fn strptime(
}
};
// Zero-initialize the output `tm` structure
// (equivalent to: tm_sec=0, tm_min=0, tm_hour=0...)
unsafe {
ptr::write_bytes(tm, 0, 1);
}
// We parse the format specifiers in a loop
let mut fmt_chars = fmt_str.chars().peekable();
let mut index_in_input = 0;
+15 -16
View File
@@ -99,22 +99,21 @@ int main(void) {
);
// TODO: Locale offset
// Also, this test is broken on Redox
/* const char redox[] = "Mon Oct 31 11:19:57 2016"; */
/* struct tm redox_expect = { */
/* .tm_year = 116, */
/* .tm_mon = 9, */
/* .tm_mday = 31, */
/* .tm_hour = 11, */
/* .tm_min = 19, */
/* .tm_sec = 57, */
/* .tm_yday = 304, */
/* .tm_wday = 1, */
/* }; */
/* strptime_test(redox, */
/* "%a%t%b%t%d%t%T%t%Y", */
/* redox_expect, */
/* ""); */
const char redox[] = "Mon Oct 31 11:19:57 2016";
struct tm redox_expect = {
.tm_year = 116,
.tm_mon = 9,
.tm_mday = 31,
.tm_hour = 11,
.tm_min = 19,
.tm_sec = 57,
/* .tm_yday = 304, */
.tm_wday = 1,
};
strptime_test(redox,
"%a%t%b%t%d%t%T%t%Y",
redox_expect,
"");
// Roundtrip
const char roundtrip[] = "2012-01-19 13:37:00";