From owner-FreeBSD-tech-jp@jp.FreeBSD.org Mon Jul 22 16:03:57 2002
Received: (from daemon@localhost)
	by castle.jp.FreeBSD.org (8.11.6+3.4W/8.11.3) id g6M73va42418;
	Mon, 22 Jul 2002 16:03:57 +0900 (JST)
	(envelope-from owner-FreeBSD-tech-jp@jp.FreeBSD.org)
Received: from mx9.freecom.ne.jp (mx9.freecom.ne.jp [210.235.164.64])
	by castle.jp.FreeBSD.org (8.11.6+3.4W/8.11.3) with SMTP/inet id g6M73qn42399
	for <FreeBSD-tech-jp@jp.FreeBSD.org>; Mon, 22 Jul 2002 16:03:52 +0900 (JST)
	(envelope-from siramoto@mx9.freecom.ne.jp)
Received: (qmail 19509 invoked by alias); 22 Jul 2002 16:03:50 +0900
Received: (qmail 19481 invoked from network); 22 Jul 2002 16:03:49 +0900
Received: from unknown (HELO mx9.freecom.ne.jp) (202.234.223.17)
  by mx9.freecom.ne.jp with SMTP; 22 Jul 2002 16:03:49 +0900
Message-ID: <3D3BAE44.541E9489@mx9.freecom.ne.jp>
Date: Mon, 22 Jul 2002 16:03:32 +0900
From: Takeyuki Shiramoto <siramoto@mx9.freecom.ne.jp>
X-Mailer: Mozilla 4.78C-ja  [ja] (X11; U; Linux 2.2.12 i386)
X-Accept-Language: ja, en
MIME-Version: 1.0
To: FreeBSD-tech-jp@jp.FreeBSD.org
Content-Type: text/plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit
Reply-To: FreeBSD-tech-jp@jp.FreeBSD.org
Precedence: list
X-Sequence: FreeBSD-tech-jp 3304
Subject: [FreeBSD-tech-jp 3304] Tcsh Japanese input enhancement
Errors-To: owner-FreeBSD-tech-jp@jp.FreeBSD.org
Sender: owner-FreeBSD-tech-jp@jp.FreeBSD.org
X-Originator: siramoto@mx9.freecom.ne.jp
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+020717

$B$O$8$a$^$7$F!#GrK\$G$9!#(B

