]> Kevux Git Server - fll/commitdiff
Bugfix: The asctime_r() function appends a new line.
authorKevin Day <Kevin@kevux.org>
Mon, 24 Nov 2025 02:27:17 +0000 (20:27 -0600)
committerKevin Day <Kevin@kevux.org>
Mon, 24 Nov 2025 02:27:17 +0000 (20:27 -0600)
Ensure that the new line is not counted as part of the date string.

level_0/f_time/c/time.c

index c061d9f79a541cc17ec598a16a053b2b06905a01..6f67b5780e647ff222127df5c175fa5420df5f98 100644 (file)
@@ -42,6 +42,11 @@ extern "C" {
     const f_status_t status = f_string_append(string, strnlen(string, F_time_calendar_string_length_d), destination);
     if (F_status_is_error(status)) return status;
 
+    // Ensure that if a new line is added by asctime_r(), it is removed.
+    if (destination->used && destination->string[destination->used - 1] == f_string_ascii_feed_line_s.string[0]) {
+      --destination->used;
+    }
+
     return F_okay;
   }
 #endif // _di_f_time_calendar_string_part_