aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2012-09-17 23:11:34 +0300
committerEli Zaretskii2012-09-17 23:11:34 +0300
commitc8b9f1bcbf98ba65fd8a311befd9df99cd143875 (patch)
tree6e0d206d4fee6b11effeccca803439f000f61bf5 /src
parent51eed9b88f82fed4dff2ced44852fe0fd4851233 (diff)
downloademacs-c8b9f1bcbf98ba65fd8a311befd9df99cd143875.tar.gz
emacs-c8b9f1bcbf98ba65fd8a311befd9df99cd143875.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog4
-rw-r--r--src/search.c24
2 files changed, 20 insertions, 8 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 36df05c25ae..6c3041105f5 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,9 @@
12012-09-17 Eli Zaretskii <eliz@gnu.org> 12012-09-17 Eli Zaretskii <eliz@gnu.org>
2 2
3 * search.c (scan_buffer): Use character positions in calls to
4 region_cache_forward and region_cache_backward, not byte
5 positions. (Bug#12196)
6
3 * w32term.c (w32_read_socket): Set pending_signals to 1, like 7 * w32term.c (w32_read_socket): Set pending_signals to 1, like
4 xterm.c does. Reported by Daniel Colascione <dancol@dancol.org>. 8 xterm.c does. Reported by Daniel Colascione <dancol@dancol.org>.
5 9
diff --git a/src/search.c b/src/search.c
index 99fd7971e4c..1735ade5d8a 100644
--- a/src/search.c
+++ b/src/search.c
@@ -674,7 +674,7 @@ scan_buffer (register int target, ptrdiff_t start, ptrdiff_t end,
674 obstacle --- the last character the dumb search loop should 674 obstacle --- the last character the dumb search loop should
675 examine. */ 675 examine. */
676 ptrdiff_t ceiling_byte = CHAR_TO_BYTE (end) - 1; 676 ptrdiff_t ceiling_byte = CHAR_TO_BYTE (end) - 1;
677 ptrdiff_t start_byte = CHAR_TO_BYTE (start); 677 ptrdiff_t start_byte;
678 ptrdiff_t tem; 678 ptrdiff_t tem;
679 679
680 /* If we're looking for a newline, consult the newline cache 680 /* If we're looking for a newline, consult the newline cache
@@ -684,18 +684,22 @@ scan_buffer (register int target, ptrdiff_t start, ptrdiff_t end,
684 ptrdiff_t next_change; 684 ptrdiff_t next_change;
685 immediate_quit = 0; 685 immediate_quit = 0;
686 while (region_cache_forward 686 while (region_cache_forward
687 (current_buffer, newline_cache, start_byte, &next_change)) 687 (current_buffer, newline_cache, start, &next_change))
688 start_byte = next_change; 688 start = next_change;
689 immediate_quit = allow_quit; 689 immediate_quit = allow_quit;
690 690
691 start_byte = CHAR_TO_BYTE (start);
692
691 /* START should never be after END. */ 693 /* START should never be after END. */
692 if (start_byte > ceiling_byte) 694 if (start_byte > ceiling_byte)
693 start_byte = ceiling_byte; 695 start_byte = ceiling_byte;
694 696
695 /* Now the text after start is an unknown region, and 697 /* Now the text after start is an unknown region, and
696 next_change is the position of the next known region. */ 698 next_change is the position of the next known region. */
697 ceiling_byte = min (next_change - 1, ceiling_byte); 699 ceiling_byte = min (CHAR_TO_BYTE (next_change) - 1, ceiling_byte);
698 } 700 }
701 else
702 start_byte = CHAR_TO_BYTE (start);
699 703
700 /* The dumb loop can only scan text stored in contiguous 704 /* The dumb loop can only scan text stored in contiguous
701 bytes. BUFFER_CEILING_OF returns the last character 705 bytes. BUFFER_CEILING_OF returns the last character
@@ -747,7 +751,7 @@ scan_buffer (register int target, ptrdiff_t start, ptrdiff_t end,
747 { 751 {
748 /* The last character to check before the next obstacle. */ 752 /* The last character to check before the next obstacle. */
749 ptrdiff_t ceiling_byte = CHAR_TO_BYTE (end); 753 ptrdiff_t ceiling_byte = CHAR_TO_BYTE (end);
750 ptrdiff_t start_byte = CHAR_TO_BYTE (start); 754 ptrdiff_t start_byte;
751 ptrdiff_t tem; 755 ptrdiff_t tem;
752 756
753 /* Consult the newline cache, if appropriate. */ 757 /* Consult the newline cache, if appropriate. */
@@ -756,18 +760,22 @@ scan_buffer (register int target, ptrdiff_t start, ptrdiff_t end,
756 ptrdiff_t next_change; 760 ptrdiff_t next_change;
757 immediate_quit = 0; 761 immediate_quit = 0;
758 while (region_cache_backward 762 while (region_cache_backward
759 (current_buffer, newline_cache, start_byte, &next_change)) 763 (current_buffer, newline_cache, start, &next_change))
760 start_byte = next_change; 764 start = next_change;
761 immediate_quit = allow_quit; 765 immediate_quit = allow_quit;
762 766
767 start_byte = CHAR_TO_BYTE (start);
768
763 /* Start should never be at or before end. */ 769 /* Start should never be at or before end. */
764 if (start_byte <= ceiling_byte) 770 if (start_byte <= ceiling_byte)
765 start_byte = ceiling_byte + 1; 771 start_byte = ceiling_byte + 1;
766 772
767 /* Now the text before start is an unknown region, and 773 /* Now the text before start is an unknown region, and
768 next_change is the position of the next known region. */ 774 next_change is the position of the next known region. */
769 ceiling_byte = max (next_change, ceiling_byte); 775 ceiling_byte = max (CHAR_TO_BYTE (next_change), ceiling_byte);
770 } 776 }
777 else
778 start_byte = CHAR_TO_BYTE (start);
771 779
772 /* Stop scanning before the gap. */ 780 /* Stop scanning before the gap. */
773 tem = BUFFER_FLOOR_OF (start_byte - 1); 781 tem = BUFFER_FLOOR_OF (start_byte - 1);