zsh-workers
 help / color / mirror / code / Atom feed
From: Clint Adams <clint@zsh.org>
To: zsh-workers@sunsite.dk
Cc: Christian Anthon <anthon@kohn.kiku.dk>, 245974@bugs.debian.org
Subject: Re: Bug#245974: zsh: export LC_ALL=da_DK causes segfault
Date: Tue, 4 May 2004 00:14:23 -0400	[thread overview]
Message-ID: <20040504041423.GA31086@scowler.net> (raw)
In-Reply-To: <20040503002722.GA15956@scowler.net>

> 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;


  reply	other threads:[~2004-05-04  4:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20040426144112.87B951C02C@kohn.kiku.dk>
     [not found] ` <20040426154922.GA8375@scowler.net>
     [not found]   ` <20040426201800.GA2029@kohn.kiku.dk>
     [not found]     ` <20040426224229.GA12757@scowler.net>
     [not found]       ` <20040427092356.GA4780@kohn.kiku.dk>
2004-05-03  0:27         ` Clint Adams
2004-05-04  4:14           ` Clint Adams [this message]
2004-05-04  9:26             ` Peter Stephenson
2004-05-04 14:41               ` Peter Stephenson
2004-05-04 15:06                 ` Clint Adams
2004-05-04 15:30                   ` Peter Stephenson
2004-05-05  4:43                     ` Wayne Davison
2004-05-05 11:17                       ` Peter Stephenson
2004-05-04  9:50             ` Oliver Kiddle
2004-05-04 12:11               ` Clint Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040504041423.GA31086@scowler.net \
    --to=clint@zsh.org \
    --cc=245974@bugs.debian.org \
    --cc=anthon@kohn.kiku.dk \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).