[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/company 93415dc 2/2: company-gtags--annotation: Fortify
From: |
ELPA Syncer |
Subject: |
[elpa] externals/company 93415dc 2/2: company-gtags--annotation: Fortify against nested parens in args |
Date: |
Sun, 17 Jan 2021 19:57:07 -0500 (EST) |
branch: externals/company
commit 93415dcef014b8aad21633bae1dabecc28742df1
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
company-gtags--annotation: Fortify against nested parens in args
#1055
---
company-gtags.el | 10 ++++++++--
test/gtags-tests.el | 7 +++++++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/company-gtags.el b/company-gtags.el
index 983a5e6..7c93bf0 100644
--- a/company-gtags.el
+++ b/company-gtags.el
@@ -116,8 +116,14 @@ completion."
(defun company-gtags--annotation (arg)
(let ((meta (get-text-property 0 'meta arg)))
- (when (string-match (concat (regexp-quote arg) "\\(([^\)]*)\\).*") meta)
- (match-string 1 meta))))
+ (when (string-match (concat (regexp-quote arg) " *(") meta)
+ (with-temp-buffer
+ (let ((start (match-end 0)))
+ (insert meta)
+ (goto-char start)
+ (forward-sexp)
+ (buffer-substring-no-properties
+ start (point)))))))
;;;###autoload
(defun company-gtags (command &optional arg &rest ignored)
diff --git a/test/gtags-tests.el b/test/gtags-tests.el
index 241f510..7dfd77e 100644
--- a/test/gtags-tests.el
+++ b/test/gtags-tests.el
@@ -53,3 +53,10 @@
"interrupt_context"
'meta "struct interrupt_context")))
(should (null (company-gtags 'annotation str)))))
+
+(ert-deftest company-gtags-C-function-with-lots-of-parens-in-arg ()
+ (let ((str (propertize
+ "test"
+ 'meta "static void test(void (*foo)(void (*bar)(void)))")))
+ (should (equal (company-gtags 'annotation str)
+ "(void (*foo)(void (*bar)(void)))"))))