From: Paul Eggert Date: Sat, 13 Apr 2019 02:43:16 +0000 (-0700) Subject: Omit/rewrite useless regexp repetitions X-Git-Tag: emacs-27.0.90~3259^2~17 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7ddd08bd3ebc48998062a7d29274cf080256a48f;p=emacs.git Omit/rewrite useless regexp repetitions Problem reported by Mattias Engdegård in: https://lists.gnu.org/r/emacs-devel/2019-04/msg00527.html * lisp/align.el (align-rules-list): * lisp/cedet/srecode/srt-mode.el (srecode-font-lock-keywords): * lisp/emacs-lisp/copyright.el (copyright-regexp): * lisp/erc/erc-backend.el (JOIN): * lisp/erc/erc-goodies.el (erc-unmorse): * lisp/mail/mail-extr.el (mail-extr-telephone-extension-pattern): * lisp/net/tramp-adb.el (tramp-adb-prompt): * lisp/org/org-table.el (org-table-range-regexp): * lisp/progmodes/idlwave.el (idlwave-where): * lisp/progmodes/verilog-mode.el (verilog-declaration-re-2-no-macro) (verilog-declaration-re-2-macro, verilog-delete-auto-buffer) (verilog-auto-inst-port): * lisp/url/url-misc.el (url-data): Omit or rewrite useless repetitions that risk being very slow in the backtracking regexp engine in Emacs. --- diff --git a/lisp/align.el b/lisp/align.el index fd88d0eda42..443237b451b 100644 --- a/lisp/align.el +++ b/lisp/align.el @@ -411,7 +411,7 @@ The possible settings for `align-region-separate' are: (c-variable-declaration (regexp . ,(concat "[*&0-9A-Za-z_]>?[&*]*\\(\\s-+[*&]*\\)" "[A-Za-z_][0-9A-Za-z:_]*\\s-*\\(\\()\\|" - "=[^=\n].*\\|(.*)\\|\\(\\[.*\\]\\)*\\)?" + "=[^=\n].*\\|(.*)\\|\\(\\[.*\\]\\)*\\)" "\\s-*[;,]\\|)\\s-*$\\)")) (group . 1) (modes . align-c++-modes) diff --git a/lisp/cedet/srecode/srt-mode.el b/lisp/cedet/srecode/srt-mode.el index 2ad7ffcdb87..6bf2d51ab41 100644 --- a/lisp/cedet/srecode/srt-mode.el +++ b/lisp/cedet/srecode/srt-mode.el @@ -64,7 +64,7 @@ (defvar srecode-font-lock-keywords '( ;; Template - ("^\\(template\\)\\s-+\\(\\w*\\)\\(\\( \\(:\\w+\\)\\|\\)+\\)$" + ("^\\(template\\)\\s-+\\(\\w*\\)\\(\\( \\(:\\w+\\)\\)*\\)$" (1 font-lock-keyword-face) (2 font-lock-function-name-face) (3 font-lock-builtin-face )) diff --git a/lisp/emacs-lisp/copyright.el b/lisp/emacs-lisp/copyright.el index 2726bbc1f3f..be335838e33 100644 --- a/lisp/emacs-lisp/copyright.el +++ b/lisp/emacs-lisp/copyright.el @@ -52,7 +52,7 @@ This is useful for ChangeLogs." (defcustom copyright-regexp "\\(©\\|@copyright{}\\|[Cc]opyright\\s *:?\\s *\\(?:(C)\\)?\ \\|[Cc]opyright\\s *:?\\s *©\\)\ -\\s *\\(?:[^0-9\n]*\\s *\\)?\ +\\s *[^0-9\n]*\\s *\ \\([1-9]\\([-0-9, ';/*%#\n\t]\\|\\s<\\|\\s>\\)*[0-9]+\\)" "What your copyright notice looks like. The second \\( \\) construct must match the years." diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 2854cde19cc..210830a2b49 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -1285,7 +1285,7 @@ add things to `%s' instead." (pcase-let ((`(,nick ,login ,host) (erc-parse-user (erc-response.sender parsed)))) ;; strip the stupid combined JOIN facility (IRC 2.9) - (if (string-match "^\\(.*\\)?\^g.*$" chnl) + (if (string-match "^\\(.*\\)\^g.*$" chnl) (setq chnl (match-string 1 chnl))) (save-excursion (let* ((str (cond diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el index 117b6783b8d..884c594b9ed 100644 --- a/lisp/erc/erc-goodies.el +++ b/lisp/erc/erc-goodies.el @@ -548,7 +548,7 @@ channel that has weird people talking in morse to each other. See also `unmorse-region'." (goto-char (point-min)) - (when (re-search-forward "[.-]+\\([.-]*/? *\\)+[.-]+/?" nil t) + (when (re-search-forward "[.-]+[./ -]*[.-]/?" nil t) (save-restriction (narrow-to-region (match-beginning 0) (match-end 0)) ;; Turn " / " into " " diff --git a/lisp/mail/mail-extr.el b/lisp/mail/mail-extr.el index cb57d8ea016..a0b96886507 100644 --- a/lisp/mail/mail-extr.el +++ b/lisp/mail/mail-extr.el @@ -383,7 +383,7 @@ by translating things like \"foo!bar!baz@host\" into \"baz@bar.UUCP\"." ;; Matches telephone extensions. (defconst mail-extr-telephone-extension-pattern (purecopy - "\\(\\([Ee]xt\\|\\|[Tt]ph\\|[Tt]el\\|[Xx]\\).?\\)? *\\+?[0-9][- 0-9]+")) + "\\(\\([Ee]xt\\|[Tt]ph\\|[Tt]el\\|[Xx]\\).?\\)? *\\+?[0-9][- 0-9]+")) ;; Matches ham radio call signs. ;; Help from: Mat Maessen N2NJZ , Mark Feit diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index db9acbfc631..f3aa55f16f5 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -53,7 +53,7 @@ It is used for TCP/IP devices." "When this method name is used, forward all calls to Android Debug Bridge.") (defcustom tramp-adb-prompt - "^\\(?:[[:digit:]]*|?\\)?\\(?:[[:alnum:]\e;[]*@?[[:alnum:]]*[^#\\$]*\\)?[#\\$][[:space:]]" + "^[[:digit:]]*|?\\(?:[[:alnum:]\e;[]*@?[[:alnum:]]*[^#\\$]*\\)?[#\\$][[:space:]]" "Regexp used as prompt in almquist shell." :type 'string :version "24.4" diff --git a/lisp/org/org-table.el b/lisp/org/org-table.el index b6e864fc9c9..147527da1d3 100644 --- a/lisp/org/org-table.el +++ b/lisp/org/org-table.el @@ -484,8 +484,8 @@ Line numbers are counted from the beginning of the table. This variable is initialized with `org-table-analyze'.") (defconst org-table-range-regexp - "@\\([-+]?I*[-+]?[0-9]*\\)?\\(\\$[-+]?[0-9]+\\)?\\(\\.\\.@?\\([-+]?I*[-+]?[0-9]*\\)?\\(\\$[-+]?[0-9]+\\)?\\)?" - ;; 1 2 3 4 5 + "@\\([-+]?I*[-+]?[0-9]*\\)\\(\\$[-+]?[0-9]+\\)?\\(\\.\\.@?\\([-+]?I*[-+]?[0-9]*\\)\\(\\$[-+]?[0-9]+\\)?\\)?" + ;; 1 2 3 4 5 "Regular expression for matching ranges in formulas.") (defconst org-table-range-regexp2 diff --git a/lisp/progmodes/idlwave.el b/lisp/progmodes/idlwave.el index bded09d5038..6f56ce052a0 100644 --- a/lisp/progmodes/idlwave.el +++ b/lisp/progmodes/idlwave.el @@ -6454,10 +6454,10 @@ ARROW: Location of the arrow" ((string-match "\\`[ \t]*\\(pro\\|function\\)\\>" match-string) nil) - ((string-match "OBJ_NEW([ \t]*['\"]\\([a-zA-Z0-9$_]*\\)?\\'" + ((string-match "OBJ_NEW([ \t]*['\"][a-zA-Z0-9$_]*\\'" match-string) (setq cw 'class)) - ((string-match "\\