summaryrefslogtreecommitdiff
path: root/src/search.c
diff options
context:
space:
mode:
authorNoam Postavsky <npostavs@gmail.com>2016-10-24 19:54:29 -0400
committerNoam Postavsky <npostavs@gmail.com>2016-10-25 20:15:33 -0400
commitfee4cef7d720e98922858e19b3161358041ec141 (patch)
tree191cdafd145e0ff5e403b95080f7baaeefbd170c /src/search.c
parent4c3f7387df339176a94f49895c92fa6a5f526bae (diff)
downloademacs-fee4cef7d720e98922858e19b3161358041ec141.tar.gz
emacs-fee4cef7d720e98922858e19b3161358041ec141.tar.bz2
emacs-fee4cef7d720e98922858e19b3161358041ec141.zip
Revert fixes to allocation of regex matching
The fix was not complete, and completing it was proving too complicated. - Revert "* src/regex.c (re_search_2): Make new code safe for -Wjump-misses-init." This reverts commit c2a17924a57483d14692c8913edbe8ad24b5ffbb. - Revert "Port to GCC 6.2.1 + --enable-gcc-warnings" This reverts commit f6134bbda259c115c06d4a9a3ab5c39340a15949. - Revert "Fix handling of allocation in regex matching" This reverts commit ad66b3fadb7ae22a4cbb82bb1507c39ceadf3897. - Revert "Fix handling of buffer relocation in regex.c functions" This reverts commit ee04aedc723b035eedaf975422d4eb242894121b.
Diffstat (limited to 'src/search.c')
-rw-r--r--src/search.c40
1 files changed, 12 insertions, 28 deletions
diff --git a/src/search.c b/src/search.c
index b50e7f032d5..fa5ac44de9d 100644
--- a/src/search.c
+++ b/src/search.c
@@ -287,10 +287,8 @@ looking_at_1 (Lisp_Object string, bool posix)
immediate_quit = 1;
QUIT; /* Do a pending quit right away, to avoid paradoxical behavior */
- /* Get pointers and sizes of the two strings that make up the
- visible portion of the buffer. Note that we can use pointers
- here, unlike in search_buffer, because we only call re_match_2
- once, after which we never use the pointers again. */
+ /* Get pointers and sizes of the two strings
+ that make up the visible portion of the buffer. */
p1 = BEGV_ADDR;
s1 = GPT_BYTE - BEGV_BYTE;
@@ -409,7 +407,6 @@ string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start,
(NILP (Vinhibit_changing_match_data)
? &search_regs : NULL));
immediate_quit = 0;
- re_match_object = Qnil; /* Stop protecting string from GC. */
/* Set last_thing_searched only when match data is changed. */
if (NILP (Vinhibit_changing_match_data))
@@ -480,7 +477,6 @@ fast_string_match_internal (Lisp_Object regexp, Lisp_Object string,
SBYTES (string), 0,
SBYTES (string), 0);
immediate_quit = 0;
- re_match_object = Qnil; /* Stop protecting string from GC. */
return val;
}
@@ -568,7 +564,6 @@ fast_looking_at (Lisp_Object regexp, ptrdiff_t pos, ptrdiff_t pos_byte,
len = re_match_2 (buf, (char *) p1, s1, (char *) p2, s2,
pos_byte, NULL, limit_byte);
immediate_quit = 0;
- re_match_object = Qnil; /* Stop protecting string from GC. */
return len;
}
@@ -1183,8 +1178,8 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
if (RE && !(trivial_regexp_p (string) && NILP (Vsearch_spaces_regexp)))
{
- unsigned char *base;
- ptrdiff_t off1, off2, s1, s2;
+ unsigned char *p1, *p2;
+ ptrdiff_t s1, s2;
struct re_pattern_buffer *bufp;
bufp = compile_pattern (string,
@@ -1198,19 +1193,16 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
can take too long. */
QUIT; /* Do a pending quit right away,
to avoid paradoxical behavior */
- /* Get offsets and sizes of the two strings that make up the
- visible portion of the buffer. We compute offsets instead of
- pointers because re_search_2 may call malloc and therefore
- change the buffer text address. */
+ /* Get pointers and sizes of the two strings
+ that make up the visible portion of the buffer. */
- base = current_buffer->text->beg;
- off1 = BEGV_ADDR - base;
+ p1 = BEGV_ADDR;
s1 = GPT_BYTE - BEGV_BYTE;
- off2 = GAP_END_ADDR - base;
+ p2 = GAP_END_ADDR;
s2 = ZV_BYTE - GPT_BYTE;
if (s1 < 0)
{
- off2 = off1;
+ p2 = p1;
s2 = ZV_BYTE - BEGV_BYTE;
s1 = 0;
}
@@ -1225,16 +1217,12 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
{
ptrdiff_t val;
- val = re_search_2 (bufp,
- (char*) (base + off1), s1,
- (char*) (base + off2), s2,
+ val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2,
pos_byte - BEGV_BYTE, lim_byte - pos_byte,
(NILP (Vinhibit_changing_match_data)
? &search_regs : &search_regs_1),
/* Don't allow match past current point */
pos_byte - BEGV_BYTE);
- /* Update 'base' due to possible relocation inside re_search_2. */
- base = current_buffer->text->beg;
if (val == -2)
{
matcher_overflow ();
@@ -1274,15 +1262,11 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
{
ptrdiff_t val;
- val = re_search_2 (bufp,
- (char*) (base + off1), s1,
- (char*) (base + off2), s2,
- pos_byte - BEGV_BYTE, lim_byte - pos_byte,
+ val = re_search_2 (bufp, (char *) p1, s1, (char *) p2, s2,
+ pos_byte - BEGV_BYTE, lim_byte - pos_byte,
(NILP (Vinhibit_changing_match_data)
? &search_regs : &search_regs_1),
lim_byte - BEGV_BYTE);
- /* Update 'base' due to possible relocation inside re_search_2. */
- base = current_buffer->text->beg;
if (val == -2)
{
matcher_overflow ();