From 11d49adcbadcfcbe844f873e63ba1d596f72e4c5 Mon Sep 17 00:00:00 2001 From: Akinori MUSHA Date: Mon, 19 Aug 2019 23:53:50 +0900 Subject: [PATCH] Save match data in ucs-normalize-region * lisp/international/ucs-normalize.el (ucs-normalize-region): Save match data. This function can be transparently called via ENCODE_FILE() when the underlying filesytem uses normalized Unicode filenames, so it requires much care not to cause any side effects. --- lisp/international/ucs-normalize.el | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lisp/international/ucs-normalize.el b/lisp/international/ucs-normalize.el index 6f1e770c09..d02d4b8e3e 100644 --- a/lisp/international/ucs-normalize.el +++ b/lisp/international/ucs-normalize.el @@ -514,19 +514,20 @@ ucs-normalize-region (narrow-to-region from to) (goto-char (point-min)) (let (start-pos starter) - (while (re-search-forward quick-check-regexp nil t) - (setq starter (string-to-char (match-string 0))) - (setq start-pos (match-beginning 0)) - (ucs-normalize-block - ;; from - (if (or (= start-pos (point-min)) - (and (= 0 (ucs-normalize-ccc starter)) - (not (memq starter ucs-normalize-combining-chars)))) - start-pos (1- start-pos)) - ;; to - (if (looking-at ucs-normalize-combining-chars-regexp) - (match-end 0) (1+ start-pos)) - translation-table composition-predicate)))))) + (save-match-data + (while (re-search-forward quick-check-regexp nil t) + (setq starter (string-to-char (match-string 0))) + (setq start-pos (match-beginning 0)) + (ucs-normalize-block + ;; from + (if (or (= start-pos (point-min)) + (and (= 0 (ucs-normalize-ccc starter)) + (not (memq starter ucs-normalize-combining-chars)))) + start-pos (1- start-pos)) + ;; to + (if (looking-at ucs-normalize-combining-chars-regexp) + (match-end 0) (1+ start-pos)) + translation-table composition-predicate))))))) ;; -------------------------------------------------------------------------------- -- 2.22.0