bugfixes

  • From: Tommy Pettersson <ptp@xxxxxxxxxxxxxx>
  • To: wilyfans@xxxxxxxxxxxxx
  • Date: Sun, 5 Dec 2004 02:13:38 +0100

Here are two more bugfixes.  :-)
Patches are against wily-9libs 0.13.41.


The first one can only happen if you have cursor keys enabled.
The data structure for a range is denoted from lower to upper
position.  A reverse range is used to denote an invalid range.
Therefore the mouse selection code has to reverse the range
if it is swept the "wrong" way.  And so does the code for
selecting the latest text with escape (or return in the tag
line) _if_ you manage to move the dot to the left of the
anchor position, which you can with cursor keys.

diff -rN -u diff-old/wily-9libs/include/msg.h diff-new/wily-9libs/include/msg.h
--- diff-old/wily-9libs/include/msg.h   Sun Dec  5 00:28:19 2004
+++ diff-new/wily-9libs/include/msg.h   Sun Dec  5 00:25:16 2004
@@ -119,5 +119,6 @@
 Range          rclip (Range, Range);
 ulong  pclipr(ulong p, Range r);
 Range  range(ulong , ulong );
+Range  maybereverserange(ulong,ulong);
 ulong  ladjust(ulong , Range , int );
 ulong  radjust(ulong , Range , int );
diff -rN -u diff-old/wily-9libs/libmsg/util.c diff-new/wily-9libs/libmsg/util.c
--- diff-old/wily-9libs/libmsg/util.c   Sun Dec  5 00:28:19 2004
+++ diff-new/wily-9libs/libmsg/util.c   Sun Dec  5 00:25:16 2004
@@ -72,6 +72,12 @@
        return r;
 }
 
+Range
+maybereverserange(ulong p0, ulong p1)
+{
+       return (p0 <= p1)? range(p0,p1) : range(p1,p0);
+}
+
 /* "Safe" realloc.   Currently all it does is crash cleanly
  * if it runs out of memory.
  */
diff -rN -u diff-old/wily-9libs/wily/keyboard.c 
diff-new/wily-9libs/wily/keyboard.c
--- diff-old/wily-9libs/wily/keyboard.c Sun Dec  5 00:28:19 2004
+++ diff-new/wily-9libs/wily/keyboard.c Sun Dec  5 00:25:16 2004
@@ -52,8 +52,7 @@
        char*cmd;
        
        if(!RLEN(v->sel)){
-               assert(v->anchor <= v->sel.p0);
-               view_select(v, range(v->anchor, v->sel.p0));
+               view_select(v, maybereverserange(v->anchor, v->sel.p0));
        }
        cmd = text_duputf(v->t, v->sel);
        if(cmd[0]==':'){
@@ -102,7 +101,7 @@
                view_cut(v, del);       
        } else {
                /* Select from v->anchor to v->sel.p0 */
-               view_select(v, range(v->anchor, v->sel.p0));
+               view_select(v, maybereverserange(v->anchor, v->sel.p0));
                view_setlastselection(v);
        }
 }
diff -rN -u diff-old/wily-9libs/wily/select.c diff-new/wily-9libs/wily/select.c
--- diff-old/wily-9libs/wily/select.c   Sun Dec  5 00:28:19 2004
+++ diff-new/wily-9libs/wily/select.c   Sun Dec  5 00:25:16 2004
@@ -155,7 +155,7 @@
        if(timer)
                estoptimer(timer);      
 
-       return range(MIN(p0,p1), MAX(p0,p1));
+       return maybereverserange(p0,p1);
 }
 
 /* Drag out a selection, starting with 'm' (mouse down),



The second one is about the :#NNN,. things you get in the tag
line with Anchor.  They get destroyd when the word to the left
is automatically removed from the tag line.  It's because the
find-word function tries to remove as much cruft as possible
after the word, and it doesn't stop at `:' as it should.

I suspect this can still fail when funnily named programs
have their names added and removed from the main tag.

diff -rN -u diff-old/wily-9libs/wily/search.c diff-new/wily-9libs/wily/search.c
--- diff-old/wily-9libs/wily/search.c   Sun Dec  5 00:28:19 2004
+++ diff-new/wily-9libs/wily/search.c   Sun Dec  5 00:25:16 2004
@@ -5,7 +5,7 @@
 #include "wily.h"
 #include "text.h"
 
-static char    *endword = "[^a-zA-Z0-9][^a-zA-Z0-9|]*";
+static char    *endword = "[^a-zA-Z0-9][^a-zA-Z0-9:|]*";
 static char    *startword = "[^a-zA-Z0-9]";
 static char    *special = ".*+?(|)\\[]^$";
 


-- 
Tommy Pettersson <ptp@xxxxxxxxxxxxxx>

Other related posts: