Skip to content

Commit

Permalink
python: Fix parsing of variables assigned to triple quoted strings
Browse files Browse the repository at this point in the history
  • Loading branch information
b4n committed Jan 28, 2015
1 parent c16f0b8 commit 8efb7be
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 34 deletions.
1 change: 1 addition & 0 deletions Units/bug1906062.py.t/expected.tags
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include_file input.py /^include_file = '''$/;" v
66 changes: 32 additions & 34 deletions python.c
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,38 @@ static void findPythonTags (void)

checkParent(nesting_levels, indent, parent);

/* Find global and class variables */
variable = findVariable(line);
if (variable)
{
const char *start = variable;
char *arglist;
boolean parent_is_class;

vStringClear (name);
while (isIdentifierCharacter ((int) *start))
{
vStringPut (name, (int) *start);
++start;
}
vStringTerminate (name);

parent_is_class = constructParentString(nesting_levels, indent, parent);
if (varIsLambda (variable, &arglist))
{
/* show class members or top-level script lambdas only */
if (parent_is_class || vStringLength(parent) == 0)
makeFunctionTag (name, parent, parent_is_class, arglist);
eFree (arglist);
}
else
{
/* skip variables in methods */
if (parent_is_class || vStringLength(parent) == 0)
makeVariableTag (name, parent);
}
}

/* Deal with multiline string start. */
longstring = find_triple_start(cp, &longStringLiteral);
if (longstring)
Expand Down Expand Up @@ -848,40 +880,6 @@ static void findPythonTags (void)
addNestingLevel(nesting_levels, indent, name, is_class);
}
}
/* Find global and class variables */
variable = findVariable(line);
if (variable)
{
const char *start = variable;
char *arglist;
boolean parent_is_class;

vStringClear (name);
while (isIdentifierCharacter ((int) *start))
{
vStringPut (name, (int) *start);
++start;
}
vStringTerminate (name);

parent_is_class = constructParentString(nesting_levels, indent, parent);

if (varIsLambda (variable, &arglist))
{
/* show class members or top-level script lambdas only */
if (parent_is_class || vStringLength(parent) == 0)
makeFunctionTag (name, parent, parent_is_class, arglist);
eFree (arglist);
}
else
{
/* skip variables in methods */
if (! parent_is_class && vStringLength(parent) > 0)
continue;

makeVariableTag (name, parent);
}
}
/* Find and parse imports */
parseImports(line);
}
Expand Down

0 comments on commit 8efb7be

Please sign in to comment.