zsh-workers
 help / color / mirror / code / Atom feed
From: Wayne Davison <wayned@users.sourceforge.net>
To: Peter Stephenson <p.w.stephenson@ntlworld.com>
Cc: Zsh hackers list <zsh-workers@sunsite.dk>
Subject: Re: changing ZLE_CHAR_T?
Date: Mon, 31 Oct 2005 20:31:04 -0800	[thread overview]
Message-ID: <20051101043104.GD18495@blorf.net> (raw)
In-Reply-To: <20051031214538.GB18495@blorf.net>

[-- Attachment #1: Type: text/plain, Size: 1198 bytes --]

FYI, I went ahead and committed the ZLE_CHAR_T changes with a few
extra minor modifications from the posted patch.

On Mon, Oct 31, 2005 at 01:45:38PM -0800, Wayne Davison wrote:
> (aside: we could switch some of the existing macros over to this
> method, such as idigit(), and free up some bits in the typtab[]
> array).

It also allows the set of characters for things like isalpha() to
flex with the OS's definition.

Attached is a diff that changes idigit(), ialpha(), and ialnum().
I almost changed icntrl() too, but I noticed that zsh is currently
treating chars 128 - 159 as control characters (something that the
normal iscntrl() function does not do), so I left it alone for now.
This does point out an inconsistency in multibyte mode: the ZC_icntrl()
macro (which currently uses iswcntrl()) will not return true for these
extended chars.  Do we need this?

In an attempt to make multibyte ZC_iblank() and ZC_inblank() work the
same as the non-multibyte versions, this patch chooses to extend the
non-multibyte versions of the functions by giving \r and \v the IBLANK
and INBLANK bits.

I'm not going to commit this, so feel free to let me know if this is
not a good way to go.

..wayne..

[-- Attachment #2: typtab.patch --]
[-- Type: text/plain, Size: 2574 bytes --]

--- Src/utils.c	1 Nov 2005 02:50:24 -0000	1.102
+++ Src/utils.c	1 Nov 2005 04:06:03 -0000
@@ -2534,9 +2534,9 @@ inittyptab(void)
 	typtab[t0] = typtab[t0 + 128] = ICNTRL;
     typtab[127] = ICNTRL;
     for (t0 = '0'; t0 <= '9'; t0++)
-	typtab[t0] = IDIGIT | IALNUM | IWORD | IIDENT | IUSER;
+	typtab[t0] = IIDENT | IUSER | IWORD;
     for (t0 = 'a'; t0 <= 'z'; t0++)
-	typtab[t0] = typtab[t0 - 'a' + 'A'] = IALPHA | IALNUM | IIDENT | IUSER | IWORD;
+	typtab[t0] = typtab[t0 - 'a' + 'A'] = IIDENT | IUSER | IWORD;
 #ifndef MULTIBYTE_SUPPORT
     /*
      * This really doesn't seem to me the right thing to do when
@@ -2547,12 +2547,14 @@ inittyptab(void)
      * should disappear into history...
      */
     for (t0 = 0240; t0 != 0400; t0++)
-	typtab[t0] = IALPHA | IALNUM | IIDENT | IUSER | IWORD;
+	typtab[t0] = IIDENT | IUSER | IWORD;
 #endif
     typtab['_'] = IIDENT | IUSER;
     typtab['-'] = IUSER;
     typtab[' '] |= IBLANK | INBLANK;
     typtab['\t'] |= IBLANK | INBLANK;
+    typtab['\r'] |= IBLANK | INBLANK;
+    typtab['\v'] |= IBLANK | INBLANK;
     typtab['\n'] |= INBLANK;
     typtab['\0'] |= IMETA;
     typtab[STOUC(Meta)  ] |= IMETA;
--- Src/ztype.h	1 Nov 2005 02:50:22 -0000	1.3
+++ Src/ztype.h	1 Nov 2005 04:06:03 -0000
@@ -27,13 +27,13 @@
  *
  */
 
-#define IDIGIT   (1 <<  0)
-#define IALNUM   (1 <<  1)
+#define UNUSED0  (1 <<  0)
+#define UNUSED1  (1 <<  1)
 #define IBLANK   (1 <<  2)
 #define INBLANK  (1 <<  3)
 #define ITOK     (1 <<  4)
 #define ISEP     (1 <<  5)
-#define IALPHA   (1 <<  6)
+#define UNUSED6  (1 <<  6)
 #define IIDENT   (1 <<  7)
 #define IUSER    (1 <<  8)
 #define ICNTRL   (1 <<  9)
@@ -42,14 +42,12 @@
 #define IMETA    (1 << 12)
 #define IWSEP    (1 << 13)
 #define INULL    (1 << 14)
+#define UNUSED15 (1 << 15)
 #define _icom(X,Y) (typtab[STOUC(X)] & Y)
-#define idigit(X) _icom(X,IDIGIT)
-#define ialnum(X) _icom(X,IALNUM)
 #define iblank(X) _icom(X,IBLANK)	/* blank, not including \n */
 #define inblank(X) _icom(X,INBLANK)	/* blank or \n */
 #define itok(X) _icom(X,ITOK)
 #define isep(X) _icom(X,ISEP)
-#define ialpha(X) _icom(X,IALPHA)
 #define iident(X) _icom(X,IIDENT)
 #define iuser(X) _icom(X,IUSER)	/* username char */
 #define icntrl(X) _icom(X,ICNTRL)
@@ -59,7 +57,10 @@
 #define iwsep(X) _icom(X,IWSEP)
 #define inull(X) _icom(X,INULL)
 
+#define ialnum(X) isalnum(STOUC(X))
+#define ialpha(X) isalpha(STOUC(X))
 #define iascii(X) isascii(STOUC(X))
+#define idigit(X) isdigit(STOUC(X))
 #define ilower(X) islower(STOUC(X))
 #define iprint(X) isprint(STOUC(X))
 #define iupper(X) isupper(STOUC(X))

  reply	other threads:[~2005-11-01  4:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-28 22:58 Wayne Davison
2005-10-29  9:59 ` Peter Stephenson
2005-10-31 21:45   ` Wayne Davison
2005-11-01  4:31     ` Wayne Davison [this message]
2005-11-01 10:20       ` Peter Stephenson

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=20051101043104.GD18495@blorf.net \
    --to=wayned@users.sourceforge.net \
    --cc=p.w.stephenson@ntlworld.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).