From: Jim Meyering Date: Wed, 17 Aug 2005 19:55:52 +0000 (+0000) Subject: Make the %s format (seconds since the epoch) work for a negative X-Git-Tag: CPPI-1_12~123 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cb3da21f16309f23b7c2a6010b85e7c6d00ef489;p=thirdparty%2Fcoreutils.git Make the %s format (seconds since the epoch) work for a negative number and when used with a zero-padded field width, e.g. %015s. (my_strftime): Move the `do_number_sign_and_padding' label so that it precedes the code to set `digits'. Otherwise, %0Ns wouldn't work. Before this change, `date -d @-22 +%05s' would print `00-22'. Now, it prints `-0022', as it should. --- diff --git a/lib/strftime.c b/lib/strftime.c index fb7354efd2..b68b4cf5ad 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -909,10 +909,10 @@ my_strftime (CHAR_T *s, size_t maxsize, const CHAR_T *format, } while (u_number_value != 0); + do_number_sign_and_padding: if (digits < width) digits = width; - do_number_sign_and_padding: if (negative_number) *--bufp = L_('-');