1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-27 10:03:20 +00:00
freebsd-ports/shells/zsh+euc_hack/files/patch-Src::Zle::compmatch.c
Akinori MUSHA f1f99beceb Add zsh+euc, Zsh with EUC encoding support.
This is just an experimental hack and cannot happily be merged into
the upstream.  Zsh's line editor apparently needs a rewrite in order
to support multi-byte encodings because it strongly relies on the
single-byte character scheme.

These patches are mostly based on the work by ono@ono.org (Thanks!):

	http://www.ono.org/software/zsh-euc/

What I did over this is disable the hack for non-EUC locales.  Maybe
the patches can be moved to shells/zsh in the future, but it's
premature for the moment.

Notes:
- forward-char, backward-char and backward-delete-char with no numeric
  argument should work properly with this hack.
- Completion and redisplay should work fine.
- There can be some trivial side-effects.
- JIS X0201-Roman and JIS X0208-Kanji are supported.
- JIS X0201-Katakana and JIS X0212 Kanji are NOT supported.
- Only tested with the EUC-JP (ja_JP.eucJP) locale.  I'm not sure if
  it works for GB 2312/CNS 11643-1/KS X 1001.  Any feedbacks is
  welcome, especially a patch if it does not work. :)
2002-05-11 21:48:26 +00:00

58 lines
1.4 KiB
C

--- Src/Zle/compmatch.c.orig Tue Apr 3 20:25:13 2001
+++ Src/Zle/compmatch.c Thu May 9 07:59:05 2002
@@ -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,6 +1357,13 @@
}
if (!t)
break;
+#ifdef ZSH_EUC
+ } else if (locale_is_euc &&
+ (_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) {
@@ -1580,6 +1590,30 @@
if (check_cmdata(md, sfx))
return ret;
+#ifdef ZSH_EUC
+ if (locale_is_euc) {
+ 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++;
+ }
+ }
+ } else
+#endif
for (l = 0, p = str, q = md->str;
l < len && l < md->len && p[ind] == q[ind];
l++, p += add, q += add);