aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1998-05-15 22:23:01 +0000
committerRichard M. Stallman1998-05-15 22:23:01 +0000
commita7e4cdde61563635ab504a881ed12cd99f1d3277 (patch)
tree0034a4b15c1ac2af1994e8248fde5db2da991cec /src
parent8332fa80b6fc27d93719218a7cdbf71ea9533b8a (diff)
downloademacs-a7e4cdde61563635ab504a881ed12cd99f1d3277.tar.gz
emacs-a7e4cdde61563635ab504a881ed12cd99f1d3277.zip
(search_buffer): Set search regs for all success with an empty string.
(set_search_regs): Clear out all regs except 0.
Diffstat (limited to 'src')
-rw-r--r--src/search.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/search.c b/src/search.c
index 3ee17bf3abc..175ae8a3f65 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1005,17 +1005,14 @@ search_buffer (string, pos, pos_byte, lim, lim_byte, n,
1005 if (running_asynch_code) 1005 if (running_asynch_code)
1006 save_search_regs (); 1006 save_search_regs ();
1007 1007
1008 /* Searching 0 times means don't move. */
1008 /* Null string is found at starting position. */ 1009 /* Null string is found at starting position. */
1009 if (len == 0) 1010 if (len == 0 || n == 0)
1010 { 1011 {
1011 set_search_regs (pos, 0); 1012 set_search_regs (pos, 0);
1012 return pos; 1013 return pos;
1013 } 1014 }
1014 1015
1015 /* Searching 0 times means don't move. */
1016 if (n == 0)
1017 return pos;
1018
1019 if (RE && !trivial_regexp_p (string)) 1016 if (RE && !trivial_regexp_p (string))
1020 { 1017 {
1021 unsigned char *p1, *p2; 1018 unsigned char *p1, *p2;
@@ -1896,12 +1893,15 @@ boyer_moore (n, base_pat, len, len_byte, trt, inverse_trt,
1896} 1893}
1897 1894
1898/* Record beginning BEG_BYTE and end BEG_BYTE + NBYTES 1895/* Record beginning BEG_BYTE and end BEG_BYTE + NBYTES
1899 for a match just found in the current buffer. */ 1896 for the overall match just found in the current buffer.
1897 Also clear out the match data for registers 1 and up. */
1900 1898
1901static void 1899static void
1902set_search_regs (beg_byte, nbytes) 1900set_search_regs (beg_byte, nbytes)
1903 int beg_byte, nbytes; 1901 int beg_byte, nbytes;
1904{ 1902{
1903 int i;
1904
1905 /* Make sure we have registers in which to store 1905 /* Make sure we have registers in which to store
1906 the match position. */ 1906 the match position. */
1907 if (search_regs.num_regs == 0) 1907 if (search_regs.num_regs == 0)
@@ -1911,6 +1911,13 @@ set_search_regs (beg_byte, nbytes)
1911 search_regs.num_regs = 2; 1911 search_regs.num_regs = 2;
1912 } 1912 }
1913 1913
1914 /* Clear out the other registers. */
1915 for (i = 1; i < search_regs.num_regs; i++)
1916 {
1917 search_regs.start[i] = -1;
1918 search_regs.end[i] = -1;
1919 }
1920
1914 search_regs.start[0] = BYTE_TO_CHAR (beg_byte); 1921 search_regs.start[0] = BYTE_TO_CHAR (beg_byte);
1915 search_regs.end[0] = BYTE_TO_CHAR (beg_byte + nbytes); 1922 search_regs.end[0] = BYTE_TO_CHAR (beg_byte + nbytes);
1916 XSETBUFFER (last_thing_searched, current_buffer); 1923 XSETBUFFER (last_thing_searched, current_buffer);