[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/repology c72e3ce 2/2: repology: Replace regexps left-ov
From: |
Nicolas Goaziou |
Subject: |
[elpa] externals/repology c72e3ce 2/2: repology: Replace regexps left-overs with their rx form |
Date: |
Wed, 20 Jan 2021 13:21:54 -0500 (EST) |
branch: externals/repology
commit c72e3cebce61876485b5eabfe1cd703c57beec6b
Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Commit: Nicolas Goaziou <mail@nicolasgoaziou.fr>
repology: Replace regexps left-overs with their rx form
* repology-license.el (repology--license-get-identifiers:gentoo):
* repology-utils.el (repology-list-repositories): Use rx form instead
of plain regexp.
---
repology-license.el | 9 +++++----
repology-utils.el | 22 +++++++++++-----------
2 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/repology-license.el b/repology-license.el
index 8ef9b59..e78d750 100644
--- a/repology-license.el
+++ b/repology-license.el
@@ -129,10 +129,11 @@ This list is populated with
`repology--license-get-identifiers:gentoo'.")
(insert (plist-get request :body))
(dolist (category repology--license-categories:gentoo)
(goto-char 1)
- (when (re-search-forward (concat "^" category " +"))
- (let ((l (buffer-substring (point) (line-end-position))))
- (setq identifiers
- (nconc (split-string l) identifiers)))))
+ (let ((regexp (rx line-start (literal category) (+ space))))
+ (when (re-search-forward regexp)
+ (let ((l (buffer-substring (point)
(line-end-position))))
+ (setq identifiers
+ (nconc (split-string l) identifiers))))))
(dolist (category repology--license-categories:gentoo)
(setq identifiers
(delete (concat "@" category) identifiers))))
diff --git a/repology-utils.el b/repology-utils.el
index 6a8b9b3..7370f70 100644
--- a/repology-utils.el
+++ b/repology-utils.el
@@ -209,18 +209,18 @@ the repositories with their full name instead of their
internal name."
("OK"
(let ((body (plist-get request :body))
(repositories nil)
- (start 0))
- (while (string-match "id=\"\\(.+?\\)\"" body start)
+ (start 0)
+ (internal-re (rx "id=\"" (group (+? nonl)) "\""))
+ (full-re (rx "href=\"/repository/"
+ (+? anychar)
+ "\">"
+ (group (+? anychar))
+ "<")))
+ (while (string-match internal-re body start)
(setq start (match-end 0))
(let* ((repo (match-string 1 body))
- (regexp
- (rx "href=\"/repository/"
- (+? anychar)
- "\">"
- (group (+? anychar))
- "<"))
(true-name
- (and (string-match regexp body start)
+ (and (string-match full-re body start)
(match-string 1 body))))
(push (cons repo true-name) repositories)))
(setq repology--repositories (nreverse repositories))))
@@ -275,9 +275,9 @@ the request."
(header nil)
(body nil))
(forward-line)
- (while (looking-at "^\\([^:]+\\): \\(.*\\)")
+ (while (looking-at (rx line-start (group (+? nonl)) ": "))
(push (match-string 1) header)
- (push (match-string 2) header)
+ (push (buffer-substring (match-end 0) (line-end-position))
header)
(forward-line))
(forward-line)
(unless (eobp)