diff options
| author | Paul Eggert | 2019-09-22 10:43:21 -0700 |
|---|---|---|
| committer | Paul Eggert | 2019-09-22 10:45:14 -0700 |
| commit | 2f600e97e7ca43965f55f019759582d93d8bca73 (patch) | |
| tree | d885dcef77f04a60da6cec56a2750b19a8e64192 /test/src | |
| parent | dddff96a585531608d5e8d27375a6363679a9fb5 (diff) | |
| download | emacs-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 'test/src')
| -rw-r--r-- | test/src/casefiddle-tests.el | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/src/casefiddle-tests.el b/test/src/casefiddle-tests.el index ed9a2f93306..54793f2cda4 100644 --- a/test/src/casefiddle-tests.el +++ b/test/src/casefiddle-tests.el | |||
| @@ -259,5 +259,22 @@ | |||
| 259 | (should (eq tc (capitalize ch))) | 259 | (should (eq tc (capitalize ch))) |
| 260 | (should (eq tc (upcase-initials ch)))))) | 260 | (should (eq tc (upcase-initials ch)))))) |
| 261 | 261 | ||
| 262 | (defvar casefiddle-oldfunc region-extract-function) | ||
| 263 | |||
| 264 | (defun casefiddle-loopfunc (method) | ||
| 265 | (if (eq method 'bounds) | ||
| 266 | (let ((looping (list '(1 . 1)))) | ||
| 267 | (setcdr looping looping)) | ||
| 268 | (funcall casefiddle-oldfunc method))) | ||
| 269 | |||
| 270 | (defun casefiddle-badfunc (method) | ||
| 271 | (if (eq method 'bounds) | ||
| 272 | '(()) | ||
| 273 | (funcall casefiddle-oldfunc method))) | ||
| 274 | |||
| 275 | (ert-deftest casefiddle-invalid-region-extract-function () | ||
| 276 | (dolist (region-extract-function '(casefiddle-badfunc casefiddle-loopfunc)) | ||
| 277 | (with-temp-buffer | ||
| 278 | (should-error (upcase-region nil nil t))))) | ||
| 262 | 279 | ||
| 263 | ;;; casefiddle-tests.el ends here | 280 | ;;; casefiddle-tests.el ends here |