diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | Src/prompt.c | 4 | ||||
-rw-r--r-- | Src/utils.c | 3 |
3 files changed, 11 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog index b65843471..d68b7c24d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-05-04 Clint Adams <clint@zsh.org> + + * 19869: Src/prompt.c, Src/utils.c: avoid segfault when + prompt-expanding '%D{%p}' or '%D{%P}' under locales with null + strings for am_pm. + 2004-05-02 Peter Stephenson <pws@pwstephenson.fsnet.co.uk> * 19858: Doc/Zsh/options.yo, Src/jobs.c, Src/options.c, diff --git a/Src/prompt.c b/Src/prompt.c index 5e80da172..e0304f298 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -528,7 +528,9 @@ putpromptchar(int doprint, int endchar) tm = localtime(&timet); for(t0=80; ; t0*=2) { addbufspc(t0); - if (ztrftime(bp, t0, tmfmt, tm)) + if (ztrftime(bp, t0, tmfmt, tm) || + !strcmp("%P", tmfmt) || + !strcmp("%p", tmfmt)) break; } bp += strlen(bp); diff --git a/Src/utils.c b/Src/utils.c index 2e061e591..c0a96a5b4 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -1831,7 +1831,8 @@ ztrftime(char *buf, int bufsize, char *fmt, struct tm *tm) */ *buf = '\0'; tmp[1] = fmt[-1]; - if (!strftime(buf, bufsize + 2, tmp, tm)) + if (!strftime(buf, bufsize + 2, tmp, tm) && + tmp[1]!='p' && tmp[1]!='P') return 0; decr = strlen(buf); buf += decr; |