diff options
| author | Basil L. Contovounesios | 2023-06-12 00:23:56 +0100 |
|---|---|---|
| committer | Basil L. Contovounesios | 2023-06-17 16:36:27 +0100 |
| commit | fef27d28fa70b52b6dc302d0b3ae1687499dd499 (patch) | |
| tree | edba954a9134bc55d4fc0f1bdac2e3b8d3c1507c | |
| parent | f47cf7110edf94b7fb7c7a5ffa97e817f7a0e9d1 (diff) | |
| download | emacs-fef27d28fa70b52b6dc302d0b3ae1687499dd499.tar.gz emacs-fef27d28fa70b52b6dc302d0b3ae1687499dd499.zip | |
Fix more shy group regexps
These issues were caught by modified versions of the GNU ELPA
packages xr and relint:
- https://github.com/mattiase/xr/pull/6
- https://github.com/mattiase/relint/pull/14
* lisp/gnus/gnus-art.el (gnus-parse-news-url): Remove redundant
numbered group and calls to match-string.
* lisp/progmodes/c-ts-mode.el (c-ts-mode--c-or-c++-regexp): Fix shy
group mistyped as optional colon (bug#64019#29).
* lisp/vc/vc-git.el (vc-git-annotate-time): Ditto. Also fix
timezone parsing by using iso8601-parse (bug#64069).
* test/lisp/vc/vc-git-tests.el (vc-git-test-annotate-time): New
test.
| -rw-r--r-- | lisp/gnus/gnus-art.el | 7 | ||||
| -rw-r--r-- | lisp/progmodes/c-ts-mode.el | 2 | ||||
| -rw-r--r-- | lisp/vc/vc-git.el | 19 | ||||
| -rw-r--r-- | test/lisp/vc/vc-git-tests.el | 17 |
4 files changed, 33 insertions, 12 deletions
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el index 6a7a3f41746..6f201f9c3df 100644 --- a/lisp/gnus/gnus-art.el +++ b/lisp/gnus/gnus-art.el | |||
| @@ -8331,11 +8331,10 @@ url is put as the `gnus-button-url' overlay property on the button." | |||
| 8331 | (when (looking-at "\\([A-Za-z]+\\):") | 8331 | (when (looking-at "\\([A-Za-z]+\\):") |
| 8332 | (setq scheme (match-string 1)) | 8332 | (setq scheme (match-string 1)) |
| 8333 | (goto-char (match-end 0))) | 8333 | (goto-char (match-end 0))) |
| 8334 | (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/") | 8334 | (when (looking-at "//\\([^:/]+\\):?\\([0-9]+\\)?/") |
| 8335 | (setq server (match-string 1)) | 8335 | (setq server (match-string 1)) |
| 8336 | (setq port (if (stringp (match-string 3)) | 8336 | (setq port (and (match-beginning 2) |
| 8337 | (string-to-number (match-string 3)) | 8337 | (string-to-number (match-string 2)))) |
| 8338 | (match-string 3))) | ||
| 8339 | (goto-char (match-end 0))) | 8338 | (goto-char (match-end 0))) |
| 8340 | 8339 | ||
| 8341 | (cond | 8340 | (cond |
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index b99388a4074..f16e06942b9 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el | |||
| @@ -1355,7 +1355,7 @@ recommended to enable `electric-pair-mode' with this mode." | |||
| 1355 | "\\|" id "::" | 1355 | "\\|" id "::" |
| 1356 | "\\|" id ws-maybe "=\\)" | 1356 | "\\|" id ws-maybe "=\\)" |
| 1357 | "\\|" "\\(?:inline" ws "\\)?namespace" | 1357 | "\\|" "\\(?:inline" ws "\\)?namespace" |
| 1358 | "\\(:?" ws "\\(?:" id "::\\)*" id "\\)?" ws-maybe "{" | 1358 | "\\(?:" ws "\\(?:" id "::\\)*" id "\\)?" ws-maybe "{" |
| 1359 | "\\|" "class" ws id | 1359 | "\\|" "class" ws id |
| 1360 | "\\(?:" ws "final" "\\)?" ws-maybe "[:{;\n]" | 1360 | "\\(?:" ws "final" "\\)?" ws-maybe "[:{;\n]" |
| 1361 | "\\|" "struct" ws id "\\(?:" ws "final" ws-maybe "[:{\n]" | 1361 | "\\|" "struct" ws id "\\(?:" ws "final" ws-maybe "[:{\n]" |
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index a3469b71386..dfca944dc74 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el | |||
| @@ -1723,14 +1723,19 @@ This requires git 1.8.4 or later, for the \"-L\" option of \"git log\"." | |||
| 1723 | 1723 | ||
| 1724 | (declare-function vc-annotate-convert-time "vc-annotate" (&optional time)) | 1724 | (declare-function vc-annotate-convert-time "vc-annotate" (&optional time)) |
| 1725 | 1725 | ||
| 1726 | (autoload 'decoded-time-set-defaults "time-date") | ||
| 1727 | (autoload 'iso8601-parse "iso8601") | ||
| 1728 | |||
| 1726 | (defun vc-git-annotate-time () | 1729 | (defun vc-git-annotate-time () |
| 1727 | (and (re-search-forward "^[0-9a-f^]+[^()]+(.*?\\([0-9]+\\)-\\([0-9]+\\)-\\([0-9]+\\) \\(:?\\([0-9]+\\):\\([0-9]+\\):\\([0-9]+\\) \\([-+0-9]+\\)\\)? *[0-9]+) " nil t) | 1730 | (and (re-search-forward "^[0-9a-f^]+[^()]+(.*?\\([0-9]+-[0-9]+-[0-9]+\\)\\(?: \\([0-9]+:[0-9]+:[0-9]+\\) \\([-+0-9]+\\)\\)? +[0-9]+) " nil t) |
| 1728 | (vc-annotate-convert-time | 1731 | (let* ((dt (match-string 1)) |
| 1729 | (apply #'encode-time (mapcar (lambda (match) | 1732 | (dt (if (not (match-beginning 2)) dt |
| 1730 | (if (match-beginning match) | 1733 | ;; Format as ISO 8601. |
| 1731 | (string-to-number (match-string match)) | 1734 | (concat dt "T" (match-string 2) (match-string 3)))) |
| 1732 | 0)) | 1735 | (decoded (ignore-errors (iso8601-parse dt)))) |
| 1733 | '(6 5 4 3 2 1 7)))))) | 1736 | (and decoded |
| 1737 | (vc-annotate-convert-time | ||
| 1738 | (encode-time (decoded-time-set-defaults decoded))))))) | ||
| 1734 | 1739 | ||
| 1735 | (defun vc-git-annotate-extract-revision-at-line () | 1740 | (defun vc-git-annotate-extract-revision-at-line () |
| 1736 | (save-excursion | 1741 | (save-excursion |
diff --git a/test/lisp/vc/vc-git-tests.el b/test/lisp/vc/vc-git-tests.el index f12c5d3434b..b331b77cf01 100644 --- a/test/lisp/vc/vc-git-tests.el +++ b/test/lisp/vc/vc-git-tests.el | |||
| @@ -64,4 +64,21 @@ | |||
| 64 | (actual-output (vc-git--program-version))) | 64 | (actual-output (vc-git--program-version))) |
| 65 | (should (equal actual-output expected-output)))) | 65 | (should (equal actual-output expected-output)))) |
| 66 | 66 | ||
| 67 | (ert-deftest vc-git-test-annotate-time () | ||
| 68 | "Test `vc-git-annotate-time'." | ||
| 69 | (require 'vc-annotate) | ||
| 70 | (with-temp-buffer | ||
| 71 | (insert "\ | ||
| 72 | 00000000 (Foo Bar 2023-06-14 1) a | ||
| 73 | 00000001 (Foo Bar 2023-06-14 00:00:00 -0130 2) b | ||
| 74 | 00000002 (Foo Bar 2023-06-14 00:00:00 +0145 3) c | ||
| 75 | 00000003 (Foo Bar 2023-06-14 00:00:00 4) d | ||
| 76 | 00000004 (Foo Bar 0-0-0 5) \n") | ||
| 77 | (goto-char (point-min)) | ||
| 78 | (should (floatp (vc-git-annotate-time))) | ||
| 79 | (should (> (vc-git-annotate-time) | ||
| 80 | (vc-git-annotate-time))) | ||
| 81 | (should-not (vc-git-annotate-time)) | ||
| 82 | (should-not (vc-git-annotate-time)))) | ||
| 83 | |||
| 67 | ;;; vc-git-tests.el ends here | 84 | ;;; vc-git-tests.el ends here |