Skip to content

Commit

Permalink
40681: strftime builtin should return 1 if ztrftime() returns -1
Browse files Browse the repository at this point in the history
  • Loading branch information
Jun-T committed Mar 2, 2017
1 parent 47c05f6 commit 0697c45
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2017-03-02 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>

* 40681: Src/Modules/datetime.c: strftime builtin should
return 1 if zstrftime() returns -1.

2017-03-01 Peter Stephenson <p.stephenson@samsung.com>

* 40622 (typos fixed): Doc/Zsh/builtins.yo, Src/builtin.c,
Expand Down
8 changes: 6 additions & 2 deletions Src/Modules/datetime.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,15 @@ output_strftime(char *nam, char **argv, Options ops, UNUSED(int func))

len = 0;
for (x=0; x < 4; x++) {
if ((len = ztrftime(buffer, bufsize, argv[0], t, 0L)) >= 0)
if ((len = ztrftime(buffer, bufsize, argv[0], t, 0L)) >= 0 || x==3)
break;
buffer = zrealloc(buffer, bufsize *= 2);
}
DPUTS(len < 0, "bad output from ztrftime");
if (len < 0) {
zwarnnam(nam, "bad/unsupported format: '%s'", argv[0]);
zfree(buffer, bufsize);
return 1;
}

if (scalar) {
setsparam(scalar, metafy(buffer, len, META_DUP));
Expand Down

0 comments on commit 0697c45

Please sign in to comment.