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

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).