From 8455f8e70d608bf2cc689af4d335482cc962ea8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Techet?= Date: Wed, 15 Feb 2017 00:31:10 +0100 Subject: [PATCH] lcpp, c: Fix signature collection First, make sure that when calling cppGetc() and cppUngetc() the signature is properly updated. Second, make sure that signature is cleared when preparing for new token read. --- ctags/main/lcpp.c | 10 ++++++++++ ctags/main/lcpp.h | 1 + ctags/parsers/c.c | 1 + tests/ctags/bug507864.c.tags | 4 ++-- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ctags/main/lcpp.c b/ctags/main/lcpp.c index 35c6e655..9fe28254 100644 --- a/ctags/main/lcpp.c +++ b/ctags/main/lcpp.c @@ -175,6 +175,8 @@ extern void cppUngetc (const int c) Assert (Cpp.ungetch2 == '\0'); Cpp.ungetch2 = Cpp.ungetch; Cpp.ungetch = c; + if (collectingSignature) + vStringChop (signature); } static inline int getcAndCollect () @@ -681,6 +683,8 @@ extern int cppGetc (void) c = Cpp.ungetch; Cpp.ungetch = Cpp.ungetch2; Cpp.ungetch2 = '\0'; + if (collectingSignature) + vStringPut (signature, c); return c; /* return here to avoid re-calling debugPutc () */ } else do @@ -1009,3 +1013,9 @@ extern void cppStopCollectingSignature (void) { collectingSignature = false; } + +extern void cppClearSignature (void) +{ + signature = vStringNewOrClear (signature); + collectingSignature = false; +} diff --git a/ctags/main/lcpp.h b/ctags/main/lcpp.h index 13b37dff..46bd1513 100644 --- a/ctags/main/lcpp.h +++ b/ctags/main/lcpp.h @@ -75,5 +75,6 @@ extern int cppSkipOverCComment (void); extern char *cppGetSignature (void); extern void cppStartCollectingSignature (void); extern void cppStopCollectingSignature (void); +extern void cppClearSignature (void); #endif /* CTAGS_MAIN_GET_H */ diff --git a/ctags/parsers/c.c b/ctags/parsers/c.c index f1855f28..f55f0b39 100644 --- a/ctags/parsers/c.c +++ b/ctags/parsers/c.c @@ -955,6 +955,7 @@ static void reinitStatement (statementInfo *const st, const bool partial) initToken (st->context); initToken (st->blockName); vStringClear (st->parentClasses); + cppClearSignature (); /* Init member info. */ if (! partial) diff --git a/tests/ctags/bug507864.c.tags b/tests/ctags/bug507864.c.tags index bcb03177..65041ccb 100644 --- a/tests/ctags/bug507864.c.tags +++ b/tests/ctags/bug507864.c.tags @@ -1,5 +1,5 @@ # format=tagmanager -ENTSEQNOÌ16Í(eq)Ö0ÏFUNCSTS +ENTSEQNOÌ16Í(seq)Ö0ÏFUNCSTS MEMTXTÌ16Í(mail)Ö0Ï -MEMTXTÌ1024Í(orm_msg)Ö0ÏFUNCSTS +MEMTXTÌ1024Í(form_msg)Ö0ÏFUNCSTS MEMTXTÌ1024Í(text)Ö0Ï