diff -ur orig/zsh-4.0.8/Src/Zle/compmatch.c zsh-4.0.8/Src/Zle/compmatch.c --- orig/zsh-4.0.8/Src/Zle/compmatch.c 2001-04-03 20:25:13.000000000 +0900 +++ zsh-4.0.8/Src/Zle/compmatch.c 2003-12-19 16:41:11.000000000 +0900 @@ -1309,6 +1309,9 @@ while (la && lb) { if (*sa != *sb) { /* Different characters, try the matchers. */ +#ifdef ZSH_EUC +ono: +#endif for (t = 0, ms = bmatchers; ms && !t; ms = ms->next) { mp = ms->matcher; if (mp && !mp->flags && mp->wlen > 0 && mp->llen > 0 && @@ -1354,7 +1357,13 @@ } if (!t) break; - } else { +#ifdef ZSH_EUC + } else if ((_mbmap_euc[*(unsigned char*)sa] & _MB1) && + (_mbmap_euc[*((unsigned char*)sa+1)] & _MB2) && + *(sa+1) != *(sb+1)) { + goto ono; +#endif + } else { /* Same character, just take it. */ if (rr <= 1) { char *or = rs; @@ -1580,9 +1589,32 @@ if (check_cmdata(md, sfx)) return ret; +#ifndef ZSH_EUC for (l = 0, p = str, q = md->str; l < len && l < md->len && p[ind] == q[ind]; l++, p += add, q += add); +#else + if (sfx) + for (l = 0, p = str, q = md->str; + l < len && l < md->len && p[ind] == q[ind]; + l++, p += add, q += add); + else + for (l = 0, p = str, q = md->str;;) { + if (!(l < len && l < md->len)) + break; + + if ((_mbmap_euc[*(unsigned char*)p] & _MB1) && (_mbmap_euc[*((unsigned char*)p+1)] & _MB2)) { + if (*p == *q && *(p+1) == *(q+1)) { + l+=2, p+=2, q+=2; + } else + break; + } else { + if (*p != *q) + break; + l++, p++, q++; + } + } +#endif if (l) { /* There was a common prefix, use it. */ diff -ur orig/zsh-4.0.8/Src/Zle/zle.h zsh-4.0.8/Src/Zle/zle.h --- orig/zsh-4.0.8/Src/Zle/zle.h 2000-05-23 17:20:57.000000000 +0900 +++ zsh-4.0.8/Src/Zle/zle.h 2003-12-19 16:41:11.000000000 +0900 @@ -194,3 +194,8 @@ /* Invalidate the completion list. */ #define invalidatelist() runhookdef(INVALIDATELISTHOOK, NULL) + +#ifdef ZSH_EUC +#define _MB1 0x01 +#define _MB2 0x02 +#endif diff -ur orig/zsh-4.0.8/Src/Zle/zle_main.c zsh-4.0.8/Src/Zle/zle_main.c --- orig/zsh-4.0.8/Src/Zle/zle_main.c 2003-11-14 22:03:16.000000000 +0900 +++ zsh-4.0.8/Src/Zle/zle_main.c 2003-12-19 16:41:11.000000000 +0900 @@ -1206,3 +1206,179 @@ return 0; } + +#ifdef ZSH_EUC +/**/ +mod_export unsigned char _mbmap_euc[256] = { +/* first byte 0x8e,0xa0 - 0xf4 */ +/* second byte 0xa0 - 0xfe */ +/* 0 - 7f all 0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +/* 80 81 82 83 */ + 0, 0, 0, 0, +/* 84 85 86 87 */ + 0, 0, 0, 0, +/* 88 89 8a 8b */ + 0, 0, 0, 0, +/* 8c 8d 8e 8f */ + 0, 0, _MB1, 0, +/* 90 - 9f all 0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +/* a0 a1 a2 a3 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* a4 a5 a6 a7 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* a8 a9 aa ab */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* ac ad ae af */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* b0 b1 b2 b3 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* b4 b5 b6 b7 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* b8 b9 ba bb */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* bc bd be bf */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* c0 c1 c2 c3 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* c4 c5 c6 c7 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* c8 c9 ca cb */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* cc cd ce cf */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* d0 d1 d2 d3 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* d4 d5 d6 d7 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* d8 d9 da db */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* dc dd de df */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* e0 e1 e2 e3 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* e4 e5 e6 e7 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* e8 e9 ea eb */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* ec ed ee ef */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* f0 f1 f2 f3 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* f4 f5 f6 f7 */ + _MB1|_MB2, _MB2, _MB2, _MB2, +/* f8 f9 fa fb */ + _MB2, _MB2, _MB2, _MB2, +/* fc fd fe ff */ + _MB2, _MB2, _MB2, 0, +}; + +unsigned short _mbmap_sjis[256] = { +/* first byte 0x81-0x9f,0xe0 - 0xfc */ +/* second byte 0x40-0x7e,0x80 - 0xfc */ +/* 0 - 3f all 0 */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +/* 40 41 42 43 */ + _MB2, _MB2, _MB2, _MB2, +/* 44 45 46 47 */ + _MB2, _MB2, _MB2, _MB2, +/* 48 49 4a 4b */ + _MB2, _MB2, _MB2, _MB2, +/* 4c 4d 4e 4f */ + _MB2, _MB2, _MB2, _MB2, +/* 50 51 52 53 */ + _MB2, _MB2, _MB2, _MB2, +/* 54 55 56 57 */ + _MB2, _MB2, _MB2, _MB2, +/* 58 59 5a 5b */ + _MB2, _MB2, _MB2, _MB2, +/* 5c 5d 5e 5f */ + _MB2, _MB2, _MB2, _MB2, +/* 60 61 62 63 */ + _MB2, _MB2, _MB2, _MB2, +/* 64 65 66 67 */ + _MB2, _MB2, _MB2, _MB2, +/* 68 69 6a 6b */ + _MB2, _MB2, _MB2, _MB2, +/* 6c 6d 6e 6f */ + _MB2, _MB2, _MB2, _MB2, +/* 70 71 72 73 */ + _MB2, _MB2, _MB2, _MB2, +/* 74 75 76 77 */ + _MB2, _MB2, _MB2, _MB2, +/* 78 79 7a 7b */ + _MB2, _MB2, _MB2, _MB2, +/* 7c 7d 7e 7f */ + _MB2, _MB2, _MB2, 0, +/* 80 81 82 83 */ + _MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* 84 85 86 87 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* 88 89 8a 8b */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* 8c 8d 8e 8f */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* 90 91 92 93 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* 94 95 96 97 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* 98 99 9a 9b */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* 9c 9d 9e 9f */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* a0 a1 a2 a3 */ + _MB2, _MB2, _MB2, _MB2, +/* a4 a5 a6 a7 */ + _MB2, _MB2, _MB2, _MB2, +/* a8 a9 aa ab */ + _MB2, _MB2, _MB2, _MB2, +/* ac ad ae af */ + _MB2, _MB2, _MB2, _MB2, +/* b0 b1 b2 b3 */ + _MB2, _MB2, _MB2, _MB2, +/* b4 b5 b6 b7 */ + _MB2, _MB2, _MB2, _MB2, +/* b8 b9 ba bb */ + _MB2, _MB2, _MB2, _MB2, +/* bc bd be bf */ + _MB2, _MB2, _MB2, _MB2, +/* c0 c1 c2 c3 */ + _MB2, _MB2, _MB2, _MB2, +/* c4 c5 c6 c7 */ + _MB2, _MB2, _MB2, _MB2, +/* c8 c9 ca cb */ + _MB2, _MB2, _MB2, _MB2, +/* cc cd ce cf */ + _MB2, _MB2, _MB2, _MB2, +/* d0 d1 d2 d3 */ + _MB2, _MB2, _MB2, _MB2, +/* d4 d5 d6 d7 */ + _MB2, _MB2, _MB2, _MB2, +/* d8 d9 da db */ + _MB2, _MB2, _MB2, _MB2, +/* dc dd de df */ + _MB2, _MB2, _MB2, _MB2, +/* e0 e1 e2 e3 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* e4 e5 e6 e7 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* e8 e9 ea eb */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* ec ed ee ef */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* f0 f1 f2 f3 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* f4 f5 f6 f7 */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* f8 f9 fa fb */ + _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, _MB1|_MB2, +/* fc fd fe ff */ + _MB1|_MB2, 0, 0, 0, +}; + +#endif diff -ur orig/zsh-4.0.8/Src/Zle/zle_misc.c zsh-4.0.8/Src/Zle/zle_misc.c --- orig/zsh-4.0.8/Src/Zle/zle_misc.c 2001-09-10 19:48:51.000000000 +0900 +++ zsh-4.0.8/Src/Zle/zle_misc.c 2003-12-19 16:41:11.000000000 +0900 @@ -94,6 +94,12 @@ return ret; } if (cs + zmult <= ll) { +#ifdef ZSH_EUC + if (zmult == 1 && + _mbmap_euc[line[cs]] & _MB1 && + _mbmap_euc[line[cs+1]] & _MB2) + cs += 1; +#endif cs += zmult; backdel(zmult); return 0; diff -ur orig/zsh-4.0.8/Src/Zle/zle_move.c zsh-4.0.8/Src/Zle/zle_move.c --- orig/zsh-4.0.8/Src/Zle/zle_move.c 1999-07-03 22:18:00.000000000 +0900 +++ zsh-4.0.8/Src/Zle/zle_move.c 2003-12-19 16:41:11.000000000 +0900 @@ -159,6 +159,15 @@ int forwardchar(char **args) { +#ifdef ZSH_EUC + if (zmult == 1) { + if (_mbmap_euc[line[cs]] & _MB1 && + cs+1 <= ll && + _mbmap_euc[line[cs+1]] & _MB2) { + cs++; + } + } +#endif ZSH_EUC cs += zmult; if (cs > ll) cs = ll; @@ -171,6 +180,15 @@ int backwardchar(char **args) { +#ifdef ZSH_EUC + if (zmult == 1) { + if (_mbmap_euc[line[cs-1]] & _MB2 && + cs-2 >=0 && + _mbmap_euc[line[cs-2]] & _MB1) { + cs--; + } + } +#endif cs -= zmult; if (cs > ll) cs = ll; diff -ur orig/zsh-4.0.8/Src/Zle/zle_refresh.c zsh-4.0.8/Src/Zle/zle_refresh.c --- orig/zsh-4.0.8/Src/Zle/zle_refresh.c 2003-10-28 23:59:59.000000000 +0900 +++ zsh-4.0.8/Src/Zle/zle_refresh.c 2003-12-19 16:41:11.000000000 +0900 @@ -647,7 +647,11 @@ static void refreshline(int ln) { - char *nl, *ol, *p1; /* line buffer pointers */ +#ifdef ZSH_EUC + unsigned char *nl, *ol, *p1; /* line buffer pointers */ +#else + char *nl, *ol, *p1; /* line buffer pointers */ +#endif int ccs = 0, /* temporary count for cursor position */ char_ins = 0, /* number of characters inserted/deleted */ col_cleareol, /* clear to end-of-line from this column */ @@ -753,7 +757,27 @@ for (;;) { if (*nl && *ol && nl[1] == ol[1]) /* skip only if second chars match */ /* skip past all matching characters */ +#ifndef ZSH_EUC for (; *nl && (*nl == *ol); nl++, ol++, ccs++) ; +#else + for (; *nl && (*nl == *ol); nl++, ol++, ccs++) { + if (_mbmap_euc[*nl] & _MB1) { + if (*(ol+1) == '\0') + continue; + if (_mbmap_euc[*(nl+1)] & _MB2) { + if (*(nl+1) != *(ol+1)) + break; + else { + nl++; + ol++; + ccs++; + } + } else if (*(nl+1) == '\0') { + continue; + } + } + } +#endif if (!*nl) { if (ccs == winw && hasam && char_ins > 0 && ins_last diff -ur orig/zsh-4.0.8/Src/Zle/zle_utils.c zsh-4.0.8/Src/Zle/zle_utils.c --- orig/zsh-4.0.8/Src/Zle/zle_utils.c 2001-03-26 17:58:34.000000000 +0900 +++ zsh-4.0.8/Src/Zle/zle_utils.c 2003-12-19 16:41:11.000000000 +0900 @@ -197,6 +197,15 @@ mod_export void backdel(int ct) { +#ifdef ZSH_EUC + if (ct == 1) { + if (_mbmap_euc[line[cs-1]] & _MB2 && + cs-2 >=0 && + _mbmap_euc[line[cs-2]] & _MB1) { + ct = 2; + } + } +#endif shiftchars(cs -= ct, ct); } diff -ur orig/zsh-4.0.8/acconfig.h zsh-4.0.8/acconfig.h --- orig/zsh-4.0.8/acconfig.h 2002-09-17 19:43:33.000000000 +0900 +++ zsh-4.0.8/acconfig.h 2003-12-19 16:41:11.000000000 +0900 @@ -326,3 +326,6 @@ /* Define to the base type of the third argument of accept */ #undef SOCKLEN_T + +/* zsh euc completion */ +#define ZSH_EUC 1 diff -ur orig/zsh-4.0.8/config.h.in zsh-4.0.8/config.h.in --- orig/zsh-4.0.8/config.h.in 2003-05-07 18:29:40.000000000 +0900 +++ zsh-4.0.8/config.h.in 2003-12-19 16:42:32.000000000 +0900 @@ -27,6 +27,8 @@ /* The default prefix for temporary files */ #define DEFAULT_TMPPREFIX "/tmp/zsh" +/* zsh euc completion */ +#define ZSH_EUC 1 /***** end of user configuration section *****/ /***** shouldn't have to change anything below here *****/