1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-07-26 10:39:01 +02:00

(show_date): Don't hang if strftime produces an empty string.

This commit is contained in:
Jim Meyering
1997-08-18 19:50:35 +00:00
parent 41347fc40e
commit b5ef7a4be7
+7 -1
View File
@@ -399,8 +399,14 @@ show_date (const char *format, time_t when)
{
out_length += 200;
out = (char *) xrealloc (out, out_length);
/* Mark the first byte of the buffer so we can detect the case
of strftime producing an empty string. Otherwise, this loop
would not terminate when date was invoked like this
`LANG=de date +%p' on a system with good language support. */
out[0] = '\1';
}
while (strftime (out, out_length, format, tm) == 0);
while (strftime (out, out_length, format, tm) == 0 && out[0] != '\0');
printf ("%s\n", out);
free (out);