summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--Src/Zle/zle.h6
-rw-r--r--Src/Zle/zle_hist.c4
-rw-r--r--Src/Zle/zle_main.c4
-rw-r--r--Src/Zle/zle_refresh.c3
-rw-r--r--Src/Zle/zle_utils.c6
-rw-r--r--Src/Zle/zle_vi.c27
-rw-r--r--Src/Zle/zle_word.c12
8 files changed, 39 insertions, 29 deletions
diff --git a/ChangeLog b/ChangeLog
index 809266fdc..ee4fea81d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-02-25  Peter Stephenson  <pws@csr.com>
+
+	* 20869: Src/Zle/zle.h, Src/Zle/zle_hist.c, Src/Zle/zle_main.c,
+	Src/Zle/zle_refresh.c, Src/Zle/zle_utils.c, Src/Zle/zle_vi.c,
+	Src/Zle/zle_word.c: more small Unicode tweaks
+
 2005-02-25  Oliver Kiddle  <opk@zsh.org>
 
 	* 20867: Completion/Unix/Command/_ant: handle imported files
diff --git a/Src/Zle/zle.h b/Src/Zle/zle.h
index d5fac1a80..f23d7aa2c 100644
--- a/Src/Zle/zle.h
+++ b/Src/Zle/zle.h
@@ -59,8 +59,8 @@ typedef wint_t   ZLE_INT_T;
 #define ZS_strncpy wcsncpy
 #define ZS_strncmp wcsncmp
 
-#define ZC_icntrl iswcntrl
 #define ZC_iblank iswspace
