aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorPaul Eggert2019-09-22 10:43:21 -0700
committerPaul Eggert2019-09-22 10:45:14 -0700
commit2f600e97e7ca43965f55f019759582d93d8bca73 (patch)
treed885dcef77f04a60da6cec56a2750b19a8e64192 /lisp
parentdddff96a585531608d5e8d27375a6363679a9fb5 (diff)
downloademacs-2f600e97e7ca43965f55f019759582d93d8bca73.tar.gz
emacs-2f600e97e7ca43965f55f019759582d93d8bca73.zip
Avoid crashes when casifying noncontiguous regions
This is a followon fix for Bug#37477. * lisp/simple.el (region-extract-function): Use setq here, since the var is now defined in C code. * src/casefiddle.c (casify_pnc_region): New function. (Fupcase_region, Fdowncase_region, Fcapitalize_region) (Fupcase_initials_region): Use it. (Fupcase_initials_region): Add region-noncontiguous-p flag for consistency with the others. All uses changed. (syms_of_casefiddle): Define Qbounds, Vregion_extract_function. * src/insdel.c (prepare_to_modify_buffer_1): * src/keyboard.c (command_loop_1): Use Vregion_extraction_function. * src/insdel.c (syms_of_insdel): No need to define Qregion_extract_function. * test/src/casefiddle-tests.el (casefiddle-oldfunc): New var. (casefiddle-loopfunc, casefiddle-badfunc): New functions. (casefiddle-invalid-region-extract-function): New test.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/simple.el16
1 files changed, 2 insertions, 14 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 31e3b2bbaba..ecd7eb797e8 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -1087,7 +1087,7 @@ instead of deleted."
1087 :group 'killing 1087 :group 'killing
1088 :version "24.1") 1088 :version "24.1")
1089 1089
1090(defvar region-extract-function 1090(setq region-extract-function
1091 (lambda (method) 1091 (lambda (method)
1092 (when (region-beginning) 1092 (when (region-beginning)
1093 (cond 1093 (cond
@@ -1096,19 +1096,7 @@ instead of deleted."
1096 ((eq method 'delete-only) 1096 ((eq method 'delete-only)
1097 (delete-region (region-beginning) (region-end))) 1097 (delete-region (region-beginning) (region-end)))
1098 (t 1098 (t
1099 (filter-buffer-substring (region-beginning) (region-end) method))))) 1099 (filter-buffer-substring (region-beginning) (region-end) method))))))
1100 "Function to get the region's content.
1101Called with one argument METHOD which can be:
1102- nil: return the content as a string (list of strings for
1103 non-contiguous regions).
1104- `delete-only': delete the region; the return value is undefined.
1105- `bounds': return the boundaries of the region as a list of one
1106 or more cons cells of the form (START . END).
1107- anything else: delete the region and return its content
1108 as a string (or list of strings for non-contiguous regions),
1109 after filtering it with `filter-buffer-substring', which
1110 is called, for each contiguous sub-region, with METHOD as its
1111 3rd argument.")
1112 1100
1113(defvar region-insert-function 1101(defvar region-insert-function
1114 (lambda (lines) 1102 (lambda (lines)