Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
changing ZLE_CHAR_T?
- X-seq: zsh-workers 21949
- From: Wayne Davison <wayned@xxxxxxxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxxxxx>
- Subject: changing ZLE_CHAR_T?
- Date: Fri, 28 Oct 2005 15:58:41 -0700
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
One thing I don't like about the current definition of ZLE_CHAR_T is
that, in the non-multibyte code, you don't end up with a ZLE_STRING_T
if you take the address of a ZLE_CHAR_T variable (due to ZLE_CHAR_T
being an "int" and ZLE_STRING_T being an "unsigned char *"). Since
we have a ZLE_INT_T for those variables that need to be able to hold
a ZLEEOF value, I thought it would be cleaner to change ZLE_CHAR_T.
For my first try, I changed ZLE_CHAR_T into an "unsigned char", which
caused a bunch of problems with comparisons against char constants,
such as "Comma", because the strings in the rest of zsh are based on
"char", not "unsigned char". I then decided to change ZLE_CHAR_T to
be a "char" and to also change ZLE_STRING_T into a "char *". This
change worked with just a few other tweaks to the code, and all the
tests pass.
However, I won't commit this until I hear some assent that this is a
desired change. Attached is the patch.
..wayne..
--- Src/zsh.h 28 Oct 2005 22:14:22 -0000 1.81
+++ Src/zsh.h 28 Oct 2005 22:49:25 -0000
@@ -1435,7 +1435,7 @@ struct histent {
#ifdef MULTIBYTE_SUPPORT
wchar_t *zle_text; /* the edited history line */
#else
- unsigned char *zle_text; /* the edited history line */
+ char *zle_text; /* the edited history line */
#endif
int zle_len; /* length of zle_text */
time_t stim; /* command started time (datestamp) */
--- Src/Zle/zle.h 28 Oct 2005 17:34:33 -0000 1.21
+++ Src/Zle/zle.h 28 Oct 2005 22:49:25 -0000
@@ -84,14 +84,14 @@ typedef wint_t ZLE_INT_T;
#else /* Not MULTIBYTE_SUPPORT: old single-byte code */
-typedef int ZLE_CHAR_T;
-typedef unsigned char *ZLE_STRING_T;
+typedef char ZLE_CHAR_T;
+typedef char *ZLE_STRING_T;
typedef int ZLE_INT_T;
-#define ZLE_CHAR_SIZE sizeof(unsigned char)
+#define ZLE_CHAR_SIZE sizeof(char)
/* Leave character or string as is, but string must be unsigned char * */
#define ZWC(c) c
-#define ZWS(s) (unsigned char *)s
+#define ZWS(s) (char *)s
#define ZLEEOF EOF
--- Src/Zle/zle_misc.c 28 Oct 2005 17:34:33 -0000 1.30
+++ Src/Zle/zle_misc.c 28 Oct 2005 22:49:25 -0000
@@ -60,18 +60,14 @@ doinsert(ZLE_STRING_T zstr, int len)
mod_export int
selfinsert(UNUSED(char **args))
{
-#ifdef MULTIBYTE_SUPPORT
- /* wint_t and wchar_t not neccessarily the same size */
- wchar_t tmp;
+ ZLE_CHAR_T tmp;
+#ifdef MULTIBYTE_SUPPORT
if (!lastchar_wide_valid)
getrestchar(lastchar);
- tmp = lastchar_wide;
- doinsert(&tmp, 1);
-#else
- unsigned char s = lastchar;
- doinsert(&s, 1);
#endif
+ tmp = LASTFULLCHAR;
+ doinsert(&tmp, 1);
return 0;
}
@@ -89,7 +85,7 @@ fixunmeta(void)
* selfinsertunmeta is intrinsically problematic
* with multibyte input.
*/
- lastchar_wide = (ZLE_CHAR_T)lastchar;
+ lastchar_wide = (ZLE_INT_T)lastchar;
lastchar_wide_valid = 1;
#endif
}
@@ -1098,7 +1094,7 @@ makesuffixstr(char *f, char *s, int n)
/**/
mod_export void
-iremovesuffix(ZLE_CHAR_T c, int keep)
+iremovesuffix(ZLE_INT_T c, int keep)
{
if (suffixfunc) {
Eprog prog = getshfunc(suffixfunc);
--- Src/Zle/zle_utils.c 28 Oct 2005 17:34:33 -0000 1.30
+++ Src/Zle/zle_utils.c 28 Oct 2005 22:49:25 -0000
@@ -170,7 +170,7 @@ zlelineasstring(ZLE_STRING_T instr, int
#ifdef MULTIBYTE_SUPPORT
unsigned char *strp = (unsigned char *)s;
#else
- unsigned char *strp = instr;
+ unsigned char *strp = (unsigned char *)instr;
#endif
unsigned char *stopcs = strp + outcs;
unsigned char *stopll = strp + outll;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author