Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: changing ZLE_CHAR_T?



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..
--- 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))


Messages sorted by: Reverse Date, Date, Thread, Author