1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-23 16:40:24 +02:00

24197: interface to ztrftime() for insufficient memory was broken

This commit is contained in:
Peter Stephenson 2007-12-09 14:58:36 +00:00
parent 0eed895796
commit 6e58a1df8f
3 changed files with 11 additions and 6 deletions

View file

@ -1,3 +1,8 @@
2007-12-09 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 24197, Src/utils.c, Src/Modules/datetime.c: interface to
ztrftime() for insufficient memory was broken.
2007-12-08 Clint Adams <clint@zsh.org>
* 24188: Completion/Unix/Command/_id: completion for GNU id.

View file

@ -1,5 +1,5 @@
/*
* datetime.c - parameter interface to langinfo via curses
* datetime.c - parameter and command interface to date and time utilities
*
* This file is part of zsh, the Z shell.
*
@ -121,7 +121,7 @@ bin_strftime(char *nam, char **argv, Options ops, UNUSED(int func))
}
t = localtime(&secs);
bufsize = strlen(argv[0]) * 2;
bufsize = strlen(argv[0]) * 8;
buffer = zalloc(bufsize);
for (x=0; x < 4; x++) {

View file

@ -2389,7 +2389,7 @@ ztrftime(char *buf, int bufsize, char *fmt, struct tm *tm)
* Fix up some longer cases specially when we get to them.
*/
if (ztrftimebuf(&bufsize, 2))
return 0;
return -1;
switch (*fmt++) {
case 'd':
*buf++ = '0' + tm->tm_mday / 10;
@ -2447,12 +2447,12 @@ ztrftime(char *buf, int bufsize, char *fmt, struct tm *tm)
#ifndef HAVE_STRFTIME
case 'a':
if (ztrftimebuf(&bufsize, strlen(astr[tm->tm_wday]) - 2))
return 0;
return -1;
strucpy(&buf, astr[tm->tm_wday]);
break;
case 'b':
if (ztrftimebuf(&bufsize, strlen(estr[tm->tm_mon]) - 2))
return 0;
return -1;
strucpy(&buf, estr[tm->tm_mon]);
break;
case 'p':
@ -2487,7 +2487,7 @@ ztrftime(char *buf, int bufsize, char *fmt, struct tm *tm)
}
} else {
if (ztrftimebuf(&bufsize, 1))
return 0;
return -1;
*buf++ = *fmt++;
}
*buf = '\0';