[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/scala-mode aa38dae 083/217: Fixes #38: 100% CPU usage for
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/scala-mode aa38dae 083/217: Fixes #38: 100% CPU usage for multi-line strings in some cases. |
Date: |
Sun, 29 Aug 2021 11:30:48 -0400 (EDT) |
branch: elpa/scala-mode
commit aa38dae7cf7310ab0a508edd9bfea53368833821
Author: Heikki Vesalainen <heikkivesalainen@yahoo.com>
Commit: Heikki Vesalainen <heikkivesalainen@yahoo.com>
Fixes #38: 100% CPU usage for multi-line strings in some cases.
If an unbalanced multi-line string contained string quotes, the
propertice function would go into an endless loop.
---
scala-mode-syntax.el | 46 ++++++++++++++++++++++++----------------------
1 file changed, 24 insertions(+), 22 deletions(-)
diff --git a/scala-mode-syntax.el b/scala-mode-syntax.el
index 2524028..d1cd41c 100644
--- a/scala-mode-syntax.el
+++ b/scala-mode-syntax.el
@@ -91,8 +91,13 @@
(concat "\\(" "[^\n\"\\\\]"
"\\|" scala-syntax:string-escape-re "\\)"))
(defconst scala-syntax:oneLineStringLiteral-re (concat "\\(\"\\)"
scala-syntax:stringElement-re "*\\(\"\\)"))
+(defconst scala-syntax:multiLineStringLiteral-start-re
+ "\\(\"\\)\"\"\\(\"?\"?[^\"]\\)*")
+(defconst scala-syntax:multiLineStringLiteral-end-re
+ "\"\"+\\(\"\\)")
(defconst scala-syntax:multiLineStringLiteral-re
- "\\(\"\\)\\(\"\"\\(\"?\"?[^\"]\\)*\"\"+\\)\\(\"\\)")
+ (concat scala-syntax:multiLineStringLiteral-start-re
+ scala-syntax:multiLineStringLiteral-end-re))
(defconst scala-syntax:stringLiteral-re
(concat "\\(" scala-syntax:multiLineStringLiteral-re
"\\|" scala-syntax:oneLineStringLiteral-re "\\)" ))
@@ -100,11 +105,12 @@
;; If you change this or any of the used regex, be sure to
;; maintain this or update propertize function acordingly:
;; group 1 = char start, 3 = char end
-;; group 4 = multi-line string start, 7 = end
-;; group 8 = string start, 11 = end
+;; group 4 = multi-line string start, 6 = end
+;; group 7 = string start, 9 = end
(defconst scala-syntax:relaxed-char-and-string-literal-re
(concat scala-syntax:characterLiteral-re
- "\\|" scala-syntax:multiLineStringLiteral-re
+ "\\|" scala-syntax:multiLineStringLiteral-start-re
+ "\\(?:" scala-syntax:multiLineStringLiteral-end-re "\\)?"
"\\|\\(\"\\)" "\\(\\\\.\\|[^\"\n\\]\\)*" "\\(\"\\)"))
;; Identifiers (Chapter 1.1)
@@ -305,9 +311,6 @@
(regexp-opt '("var" "val" "import") 'words)
("Keywords that can start a list"))
-(defconst scala-syntax:multiLineStringLiteral-start-re
- "\\(\"\\)\"\"")
-
(defconst scala-syntax:multiLineStringLiteral-end-re
"\"\"+\\(\"\\)")
@@ -442,34 +445,33 @@ characters and one-line strings will not be fontified."
scala-syntax:relaxed-char-and-string-literal-re end t)
;; Expects the following groups:
;; group 1 = char start, 3 = char end
- ;; group 4 = multi-line string start, 7 = end
- ;; group 8 = string start, 10 = end
+ ;; group 4 = multi-line string start, 6 = end
+ ;; group 7 = string start, 9 = end
(cond
((match-beginning 1)
(scala-syntax:put-syntax-table-property 1 '(7 . nil))
(scala-syntax:put-syntax-table-property 3 '(7 . nil)))
- ((match-beginning 4) ;; balanced multi-line literal
+ ((match-beginning 4) ;; start of multi-line literal
(scala-syntax:put-syntax-table-property 4 '(15 . nil))
- (scala-syntax:put-syntax-table-property 7 '(15 . nil)))
+ (if (match-beginning 6)
+ ;; balanced multi-line
+ (scala-syntax:put-syntax-table-property 6 '(15 . nil))
+ ;; un-balanced multi-line
+ (throw 'break nil)))
((or
;; normal string, content is not empty
- (match-beginning 9)
+ (match-beginning 8)
;; empty string at line end
- (= (match-end 10) (line-end-position))
+ (= (match-end 9) (line-end-position))
;; no " after empty string
(not (= (char-after (match-end 10)) ?\")))
(when (save-excursion
- (goto-char (match-beginning 8))
+ (goto-char (match-beginning 7))
;; really valid?
(looking-at-p scala-syntax:oneLineStringLiteral-re))
- (scala-syntax:put-syntax-table-property 8 '(7 . nil))
- (scala-syntax:put-syntax-table-property 10 '(7 . nil))))
- (t ;; backtrack and continue to next while loop
- (goto-char (match-beginning 0))
- (throw 'break nil)))))
- ;; match any start of multi-line literals that are not yet balanced
- (when (re-search-forward scala-syntax:multiLineStringLiteral-start-re
end t)
- (scala-syntax:put-syntax-table-property 1 '(15 . nil)))))))
+ (scala-syntax:put-syntax-table-property 7 '(7 . nil))
+ (scala-syntax:put-syntax-table-property 9 '(7 . nil))))
+ (t (throw 'break nil)))))))))
(defun scala-syntax:propertize-underscore-and-idrest (start end)
"Mark all underscores (_) as symbol constituents (syntax 3) or
- [nongnu] elpa/scala-mode 3953269 127/217: Tweaked syntax rules to make highlighting more customizeable, (continued)
- [nongnu] elpa/scala-mode 3953269 127/217: Tweaked syntax rules to make highlighting more customizeable, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode c0842f6 157/217: Use cl functions to avoid mapcan missing error., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode d1fbe2d 171/217: Implemented prettify/conceal with a base set of rules. (#108), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 2e8fd35 180/217: Fix for fill-paragraph with prefix arg. Fixes #125. (#126), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 7e63002 182/217: Add "inline" keyword from scalameta (#128), ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 1357eba 183/217: Fix for #94, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 730e16d 186/217: Merge pull request #130 from ensime/fix/120, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 1dd5825 085/217: Added comment syntax for bash preambles (#!...!#) in scala script files, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 16d6f36 067/217: Added a not to README about font-lock-doc-face, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode b55ca83 066/217: Merge pull request #23 from hvesalai/issue22, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode aa38dae 083/217: Fixes #38: 100% CPU usage for multi-line strings in some cases.,
ELPA Syncer <=
- [nongnu] elpa/scala-mode 0af3b07 069/217: Added Makefile and fixed compilation warnings, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode be89855 084/217: Multi-line comment indentation and asterisk-insertion on mid-line return., ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 711091a 087/217: moved provides to end of files, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 6312b36 082/217: Make the code agreeable to Emacs-Lisp mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 18a52f0 094/217: Update installation instructions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode a1ea0b7 097/217: Proper instructions and autoload settings for package-based install, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode 763c93c 107/217: scala-indent:join-line, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode c62ecf9 109/217: Update README.md, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode aea047a 104/217: Create .gitignore with *.elc, ELPA Syncer, 2021/08/29
- [nongnu] elpa/scala-mode d4cccb0 112/217: scala-mode:set-scala-syntax-mode to support sbt-mode, ELPA Syncer, 2021/08/29