[Mew-dist 14880] case fold search for pick

SAKAI Kiyotaka ksakai at example.com
2000年 11月 15日 (水) 17:13:27 JST


pick 時に大文字・小文字が区別されて検索されるのは不便でしたので、
大文字・小文字を区別せずに検索するようパッチを作ってみました。

# 最終的にはオプションにするのがいいのでしょうか?
-- 
酒井 清隆 (E-mail: ksakai at example.com)


Index: mewls.c
===================================================================
RCS file: /home/ksakai/cvsroot/mew-1.95b76/bin/mewls.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 mewls.c
--- mewls.c	2000/11/08 01:36:06	1.1.1.1
+++ mewls.c	2000/11/15 07:56:14
@@ -425,6 +425,30 @@
 	Search_ctx_lim = lim;
 }
 
+static int strcasestr(const char *s0, const char *s1) {
+	int len0, len1, i, j;
+
+	len0 = strlen(s0);
+	len1 = strlen(s1);
+
+	if (len0 < len1)
+		return NULL;
+
+	for (i = 0; i < len0 - len1 + 1; i++) {
+		if (tolower(*(s0 + i)) == tolower(*s1)) {
+			for (j = 0; j < len1; j++) {
+				if (tolower(*(s0 + i + j)) != tolower(*(s1 + j))) {
+					break;
+				}
+			}
+			if (j == len1)
+				return i;
+		}
+	}
+
+	return NULL;
+}
+
 public int
 search_string(char *key, char *value) {
 	unsigned int len = strlen(key);
@@ -455,7 +479,7 @@
 				end = p - 1;	/* end == LF */
 			tmp = *end;
 			*end = NUL;
-			if (strstr(beg, value) != NULL) {
+			if (strcasestr(beg, value) != NULL) {
 				*end = tmp;
 				return TRUE;
 			}



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