about summary refs log tree commit diff
path: root/time/strftime.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-11-28 21:12:43 +0000
committerUlrich Drepper <drepper@redhat.com>2000-11-28 21:12:43 +0000
commitbffef76ec222e1330b8f2fb625a46726effbc9f7 (patch)
treebe865ce51bc31bacba58413602166b2a20b3259c /time/strftime.c
parentaea6353acfdd7c41ee405899cb40240d9581c54c (diff)
downloadglibc-bffef76ec222e1330b8f2fb625a46726effbc9f7.tar.gz
glibc-bffef76ec222e1330b8f2fb625a46726effbc9f7.tar.xz
glibc-bffef76ec222e1330b8f2fb625a46726effbc9f7.zip
Update.
2000-11-22  Paul Eggert  <eggert@twinsun.com>

	* time/strftime.c (my_strftime): Do not invoke mbrlen with a
	size of (size_t) -1; it's not portable.
Diffstat (limited to 'time/strftime.c')
-rw-r--r--time/strftime.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/time/strftime.c b/time/strftime.c
index f98fe21079..2f99143771 100644
--- a/time/strftime.c
+++ b/time/strftime.c
@@ -513,6 +513,9 @@ my_strftime (s, maxsize, format, tp ut_argument)
   size_t i = 0;
   CHAR_T *p = s;
   const CHAR_T *f;
+#if DO_MULTIBYTE && !defined COMPILE_WIDE
+  const char *format_end = NULL;
+#endif
 
   zone = NULL;
 #if HAVE_TM_ZONE
@@ -605,10 +608,15 @@ my_strftime (s, maxsize, format, tp ut_argument)
 	  {
 	    mbstate_t mbstate = mbstate_zero;
 	    size_t len = 0;
+	    size_t fsize;
+
+	    if (! format_end)
+	      format_end = f + strlen (f) + 1;
+	    fsize = format_end - f;
 
 	    do
 	      {
-		size_t bytes = mbrlen (f + len, (size_t) -1, &mbstate);
+		size_t bytes = mbrlen (f + len, fsize - len, &mbstate);
 
 		if (bytes == 0)
 		  break;