unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: Emacs developers <emacs-devel@gnu.org>
Subject: Experimental regexp check: repetition of empty-matching expression
Date: Fri, 12 Apr 2019 22:00:28 +0200	[thread overview]
Message-ID: <30C4697B-B2C4-48F3-B01E-B17C00C152B4@acm.org> (raw)

[-- 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)
  "\\(?:\\)+"
   ........^

             reply	other threads:[~2019-04-12 20:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-12 20:00 Mattias Engdegård [this message]
2019-04-13  2:47 ` Experimental regexp check: repetition of empty-matching expression Paul Eggert
2019-04-13  8:09   ` Mattias Engdegård
2019-04-19 15:24     ` Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=30C4697B-B2C4-48F3-B01E-B17C00C152B4@acm.org \
    --to=mattiase@acm.org \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).