+#define ZC_icntrl iswcntrl
 /*
  * TODO: doesn't work on arguments with side effects.
  * Also YUK.  Not even sure this is guaranteed to work.
@@ -68,6 +68,7 @@ typedef wint_t   ZLE_INT_T;
 #define ZC_iident(x)	(x < 256 && iident((int)x))
 
 #define ZC_tolower towlower
+#define ZC_toupper towupper
 
 #define LASTFULLCHAR	lastchar_wide
 
@@ -93,11 +94,12 @@ typedef int ZLE_INT_T;
 #define ZS_strncpy strncpy
 #define ZS_strncmp strncmp
 
-#define ZC_icntrl icntrl
 #define ZC_iblank iblank
+#define ZC_icntrl icntrl
 #define ZC_iident iident
 
 #define ZC_tolower tulower
+#define ZC_toupper tuupper
 
 #define LASTFULLCHAR	lastchar
 
diff --git a/Src/Zle/zle_hist.c b/Src/Zle/zle_hist.c
index 1f49369de..f187d171b 100644
--- a/Src/Zle/zle_hist.c
+++ b/Src/Zle/zle_hist.c
@@ -865,10 +865,6 @@ get_isrch_spot(int num, int *hlp, int *posp, int *csp, int *lenp, int *dirp, int
 #define NORM_PROMPT_POS		8
 #define FIRST_SEARCH_CHAR	(NORM_PROMPT_POS + 14)
 
-/*
- * TODO: use of isearch buffer and strings need fixing for Unicode.
- */
-
 /**/
 static void
 doisearch(char **args, int dir)
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 1333e5f75..eec547712 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -702,8 +702,8 @@ getbyte(int keytmout)
 	ret = STOUC(cc);
     }
     /*
-     * TODO: if vichgbuf is to be characters instead of a multibyte
-     * string the following needs moving to getfullchar().
+     * vichgbuf is raw bytes, not wide characters, so is dealt
+     * with here.
      */
     if (vichgflag) {
 	if (vichgbufptr == vichgbufsz)
diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index aa94930fe..0915254c5 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -105,7 +105,8 @@ int cost;
 # define zwrite(a, b)		zwcwrite(a, b)
 #endif
 
-static int
+/**/
+int
 zwcputc(ZLE_CHAR_T c)
 {
 #ifdef ZLE_UNICODE_SUPPORT
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 1ccf98938..59cd1be95 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -578,14 +578,14 @@ getzlequery(int yesno)
     if (yesno) {
 	if (c == ZWC('\t'))
 	    c = ZWC('y');
-	else if (icntrl(c) || c == ZLEEOF) /* TODO iswcntrl */
+	else if (ZS_icntrl(c) || c == ZLEEOF)
 	    c = ZWC('n');
 	else
-	    c = tulower(c);	/* TODO tulower doesn't handle wint_t */
+	    c = ZS_tolower(c);
     }
     /* echo response and return */
     if (c != ZWC('\n'))
-	putc(c, shout);		/* TODO: convert to multibyte */
+	zwcputc(c);
     return c;
 }
 
diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c
index f44452550..66332e626 100644
--- a/Src/Zle/zle_vi.c
+++ b/Src/Zle/zle_vi.c
@@ -51,9 +51,10 @@ int vilinerange;
 int vichgbufsz, vichgbufptr, vichgflag;
 
 /*
- * TODO: need consistent handling of vichgbuf: ZLE_STRING_T or
- * char *?  Consequently, use of lastchar in this file needs fixing
- * too.
+ * Examination of the code suggests vichgbuf is consistently tied
+ * to raw byte input, so it is left as a character array rather
+ * than turned into wide characters.  In particular, when we replay
+ * it we use ungetbytes().
  */
 /**/
 char *vichgbuf;
@@ -117,11 +118,6 @@ vigetkey(void)
     else
 	cmd = t_undefinedkey;
 
-    /*
-     * TODO: if this was bound to self-insert, we may
-     * be on the first character of a multibyte string
-     * and need to acquire the rest.
-     */
     if (!cmd || cmd == Th(z_sendbreak)) {
 	return ZLEEOF;
     } else if (cmd == Th(z_quotedinsert)) {
@@ -575,9 +571,9 @@ vioperswapcase(UNUSED(char **args))
 	/* swap the case of all letters within range */
 	while (zlecs < c2) {
 	    if (islower(zleline[zlecs]))
-		zleline[zlecs] = tuupper(zleline[zlecs]);
+		zleline[zlecs] = ZS_toupper(zleline[zlecs]);
 	    else if (isupper(zleline[zlecs]))
-		zleline[zlecs] = tulower(zleline[zlecs]);
+		zleline[zlecs] = ZS_tolower(zleline[zlecs]);
 	    zlecs++;
 	}
 	/* go back to the first line of the range */
@@ -815,9 +811,9 @@ viswapcase(UNUSED(char **args))
     eol = findeol();
     while (zlecs < eol && n--) {
 	if (islower(zleline[zlecs]))
-	    zleline[zlecs] = tuupper(zleline[zlecs]);
+	    zleline[zlecs] = ZS_toupper(zleline[zlecs]);
 	else if (isupper(zleline[zlecs]))
-	    zleline[zlecs] = tulower(zleline[zlecs]);
+	    zleline[zlecs] = ZS_tolower(zleline[zlecs]);
 	zlecs++;
     }
     if (zlecs && zlecs == eol)
@@ -862,8 +858,11 @@ visetbuffer(UNUSED(char **args))
 	zmod.flags |= MOD_VIAPP;
     else
 	zmod.flags &= ~MOD_VIAPP;
-    /* TODO tulower, idigit doen't handle wint_t */
-    zmod.vibuf = tulower(ch) + (idigit(ch) ? - ZWC('1') + 26 : -ZWC('a'));
+    zmod.vibuf = ZS_tolower(ch);
+    if (ch >= ZWC('1') && ch <= ZWC('9'))
+	zmod.vibuf += - (int)ZWC('1') + 26;
+    else
+	zmod.vibuf += - (int)ZWC('a');
     zmod.flags |= MOD_VIBUF;
     prefixflag = 1;
     return 0;
diff --git a/Src/Zle/zle_word.c b/Src/Zle/zle_word.c
index ea8d31bc5..7f15cac13 100644
--- a/Src/Zle/zle_word.c
+++ b/Src/Zle/zle_word.c
@@ -30,6 +30,11 @@
 #include "zle.mdh"
 #include "zle_word.pro"
 
+/*
+ * TODO: use of iword needs completely rethinking for Unicode
+ * since we can't base it on a table lookup.
+ */
+
 /**/
 int
 forwardword(char **args)
@@ -354,7 +359,7 @@ upcaseword(UNUSED(char **args))
 	while (zlecs != zlell && !iword(zleline[zlecs]))
 	    zlecs++;
 	while (zlecs != zlell && iword(zleline[zlecs])) {
-	    zleline[zlecs] = tuupper(zleline[zlecs]);
+	    zleline[zlecs] = ZS_toupper(zleline[zlecs]);
 	    zlecs++;
 	}
     }
@@ -376,7 +381,7 @@ downcaseword(UNUSED(char **args))
 	while (zlecs != zlell && !iword(zleline[zlecs]))
 	    zlecs++;
 	while (zlecs != zlell && iword(zleline[zlecs])) {
-	    zleline[zlecs] = tulower(zleline[zlecs]);
+	    zleline[zlecs] = ZS_tolower(zleline[zlecs]);
 	    zlecs++;
 	}
     }
@@ -401,7 +406,8 @@ capitalizeword(UNUSED(char **args))
 	while (zlecs != zlell && iword(zleline[zlecs]) && !isalpha(zleline[zlecs]))
 	    zlecs++;
 	while (zlecs != zlell && iword(zleline[zlecs])) {
-	    zleline[zlecs] = (first) ? tuupper(zleline[zlecs]) : tulower(zleline[zlecs]);
+	    zleline[zlecs] = (first) ? ZS_toupper(zleline[zlecs]) :
+		ZS_tolower(zleline[zlecs]);
 	    first = 0;
 	    zlecs++;
 	}