From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 958 invoked from network); 4 May 2004 04:15:21 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (qmailr@130.225.247.86) by ns1.primenet.com.au with SMTP; 4 May 2004 04:15:21 -0000 Received: (qmail 5082 invoked from network); 4 May 2004 04:15:00 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 4 May 2004 04:15:00 -0000 Received: (qmail 25982 invoked by alias); 4 May 2004 04:14:58 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19869 Received: (qmail 25971 invoked from network); 4 May 2004 04:14:58 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (qmailr@130.225.247.86) by sunsite.dk with SMTP; 4 May 2004 04:14:55 -0000 Received: (qmail 4956 invoked from network); 4 May 2004 04:14:54 -0000 Received: from acolyte.scowler.net (216.254.112.45) by a.mx.sunsite.dk with SMTP; 4 May 2004 04:14:52 -0000 Received: by acolyte.scowler.net (Postfix, from userid 1000) id A6CA57004A; Tue, 4 May 2004 00:14:23 -0400 (EDT) Date: Tue, 4 May 2004 00:14:23 -0400 From: Clint Adams To: zsh-workers@sunsite.dk Cc: Christian Anthon , 245974@bugs.debian.org Subject: Re: Bug#245974: zsh: export LC_ALL=da_DK causes segfault Message-ID: <20040504041423.GA31086@scowler.net> References: <20040426144112.87B951C02C@kohn.kiku.dk> <20040426154922.GA8375@scowler.net> <20040426201800.GA2029@kohn.kiku.dk> <20040426224229.GA12757@scowler.net> <20040427092356.GA4780@kohn.kiku.dk> <20040503002722.GA15956@scowler.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20040503002722.GA15956@scowler.net> User-Agent: Mutt/1.5.5.1+cvs20040105i X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=-0.0 required=6.0 tests=BAYES_40 autolearn=no version=2.63 X-Spam-Hits: -0.0 > Seems that when LC_TIME (or LC_ALL or LANG) is set to a locale such as > da_DK or de_DE, wherein am_pm is set to null strings, zsh will segfault > upon prompt-expanding %p or %P. Seems that the first argument to So, when am_pm is set to null strings, strftime() with format "%p" or "%P" will return 0, which zsh is ill-equipped to handle. The following patch avoids the segfault. I hope there's a better way to do this. Index: Src/prompt.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/prompt.c,v retrieving revision 1.15 diff -u -r1.15 prompt.c --- Src/prompt.c 21 Apr 2004 08:33:37 -0000 1.15 +++ Src/prompt.c 4 May 2004 04:08:54 -0000 @@ -528,7 +528,9 @@ 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); Index: Src/utils.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/utils.c,v retrieving revision 1.58 diff -u -r1.58 utils.c --- Src/utils.c 25 Mar 2004 12:32:11 -0000 1.58 +++ Src/utils.c 4 May 2004 04:08:55 -0000 @@ -1831,7 +1831,8 @@ */ *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;