aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa1998-01-28 12:37:25 +0000
committerKenichi Handa1998-01-28 12:37:25 +0000
commit4996330bfb44680cb2b10c42b6d81387fb65c993 (patch)
tree15b84019984d209e34578f4841beede097acfb15 /src
parent024bda024c737b337ed924db6d1bb6c7af7a4217 (diff)
downloademacs-4996330bfb44680cb2b10c42b6d81387fb65c993.tar.gz
emacs-4996330bfb44680cb2b10c42b6d81387fb65c993.zip
(fast_string_match): Give re_search byte size of
STRING. (trivial_regexp_p): Initialize LEN to byte size of REGEXP. (search_buffer): Give re_search_2 STARTPOS, RANGE and STOP by counting them by bytes.
Diffstat (limited to 'src')
-rw-r--r--src/search.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/search.c b/src/search.c
index 42cfa9350fc..5f5a3e60500 100644
--- a/src/search.c
+++ b/src/search.c
@@ -429,7 +429,7 @@ fast_string_match (regexp, string)
429 re_match_object = string; 429 re_match_object = string;
430 430
431 val = re_search (bufp, (char *) XSTRING (string)->data, 431 val = re_search (bufp, (char *) XSTRING (string)->data,
432 XSTRING (string)->size, 0, XSTRING (string)->size, 432 XSTRING (string)->size_byte, 0, XSTRING (string)->size_byte,
433 0); 433 0);
434 immediate_quit = 0; 434 immediate_quit = 0;
435 return val; 435 return val;
@@ -922,7 +922,7 @@ static int
922trivial_regexp_p (regexp) 922trivial_regexp_p (regexp)
923 Lisp_Object regexp; 923 Lisp_Object regexp;
924{ 924{
925 int len = XSTRING (regexp)->size; 925 int len = XSTRING (regexp)->size_byte;
926 unsigned char *s = XSTRING (regexp)->data; 926 unsigned char *s = XSTRING (regexp)->data;
927 unsigned char c; 927 unsigned char c;
928 while (--len >= 0) 928 while (--len >= 0)
@@ -1005,6 +1005,8 @@ search_buffer (string, pos, lim, n, RE, trt, inverse_trt, posix)
1005 if (RE && !trivial_regexp_p (string)) 1005 if (RE && !trivial_regexp_p (string))
1006 { 1006 {
1007 struct re_pattern_buffer *bufp; 1007 struct re_pattern_buffer *bufp;
1008 int pos_byte = CHAR_TO_BYTE (pos);
1009 int lim_byte = CHAR_TO_BYTE (lim);
1008 1010
1009 bufp = compile_pattern (string, &search_regs, trt, posix, 1011 bufp = compile_pattern (string, &search_regs, trt, posix,
1010 !NILP (current_buffer->enable_multibyte_characters)); 1012 !NILP (current_buffer->enable_multibyte_characters));
@@ -1038,9 +1040,10 @@ search_buffer (string, pos, lim, n, RE, trt, inverse_trt, posix)
1038 { 1040 {
1039 int val; 1041 int val;
1040 val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2, 1042 val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2,
1041 pos - BEGV, lim - pos, &search_regs, 1043 pos_byte - BEGV_BYTE, lim_byte - pos_byte,
1044 &search_regs,
1042 /* Don't allow match past current point */ 1045 /* Don't allow match past current point */
1043 pos - BEGV); 1046 pos_byte - BEGV_BYTE);
1044 if (val == -2) 1047 if (val == -2)
1045 { 1048 {
1046 matcher_overflow (); 1049 matcher_overflow ();
@@ -1070,8 +1073,9 @@ search_buffer (string, pos, lim, n, RE, trt, inverse_trt, posix)
1070 { 1073 {
1071 int val; 1074 int val;
1072 val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2, 1075 val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2,
1073 pos - BEGV, lim - pos, &search_regs, 1076 pos_byte - BEGV_BYTE, lim_byte - pos_byte,
1074 lim - BEGV); 1077 &search_regs,
1078 lim_byte - BEGV_BYTE);
1075 if (val == -2) 1079 if (val == -2)
1076 { 1080 {
1077 matcher_overflow (); 1081 matcher_overflow ();