The attached patch makes the search function interruptible by Ctrl-C.

It also removes redundant got_interrupt() calls before
enable_interrupt_key(), as enable_interrupt_key() takes care of clearing
the interrupt flag itself. Furthermore, this feature makes search
virtually uninterruptible, because the flags gets constantly cleared and
the ocassional got_interrupt() check has no chance to catch the
keypress. After removing the disable/enable pair in the middle of the
loop, it works fine. I am not sure it it doesn't interfere with
get_byte() stuff which can do some I/O, but block_search doesn't disable
the interrupts during I/O either.

If you still want to use the approach with temporary disabled
interrupts, please at least move the check right before
enable_interrupt_key(), where it has some sense - it doesn't work 100%,
but it is at least possible to stop the search after a while of Ctrl-C
bashing.

Best regards,
-- 
Jindrich Makovicka
Index: view.c
===================================================================
RCS file: /cvsroot/mc/mc/src/view.c,v
retrieving revision 1.314
diff -u -r1.314 view.c
--- view.c      6 Aug 2005 18:19:14 -0000       1.314
+++ view.c      14 Aug 2005 17:03:04 -0000
@@ -2225,8 +2225,6 @@
     offset_type forward_line_start;
     offset_type reverse_line_start;
     offset_type t;
-    /* Clear interrupt status */
-    got_interrupt ();
 
     if (verbose) {
        d = create_message (D_NORMAL, _("Search"), _("Searching %s"), text);
@@ -2247,6 +2245,7 @@
     search_update_steps (view);
     view->update_activate = 0;
 
+    enable_interrupt_key ();
     for (;; g_free (s)) {
        if (p >= view->update_activate) {
            view->update_activate += view->update_steps;
@@ -2258,10 +2257,8 @@
                break;
        }
        forward_line_start = p;
-       disable_interrupt_key ();
        s = get_line_at (view, &p, &t);
        reverse_line_start = p;
-       enable_interrupt_key ();
 
        if (!s)
            break;
@@ -2321,8 +2318,6 @@
     char b;
     offset_type e;
 
-    /* clear interrupt status */
-    got_interrupt ();
     enable_interrupt_key ();
     if (direction == 1)
        e = view->search_start + ((view->found_len) ? 1 : 0);
_______________________________________________
Mc-devel mailing list
http://mail.gnome.org/mailman/listinfo/mc-devel

Reply via email to