diff options
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); |