qemacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemacs-devel] a few bugs in 0.3 (patch included)


From: Manuel Novoa III
Subject: [Qemacs-devel] a few bugs in 0.3 (patch included)
Date: Sun, 23 Feb 2003 14:19:03 -0700
User-agent: Mutt/1.3.28i

Hello,

I grabbed 0.3 the other day and found a few problems.  The following
patch fixes most of them.  The help buffer was being freed to soon
in do_describe_bindings(), various window ops (C-x 1, C-x 0, C-x k)
weren't aware of the special nature of popups, there were some
unitialized variables used (found by valgrind... highly recommended),
output to ptys (screen, xterm) could be incomplete because of EAGAIN,
splitting dired view windows could result in segfaults, and the UTF-8
test in tty.c failed on uClibc because of stronger checking of the
printf format string.  Anyway, there are comments with the various
patched sections.

Regarding the do_c_electric problems though, I just disabled it.
I'd get a segfault as soon as I typed the ';' in the following:
-----------------
int main(void)
{
int i;
-----------------
There would be a "cursor not found" error message, and then boom.
Since I didn't have the time to put into looking at the do_c_electric()
routine in detail, I just punted for now.

Manuel



diff -u -r -N qemacs-0.3/clang.c qemacs-0.3-mjn3/clang.c
--- qemacs-0.3/clang.c  2003-02-02 14:07:45.000000000 -0600
+++ qemacs-0.3-mjn3/clang.c     2003-02-23 13:45:12.000000000 -0600
@@ -508,10 +508,13 @@
 static CmdDef c_commands[] = {
     CMD0( KEY_CTRL('i'), KEY_NONE, "c-indent-command", do_c_indent)
     CMD0( KEY_NONE, KEY_NONE, "c-indent-region", do_c_indent_region)
+#if 0
+    /* These are causing segfaults... "cursor not found". */
     CMD1( ';', KEY_NONE, "c-electric-semi&comma", do_c_electric, ';')
     CMD1( ':', KEY_NONE, "c-electric-colon", do_c_electric, ':')
     CMD1( '{', KEY_NONE, "c-electric-obrace", do_c_electric, '{')
     CMD1( '}', KEY_NONE, "c-electric-cbrace", do_c_electric, '}')
+#endif
     CMD_DEF_END,
 };
 
diff -u -r -N qemacs-0.3/dired.c qemacs-0.3-mjn3/dired.c
--- qemacs-0.3/dired.c  2003-02-02 14:07:45.000000000 -0600
+++ qemacs-0.3-mjn3/dired.c     2003-02-23 14:36:03.000000000 -0600
@@ -230,7 +230,18 @@
     b = e->b;
     if ((b->flags & BF_PREVIEW) && !b->modified) {
         switch_to_buffer(e, NULL);
-        eb_free(b);
+       {
+           /* Before freeing buffer, make sure it isn't used by another window.
+            * This could happen if we split the view window and continue 
browsing. */
+           EditState *e1;
+           for(e1 = qe_state.first_window; e1 != NULL; e1 = e1->next_window) {
+               if (e1 != s && e1->b == b)
+                   break;
+           }
+           if (!e1) {
+               eb_free(b);
+           }
+       }
     }
 
     get_dired_filename(s, filename, sizeof(filename), 
diff -u -r -N qemacs-0.3/libqhtml/Makefile qemacs-0.3-mjn3/libqhtml/Makefile
--- qemacs-0.3/libqhtml/Makefile        2003-02-02 14:07:45.000000000 -0600
+++ qemacs-0.3-mjn3/libqhtml/Makefile   2003-02-23 14:30:10.000000000 -0600
@@ -21,7 +21,7 @@
        $(AR) rc $@ $(OBJS)
 
 clean:
-       rm -f *~ *.o *.a
+       rm -f *~ *.o *.a csstoqe html_style.c docbook_style.c
 
 #
 # build default style sheet file
diff -u -r -N qemacs-0.3/qe.c qemacs-0.3-mjn3/qe.c
--- qemacs-0.3/qe.c     2003-02-02 14:07:45.000000000 -0600
+++ qemacs-0.3-mjn3/qe.c        2003-02-23 14:34:34.000000000 -0600
@@ -2196,6 +2196,12 @@
     if (s->nb_fragments >= MAX_SCREEN_WIDTH) 
         goto the_end;
 
+    if (s->nb_fragments == 0) {
+       /* Make sure these are initialed.  Bug detected using valgrind. */
+        s->last_word_space = s->last_space;
+        s->word_index = s->nb_fragments;
+    }
+
     /* update word start index if needed */
     if (s->nb_fragments >= 1 && s->last_word_space != s->last_space) {
         s->last_word_space = s->last_space;
@@ -4245,6 +4251,10 @@
             minibuffer_edit(NULL, buf, NULL, NULL,
                             kill_buffer_confirm_cb, b);
         } else {
+           if (s->flags & WF_POPUP) {  /* ugh... popups are special */
+               do_less_quit(s);
+               return;
+           }
             kill_buffer_noconfirm(b);
         }
     }
@@ -5258,6 +5268,11 @@
     int count, x1, y1, x2, y2;
     int ex1, ey1, ex2, ey2;
 
+    if (s->flags & WF_POPUP) { /* ugh... popups are special */
+       do_less_quit(s);
+       return;
+    }
+
     count = 0;
     for(e = qs->first_window; e != NULL; e = e->next_window) {
         if (!e->minibuf)
@@ -5298,7 +5313,11 @@
                 break;
             }
         }
