X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fstrftime.c;h=acebc9adfad65b9f968c96055b50d26ec38f89fc;hb=4a1579d7560659ef5723325726eda14490a967f6;hp=35f6478f35d94d130a2bfdda67ca18518b45359a;hpb=3030c5b5e0a5199e16b05927da72c43c42f211c3;p=gnulib.git diff --git a/lib/strftime.c b/lib/strftime.c index 35f6478f3..acebc9adf 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991-2001, 2003-2007, 2009 Free Software Foundation, Inc. +/* Copyright (C) 1991-2001, 2003-2007, 2009-2011 Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. @@ -48,8 +48,11 @@ extern char *tzname[]; GB18030, EUC-TW, BIG5, BIG5-HKSCS, CP950, EUC-JP, EUC-KR, CP949, SHIFT_JIS, CP932, JOHAB) are safe for formats, because the byte '%' cannot occur in a multibyte character except in the first byte. - But this does not hold for the DEC-HANYU encoding used on OSF/1. */ -#if !defined __osf__ + + The DEC-HANYU encoding used on OSF/1 is not safe for formats, but + this encoding has never been seen in real-life use, so we ignore + it. */ +#if !(defined __osf__ && 0) # define MULTIBYTE_IS_FORMAT_SAFE 1 #endif #define DO_MULTIBYTE (! MULTIBYTE_IS_FORMAT_SAFE) @@ -169,15 +172,16 @@ extern char *tzname[]; #define add(n, f) \ do \ { \ - int _n = (n); \ - int _delta = width - _n; \ - int _incr = _n + (_delta > 0 ? _delta : 0); \ - if ((size_t) _incr >= maxsize - i) \ + size_t _n = (n); \ + size_t _w = (width < 0 ? 0 : width); \ + size_t _incr = _n < _w ? _w : _n; \ + if (_incr >= maxsize - i) \ return 0; \ if (p) \ { \ - if (digits == 0 && _delta > 0) \ + if (digits == 0 && _n < _w) \ { \ + size_t _delta = width - _n; \ if (pad == L_('0')) \ memset_zero (p, _delta); \ else \