Enrico Tröger fixed a bug with triple strings inside other strings (bug #1988130).

git-svn-id: svn://svn.code.sf.net/p/ctags/code/trunk@669 c5d04d22-be80-434c-894e-aa346cc9e8e8
This commit is contained in:
elias 2008-06-11 13:50:46 +00:00
parent c0d12ba3cf
commit 43b8d6c03f
3 changed files with 32 additions and 8 deletions

1
NEWS
View File

@ -1,6 +1,7 @@
Current Version: @VERSION@
ctags-@VERSION@ (@DATE@)
* Fixed detection of triple strings inside other strings [Python, But #1988130].
* Fixed an endless loop with comments in triple strings [Python, Bug #1988027].
* Fixed bug where functions were sometimes seen as methods [Python, Bug #1988026].
* Added support for VHDL [VHDL, Bug #1943306].

7
Test/bug1988130.py Normal file
View File

@ -0,0 +1,7 @@
def testFunc():
print 'The following works now' + '"""'
def main():
print 'nothing'
print 'This is another quoted triple string: """.'
return 0

View File

@ -366,14 +366,29 @@ static void addNestingLevel(NestingLevels *nls, int indentation,
/* Return a pointer to the start of the next triple string, or NULL. Store
* the kind of triple string in "which" if the return is not NULL.
*/
static char *find_triple_start(char const *string, char const **which)
{
char *s;
if ((s = strstr (string, doubletriple)))
*which = doubletriple;
else if ((s = strstr (string, singletriple)))
*which = singletriple;
return s;
static char const *find_triple_start(char const *string, char const **which)
{
char const *cp = string;
for (; *cp; cp++)
{
if (*cp == '"' || *cp == '\'')
{
if (strcmp(cp, doubletriple) == 0)
{
*which = doubletriple;
return cp;
}
if (strcmp(cp, singletriple) == 0)
{
*which = singletriple;
return cp;
}
cp = skipString(cp);
if (!*cp) break;
}
}
return NULL;
}
/* Find the end of a triple string as pointed to by "which", and update "which"
@ -457,6 +472,7 @@ static void findPythonTags (void)
* string. I.e. we don't parse for any tags in the rest of the
* line, but we do look for the string ending of course.
*/
/* FIXME: can we actually write to the string here? */
*longstring = '\0';
longstring += 3;