aboutsummaryrefslogtreecommitdiffstats
path: root/src/regex.c
diff options
context:
space:
mode:
authorPaul Eggert2016-11-04 15:01:17 -0700
committerPaul Eggert2016-11-04 15:01:17 -0700
commit6a20bd3579ef87103d5ea37e6b8193dc6385e547 (patch)
treee11a49c3cbb7e72ccfb6689fbad81bcccfd12665 /src/regex.c
parent29559361f56c9398dcb69db7396dcfc0887843a2 (diff)
parentdbb341022870ecad4c9177485a6770a355633cc0 (diff)
downloademacs-6a20bd3579ef87103d5ea37e6b8193dc6385e547.tar.gz
emacs-6a20bd3579ef87103d5ea37e6b8193dc6385e547.zip
Merge from origin/emacs-25
dbb3410 python.el: Fix detection of native completion in Python 3 (bu... 91c97b6 * Makefile.in (install-arch-indep): Skip etc/refcards/emacsve... 9c1cb8d * lisp/subr.el (set-transient-map): Exit for unbound events (... 9c247d2 Update category-table for Chinese characters 43986d1 Inhibit buffer relocation during regex searches fee4cef Revert fixes to allocation of regex matching
Diffstat (limited to 'src/regex.c')
-rw-r--r--src/regex.c73
1 files changed, 0 insertions, 73 deletions
diff --git a/src/regex.c b/src/regex.c
index 8d769cc6c82..1c6c9e5c18b 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -1365,62 +1365,11 @@ typedef struct
1365#define NEXT_FAILURE_HANDLE(h) fail_stack.stack[(h) - 3].integer 1365#define NEXT_FAILURE_HANDLE(h) fail_stack.stack[(h) - 3].integer
1366#define TOP_FAILURE_HANDLE() fail_stack.frame 1366#define TOP_FAILURE_HANDLE() fail_stack.frame
1367 1367
1368#ifdef emacs
1369# define STR_BASE_PTR(obj) \
1370 (NILP (obj) ? current_buffer->text->beg \
1371 : STRINGP (obj) ? SDATA (obj) \
1372 : NULL)
1373#else
1374# define STR_BASE_PTR(obj) NULL
1375#endif
1376 1368
1377#define ENSURE_FAIL_STACK(space) \ 1369#define ENSURE_FAIL_STACK(space) \
1378while (REMAINING_AVAIL_SLOTS <= space) { \ 1370while (REMAINING_AVAIL_SLOTS <= space) { \
1379 re_char *orig_base = STR_BASE_PTR (re_match_object); \
1380 bool might_relocate = orig_base != NULL; \
1381 ptrdiff_t string1_off, end1_off, end_match_1_off; \
1382 ptrdiff_t string2_off, end2_off, end_match_2_off; \
1383 ptrdiff_t d_off, dend_off, dfail_off; \
1384 if (might_relocate) \
1385 { \
1386 if (string1) \
1387 { \
1388 string1_off = string1 - orig_base; \
1389 end1_off = end1 - orig_base; \
1390 end_match_1_off = end_match_1 - orig_base; \
1391 } \
1392 if (string2) \
1393 { \
1394 string2_off = string2 - orig_base; \
1395 end2_off = end2 - orig_base; \
1396 end_match_2_off = end_match_2 - orig_base; \
1397 } \
1398 d_off = d - orig_base; \
1399 dend_off = dend - orig_base; \
1400 dfail_off = dfail - orig_base; \
1401 } \
1402 if (!GROW_FAIL_STACK (fail_stack)) \ 1371 if (!GROW_FAIL_STACK (fail_stack)) \
1403 return -2; \ 1372 return -2; \
1404 /* In Emacs, GROW_FAIL_STACK might relocate string pointers. */ \
1405 if (might_relocate) \
1406 { \
1407 re_char *new_base = STR_BASE_PTR (re_match_object); \
1408 if (string1) \
1409 { \
1410 string1 = new_base + string1_off; \
1411 end1 = new_base + end1_off; \
1412 end_match_1 = new_base + end_match_1_off; \
1413 } \
1414 if (string2) \
1415 { \
1416 string2 = new_base + string2_off; \
1417 end2 = new_base + end2_off; \
1418 end_match_2 = new_base + end_match_2_off; \
1419 } \
1420 d = new_base + d_off; \
1421 dend = new_base + dend_off; \
1422 dfail = new_base + dfail_off; \
1423 } \
1424 DEBUG_PRINT ("\n Doubled stack; size now: %zd\n", (fail_stack).size);\ 1373 DEBUG_PRINT ("\n Doubled stack; size now: %zd\n", (fail_stack).size);\
1425 DEBUG_PRINT (" slots available: %zd\n", REMAINING_AVAIL_SLOTS);\ 1374 DEBUG_PRINT (" slots available: %zd\n", REMAINING_AVAIL_SLOTS);\
1426} 1375}
@@ -4346,11 +4295,6 @@ re_search_2 (struct re_pattern_buffer *bufp, const char *str1, size_t size1,
4346 /* Loop through the string, looking for a place to start matching. */ 4295 /* Loop through the string, looking for a place to start matching. */
4347 for (;;) 4296 for (;;)
4348 { 4297 {
4349 ptrdiff_t offset1;
4350 ptrdiff_t offset2 UNINIT; /* The UNINIT works around GCC bug 78081. */
4351 re_char *orig_base;
4352 bool might_relocate;
4353
4354 /* If the pattern is anchored, 4298 /* If the pattern is anchored,
4355 skip quickly past places we cannot match. 4299 skip quickly past places we cannot match.
4356 We don't bother to treat startpos == 0 specially 4300 We don't bother to treat startpos == 0 specially
@@ -4467,16 +4411,6 @@ re_search_2 (struct re_pattern_buffer *bufp, const char *str1, size_t size1,
4467 && !bufp->can_be_null) 4411 && !bufp->can_be_null)
4468 return -1; 4412 return -1;
4469 4413
4470 /* re_match_2_internal may allocate, relocating the Lisp text
4471 object that we're searching. */
4472 orig_base = STR_BASE_PTR (re_match_object);
4473 might_relocate = orig_base != NULL;
4474 if (might_relocate)
4475 {
4476 if (string1) offset1 = string1 - orig_base;
4477 if (string2) offset2 = string2 - orig_base;
4478 }
4479
4480 val = re_match_2_internal (bufp, string1, size1, string2, size2, 4414 val = re_match_2_internal (bufp, string1, size1, string2, size2,
4481 startpos, regs, stop); 4415 startpos, regs, stop);
4482 4416
@@ -4486,13 +4420,6 @@ re_search_2 (struct re_pattern_buffer *bufp, const char *str1, size_t size1,
4486 if (val == -2) 4420 if (val == -2)
4487 return -2; 4421 return -2;
4488 4422
4489 if (might_relocate)
4490 {
4491 re_char *new_base = STR_BASE_PTR (re_match_object);
4492 if (string1) string1 = offset1 + new_base;
4493 if (string2) string2 = offset2 + new_base;
4494 }
4495
4496 advance: 4423 advance:
4497 if (!range) 4424 if (!range)
4498 break; 4425 break;