summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2019-04-12 19:43:16 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2019-04-12 19:43:41 -0700
commit7ddd08bd3ebc48998062a7d29274cf080256a48f (patch)
treeda54083040dc4675dc5b9084ab32a0ed4ec6a8f5
parent8635e011edd1c50678074a49cbbf857b35823e9d (diff)
downloademacs-7ddd08bd3ebc48998062a7d29274cf080256a48f.tar.gz
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.
-rw-r--r--lisp/align.el2
-rw-r--r--lisp/cedet/srecode/srt-mode.el2
-rw-r--r--lisp/emacs-lisp/copyright.el2
-rw-r--r--lisp/erc/erc-backend.el2
-rw-r--r--lisp/erc/erc-goodies.el2
-rw-r--r--lisp/mail/mail-extr.el2
-rw-r--r--lisp/net/tramp-adb.el2
-rw-r--r--lisp/org/org-table.el4
-rw-r--r--lisp/progmodes/idlwave.el4
-rw-r--r--lisp/progmodes/verilog-mode.el8
-rw-r--r--lisp/url/url-misc.el2
11 files changed, 16 insertions, 16 deletions
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 <maessm@rpi.edu>, 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 "\\<inherits\\s-+\\([a-zA-Z0-9$_]*\\)?\\'"
+ ((string-match "\\<inherits\\s-+[a-zA-Z0-9$_]*\\'"
match-string)
(setq cw 'class))
((and func
diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el
index 9226291ffbb..e75e5845ef3 100644
--- a/lisp/progmodes/verilog-mode.el
+++ b/lisp/progmodes/verilog-mode.el
@@ -2761,12 +2761,12 @@ find the errors."
(defconst verilog-declaration-re-2-no-macro
(concat "\\s-*" verilog-declaration-re
"\\s-*\\(\\(" verilog-optional-signed-range-re "\\)\\|\\(" verilog-delay-re "\\)"
- "\\)?"))
+ "\\)"))
(defconst verilog-declaration-re-2-macro
(concat "\\s-*" verilog-declaration-re
"\\s-*\\(\\(" verilog-optional-signed-range-re "\\)\\|\\(" verilog-delay-re "\\)"
"\\|\\(" verilog-macroexp-re "\\)"
- "\\)?"))
+ "\\)"))
(defconst verilog-declaration-re-1-macro
(concat "^" verilog-declaration-re-2-macro))
@@ -10810,7 +10810,7 @@ Intended for internal use inside a `verilog-save-font-no-change-functions' block
'verilog-delete-auto-star-all)
;; Remove template comments ... anywhere in case was pasted after AUTOINST removed
(goto-char (point-min))
- (while (re-search-forward "\\s-*// \\(Templated\\|Implicit \\.\\*\\)\\([ \tLT0-9]*\\| LHS: .*\\)?$" nil t)
+ (while (re-search-forward "\\s-*// \\(Templated\\|Implicit \\.\\*\\)\\([ \tLT0-9]*\\| LHS: .*\\)$" nil t)
(replace-match ""))
;; Final customize
@@ -11412,7 +11412,7 @@ If PAR-VALUES replace final strings with these parameter values."
(when tpl-ass
;; Evaluate @"(lispcode)"
(when (string-match "@\".*[^\\]\"" tpl-net)
- (while (string-match "@\"\\(\\([^\\\"]*\\(\\\\.\\)*\\)*\\)\"" tpl-net)
+ (while (string-match "@\"\\(\\([^\\\"]\\|\\\\.\\)*\\)\"" tpl-net)
(setq tpl-net
(concat
(substring tpl-net 0 (match-beginning 0))
diff --git a/lisp/url/url-misc.el b/lisp/url/url-misc.el
index 4969cba6688..aa44ea78a22 100644
--- a/lisp/url/url-misc.el
+++ b/lisp/url/url-misc.el
@@ -88,7 +88,7 @@
(encoding "8bit")
(data nil))
(save-excursion
- (if (not (string-match "\\([^,]*\\)?," desc))
+ (if (not (string-match "\\([^,]*\\)," desc))
(error "Malformed data URL: %s" desc)
(setq mediatype (match-string 1 desc)
data (url-unhex-string (substring desc (match-end 0))))