emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r110079: Fix bug #12196 with infloop


From: Eli Zaretskii
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r110079: Fix bug #12196 with infloop when cache-long-line-scans is non-nil.
Date: Mon, 17 Sep 2012 23:11:34 +0300
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 110079
fixes bug: http://debbugs.gnu.org/12196
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Mon 2012-09-17 23:11:34 +0300
message:
  Fix bug #12196 with infloop when cache-long-line-scans is non-nil.
  
   src/search.c (scan_buffer): Use character positions in calls to
   region_cache_forward and region_cache_backward, not byte
   positions.
modified:
  src/ChangeLog
  src/search.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-09-17 07:56:20 +0000
+++ b/src/ChangeLog     2012-09-17 20:11:34 +0000
@@ -1,5 +1,9 @@
 2012-09-17  Eli Zaretskii  <address@hidden>
 
+       * search.c (scan_buffer): Use character positions in calls to
+       region_cache_forward and region_cache_backward, not byte
+       positions.  (Bug#12196)
+
        * w32term.c (w32_read_socket): Set pending_signals to 1, like
        xterm.c does.  Reported by Daniel Colascione <address@hidden>.
 

=== modified file 'src/search.c'
--- a/src/search.c      2012-09-15 07:06:56 +0000
+++ b/src/search.c      2012-09-17 20:11:34 +0000
@@ -674,7 +674,7 @@
            obstacle --- the last character the dumb search loop should
            examine.  */
        ptrdiff_t ceiling_byte = CHAR_TO_BYTE (end) - 1;
-       ptrdiff_t start_byte = CHAR_TO_BYTE (start);
+       ptrdiff_t start_byte;
        ptrdiff_t tem;
 
         /* If we're looking for a newline, consult the newline cache
@@ -684,18 +684,22 @@
             ptrdiff_t next_change;
             immediate_quit = 0;
             while (region_cache_forward
-                   (current_buffer, newline_cache, start_byte, &next_change))
-              start_byte = next_change;
+                   (current_buffer, newline_cache, start, &next_change))
+              start = next_change;
             immediate_quit = allow_quit;
 
+           start_byte = CHAR_TO_BYTE (start);
+
             /* START should never be after END.  */
             if (start_byte > ceiling_byte)
               start_byte = ceiling_byte;
 
             /* Now the text after start is an unknown region, and
                next_change is the position of the next known region. */
-            ceiling_byte = min (next_change - 1, ceiling_byte);
+            ceiling_byte = min (CHAR_TO_BYTE (next_change) - 1, ceiling_byte);
           }
+       else
+         start_byte = CHAR_TO_BYTE (start);
 
         /* The dumb loop can only scan text stored in contiguous
            bytes. BUFFER_CEILING_OF returns the last character
@@ -747,7 +751,7 @@
       {
         /* The last character to check before the next obstacle.  */
        ptrdiff_t ceiling_byte = CHAR_TO_BYTE (end);
-       ptrdiff_t start_byte = CHAR_TO_BYTE (start);
+       ptrdiff_t start_byte;
        ptrdiff_t tem;
 
         /* Consult the newline cache, if appropriate.  */
@@ -756,18 +760,22 @@
             ptrdiff_t next_change;
             immediate_quit = 0;
             while (region_cache_backward
-                   (current_buffer, newline_cache, start_byte, &next_change))
-              start_byte = next_change;
+                   (current_buffer, newline_cache, start, &next_change))
+              start = next_change;
             immediate_quit = allow_quit;
 
+           start_byte = CHAR_TO_BYTE (start);
+
             /* Start should never be at or before end.  */
             if (start_byte <= ceiling_byte)
               start_byte = ceiling_byte + 1;
 
             /* Now the text before start is an unknown region, and
                next_change is the position of the next known region. */
-            ceiling_byte = max (next_change, ceiling_byte);
+            ceiling_byte = max (CHAR_TO_BYTE (next_change), ceiling_byte);
           }
+       else
+         start_byte = CHAR_TO_BYTE (start);
 
         /* Stop scanning before the gap.  */
        tem = BUFFER_FLOOR_OF (start_byte - 1);


reply via email to

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