small bugfixes for wily-0.13.41-9libs

  • From: Tommy Pettersson <ptp@xxxxxxxxxxxxxx>
  • To: wilyfans@xxxxxxxxxxxxx
  • Date: Thu, 27 Jan 2005 18:59:51 +0100

Here are some bugfixes for wily-0.13.41-9libs.



The function prototype for rpc_freehandle() has the wrong
name in the header file.

diff -rN -u diff-old/wily-9libs/include/msg.h 
diff-new-1/wily-9libs/include/msg.h
--- diff-old/wily-9libs/include/msg.h   Thu Jan 27 17:37:26 2005
+++ diff-new-1/wily-9libs/include/msg.h Thu Jan 27 17:35:27 2005
@@ -87,7 +87,7 @@
 Handle*        rpc_init                (int);
 int            rpc_fileno(Handle *h);
 Bool           rpc_isconnected(Handle*);
-void           rpc_free (Handle*);
+void           rpc_freehandle (Handle*);
 
 char*  rpc_list                (Handle*h, char **bufptr);
 char*  rpc_new         (Handle*, char *, Id*, ushort);



This one has already been reported to the list by Elliott
Hughes; errno should be set to 0 before call to diag().

diff -rN -u diff-old/wily-9libs/wily/event.c diff-new-1/wily-9libs/wily/event.c
--- diff-old/wily-9libs/wily/event.c    Thu Jan 27 17:37:26 2005
+++ diff-new-1/wily-9libs/wily/event.c  Thu Jan 27 17:35:27 2005
@@ -168,6 +168,7 @@
 kill_list(void){
        Key     *k;
        
+       errno = 0;
        for(k = keytab; k < keytab + MAXKEYS; k++)
                if(k->t == Kout && !k->v)
                        diag(0, "Kill %s", k->cmd);



Here's another place where errno should be set to 0 before a
call to diag().  And I have added a comment about a missing
check for nulls in the input, which may be both a bug and
a feature?

The main bug is that utftotext() resets the global variable
utfHadNulls on each call but it may be called several times
consecutively by readtext() if the text is large, and so
only nulls in the last block to utftotext() will be detected.
The fix is that every function that wants to check utfHadNulls
must itself reset it beforehand.

diff -rN -u diff-old/wily-9libs/wily/util.c diff-new-1/wily-9libs/wily/util.c
--- diff-old/wily-9libs/wily/util.c     Thu Jan 27 17:37:26 2005
+++ diff-new-1/wily-9libs/wily/util.c   Thu Jan 27 17:35:27 2005
@@ -171,7 +171,7 @@
        strcpy(s, "+Errors");
        
        v = openlabel(errwin, true);
-       base[n] = 0;
+       base[n] = 0;    /* bug - assuming no nulls in 'base' */
        t = view_text(v);
        p = text_length(t);
        r = text_replaceutf(t, range(p,p), base);
@@ -444,7 +444,6 @@
        Rune    *q;
        char    *v;
        
-       utfHadNulls = false;
        if (s2 <= s1)
                return 0;
        for (v = s1, q = r; v < s2; ) {
diff -rN -u diff-old/wily-9libs/wily/file.c diff-new-1/wily-9libs/wily/file.c
--- diff-old/wily-9libs/wily/file.c     Thu Jan 27 17:37:26 2005
+++ diff-new-1/wily-9libs/wily/file.c   Thu Jan 27 17:35:27 2005
@@ -176,10 +176,11 @@
        d->names = 0;
 
        /* d->t */
+       utfHadNulls = false;
        text_read(d->t, fd, buf->st_size);
        close(fd);
        if (utfHadNulls) {
-               diag(path, "removed nulls from [%s]", path);
+               errno=0, diag(path, "removed nulls from [%s]", path);
                data_setbackup(d,0);
        }
 


Here's another place where nulls are not checked for in
the input.  Bug or feature...?

The big bug is that the main event loop keeps a local pointer
to the currently focused view, and that view can become
deleted so it turns into a bad pointer.  I simply made the
pointer global and set it to 0 in view_delete(), just like
is done with the last_selection pointer.  Don't know if it's
so pretty, but it works.

diff -rN -u diff-old/wily-9libs/wily/global.c 
diff-new-1/wily-9libs/wily/global.c
--- diff-old/wily-9libs/wily/global.c   Thu Jan 27 17:37:26 2005
+++ diff-new-1/wily-9libs/wily/global.c Thu Jan 27 17:35:27 2005
@@ -9,6 +9,12 @@
 /* widget with most recent b1 click */
 View * last_selection;
 
+/* 'last_focus' is a cache of the view we are pointing at,
+ * (we use point to type).  We update this only when we start
+ * typing after moving the pointer, or if the view is deleted.
+ */
+View   *last_focus;
+
 /* "stop" characters for various text expansions.
  * heuristic guesses only.
  */
diff -rN -u diff-old/wily-9libs/wily/global.h 
diff-new-1/wily-9libs/wily/global.h
--- diff-old/wily-9libs/wily/global.h   Thu Jan 27 17:37:26 2005
+++ diff-new-1/wily-9libs/wily/global.h Thu Jan 27 17:35:27 2005
@@ -6,6 +6,7 @@
 extern Bool show_dot_files;
 extern Bool autoindent_enabled;
 extern View *last_selection;
+extern View    *last_focus;
 extern char * notfilename, *notdoubleclick , *notcommand,
                *notaddress, *notinclude;
 extern char*   whitespace;
diff -rN -u diff-old/wily-9libs/wily/view.c diff-new-1/wily-9libs/wily/view.c
--- diff-old/wily-9libs/wily/view.c     Thu Jan 27 17:37:26 2005
+++ diff-new-1/wily-9libs/wily/view.c   Thu Jan 27 17:35:27 2005
@@ -72,6 +72,8 @@
                return -1;
        if(v==last_selection)
                view_setlastselection(0);
+       if (v == last_focus)
+               last_focus = 0;
        frclear(&v->f);
        releasefont(v->font);
        if(v->scroll)
@@ -188,7 +190,7 @@
        t = v->t;
        len = text_length(t);
        end = range(len,len);
-       s[n] = 0;
+       s[n] = 0;       /* bug - assuming no nulls in 'base' */
        
        text_replaceutf(v->t, end, s);
 }
diff -rN -u diff-old/wily-9libs/wily/wily.c diff-new-1/wily-9libs/wily/wily.c
--- diff-old/wily-9libs/wily/wily.c     Thu Jan 27 17:37:26 2005
+++ diff-new-1/wily-9libs/wily/wily.c   Thu Jan 27 17:35:27 2005
@@ -206,28 +206,23 @@
        Event   e;
        Bool    mouseaction=true;
        Point   lastp={0,0};
-       View    *v=0;
 
        while ((type = eread(~0, &e))) {
                switch(type){
                case Ekeyboard:
                        if(mouseaction) {
-                               /* 'v' is a cache of the view we are pointing 
at,
-                                * (we use point to type).  We update this only
-                                * when we start typing after moving the 
pointer.
-                                */
-                               v = point2view(lastp);
+                               last_focus = point2view(lastp);
                                mouseaction=false;
                        }
-                       if(v)
-                               dokeyboard(v, e.kbdc);
+                       if (last_focus)
+                               dokeyboard(last_focus, e.kbdc);
                        break;
 
                case Emouse:
                        lastp = e.mouse.xy;
                        mouseaction=true;
-                       if(e.mouse.buttons && (v = point2view(e.mouse.xy)))
-                               domouse(v, &e.mouse);   
+                       if(e.mouse.buttons && (last_focus = 
point2view(e.mouse.xy)))
+                               domouse(last_focus, &e.mouse);  
                        break;
 
                default:



text_startOfLine() misses if first char is a newline, which
makes autoindent behave funny.  I think this has already been
pointed out on the list by someone else, but can't find it now.

diff -rN -u diff-old/wily-9libs/wily/line.c diff-new-1/wily-9libs/wily/line.c
--- diff-old/wily-9libs/wily/line.c     Thu Jan 27 17:37:26 2005
+++ diff-new-1/wily-9libs/wily/line.c   Thu Jan 27 17:35:27 2005
@@ -109,5 +109,5 @@
        do {
                c=Tbgetc(t);
        } while ( c != -1 && c != NEWLINE);
-       return t->pos ? t->pos+1 : t->pos;
+       return (c != -1) ? t->pos+1 : t->pos;
 }



A previous patch of mine added a colon the the endword regexp
to protect anchors in the tag line.  A dot and a dollar sign
will likewise protect some unusual names of running processes
in the main tag.  This way of fixing it doesn't seem "clean"
to me, but I can't think of anything else that is easy.

diff -rN -u diff-old/wily-9libs/wily/search.c 
diff-new-1/wily-9libs/wily/search.c
--- diff-old/wily-9libs/wily/search.c   Thu Jan 27 17:37:26 2005
+++ diff-new-1/wily-9libs/wily/search.c Thu Jan 27 17:35:27 2005
@@ -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 = ".*+?(|)\\[]^$";
 



Here's a rendering bug.  If prop and fixed fonts have different
heights and the font is toggled, the tag line of the window
below can be partially erased.  I think the clearing of the
old contents when the window is redrawn with the new font
is calculated with the new font metrics, which may extend
beyond the old ones into the next window.  An extra limit
check fixed it.

diff -rN -u diff-old/wily-9libs/wily/vgeom.c diff-new-1/wily-9libs/wily/vgeom.c
--- diff-old/wily-9libs/wily/vgeom.c    Thu Jan 27 17:37:26 2005
+++ diff-new-1/wily-9libs/wily/vgeom.c  Thu Jan 27 17:35:27 2005
@@ -100,7 +100,7 @@
                /* Last line. */
                r.max = r.min = frptofchar(f, f->nchars + 1);
                r.max.x = f->r.max.x;
-               r.max.y += f->font->height;
+               r.max.y = MAX(r.max.y+f->font->height, v->r.max.y);
                if (r.min.x != r.max.x)
                        cls(r);
 

-- 
Tommy Pettersson <ptp@xxxxxxxxxxxxxx>

Other related posts: