Two minor bugfixes
Martin Stein <[email protected]> Wed, 11 Feb 2015 23:47:09 +0100
| Newsgroups | gmane.emacs.cedet |
|---|---|
| Message-ID | <[email protected]> |
First bug: File: 0001-Check-that-bounds-is-non-nil-in-semantic-ia-complete.patch In semantic-ia-complete-symbol-menu in ia.el a check whether bounds are valid is missing. There is a check in semantic-ia-complete-symbol. The bug is triggered when completing something like myfun( with empty prefix (see example in commit message). Remark: In contrast to the code snippet in semantic-ia-complete-symbol I have used a let instead of having four (oref a bounds) evaluations. I also omitted the (goto-char (car (oref a bounds)), as delete-region already places point at this position. Second bug: File: 0001-Save-global-variable-wisent-lookahead-before-calling.patch The wisent parser uses some global variables, which is a bit of a hassle considering that it calls itself (via EXPANDFULL and the like). If the last token of a recursive call does not match, it can corrupt the unmatched-syntax-cache or even lead to wrong parse results. If recursive calls of the parser are only done with parenthesised blocks and rules are accordingly, then the last token must be something like ')' and thus always matches and the bug is not triggered. For languages like fortran this is different. I am very sure that the commit indeed fixes a bug and nothing more, but the wisent parser and its token stream organisation is a rather complex automaton, so I might have missed something. ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Cedet-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/cedet-devel
0001-Check-that-bounds-is-non-nil-in-semantic-ia-complete.patch
(text/x-patch, 1.3 KB)
>From be8a53f750238b0cba5177671f482ceec78656fd Mon Sep 17 00:00:00 2001 From: Martin Stein <[email protected]> Date: Wed, 11 Feb 2015 23:27:03 +0100 Subject: [PATCH] Check that bounds is non nil in semantic-ia-complete-symbol-menu Delete region fails if bounds are nil. Bunds are nil if we are completing an empty prefix string, e.g. type constrained within a function argument list. Example (in C) void myfun(int x) { ... } int main() { int locvar; myfun(*try to complete here choosing locvar* } --- lisp/cedet/semantic/ia.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lisp/cedet/semantic/ia.el b/lisp/cedet/semantic/ia.el index 67fc809..e6d71ef 100644 --- a/lisp/cedet/semantic/ia.el +++ b/lisp/cedet/semantic/ia.el @@ -188,7 +188,11 @@ Completion options are calculated with `semantic-analyze-possible-completions'." (when ans (if (not (semantic-tag-p ans)) (setq ans (aref (cdr ans) 0))) - (delete-region (car (oref a bounds)) (cdr (oref a bounds))) + (let ((bnds (oref a bounds))) + ;; bounds could be nil if we are completing an empty prefix string + ;; (e.g. type constrained within a function argument list) + (when (and (car bnds) (cdr bnds)) + (delete-region (car bnds) (cdr bnds)))) (semantic-ia-insert-tag ans)) )))) -- 1.9.1
0001-Save-global-variable-wisent-lookahead-before-calling.patch
(text/x-patch, 2 KB)
>From cd7567a61566e375a9186345b03938469cfb22e8 Mon Sep 17 00:00:00 2001 From: Martin Stein <[email protected]> Date: Mon, 19 Jan 2015 22:26:02 +0100 Subject: [PATCH] Save global variable wisent-lookahead before calling semantic action The semantic action might be an EXPAND, EXPANDFULL or some similar action calling the parser recursively. If the last token of the recursively called parsing step failed to match it ends up in wisent-lookahead, and function wisent-parse-stream pushs it back onto wisent-lex-istream. From there on it simply ends up occuring twice on the unmatched-syntax-cache, or worse might even lead to parse errors in rare cases. --- lisp/cedet/semantic/wisent/wisent.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lisp/cedet/semantic/wisent/wisent.el b/lisp/cedet/semantic/wisent/wisent.el index 3278838..fb98c7a 100644 --- a/lisp/cedet/semantic/wisent/wisent.el +++ b/lisp/cedet/semantic/wisent/wisent.el @@ -376,7 +376,7 @@ automaton has only one entry point." (wisent-parse-lexer-function lexer) (wisent-recovering nil) (wisent-input (wisent-parse-start start starts)) - state tokid choices choice) + state tokid choices choice wisent-lookahead-save) (setq wisent-nerrs 0 ;; Reset parse error counter wisent-lookahead nil) ;; and lookahead token (aset stack 0 0) ;; Initial state @@ -468,7 +468,12 @@ automaton has only one entry point." ;; Reduce by rule (call semantic action) ;; ------------------------------------- (t + ;; save the global variable wisent-lookahead, + ;; as the semantic action might be an expand or expandfull + ;; which calls this function recursively + (setq wisent-lookahead-save wisent-lookahead) (setq sp (funcall wisent-loop stack sp gotos)) + (setq wisent-lookahead wisent-lookahead-save) (or wisent-input (setq wisent-input (wisent-lexer)))))) (run-hooks 'wisent-post-parse-hook) (car (aref stack 1)))) -- 1.9.1