b4n left a comment (geany/geany#4303) > > I think ctags main should make sure such things don't happen because > > parsers can be tricky to get right. > > Done in the last commit of #4330 and it fixes the hang for me. It was also > pretty straightforward. What do you think?
That I had that in my diff awaiting cleanup and committing this afternoon :laughing: ```diff diff --git a/ctags/main/promise.c b/ctags/main/promise.c index 01e84f5ca..fa723ca31 100644 --- a/ctags/main/promise.c +++ b/ctags/main/promise.c @@ -62,6 +62,39 @@ static void attachPromiseModifier (int promise, void *data); +static bool isPromiseRedundant(const char *parser, int lang, + unsigned long startLine, long startCharOffset, + unsigned long endLine, long endCharOffset, + unsigned long sourceLineOffset) +{ + int i; + + /* look at previous promises, to check if there's one with the same language + * at the same offsets (or a superset) */ + for (i = 0; i < promise_count; i++) + { + struct promise *p = promises + i; + + if (lang != p->lang) + continue; + if (startLine > p->endLine) + continue; + if (startLine == p->endLine && startCharOffset > p->endCharOffset) + continue; + if (endLine < p->startLine) + continue; + if (endLine == p->startLine && endCharOffset < p->startCharOffset) + continue; + + verbose("redundant with existing promise %s start(line: %lu, offset: %ld, srcline: %lu), end(line: %lu, offset: %ld)!\n", + parser ? parser : "*", + p->startLine, p->startCharOffset, p->sourceLineOffset, p->endLine, p->endCharOffset); + return true; + } + + return false; +} + int makePromise (const char *parser, unsigned long startLine, long startCharOffset, unsigned long endLine, long endCharOffset, @@ -96,6 +129,9 @@ int makePromise (const char *parser, return -1; } + if (isPromiseRedundant (parser, lang, startLine, startCharOffset, endLine, endCharOffset, sourceLineOffset)) + return -1; + if ( promise_count == promise_allocated) { size_t c = promise_allocated? (promise_allocated * 2): 8; ``` -- Reply to this email directly or view it on GitHub: https://github.com/geany/geany/pull/4303#issuecomment-2971517395 You are receiving this because you are subscribed to this thread. Message ID: <geany/geany/pull/4303/c2971517...@github.com>