From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9618 invoked by alias); 27 Jul 2015 13:31:38 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35930 Received: (qmail 17927 invoked from network); 27 Jul 2015 13:31:34 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=WEWGxuZOtnpYTr7k7CLeARGVe+DFU4jsEbDKAjCpd/A=; b=ix0qVtHZtTc1yTQuhdbGaJdA4f4S2MrikixiRlJJekek0+b9/O4o1YYFxwLO4zuDE8 gbL3+OW4BjioVctn7GtbcZGcAKdtGppl5OMMTPhzFi9yB0rppLcqv8SCD9pfxTnq+UYo fN7w3FWWK9swBsy38rtfumXyR6mRGCEdCslrY57/8kNi4gGvMpsvND3eT0E+yJALspq7 n+y0+N3XvFsS86wGaP+MEX9JwHNgMwZwRsl/piUC/tzr/SlZP2HmhOOGru6Qn9BsLCSl SPY0mOk/tVmATBAvhPgk8Fg1KWLyw5fpsilpxt64xqfGUa2prwYGGK9FFGQDQ69yNxjz T/9A== MIME-Version: 1.0 X-Received: by 10.50.143.101 with SMTP id sd5mr18378847igb.44.1438003890470; Mon, 27 Jul 2015 06:31:30 -0700 (PDT) In-Reply-To: References: <20150709094122.17abacc8@pwslap01u.europe.root.pri> <1436435887-28736-1-git-send-email-mikachu@gmail.com> Date: Mon, 27 Jul 2015 15:31:30 +0200 Message-ID: Subject: Re: PATCH: ztrftime: Pass everything unhandled to the system strftime() From: Mikael Magnusson To: "Jun T." Cc: "zsh-workers@zsh.org" Content-Type: text/plain; charset=UTF-8 On Mon, Jul 27, 2015 at 1:56 PM, Jun T. wrote: > I wrote: >> Is it possible to pass the entire format string to strftime() >> if HAVE_STRFTIME is defined? > > but this was not a good idea. On cygwin, V09datetime.ztst fails as > > *** 1,2 **** > ! 6_6_3_3 > 000000 > --- 1,2 ---- > ! > 000000 > Test ./V09datetime.ztst failed: output differs from expected as shown above for: > strftime %-m_%f_%K_%L 1181100000 > strftime %6. 0 > Was testing: zsh extensions > ./V09datetime.ztst: test failed. > > strftime(3) on cygwin is from newlib (not gnu libc) and does not support > any of gnu extensions including the %- modifier. But man zshmisc says: > > The GNU extension that a `-' between the % and the format char- > acter causes a leading zero or space to be stripped is handled > directly by the shell for the format characters d, f, H, k, l, > m, M, S and y; any other format characters are provided to strf- > time() with any leading `-', present, so the handling is system > dependent. Further GNU extensions are not supported at present. Oops, but it's nice that writing the tests paid off :). ACK on the patch from me. > so %-m etc. needs be supported also on cygwin? The simplest fix would be > to move the #ifndef HAVE_STRFTIME back to the original position: > > diff --git a/Src/utils.c b/Src/utils.c > index f7aaaed..236661a 100644 > --- a/Src/utils.c > +++ b/Src/utils.c > @@ -3006,7 +3006,6 @@ morefmt: > > *buf++ = '0' + (hr12 % 10); > break; > -#ifndef HAVE_STRFTIME > case 'd': > if (tm->tm_mday > 9 || !strip) > *buf++ = '0' + tm->tm_mday / 10; > @@ -3032,6 +3031,7 @@ morefmt: > *buf++ = '0' + (tm->tm_year / 10) % 10; > *buf++ = '0' + tm->tm_year % 10; > break; > +#ifndef HAVE_STRFTIME > case 'Y': > { > int year, digits, testyear; > > > > BTW, the last part of the above man page > "Further GNU extensions are not supported at present." > needs be updated? I guess it could say something along the lines of "Further GNU (or other) extensions are not supported, but will work if the system libc supports them." ? -- Mikael Magnusson