zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: "Jun T." <takimoto-j@kba.biglobe.ne.jp>
Cc: "zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: PATCH: ztrftime: Pass everything unhandled to the system strftime()
Date: Mon, 27 Jul 2015 15:31:30 +0200	[thread overview]
Message-ID: <CAHYJk3TEBJTr2+xMgix+pB7pc3bQx2Eezw=1+71YAcZdPOCoGw@mail.gmail.com> (raw)
In-Reply-To: <F7DE1B62-B947-40C8-A1A5-B2ED74C8762F@kba.biglobe.ne.jp>

On Mon, Jul 27, 2015 at 1:56 PM, Jun T. <takimoto-j@kba.biglobe.ne.jp> 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


  reply	other threads:[~2015-07-27 13:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-07 23:15 PATCH: Make ztrftime pass more things to strftime Mikael Magnusson
2015-07-07 23:21 ` Mikael Magnusson
2015-07-08 10:53   ` Peter Stephenson
2015-07-09  5:16     ` Mikael Magnusson
2015-07-09  8:41       ` Peter Stephenson
2015-07-09  9:58         ` PATCH: ztrftime: Pass everything unhandled to the system strftime() Mikael Magnusson
2015-07-09 10:17           ` Peter Stephenson
2015-07-10 13:37             ` Peter Stephenson
2015-07-10 16:18               ` Skipping tests (was Re: PATCH: ztrftime: Pass everything ...) Bart Schaefer
2015-07-10 16:23                 ` Peter Stephenson
2015-07-10 18:31               ` PATCH: ztrftime: Pass everything unhandled to the system strftime() Daniel Shahaf
2015-07-10 23:54                 ` ZTST_skip (was Re: PATCH: ztrftime ...) Bart Schaefer
2015-07-09 15:52           ` PATCH: ztrftime: Pass everything unhandled to the system strftime() Jun T.
2015-07-10 14:53           ` Jun T.
2015-07-10 18:23             ` Mikael Magnusson
2015-07-27 11:56           ` Jun T.
2015-07-27 13:31             ` Mikael Magnusson [this message]
2015-07-27 16:50               ` Jun T.
2015-07-27 17:01               ` Jun T.
2015-09-01 13:53           ` Oliver Kiddle
2015-09-01 14:07             ` Peter Stephenson
2015-09-01 21:16             ` PATCH: Avoid gcc case syntax Mikael Magnusson
2015-07-08 14:03   ` PATCH: Make ztrftime pass more things to strftime Jun T.
2015-07-09  4:36     ` Mikael Magnusson
2015-07-08 10:39 ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHYJk3TEBJTr2+xMgix+pB7pc3bQx2Eezw=1+71YAcZdPOCoGw@mail.gmail.com' \
    --to=mikachu@gmail.com \
    --cc=takimoto-j@kba.biglobe.ne.jp \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).