zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: Re: PATCH: multibyte odds and ends
Date: Wed, 02 Aug 2006 18:12:47 +0100	[thread overview]
Message-ID: <200608021712.k72HCldt029122@news01.csr.com> (raw)
In-Reply-To: <060801195507.ZM16505@torch.brasslantern.com>

Bart Schaefer wrote:
> On Aug 1,  9:44pm, Peter Stephenson wrote:
> } Does anybody have any preferences?  Does anybody ever redefine HISTCHARS?
> 
> I've been redefining HISTCHARS/histchars to replace ^ with = for longer
> than I've been using zsh (dating from using csh way back when some tty
> terminals did not have | and the Bourne shell interpreted ^ as a pipe).
> 
> I'd be fine with restricting HISTCHARS to ASCII, or even to non-alpha-
> numeric ASCII.

I presume this is the only response I'm likely to get.

The shell will now issue a warning and refuse to set histchars/HISTCHARS
if either contains non-ASCII characters.  I thought about an error, but
the most likely place to set HISTCHARS is in .zshrc, and aborting all
processing if setting the variable fails is not likely to be the right
thing to do.

It also fixes a hard-to-find bug with metafication.

By the way, I've no intention of removing HISTCHARS so the note that
it's "deprecated" isn't really true, particularly since upper case is
the natural form for scalars in zsh.

Index: README
===================================================================
RCS file: /cvsroot/zsh/zsh/README,v
retrieving revision 1.34
diff -u -r1.34 README
--- README	10 Jul 2006 13:08:22 -0000	1.34
+++ README	2 Aug 2006 17:05:51 -0000
@@ -81,6 +81,11 @@
 on some fairly common PC configurations.  This change is only likely to
 affect some highly specialised uses of the shell.
 
+The variables HISTCHARS and histchars now reject any attempt to
+set non-ASCII characters for history or comments.  Multibyte characters
+have never worked and the most consistent change was to restrict the
+set to portable characters only.
+
 Documentation
 -------------
 
Index: Doc/Zsh/params.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/params.yo,v
retrieving revision 1.32
diff -u -r1.32 params.yo
--- Doc/Zsh/params.yo	2 Aug 2006 09:59:23 -0000	1.32
+++ Doc/Zsh/params.yo	2 Aug 2006 17:05:51 -0000
@@ -803,6 +803,10 @@
 expansion (default `tt(!)').  The second character signals the
 start of a quick history substitution (default `tt(^)').  The third
 character is the comment character (default `tt(#)').
+
+The characters must be in the ASCII character set; any attempt to set
+tt(histchars) to characters with a locale-dependent meaning will be
+rejected with an error message.
 )
 vindex(HISTCHARS)
 item(tt(HISTCHARS) <S> <Z>)(
Index: Src/params.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/params.c,v
retrieving revision 1.117
diff -u -r1.117 params.c
--- Src/params.c	10 Jul 2006 13:08:23 -0000	1.117
+++ Src/params.c	2 Aug 2006 17:05:52 -0000
@@ -3548,10 +3548,21 @@
 histcharssetfn(UNUSED(Param pm), char *x)
 {
     if (x) {
-	bangchar = x[0];
-	hatchar = (bangchar) ? x[1] : '\0';
-	hashchar = (hatchar) ? x[2] : '\0';
-	zsfree(x);
+	int len, i;
+
+	unmetafy(x, &len);
+	if (len > 3)
+	    len = 3;
+	for (i = 0; i < len; i++) {
+	    if (!isascii(STOUC(x[i]))) {
+		zwarn("HISTCHARS can only contain ASCII characters");
+		return;
+	    }
+	}
+	bangchar = len ? STOUC(x[0]) : '\0';
+	hatchar =  len > 1 ? STOUC(x[1]) : '\0';
+	hashchar = len > 2 ? STOUC(x[2]) : '\0';
+	free(x);
     } else {
 	bangchar = '!';
 	hashchar = '#';

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php


      reply	other threads:[~2006-08-02 17:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-01 20:44 Peter Stephenson
2006-08-02  2:55 ` Bart Schaefer
2006-08-02 17:12   ` Peter Stephenson [this message]

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=200608021712.k72HCldt029122@news01.csr.com \
    --to=pws@csr.com \
    --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).