jed-users mailing list

[2004 Date Index] [2004 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: jed 0.99-17 looks good


Jacob (=Jouk) Jansen <joukj@xxxxxxxxxxxxxxxxxxx> wrote:
>This was as it was in previous versions. and thus I like it
>but now in 0.99-17 it seems to be the other way round and only half
>functioning: (I normally use the the VT200-keypad in EDT mode) The first
>search (*FIND = gold=PF3) is always case sensitive. following search with
>(*FNDNEXT=PF3) is case insensitive if the seach string is all uppercase.
>How can I get back the behaviour of the previous versions

There is a bug in slang2 that is causing this behavior.  This weekend,
I will release a new snapshot.  In the meantime, you may want to use
the following patch.  Thanks, --John

--- /nfs/cxc/h1/davis/src/release/slang/slang-pre2-r1/src/slsearch.c	Sat Nov 20 21:06:59 2004
+++ slsearch.c	Wed Nov 24 12:47:45 2004
@@ -448,14 +448,15 @@
    if (dir < 0)
      key += (key_len-1);
    
+   /* For a case-insensitive search, the key here will be uppercased */
    flags = flags & SLSEARCH_CASELESS;
    i = 0;
    while (i < key_len)
      {
 	i++;
 	skip_table[*key] = key_len - i;
-        if (flags)
-          skip_table[LOWER_CASE(*key)] = key_len - i;
+	if (flags)
+	  skip_table[LOWER_CASE(*key)] = key_len - i;
 	key += dir;
      }
 }
@@ -505,21 +506,46 @@
    SLfree ((char *)st);
 }
 
+/* This is used if the key is not UTF-8, or it is but the search is case-sensitive */
 static SLsearch_Type *bm_open_search (SLuchar_Type *key, int flags)
 {
    SLsearch_Type *st;
+   unsigned int keylen;
 
+   keylen = strlen ((char *)key);
    if (NULL == (st = (SLsearch_Type *)SLcalloc (1, sizeof (SLsearch_Type))))
      return NULL;
 
    st->free_fun = bm_free;
 
-   if (NULL == (st->s.bm.key = (SLuchar_Type*) SLang_create_slstring ((char *)key)))
+   /* If the search is case-insensitive, then it must either be all ascii, or
+    * it is not unicode.  In either case, the UPPER_CASE and LOWER_CASE macros
+    * should be ok to use.
+    */
+   if (flags & SLSEARCH_CASELESS)
+     {
+	char *keyup = SLmake_nstring ((char *)key, keylen);
+	if (keyup != NULL)
+	  {
+	     unsigned char *k = (unsigned char *)keyup;
+	     while (*k != 0)
+	       {
+		  *k = UPPER_CASE(*k);
+		  k++;
+	       }
+	     st->s.bm.key = (SLuchar_Type *)SLang_create_slstring (keyup);
+	     SLfree (keyup);
+	  }
+	else st->s.bm.key = NULL;
+     }
+   else st->s.bm.key = (SLuchar_Type*) SLang_create_slstring ((char *)key);
+   
+   if (st->s.bm.key == NULL)
      {
         SLsearch_delete (st);
         return NULL;
      }
-   st->s.bm.key_len = strlen ((char *)key);
+   st->s.bm.key_len = keylen;
    st->flags = flags;
 
    st->search_fun = bm_search;
@@ -600,6 +626,7 @@
        || (0 == (flags & SLSEARCH_UTF8)))
      return bm_open_search (key, flags);
 
+   /* Otherwise the key is UTF-8 and the search is case-insensitive */
    len = strlen ((char *)key);
    key_upper = SLutf8_strup (key, key + len);
    if (key_upper == NULL)


--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2004 date index] [2004 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]