diff options
author | Jim Meyering <jim@meyering.net> | 2000-11-23 07:24:51 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2000-11-23 07:24:51 +0000 |
commit | d5b2ff2b994191b20557132685f51064cc08dc11 (patch) | |
tree | 752a85033c1e938c4624a912dbffb636ef3be2a7 /lib | |
parent | a3e608b76a42887a7a1893fe3a85b077efb25562 (diff) | |
download | coreutils-d5b2ff2b994191b20557132685f51064cc08dc11.tar.xz |
(my_strftime): Do not invoke mbrlen with a
size of (size_t) -1; it's not portable.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/strftime.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/strftime.c b/lib/strftime.c index e10a87c78..a8c907267 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -515,6 +515,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 @@ -607,10 +610,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; |