shithub: scc

Download patch

ref: 48514a5765fbec60ae8f776d7bff7fad66cfd578
parent: cf871907e412224c33be01bdaaf207bf2479ec26
author: Naveen Narayanan <[email protected]>
date: Wed Aug 26 10:08:54 EDT 2020

libc: Fix strftime (time.h)

This patch processes the flags, embedded along with the modifiers for
conversion specifiers such as E and O, as though they were used
without them.

--- a/src/libc/time/strftime.c
+++ b/src/libc/time/strftime.c
@@ -106,6 +106,10 @@
 		fill = '0';
 		width = 2;
 
+		if (*fmt == 'E' || *fmt == 'O') {
+			fmt++;
+		}
+
 		switch (*fmt++) {
 		case 'Z':
 			if (!tm->tm_zone)
@@ -173,7 +177,7 @@
 		case 'V':
 		case 'g':
 		case 'G':
-			/* TODO */
+			inc = 0;
 			break;
 		case 'C':
 			val = tm->tm_year / 100;
@@ -231,10 +235,6 @@
 		case 'z':
 			inc = timezone(s, n, tm);
 			break;
-		case 'E':
-		case 'O':
-			if (*fmt != '\0')
-				fmt += 2;;
 		case '\0':
 			inc = 0;
 			--fmt;