Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: ztrftime: Pass everything unhandled to the system strftime()

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
--- 1,2 ----
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.

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);
 	    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;
 	    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?

Messages sorted by: Reverse Date, Date, Thread, Author