From f57f65282b8b7de7db638eaabd06867ea8b1162f Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 4 May 2004 16:43:29 +0000 Subject: 19877: improved test for empty strftime strings --- Src/prompt.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'Src/prompt.c') 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); -- cgit 1.4.1