-        compute_client_area(e);        
+       /* This test may no longer be necessary, with the various popup checks
+        * in place. */
+       if (e) {
+           compute_client_area(e);
+       }
         edit_close(s);
         do_refresh(qs->first_window);
     }
@@ -5310,6 +5329,10 @@
     QEmacsState *qs = s->qe_state;
     EditState *e, *e1;
     
+    if (s->flags & WF_POPUP) { /* ugh... popups are special */
+       return;
+    }
+
     for(e = qs->first_window; e != NULL; e = e1) {
         e1 = e->next_window;
         if (!e->minibuf && e != s)
@@ -5331,8 +5354,8 @@
     EditState *e;
     int x, y;
 
-    /* cannot split minibuf */
-    if (s->minibuf)
+    /* cannot split minibuf or popups */
+    if (s->minibuf || (s->flags & WF_POPUP))
         return;
             
     if (horiz) {
@@ -5422,7 +5445,6 @@
     b->flags |= BF_READONLY;
     if (show) {
         show_popup(b);
-        eb_free(b);
     }
 }
 
diff -u -r -N qemacs-0.3/tty.c qemacs-0.3-mjn3/tty.c
--- qemacs-0.3/tty.c    2003-02-02 14:07:45.000000000 -0600
+++ qemacs-0.3-mjn3/tty.c       2003-02-23 14:05:18.000000000 -0600
@@ -101,8 +101,11 @@
     tcsetattr (0, TCSANOW, &tty);
 
     /* test UTF8 support by looking at the cursor position (idea from
-       Ricardas Cepas <address@hidden>) */
-    printf ("\030\032" "\r\xEF\x81\x81" "\033[6n\033D");
+       Ricardas Cepas <address@hidden>). */
+    /* Since uClibc actually tests to ensure that the format string is
+     * a valid multibyte sequence in the current locale (ANSI/ISO C99),
+     * use a format specifer of %s to avoid printf() failing with EILSEQ. */
+    printf ("%s", "\030\032" "\r\xEF\x81\x81" "\033[6n\033D");
     scanf ("\033[%u;%u", &y, &x);/* get cursor position */
     printf("\033[1F" "\033[%uX", (x-1)); /* go back; erase 1 or 3 char */
     s->charset = &charset_8859_1;
@@ -118,6 +121,12 @@
     sigaction(SIGWINCH, &sig, NULL);
     fcntl(0, F_SETFL, O_NONBLOCK);
 
+    /* If stdout is to a pty, make sure we aren't in nonblocking mode.
+     * Otherwise, the printf()s in term_flush() can fail with EAGAIN,
+     * causing repaint errors when running in an xterm or in a screen
+     * session. */
+    fcntl(1, F_SETFL, 0);
+
     set_read_handler(0, tty_read_handler, s);
 
     tty_resize(0);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]