projects
/
platform
/
upstream
/
coreutils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
41347fc
)
(show_date): Don't hang if strftime produces an empty string.
author
Jim Meyering
<jim@meyering.net>
Mon, 18 Aug 1997 19:50:35 +0000
(19:50 +0000)
committer
Jim Meyering
<jim@meyering.net>
Mon, 18 Aug 1997 19:50:35 +0000
(19:50 +0000)
src/date.c
patch
|
blob
|
history
diff --git
a/src/date.c
b/src/date.c
index
36bc01f
..
591264e
100644
(file)
--- a/
src/date.c
+++ b/
src/date.c
@@
-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);