[Mew-dist 14928] Re: case fold search for pick

SAKAI Kiyotaka ksakai at example.com
2000年 11月 20日 (月) 10:08:17 JST


>> In article <20001116.225856.71180720.kazu at example.com>, Kazu Yamamoto (山本和彦) <kazu at example.com> writes:

>> pick 時に大文字・小文字が区別されて検索されるのは不便でしたので、
>> 大文字・小文字を区別せずに検索するようパッチを作ってみました。
>> 
>> # 最終的にはオプションにするのがいいのでしょうか?

> オプションだと切り替えるのが面倒なので、明示的にしていできる方がいいで
> しょうね。

> 案1)
> 	case-insensitive: =,  !=
> 	case-sensitive:   ==, !==

> 案2)
> 	case-insensitive: =,  !=
> 	case-sensitive:   #,  !#

案1) でパッチを作ってみましたが、どうでしょうか。
-- 
酒井 清隆 (E-mail: ksakai at example.com)


Index: mew.h
===================================================================
RCS file: /home/ksakai/cvsroot/mew-1.95b77/bin/mew.h,v
retrieving revision 1.1.1.1
diff -u -c -r1.1.1.1 mew.h
*** mew.h	2000/11/20 00:38:35	1.1.1.1
--- mew.h	2000/11/20 00:53:40
***************
*** 117,123 ****
  public char *getprogname(char *);
  public void warning(const char *, ...);
  public void warn_exit(const char *, ...);
! public int search_string(char *, char *);
  public void pattern_init(char *);
  public int pattern_match(void);
  public int Getopt(int, char **, const char *);
--- 117,123 ----
  public char *getprogname(char *);
  public void warning(const char *, ...);
  public void warn_exit(const char *, ...);
! public int search_string(char *, char *, int);
  public void pattern_init(char *);
  public int pattern_match(void);
  public int Getopt(int, char **, const char *);
Index: mewls.c
===================================================================
RCS file: /home/ksakai/cvsroot/mew-1.95b77/bin/mewls.c,v
retrieving revision 1.1.1.1
diff -u -c -r1.1.1.1 mewls.c
*** mewls.c	2000/11/20 00:38:35	1.1.1.1
--- mewls.c	2000/11/20 00:59:29
***************
*** 455,461 ****
  }
  
  public int
! search_string(char *key, char *value) {
  	unsigned int len = strlen(key);
  	char *beg = NULL, *end = NULL;
  	char *p = Search_ctx_buf, *limp = p + Search_ctx_lim, tmp;
--- 455,461 ----
  }
  
  public int
! search_string(char *key, char *value, int case_sensitive) {
  	unsigned int len = strlen(key);
  	char *beg = NULL, *end = NULL;
  	char *p = Search_ctx_buf, *limp = p + Search_ctx_lim, tmp;
***************
*** 484,490 ****
  				end = p - 1;	/* end == LF */
  			tmp = *end;
  			*end = NUL;
! 			if (strcasestr(beg, value) != NULL) {
  				*end = tmp;
  				return TRUE;
  			}
--- 484,491 ----
  				end = p - 1;	/* end == LF */
  			tmp = *end;
  			*end = NUL;
! 			if ((case_sensitive && strstr(beg, value) != NULL) ||
! 				(!case_sensitive && strcasestr(beg, value) != NULL)) {
  				*end = tmp;
  				return TRUE;
  			}
Index: pattern.c
===================================================================
RCS file: /home/ksakai/cvsroot/mew-1.95b77/bin/pattern.c,v
retrieving revision 1.1.1.1
diff -u -c -r1.1.1.1 pattern.c
*** pattern.c	2000/11/20 00:38:35	1.1.1.1
--- pattern.c	2000/11/20 01:02:09
***************
*** 24,31 ****
  	P_NUL, /* terminator */
  	P_EXP, /* abstracted expression */
  	P_STR, /* str, "str", "\"" */
! 	P_EQ,  /* =, == */
  	P_NEQ, /* != */
  	P_AND, /* &, && */
  	P_OR,  /* |, || */
  	P_NOT, /* ! */
--- 24,33 ----
  	P_NUL, /* terminator */
  	P_EXP, /* abstracted expression */
  	P_STR, /* str, "str", "\"" */
! 	P_EQ,  /* = */
! 	P_EQ2, /* == */
  	P_NEQ, /* != */
+ 	P_NEQ2,/* !== */
  	P_AND, /* &, && */
  	P_OR,  /* |, || */
  	P_NOT, /* ! */
***************
*** 183,192 ****
  			Ungetc();
  			break;
  		case EQ:
! 			if (type == P_EQ)
  				break;
! 			else if (type == P_NOT) {
! 				type = P_NEQ;
  				break;
  			} else {
  				Ungetc();
--- 185,200 ----
  			Ungetc();
  			break;
  		case EQ:
! 			if (type == P_EQ) {
! 				type = P_EQ2;
  				break;
! 			} else if (type == P_NOT) {
! 				if ((c = Getc()) == EQ) {
! 					type = P_NEQ2;
! 				} else {
! 					type = P_NEQ;
! 					Ungetc();
! 				}
  				break;
  			} else {
  				Ungetc();
***************
*** 261,267 ****
  	struct pat *n, *p, *q = top;
  
  	while (q != NULL)
! 		if (q->typ == P_EQ || q->typ == P_NEQ) {
  			if (q->prv == NULL || q->nxt == NULL)
  				warn_exit("broken eq/neq.\n");
  			if (q->prv->typ != P_STR || q->nxt->typ != P_STR)
--- 269,275 ----
  	struct pat *n, *p, *q = top;
  
  	while (q != NULL)
! 		if (q->typ == P_EQ || q->typ == P_EQ2 || q->typ == P_NEQ || q->typ == P_NEQ2) {
  			if (q->prv == NULL || q->nxt == NULL)
  				warn_exit("broken eq/neq.\n");
  			if (q->prv->typ != P_STR || q->nxt->typ != P_STR)
***************
*** 512,523 ****
  		return FALSE;
  #ifndef DEBUG
  	case P_EQ:
! 		if ((search_string(p->key, p->val)) == TRUE)
  			return TRUE;
  		else
  			return FALSE;
  	case P_NEQ:
! 		if ((search_string(p->key, p->val)) == TRUE)
  			return FALSE;
  		else
  			return TRUE;
--- 520,541 ----
  		return FALSE;
  #ifndef DEBUG
  	case P_EQ:
! 		if ((search_string(p->key, p->val, 0)) == TRUE)
! 			return TRUE;
! 		else
! 			return FALSE;
! 	case P_EQ2:
! 		if ((search_string(p->key, p->val, 1)) == TRUE)
  			return TRUE;
  		else
  			return FALSE;
  	case P_NEQ:
! 		if ((search_string(p->key, p->val, 0)) == TRUE)
! 			return FALSE;
! 		else
! 			return TRUE;
! 	case P_NEQ2:
! 		if ((search_string(p->key, p->val, 1)) == TRUE)
  			return FALSE;
  		else
  			return TRUE;



Mew-dist メーリングリストの案内