Mercurial > emacs
comparison src/regex.c @ 22372:ffea5f2dd01b
(POS_AS_IN_BUFFER): Add 1 only if operating on a buffer.
(re_match_2, re_search_2): Adjust startpos or pos by 1
only if acting on a buffer.
nil for re_match_object means a buffer.
(re_match_2_internal <notwordbeg>): Assume POS1 is positive.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 06 Jun 1998 21:59:21 +0000 |
parents | 566c88b62de6 |
children | 6e7a11ac850d |
comparison
equal
deleted
inserted
replaced
22371:f3cf0507c362 | 22372:ffea5f2dd01b |
---|---|
29 | 29 |
30 /* Converts the pointer to the char to BEG-based offset from the start. */ | 30 /* Converts the pointer to the char to BEG-based offset from the start. */ |
31 #define PTR_TO_OFFSET(d) \ | 31 #define PTR_TO_OFFSET(d) \ |
32 POS_AS_IN_BUFFER (MATCHING_IN_FIRST_STRING \ | 32 POS_AS_IN_BUFFER (MATCHING_IN_FIRST_STRING \ |
33 ? (d) - string1 : (d) - (string2 - size1)) | 33 ? (d) - string1 : (d) - (string2 - size1)) |
34 #define POS_AS_IN_BUFFER(p) ((p) + 1) | 34 #define POS_AS_IN_BUFFER(p) ((p) + (NILP (re_match_object) || BUFFERP (re_match_object))) |
35 | 35 |
36 #ifdef HAVE_CONFIG_H | 36 #ifdef HAVE_CONFIG_H |
37 #include <config.h> | 37 #include <config.h> |
38 #endif | 38 #endif |
39 | 39 |
3740 anchored_start = 1; | 3740 anchored_start = 1; |
3741 | 3741 |
3742 #ifdef emacs | 3742 #ifdef emacs |
3743 gl_state.object = re_match_object; | 3743 gl_state.object = re_match_object; |
3744 { | 3744 { |
3745 int charpos | 3745 int adjpos = NILP (re_match_object) || BUFFERP (re_match_object); |
3746 = SYNTAX_TABLE_BYTE_TO_CHAR (startpos > 0 ? startpos : startpos + 1); | 3746 int charpos = SYNTAX_TABLE_BYTE_TO_CHAR (startpos + adjpos); |
3747 | 3747 |
3748 SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, charpos, 1); | 3748 SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, charpos, 1); |
3749 } | 3749 } |
3750 #endif | 3750 #endif |
3751 | 3751 |
4061 { | 4061 { |
4062 int result; | 4062 int result; |
4063 | 4063 |
4064 #ifdef emacs | 4064 #ifdef emacs |
4065 int charpos; | 4065 int charpos; |
4066 int adjpos = NILP (re_match_object) || BUFFERP (re_match_object); | |
4066 gl_state.object = re_match_object; | 4067 gl_state.object = re_match_object; |
4067 charpos = SYNTAX_TABLE_BYTE_TO_CHAR (POS_AS_IN_BUFFER (pos)); | 4068 charpos = SYNTAX_TABLE_BYTE_TO_CHAR (pos + adjpos); |
4068 SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, charpos, 1); | 4069 SETUP_SYNTAX_TABLE_FOR_OBJECT (re_match_object, charpos, 1); |
4069 #endif | 4070 #endif |
4070 | 4071 |
4071 result = re_match_2_internal (bufp, string1, size1, string2, size2, | 4072 result = re_match_2_internal (bufp, string1, size1, string2, size2, |
4072 pos, regs, stop); | 4073 pos, regs, stop); |
5356 int charpos; | 5357 int charpos; |
5357 | 5358 |
5358 GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2); | 5359 GET_CHAR_BEFORE_2 (c1, d, string1, end1, string2, end2); |
5359 GET_CHAR_AFTER_2 (c2, d, string1, end1, string2, end2); | 5360 GET_CHAR_AFTER_2 (c2, d, string1, end1, string2, end2); |
5360 #ifdef emacs | 5361 #ifdef emacs |
5361 charpos = SYNTAX_TABLE_BYTE_TO_CHAR (pos1 ? pos1 : 1); | 5362 charpos = SYNTAX_TABLE_BYTE_TO_CHAR (pos1); |
5362 UPDATE_SYNTAX_TABLE (charpos); | 5363 UPDATE_SYNTAX_TABLE (charpos); |
5363 #endif | 5364 #endif |
5364 s1 = SYNTAX (c1); | 5365 s1 = SYNTAX (c1); |
5365 #ifdef emacs | 5366 #ifdef emacs |
5366 UPDATE_SYNTAX_TABLE_FORWARD (charpos + 1); | 5367 UPDATE_SYNTAX_TABLE_FORWARD (charpos + 1); |