changeset 5701:37123bca7528

* strftime.c (my_strftime) [HAVE_STRFTIME && ! (_NL_CURRENT && HAVE_STRUCT_ERA_ENTRY)]: Initialize the first byte of ubuf[].
author Paul Eggert <eggert@cs.ucla.edu>
date Mon, 14 Mar 2005 23:23:43 +0000
parents eea92bfb3f7d
children 77963efbc20d
files lib/ChangeLog lib/strftime.c
diffstat 2 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,12 @@
+2005-03-14  Jim Meyering  <jim@meyering.net>
+
+	* strftime.c (my_strftime) [HAVE_STRFTIME && ! (_NL_CURRENT
+	&& HAVE_STRUCT_ERA_ENTRY)]: Initialize the first byte of ubuf[]
+	to be nonzero so that we (and caller) can detect the difference
+	between a valid zero-length expansion and an error return, even
+	when the underlying strftime fails before writing anything into
+	that location.
+
 2005-03-10  Jim Meyering  <jim@meyering.net>
 
 	* save-cwd.c [!HAVE_FCHDIR]: Define open, fchdir, and chdir_long
--- a/lib/strftime.c
+++ b/lib/strftime.c
@@ -776,6 +776,7 @@
 	      *u++ = modifier;
 	    *u++ = format_char;
 	    *u = '\0';
+	    ubuf[0] = '\1';
 	    len = strftime (ubuf, sizeof ubuf, ufmt, tp);
 	    if (len == 0 && ubuf[0] != '\0')
 	      return 0;