Tcsh$B$NF|K\8l$N%U%!%$%kL>$J$I$NJd405!G=$r6/2=$7$F$_$^$7$?!#(B
$B<!$N$h$&$J(B5$B$D$N%U%!%$%k!"(B

  $B:#F|$NM<HS(B  $B:#F|$NM=Dj(B  $B:rF|$NM<HS(B  $B:rF|$NM=Dj(B  $BL@F|$NM=Dj(B

$B$,$"$k$H$-$K!"%3%^%s%I%i%$%s$+$i!"(B
  %more kin[TAB]
$B$HF~NO$9$k$H(B
  %more kinounoy
$B$HJd40$5$l!"$5$i$K(B
  %more kinounoyo[TAB]
$B$G(B
  %more $B:rF|$NM=Dj(B
$B$HJd40$5$l$^$9!#(B


$B%Q%C%A$K$D$$$F(B
$B:n6H$O(B4.4-RELEASE$B$G9T$$$^$7$?!#(B
$B%3%s%Q%$%k$9$k$K$O!"$^$:(Bports$B$+$i(Bja-chasen$B$r%$%s%9%H!<%k$7$F$/$@$5$$!#(B
$B$=$N8e!"E,Ev$J%G%#%l%/%H%j$G(B
mkdir -p tcsh/contrib tcsh/bin
cp -R /usr/src/contrib/tcsh tcsh/contrib
cp -R /usr/src/bin/csh tcsh/bin
cp -R tcsh tcsh.orig
$B$G(Btcsh$B$N%3%T!<$r:n$C$F0J2<$N%Q%C%A$rEv$F$F$/$@$5$$!#(B
$B%3%s%Q%$%k$O!"(B
cd tcsh/bin/csh
make
$B$G$G$-$^$9!#(B
($BCm0UE@(B)$B:#$N$H$3$m0\?"@-$,$"$j$^$;$s!#$^$?!"%m!<%^;z$X$NJQ49$,(B
$B4JC1$K$7$+:n$C$F$$$J$$$N$G!"!V$-$c!W$J$I$O!V(Bkixya$B!W$HF~NO$9$kI,MW$,(B
$B$"$j$^$9!#(B

============ $B$3$3$+$i(B ==========
diff -crN tcsh.orig/bin/csh/Makefile tcsh/bin/csh/Makefile
*** tcsh.orig/bin/csh/Makefile	Mon Jul 22 15:25:39 2002
--- tcsh/bin/csh/Makefile	Mon Jul 22 15:25:51 2002
***************
*** 19,25 ****
  	sh.set.c sh.time.c sh.char.h sh.dir.h sh.proc.h sh.h
  SRCS+=	sh.decls.h glob.c glob.h mi.termios.c mi.wait.h mi.varargs.h
  SRCS+=	tw.decls.h tw.h tw.help.c tw.init.c tw.parse.c tw.spell.c \
! 	tw.comp.c tw.color.c
  SRCS+=	ed.chared.c ed.decls.h ed.defns.c ed.h ed.init.c ed.inputl.c \
  	ed.refresh.c ed.screen.c ed.xmap.c ed.term.c ed.term.h
  SRCS+=	tc.alloc.c tc.bind.c tc.const.c tc.decls.h tc.disc.c \
--- 19,25 ----
  	sh.set.c sh.time.c sh.char.h sh.dir.h sh.proc.h sh.h
  SRCS+=	sh.decls.h glob.c glob.h mi.termios.c mi.wait.h mi.varargs.h
  SRCS+=	tw.decls.h tw.h tw.help.c tw.init.c tw.parse.c tw.spell.c \
! 	tw.comp.c tw.color.c tw.euc2alpha.c
  SRCS+=	ed.chared.c ed.decls.h ed.defns.c ed.h ed.init.c ed.inputl.c \
  	ed.refresh.c ed.screen.c ed.xmap.c ed.term.c ed.term.h
  SRCS+=	tc.alloc.c tc.bind.c tc.const.c tc.decls.h tc.disc.c \
***************
*** 35,41 ****
  # builtin.1 in share/man/man1/.
  
  DPADD=	${LIBTERMCAP} ${LIBCRYPT}
! LDADD=	-ltermcap -lcrypt
  
  LINKS=	${BINDIR}/csh ${BINDIR}/tcsh
  
--- 35,42 ----
  # builtin.1 in share/man/man1/.
  
  DPADD=	${LIBTERMCAP} ${LIBCRYPT}
! LDADD=	-L /usr/local/lib -lchasen -ltermcap -lcrypt
! COPTS+= -I /usr/local/include
  
  LINKS=	${BINDIR}/csh ${BINDIR}/tcsh
  
diff -crN tcsh.orig/contrib/tcsh/sh.c tcsh/contrib/tcsh/sh.c
*** tcsh.orig/contrib/tcsh/sh.c	Mon Jul 22 15:25:37 2002
--- tcsh/contrib/tcsh/sh.c	Mon Jul 22 15:25:49 2002
***************
*** 37,42 ****
--- 37,45 ----
  #define EXTERN	/* Intern */
  #include "sh.h"
  
+ #include <stdio.h>
+ #include <chasen.h>
+ 
  #ifndef lint
  char    copyright[] =
  "@(#) Copyright (c) 1991 The Regents of the University of California.\n\
***************
*** 260,265 ****
--- 263,273 ----
  	if (*t == '-') t++;
  	progname = strsave((t && *t) ? t : tcshstr);    /* never want a null */
  	tcsh = strcmp(progname, tcshstr) == 0;
+     }
+ 
+     {
+ 	char *chasen_opt[] = {"tcsh", "-F", "%y", NULL};
+ 	chasen_getopt_argv(chasen_opt, stderr);
      }
  
      /*
diff -crN tcsh.orig/contrib/tcsh/tw.euc2alpha.c tcsh/contrib/tcsh/tw.euc2alpha.c
*** tcsh.orig/contrib/tcsh/tw.euc2alpha.c	Thu Jan  1 09:00:00 1970
--- tcsh/contrib/tcsh/tw.euc2alpha.c	Mon Jul 22 15:25:51 2002
***************
*** 0 ****
--- 1,53 ----
+ #include<stdio.h>
+ #include<sys/types.h>
+ #include<dirent.h>
+ #include<chasen.h>
+ 
+ static
+ char *kana_alpha_table[] = {
+     /* start from 2521 to 2576 */
+     "xa",  "a",  "xi",  "i",  "xu",  "u",  "xe",  "e",  "xo",  "o",
+     "ka", "ga", "ki", "gi", "ku", "gu", "ke", "ge", "ko", "go",
+     "sa", "za", "shi", "ji", "su", "zu", "se", "ze", "so", "zo",
+     "ta", "da", "chi", "di", "xtu", "tu", "du", "te", "de", "to", "do",
+     "na", "ni", "nu", "ne", "no",
+     "ha", "ba", "pa", "hi", "bi", "pi", "hu", "bu", "pu", "he", "be", "pe",
+ 	  "ho", "bo", "po",
+     "ma", "mi", "mu", "me", "mo",
+     "xya", "ya", "xyu", "yu", "xyo", "yo",
+     "ra", "ri", "ru", "re", "ro",
+     "xwa", "wa", "wi", "we", "wo", "n", "vu", "xka", "xke"};
+ 
+ 
+ static void
+ katakana2alpha(unsigned char *dist, unsigned char *src)
+ {
+     while(*src){
+ 	if (*src < 128){	/* ascii code */
+ 	    *dist++ = *src++;
+ 	} else {		/* euc code */
+ 	    unsigned short sch;
+ 
+ 	    sch = (*src & 0x7f) << 8 | (*(src + 1) & 0x7f);
+ 	    if (0x2521 <= sch && sch <= 0x2576){
+ 		char *p;
+ 		p = kana_alpha_table[sch - 0x2521];
+ 		while(*p) *dist++ = *p++;
+ 		src += 2;
+ 	    }else{
+ 		*dist++ = *src++;
+ 		*dist++ = *src++;
+ 	    }
+ 	}
+     }
+     *(dist - 1) = '\0';
+ }
+ 
+ char *
+ euc2alpha(char *euc)
+ {
+     static char buf[512];
+ 
+     katakana2alpha(buf, chasen_sparse_tostr(euc));
+     return buf;
+ }
diff -crN tcsh.orig/contrib/tcsh/tw.parse.c tcsh/contrib/tcsh/tw.parse.c
*** tcsh.orig/contrib/tcsh/tw.parse.c	Mon Jul 22 15:25:39 2002
--- tcsh/contrib/tcsh/tw.parse.c	Mon Jul 22 15:25:51 2002
***************
*** 879,884 ****
--- 879,885 ----
      int flags;
  
  {
+     extern char *euc2alpha(char *);
      int done = FALSE;			 /* Search is done */
      int showdots;			 /* Style to show dot files */
      int nignored = 0;			 /* Number of fignored items */
***************
*** 897,902 ****
--- 898,906 ----
      int len, enhanced;
      int cnt = 0;
      int igncase = 0;
+     int isyomimatch = 0;
+     Char yomi[MAXPATHLEN+1];
+     Char onematcheuc[MAXPATHLEN+1];
  
  
      flags = 0;
***************
*** 916,923 ****
--- 920,930 ----
  	    }
  
      while (!done && (item = (*tw_next_entry[looking])(exp_dir, &flags))) {
+ 	copyn(yomi, str2short(euc2alpha(short2str(item))), MAXPATHLEN+1);
+ 	isyomimatch = 0;
  #ifdef TDEBUG
  	xprintf("item = %S\n", item);
+ 	xprintf("yomi = %S\n", yomi);
  #endif
  	switch (looking) {
  	case TW_FILE:
***************
*** 998,1008 ****
  #endif /* WINNT_NATIVE */
  	    enhanced = (vp = adrof(STRcomplete)) != NULL && !Strcmp(*(vp->vec),STRenhance);
  	    if (enhanced || igncase) {
! 	        if (!is_prefixmatch(target, item, igncase)) 
! 		    break;
       	    } else {
! 	        if (!is_prefix(target, item)) 
! 		    break;
  	    }
  
  	    if (exec_check && !executable(exp_dir, item, dir_ok))
--- 1005,1031 ----
  #endif /* WINNT_NATIVE */
  	    enhanced = (vp = adrof(STRcomplete)) != NULL && !Strcmp(*(vp->vec),STRenhance);
  	    if (enhanced || igncase) {
! 	        if (is_prefixmatch(target, item, igncase)) {
! 		    isyomimatch = 0;
! 		    copyn(onematcheuc, item, MAXPATHLEN+1);
! 		}else{
! 		    if(is_prefixmatch(target, yomi, igncase)){
! 			isyomimatch = 1;
! 			copyn(onematcheuc, item, MAXPATHLEN+1);
! 		    }
! 		    else break;
! 		}
       	    } else {
! 	        if (is_prefix(target, item)) {
! 		    isyomimatch = 0;
! 		    copyn(onematcheuc, item, MAXPATHLEN+1);
! 		}else{
! 		    if(is_prefix(target, yomi)){
! 			isyomimatch = 1;
! 			copyn(onematcheuc, item, MAXPATHLEN+1);
! 		    }
! 		    else break;
! 		}
  	    }
  
  	    if (exec_check && !executable(exp_dir, item, dir_ok))
***************
*** 1081,1087 ****
  			break;
  		    }
  		}
! 		if (recognize(exp_name, item, name_length, ++numitems, enhanced)) 
  		    if (command != RECOGNIZE_SCROLL)
  			done = TRUE;
  		if (enhanced && (int)Strlen(exp_name) < name_length)
--- 1104,1112 ----
  			break;
  		    }
  		}
! 		if (recognize(exp_name,
! 			      isyomimatch? yomi: item,
! 			      name_length, ++numitems, enhanced)) 
  		    if (command != RECOGNIZE_SCROLL)
  			done = TRUE;
  		if (enhanced && (int)Strlen(exp_name) < name_length)
***************
*** 1095,1100 ****
--- 1120,1128 ----
  #ifdef TDEBUG
  	xprintf("done item = %S\n", item);
  #endif
+     }
+     if (command == RECOGNIZE && numitems == 1){
+ 	copyn(exp_name, onematcheuc, MAXPATHLEN+1);
      }
  
  
================ $B$3$3$^$G(B =============
