diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2004-05-04 16:43:29 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2004-05-04 16:43:29 +0000 |
commit | f57f65282b8b7de7db638eaabd06867ea8b1162f (patch) | |
tree | 64bb58c0fe67fc88c212f6f7fc1b7260400da2e2 /Src/prompt.c | |
parent | c98b9dc800171365eee34a3adbf5a741dbef69ca (diff) | |
download | zsh-f57f65282b8b7de7db638eaabd06867ea8b1162f.tar.gz zsh-f57f65282b8b7de7db638eaabd06867ea8b1162f.tar.xz zsh-f57f65282b8b7de7db638eaabd06867ea8b1162f.zip |
19877: improved test for empty strftime strings
Diffstat (limited to 'Src/prompt.c')
-rw-r--r-- | Src/prompt.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Src/prompt.c b/Src/prompt.c index e0304f298..d83ec9417 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -526,11 +526,16 @@ putpromptchar(int doprint, int endchar) } timet = time(NULL); tm = localtime(&timet); - for(t0=80; ; t0*=2) { + /* + * Hack because strftime won't say how + * much space it actually needs. Try to add it + * a few times until it works. Some formats don't + * actually have a length, so we could go on for + * ever. + */ + for(j = 0, t0 = strlen(tmfmt)*8; j < 3; j++, t0*=2) { addbufspc(t0); - if (ztrftime(bp, t0, tmfmt, tm) || - !strcmp("%P", tmfmt) || - !strcmp("%p", tmfmt)) + if (ztrftime(bp, t0, tmfmt, tm) >= 0) break; } bp += strlen(bp); |