unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Experimental regexp check: repetition of empty-matching expression
@ 2019-04-12 20:00 Mattias Engdegård
  2019-04-13  2:47 ` Paul Eggert
  0 siblings, 1 reply; 4+ messages in thread
From: Mattias Engdegård @ 2019-04-12 20:00 UTC (permalink / raw)
  To: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 617 bytes --]

As an experiment I added, to xr, a check for repetitions of expressions that can match the empty string, like

\(a*b*\)*

on the grounds that these are either mistakes or potentially risk being very slow on the backtracking regexp engine in Emacs. (A DFA would have no problem whatsoever; the regexp above would become a single state.)

Is this useful, or a pointless waste of time? Attached are the results from a relint run on the Emacs tree so that you can judge for yourselves. If the consensus is that it too often complains about perfectly fine regexps, then the check will be dropped unceremoniously.


[-- Attachment #2: relint.log --]
[-- Type: application/octet-stream, Size: 10463 bytes --]

;; -*- compilation -*-
Relint results for ~/emacs
lisp/cedet/srecode/srt-mode.el:65:3: In srecode-font-lock-keywords: Repetition of expression matching an empty string (pos 41)
  "^\\(template\\)\\s-+\\(\\w*\\)\\(\\( \\(:\\w+\\)\\|\\)+\\)$"
   ......................................................^
lisp/emacs-lisp/copyright.el:53:2: In copyright-regexp: Repetition of expression matching an empty string (pos 100)
  "\\(\251\\|@copyright{}\\|[Cc]opyright\\s *:?\\s *\\(?:(C)\\)?\\|[Cc]opyright\\s *:?\\s *\251\\)\\s *\\(?:[^0-9\n]*\\s *\\)?\\([1-9]\\([-0-9, ';/*%#\n\t]\\|\\s<\\|\\s>\\)*[0-9]+\\)"
   ..........................................................................................................................^
lisp/emacs-lisp/copyright.el:154:26: In call to copyright-re-search: Repetition of expression matching an empty string (pos 102)
  "\\(\\(\251\\|@copyright{}\\|[Cc]opyright\\s *:?\\s *\\(?:(C)\\)?\\|[Cc]opyright\\s *:?\\s *\251\\)\\s *\\(?:[^0-9\n]*\\s *\\)?\\([1-9]\\([-0-9, ';/*%#\n\t]\\|\\s<\\|\\s>\\)*[0-9]+\\)\\)\\([ \t]*\n\\)?.*\\(?:\\)"
   .............................................................................................................................^
lisp/erc/erc-backend.el:1288:25: In call to string-match: Repetition of expression matching an empty string (pos 7)
  "^\\(.*\\)?\007.*$"
   .........^
lisp/erc/erc-goodies.el:551:28: In call to re-search-forward: Repetition of expression matching an empty string (pos 18)
  "[.-]+\\([.-]*/? *\\)+[.-]+/?"
   ....................^
lisp/mail/mail-extr.el:385:3: In mail-extr-telephone-extension-pattern: Repetition of expression matching an empty string (pos 40)
  "\\(\\([Ee]xt\\|\\|[Tt]ph\\|[Tt]el\\|[Xx]\\).?\\)? *\\+?[0-9][- 0-9]+"
   ................................................^
lisp/net/tramp-adb.el:56:3: In tramp-adb-prompt: Repetition of expression matching an empty string (pos 21)
  "^\\(?:[[:digit:]]*|?\\)?\\(?:[[:alnum:]\e;[]*@?[[:alnum:]]*[^#\\$]*\\)?[#\\$][[:space:]]"
   .......................^
lisp/net/tramp-adb.el:56:3: In tramp-adb-prompt: Repetition of expression matching an empty string (pos 64)
  "^\\(?:[[:digit:]]*|?\\)?\\(?:[[:alnum:]\e;[]*@?[[:alnum:]]*[^#\\$]*\\)?[#\\$][[:space:]]"
   ......................................................................^
lisp/org/org-table.el:487:3: In org-table-range-regexp: Repetition of expression matching an empty string (pos 23)
  "@\\([-+]?I*[-+]?[0-9]*\\)?\\(\\$[-+]?[0-9]+\\)?\\(\\.\\.@?\\([-+]?I*[-+]?[0-9]*\\)?\\(\\$[-+]?[0-9]+\\)?\\)?"
   .........................^
lisp/org/org-table.el:487:3: In org-table-range-regexp: Repetition of expression matching an empty string (pos 72)
  "@\\([-+]?I*[-+]?[0-9]*\\)?\\(\\$[-+]?[0-9]+\\)?\\(\\.\\.@?\\([-+]?I*[-+]?[0-9]*\\)?\\(\\$[-+]?[0-9]+\\)?\\)?"
   ..................................................................................^
lisp/progmodes/idlwave.el:6457:21: In call to string-match: Repetition of expression matching an empty string (pos 35)
  "OBJ_NEW([ \t]*['\"]\\([a-zA-Z0-9$_]*\\)?\\'"
   .......................................^
lisp/progmodes/idlwave.el:6460:21: In call to string-match: Repetition of expression matching an empty string (pos 32)
  "\\<inherits\\s-+\\([a-zA-Z0-9$_]*\\)?\\'"
   ....................................^
lisp/progmodes/verilog-mode.el:6958:38: In call to looking-at: Repetition of expression matching an empty string (pos 585)
  "\\s-*\\(\\<\\(inout\\|input\\|output\\|ref\\|const\\|static\\|protected\\|local\\|localparam\\|parameter\\|var\\|typedef\\|rand\\)\\>\\s-*\\)?\\<\\(inout\\|input\\|output\\|byte\\|shortint\\|int\\|longint\\|integer\\|time\\|bit\\|logic\\|reg\\|shortreal\\|real\\|realtime\\|supply0\\|supply1\\|tri\\|triand\\|trior\\|trireg\\|tri0\\|tri1\\|uwire\\|wire\\|wand\\|wor\\|string\\|event\\|chandle\\|virtual\\|enum\\|genvar\\|struct\\|union\\|mailbox\\|semaphore\\)\\>\\s-*\\(\\(\\s-*\\(\\<\\(reg\\|wire\\)\\>\\s-*\\)?\\(\\<\\(un\\)?signed\\>\\s-*\\)?\\(\\(\\[[^]]*\\]\\s-*\\)+\\)?\\)\\|\\(#\\s-*\\(\\([0-9_]+\\('s?[hdxbo][0-9a-fA-F_xz]+\\)?\\)\\|\\(([^()]*)\\)\\|\\(\\sw+\\)\\)\\)\\|\\(`\\sw+\\)\\)?"
   ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................^
lisp/progmodes/verilog-mode.el:6959:33: In call to looking-at: Repetition of expression matching an empty string (pos 574)
  "\\s-*\\(\\<\\(inout\\|input\\|output\\|ref\\|const\\|static\\|protected\\|local\\|localparam\\|parameter\\|var\\|typedef\\|rand\\)\\>\\s-*\\)?\\<\\(inout\\|input\\|output\\|byte\\|shortint\\|int\\|longint\\|integer\\|time\\|bit\\|logic\\|reg\\|shortreal\\|real\\|realtime\\|supply0\\|supply1\\|tri\\|triand\\|trior\\|trireg\\|tri0\\|tri1\\|uwire\\|wire\\|wand\\|wor\\|string\\|event\\|chandle\\|virtual\\|enum\\|genvar\\|struct\\|union\\|mailbox\\|semaphore\\)\\>\\s-*\\(\\(\\s-*\\(\\<\\(reg\\|wire\\)\\>\\s-*\\)?\\(\\<\\(un\\)?signed\\>\\s-*\\)?\\(\\(\\[[^]]*\\]\\s-*\\)+\\)?\\)\\|\\(#\\s-*\\(\\([0-9_]+\\('s?[hdxbo][0-9a-fA-F_xz]+\\)?\\)\\|\\(([^()]*)\\)\\|\\(\\sw+\\)\\)\\)\\)?"
   .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................^
lisp/progmodes/verilog-mode.el:7125:36: In call to looking-at: Repetition of expression matching an empty string (pos 585)
  "\\s-*\\(\\<\\(inout\\|input\\|output\\|ref\\|const\\|static\\|protected\\|local\\|localparam\\|parameter\\|var\\|typedef\\|rand\\)\\>\\s-*\\)?\\<\\(inout\\|input\\|output\\|byte\\|shortint\\|int\\|longint\\|integer\\|time\\|bit\\|logic\\|reg\\|shortreal\\|real\\|realtime\\|supply0\\|supply1\\|tri\\|triand\\|trior\\|trireg\\|tri0\\|tri1\\|uwire\\|wire\\|wand\\|wor\\|string\\|event\\|chandle\\|virtual\\|enum\\|genvar\\|struct\\|union\\|mailbox\\|semaphore\\)\\>\\s-*\\(\\(\\s-*\\(\\<\\(reg\\|wire\\)\\>\\s-*\\)?\\(\\<\\(un\\)?signed\\>\\s-*\\)?\\(\\(\\[[^]]*\\]\\s-*\\)+\\)?\\)\\|\\(#\\s-*\\(\\([0-9_]+\\('s?[hdxbo][0-9a-fA-F_xz]+\\)?\\)\\|\\(([^()]*)\\)\\|\\(\\sw+\\)\\)\\)\\|\\(`\\sw+\\)\\)?"
   ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................^
lisp/progmodes/verilog-mode.el:7139:33: In call to looking-at: Repetition of expression matching an empty string (pos 574)
  "\\s-*\\(\\<\\(inout\\|input\\|output\\|ref\\|const\\|static\\|protected\\|local\\|localparam\\|parameter\\|var\\|typedef\\|rand\\)\\>\\s-*\\)?\\<\\(inout\\|input\\|output\\|byte\\|shortint\\|int\\|longint\\|integer\\|time\\|bit\\|logic\\|reg\\|shortreal\\|real\\|realtime\\|supply0\\|supply1\\|tri\\|triand\\|trior\\|trireg\\|tri0\\|tri1\\|uwire\\|wire\\|wand\\|wor\\|string\\|event\\|chandle\\|virtual\\|enum\\|genvar\\|struct\\|union\\|mailbox\\|semaphore\\)\\>\\s-*\\(\\(\\s-*\\(\\<\\(reg\\|wire\\)\\>\\s-*\\)?\\(\\<\\(un\\)?signed\\>\\s-*\\)?\\(\\(\\[[^]]*\\]\\s-*\\)+\\)?\\)\\|\\(#\\s-*\\(\\([0-9_]+\\('s?[hdxbo][0-9a-fA-F_xz]+\\)?\\)\\|\\(([^()]*)\\)\\|\\(\\sw+\\)\\)\\)\\)?"
   .......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................^
lisp/progmodes/verilog-mode.el:10813:29: In call to re-search-forward: Repetition of expression matching an empty string (pos 59)
  "\\s-*// \\(Templated\\|Implicit \\.\\*\\)\\([ \tLT0-9]*\\| LHS: .*\\)?$"
   .....................................................................^
lisp/progmodes/verilog-mode.el:11415:30: In call to string-match: Repetition of expression matching an empty string (pos 22)
  "@\"\\(\\([^\\\"]*\\(\\\\.\\)*\\)*\\)\""
   ................................^
lisp/url/url-misc.el:91:30: In call to string-match: Repetition of expression matching an empty string (pos 9)
  "\\([^,]*\\)?,"
   ...........^
lisp/align.el:386:3: In align-rules-list (c-variable-declaration): Repetition of expression matching an empty string (pos 97)
  "[*&0-9A-Za-z_]>?[&*]*\\(\\s-+[*&]*\\)[A-Za-z_][0-9A-Za-z:_]*\\s-*\\(\\()\\|=[^=\n].*\\|(.*)\\|\\(\\[.*\\]\\)*\\)?\\s-*[;,]\\|)\\s-*$\\)"
   ................................................................................................................^
lisp/dabbrev.el:495:20: In call to re-search-forward: Repetition of expression matching an empty string (pos 6)
  "\\(?:\\)+"
   ........^

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Experimental regexp check: repetition of empty-matching expression
  2019-04-12 20:00 Experimental regexp check: repetition of empty-matching expression Mattias Engdegård
@ 2019-04-13  2:47 ` Paul Eggert
  2019-04-13  8:09   ` Mattias Engdegård
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Eggert @ 2019-04-13  2:47 UTC (permalink / raw)
  To: Mattias Engdegård, Emacs developers

[-- Attachment #1: Type: text/plain, Size: 384 bytes --]

Mattias Engdegård wrote:

> Is this useful, or a pointless waste of time?

I think it's useful, except that the last entry (in dabbrev.el) seems to be a 
false alarm, as a regexp pattern is initially nil but is assigned something else 
before use, and the trawler assumes it's nil. I installed the attached patch 
into master to fix the other issues as best I could. Thanks.

[-- Attachment #2: 0001-Omit-rewrite-useless-regexp-repetitions.txt --]
[-- Type: text/plain, Size: 8883 bytes --]

From cf536bdf913f6d6939492276759061759355e7d3 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Fri, 12 Apr 2019 19:43:16 -0700
Subject: [PATCH] Omit/rewrite useless regexp repetitions
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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.
---
 lisp/align.el                  | 2 +-
 lisp/cedet/srecode/srt-mode.el | 2 +-
 lisp/emacs-lisp/copyright.el   | 2 +-
 lisp/erc/erc-backend.el        | 2 +-
 lisp/erc/erc-goodies.el        | 2 +-
 lisp/mail/mail-extr.el         | 2 +-
 lisp/net/tramp-adb.el          | 2 +-
 lisp/org/org-table.el          | 4 ++--
 lisp/progmodes/idlwave.el      | 4 ++--
 lisp/progmodes/verilog-mode.el | 8 ++++----
 lisp/url/url-misc.el           | 2 +-
 11 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/lisp/align.el b/lisp/align.el
index fd88d0eda4..443237b451 100644
--- a/lisp/align.el
+++ b/lisp/align.el
@@ -411,7 +411,7 @@ align-rules-list
     (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 2ad7ffcdb8..6bf2d51ab4 100644
--- a/lisp/cedet/srecode/srt-mode.el
+++ b/lisp/cedet/srecode/srt-mode.el
@@ -64,7 +64,7 @@ srecode-separator-face
 (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 2726bbc1f3..be335838e3 100644
--- a/lisp/emacs-lisp/copyright.el
+++ b/lisp/emacs-lisp/copyright.el
@@ -52,7 +52,7 @@ copyright-at-end-flag
 (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 2854cde19c..210830a2b4 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -1285,7 +1285,7 @@ erc-handle-unknown-server-response
     (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 117b6783b8..884c594b9e 100644
--- a/lisp/erc/erc-goodies.el
+++ b/lisp/erc/erc-goodies.el
@@ -548,7 +548,7 @@ erc-unmorse
 
 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 cb57d8ea01..a0b9688650 100644
--- a/lisp/mail/mail-extr.el
+++ b/lisp/mail/mail-extr.el
@@ -383,7 +383,7 @@ mail-extr-initial-pattern
 ;; 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 db9acbfc63..f3aa55f16f 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -53,7 +53,7 @@ tramp-adb-method
   "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 b6e864fc9c..147527da1d 100644
--- a/lisp/org/org-table.el
+++ b/lisp/org/org-table.el
@@ -484,8 +484,8 @@ org-table-hlines
 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 bded09d503..6f56ce052a 100644
--- a/lisp/progmodes/idlwave.el
+++ b/lisp/progmodes/idlwave.el
@@ -6454,10 +6454,10 @@ idlwave-where
      ((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 9226291ffb..e75e5845ef 100644
--- a/lisp/progmodes/verilog-mode.el
+++ b/lisp/progmodes/verilog-mode.el
@@ -2761,12 +2761,12 @@ verilog-delay-re
 (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 @@ verilog-delete-auto-buffer
                              '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 @@ verilog-auto-inst-port
     (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 4969cba668..aa44ea78a2 100644
--- a/lisp/url/url-misc.el
+++ b/lisp/url/url-misc.el
@@ -88,7 +88,7 @@ url-data
 	(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))))
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: Experimental regexp check: repetition of empty-matching expression
  2019-04-13  2:47 ` Paul Eggert
@ 2019-04-13  8:09   ` Mattias Engdegård
  2019-04-19 15:24     ` Paul Eggert
  0 siblings, 1 reply; 4+ messages in thread
From: Mattias Engdegård @ 2019-04-13  8:09 UTC (permalink / raw)
  To: Paul Eggert; +Cc: Emacs developers

13 apr. 2019 kl. 04.47 skrev Paul Eggert <eggert@cs.ucla.edu>:
> 
> I think it's useful, except that the last entry (in dabbrev.el) seems to be a false alarm, as a regexp pattern is initially nil but is assigned something else before use, and the trawler assumes it's nil.

Yes, I couldn't make up my mind about the best way to suppress that one. Ignoring repetitions of the empty string, like \(?:\)*, may be the answer.

> I installed the attached patch into master to fix the other issues as best I could. Thanks.

That was quick work!

--- a/lisp/mail/mail-extr.el
+++ b/lisp/mail/mail-extr.el
@@ -383,7 +383,7 @@ mail-extr-initial-pattern
 ;; 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]+"))
                                             ^
Doesn't it look like the dot is meant to be escaped?
 
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -53,7 +53,7 @@ tramp-adb-method
   "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:]]"
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
There is a second one a bit later in the same regexp.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Experimental regexp check: repetition of empty-matching expression
  2019-04-13  8:09   ` Mattias Engdegård
@ 2019-04-19 15:24     ` Paul Eggert
  0 siblings, 0 replies; 4+ messages in thread
From: Paul Eggert @ 2019-04-19 15:24 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 1168 bytes --]

On 4/13/19 1:09 AM, Mattias Engdegård wrote:
>
> --- a/lisp/mail/mail-extr.el
> +++ b/lisp/mail/mail-extr.el
> @@ -383,7 +383,7 @@ mail-extr-initial-pattern
>  ;; 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]+"))
>                                              ^
> Doesn't it look like the dot is meant to be escaped?

Yes, and I installed the attached patch to fix that. Thanks.

>  
> --- a/lisp/net/tramp-adb.el
> +++ b/lisp/net/tramp-adb.el
> @@ -53,7 +53,7 @@ tramp-adb-method
>    "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:]]"
>                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
> There is a second one a bit later in the same regexp.
>
Michael already fixed this.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-mail-extr-regexp-typo-with.patch --]
[-- Type: text/x-patch; name="0001-Fix-mail-extr-regexp-typo-with.patch", Size: 1189 bytes --]

From 938a6c6fa8e8685539590df402e749428d04ca06 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Fri, 19 Apr 2019 08:23:15 -0700
Subject: [PATCH] Fix mail-extr regexp typo with ".".
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Problem reported by Mattias Engdegård in:
https://lists.gnu.org/r/emacs-devel/2019-04/msg00543.html
* lisp/mail/mail-extr.el (mail-extr-telephone-extension-pattern):
Escape the trailing optional period after an abbreviation.
---
 lisp/mail/mail-extr.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/mail/mail-extr.el b/lisp/mail/mail-extr.el
index a0b9688650..c1e90c3dcb 100644
--- a/lisp/mail/mail-extr.el
+++ b/lisp/mail/mail-extr.el
@@ -383,7 +383,7 @@ mail-extr-initial-pattern
 ;; 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
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-04-19 15:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-12 20:00 Experimental regexp check: repetition of empty-matching expression Mattias Engdegård
2019-04-13  2:47 ` Paul Eggert
2019-04-13  8:09   ` Mattias Engdegård
2019-04-19 15:24     ` Paul Eggert

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).