summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2016-11-04 15:01:17 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2016-11-04 15:01:17 -0700
commit6a20bd3579ef87103d5ea37e6b8193dc6385e547 (patch)
treee11a49c3cbb7e72ccfb6689fbad81bcccfd12665
parent29559361f56c9398dcb69db7396dcfc0887843a2 (diff)
parentdbb341022870ecad4c9177485a6770a355633cc0 (diff)
downloademacs-6a20bd3579ef87103d5ea37e6b8193dc6385e547.tar.gz
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
-rw-r--r--Makefile.in2
-rw-r--r--lisp/international/characters.el8
-rw-r--r--lisp/progmodes/python.el2
-rw-r--r--lisp/subr.el6
-rw-r--r--src/dired.c4
-rw-r--r--src/regex.c73
-rw-r--r--src/regex.h4
-rw-r--r--src/search.c71
8 files changed, 55 insertions, 115 deletions
diff --git a/Makefile.in b/Makefile.in
index 7aac403adac..3c1f29b7e76 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -584,7 +584,7 @@ install-arch-indep: lisp install-info install-man ${INSTALL_ARCH_INDEP_EXTRA}
if [ "$${dir}" = "${srcdir}/etc" ]; then \
rm -f "$${dest}/DOC"* ; \
rm -f "$${dest}/refcards"/*.aux "$${dest}/refcards"/*.dvi; \
- rm -f "$${dest}/refcards"/*.log; \
+ rm -f "$${dest}/refcards"/*.log "$${dest}/refcards"/*.in; \
else true; \
fi; \
(cd "$${dest}" || exit 1; \
diff --git a/lisp/international/characters.el b/lisp/international/characters.el
index 2a7bc32f821..5085e637e39 100644
--- a/lisp/international/characters.el
+++ b/lisp/international/characters.el
@@ -141,10 +141,10 @@ with L, LRE, or LRO Unicode bidi character type.")
;; Chinese characters (Unicode)
(modify-category-entry '(#x2E80 . #x312F) ?|)
(modify-category-entry '(#x3190 . #x33FF) ?|)
-(modify-category-entry '(#x3400 . #x4DBF) ?C)
-(modify-category-entry '(#x4E00 . #x9FAF) ?C)
-(modify-category-entry '(#x3400 . #x9FAF) ?c)
-(modify-category-entry '(#x3400 . #x9FAF) ?|)
+(modify-category-entry '(#x3400 . #x4DB5) ?C)
+(modify-category-entry '(#x4E00 . #x9FD5) ?C)
+(modify-category-entry '(#x3400 . #x9FD5) ?c)
+(modify-category-entry '(#x3400 . #x9FD5) ?|)
(modify-category-entry '(#xF900 . #xFAFF) ?C)
(modify-category-entry '(#xF900 . #xFAFF) ?c)
(modify-category-entry '(#xF900 . #xFAFF) ?|)
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index ad69f8779e0..290cdc8120d 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -3318,7 +3318,7 @@ When a match is found, native completion is disabled."
python-shell-completion-native-try-output-timeout))
(python-shell-completion-native-get-completions
(get-buffer-process (current-buffer))
- nil "")))
+ nil "_")))
(defun python-shell-completion-native-setup ()
"Try to setup native completion, return non-nil on success."
diff --git a/lisp/subr.el b/lisp/subr.el
index fba43be9e34..fd46a818df9 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4562,8 +4562,10 @@ to deactivate this transient map, regardless of KEEP-PRED."
;; exit C-u.
t)
((eq t keep-pred)
- (eq this-command
- (lookup-key map (this-command-keys-vector))))
+ (let ((mc (lookup-key map (this-command-keys-vector))))
+ ;; If the key is unbound `this-command` is
+ ;; nil and so is `mc`.
+ (and mc (eq this-command mc))))
(t (funcall keep-pred)))
(funcall exitfun)))))
(add-hook 'pre-command-hook clearfun)
diff --git a/src/dired.c b/src/dired.c
index c69164b2a1f..e468147e8b2 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -253,11 +253,9 @@ directory_files_internal (Lisp_Object directory, Lisp_Object full,
QUIT;
bool wanted = (NILP (match)
- || (re_match_object = name,
- re_search (bufp, SSDATA (name), len, 0, len, 0) >= 0));
+ || re_search (bufp, SSDATA (name), len, 0, len, 0) >= 0);
immediate_quit = 0;
- re_match_object = Qnil; /* Stop protecting name from GC. */
if (wanted)
{
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
#define NEXT_FAILURE_HANDLE(h) fail_stack.stack[(h) - 3].integer
#define TOP_FAILURE_HANDLE() fail_stack.frame
-#ifdef emacs
-# define STR_BASE_PTR(obj) \
- (NILP (obj) ? current_buffer->text->beg \
- : STRINGP (obj) ? SDATA (obj) \
- : NULL)
-#else
-# define STR_BASE_PTR(obj) NULL
-#endif
#define ENSURE_FAIL_STACK(space) \
while (REMAINING_AVAIL_SLOTS <= space) { \
- re_char *orig_base = STR_BASE_PTR (re_match_object); \
- bool might_relocate = orig_base != NULL; \
- ptrdiff_t string1_off, end1_off, end_match_1_off; \
- ptrdiff_t string2_off, end2_off, end_match_2_off; \
- ptrdiff_t d_off, dend_off, dfail_off; \
- if (might_relocate) \
- { \
- if (string1) \
- { \
- string1_off = string1 - orig_base; \
- end1_off = end1 - orig_base; \
- end_match_1_off = end_match_1 - orig_base; \
- } \
- if (string2) \
- { \
- string2_off = string2 - orig_base; \
- end2_off = end2 - orig_base; \
- end_match_2_off = end_match_2 - orig_base; \
- } \
- d_off = d - orig_base; \
- dend_off = dend - orig_base; \
- dfail_off = dfail - orig_base; \
- } \
if (!GROW_FAIL_STACK (fail_stack)) \
return -2; \
- /* In Emacs, GROW_FAIL_STACK might relocate string pointers. */ \
- if (might_relocate) \
- { \
- re_char *new_base = STR_BASE_PTR (re_match_object); \
- if (string1) \
- { \
- string1 = new_base + string1_off; \
- end1 = new_base + end1_off; \
- end_match_1 = new_base + end_match_1_off; \
- } \
- if (string2) \
- { \
- string2 = new_base + string2_off; \
- end2 = new_base + end2_off; \
- end_match_2 = new_base + end_match_2_off; \
- } \
- d = new_base + d_off; \
- dend = new_base + dend_off; \
- dfail = new_base + dfail_off; \
- } \
DEBUG_PRINT ("\n Doubled stack; size now: %zd\n", (fail_stack).size);\
DEBUG_PRINT (" slots available: %zd\n", REMAINING_AVAIL_SLOTS);\
}
@@ -4346,11 +4295,6 @@ re_search_2 (struct re_pattern_buffer *bufp, const char *str1, size_t size1,
/* Loop through the string, looking for a place to start matching. */
for (;;)
{
- ptrdiff_t offset1;
- ptrdiff_t offset2 UNINIT; /* The UNINIT works around GCC bug 78081. */
- re_char *orig_base;
- bool might_relocate;
-
/* If the pattern is anchored,
skip quickly past places we cannot match.
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,
&& !bufp->can_be_null)
return -1;
- /* re_match_2_internal may allocate, relocating the Lisp text
- object that we're searching. */
- orig_base = STR_BASE_PTR (re_match_object);
- might_relocate = orig_base != NULL;
- if (might_relocate)
- {
- if (string1) offset1 = string1 - orig_base;
- if (string2) offset2 = string2 - orig_base;
- }
-
val = re_match_2_internal (bufp, string1, size1, string2, size2,
startpos, regs, stop);
@@ -4486,13 +4420,6 @@ re_search_2 (struct re_pattern_buffer *bufp, const char *str1, size_t size1,
if (val == -2)
return -2;
- if (might_relocate)
- {
- re_char *new_base = STR_BASE_PTR (re_match_object);
- if (string1) string1 = offset1 + new_base;
- if (string2) string2 = offset2 + new_base;
- }
-
advance:
if (!range)
break;
diff --git a/src/regex.h b/src/regex.h
index cb0796fe9cb..4922440e472 100644
--- a/src/regex.h
+++ b/src/regex.h
@@ -176,9 +176,7 @@ extern reg_syntax_t re_syntax_options;
#ifdef emacs
# include "lisp.h"
/* In Emacs, this is the string or buffer in which we are matching.
- It is used for looking up syntax properties, and also to recompute
- pointers in case the object is relocated as a side effect of
- calling malloc (if it calls r_alloc_sbrk in ralloc.c).
+ It is used for looking up syntax properties.
If the value is a Lisp string object, we are matching text in that
string; if it's nil, we are matching text in the current buffer; if
diff --git a/src/search.c b/src/search.c
index 92bfa88eb82..25d81f2baf6 100644
--- a/src/search.c
+++ b/src/search.c
@@ -280,10 +280,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;
@@ -303,12 +301,20 @@ looking_at_1 (Lisp_Object string, bool posix)
re_match_object = Qnil;
+#ifdef REL_ALLOC
+ /* Prevent ralloc.c from relocating the current buffer while
+ searching it. */
+ r_alloc_inhibit_buffer_relocation (1);
+#endif
i = re_match_2 (bufp, (char *) p1, s1, (char *) p2, s2,
PT_BYTE - BEGV_BYTE,
(NILP (Vinhibit_changing_match_data)
? &search_regs : NULL),
ZV_BYTE - BEGV_BYTE);
immediate_quit = 0;
+#ifdef REL_ALLOC
+ r_alloc_inhibit_buffer_relocation (0);
+#endif
if (i == -2)
matcher_overflow ();
@@ -402,7 +408,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))
@@ -473,7 +478,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;
}
@@ -558,10 +562,17 @@ fast_looking_at (Lisp_Object regexp, ptrdiff_t pos, ptrdiff_t pos_byte,
buf = compile_pattern (regexp, 0, Qnil, 0, multibyte);
immediate_quit = 1;
+#ifdef REL_ALLOC
+ /* Prevent ralloc.c from relocating the current buffer while
+ searching it. */
+ r_alloc_inhibit_buffer_relocation (1);
+#endif
len = re_match_2 (buf, (char *) p1, s1, (char *) p2, s2,
pos_byte, NULL, limit_byte);
+#ifdef REL_ALLOC
+ r_alloc_inhibit_buffer_relocation (0);
+#endif
immediate_quit = 0;
- re_match_object = Qnil; /* Stop protecting string from GC. */
return len;
}
@@ -1176,8 +1187,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,
@@ -1191,19 +1202,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;
}
@@ -1214,20 +1222,22 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
}
re_match_object = Qnil;
+#ifdef REL_ALLOC
+ /* Prevent ralloc.c from relocating the current buffer while
+ searching it. */
+ r_alloc_inhibit_buffer_relocation (1);
+#endif
+
while (n < 0)
{
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 ();
@@ -1259,6 +1269,9 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
else
{
immediate_quit = 0;
+#ifdef REL_ALLOC
+ r_alloc_inhibit_buffer_relocation (0);
+#endif
return (n);
}
n++;
@@ -1267,15 +1280,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 ();
@@ -1305,11 +1314,17 @@ search_buffer (Lisp_Object string, ptrdiff_t pos, ptrdiff_t pos_byte,
else
{
immediate_quit = 0;
+#ifdef REL_ALLOC
+ r_alloc_inhibit_buffer_relocation (0);
+#endif
return (0 - n);
}
n--;
}
immediate_quit = 0;
+#ifdef REL_ALLOC
+ r_alloc_inhibit_buffer_relocation (0);
+#endif
return (pos);
}
else /* non-RE case */