Teach wmllint to detect unbalanced string quotes in macro calls,
...and fix the example.
This commit is contained in:
parent
3de9a5a1ea
commit
878f5a32a5
2 changed files with 9 additions and 3 deletions
|
@ -146,7 +146,7 @@
|
|||
name=time over
|
||||
{OLD_ORCISH_SHAMAN 32 30 Fabstep _"Fabstep"}
|
||||
{OLD_ORCISH_SHAMAN 32 30 Klebar _"Klebar"}
|
||||
{OLD_ORCISH_SHAMAN 32 30 Echarp _"Echarp""}
|
||||
{OLD_ORCISH_SHAMAN 32 30 Echarp _"Echarp"}
|
||||
# wmllint: recognize Fabstep
|
||||
# wmllint: recognize Klebar
|
||||
# wmllint: recognize Echarp
|
||||
|
|
|
@ -1827,18 +1827,24 @@ def translator(filename, mapxforms, textxform, versions):
|
|||
# Simple check for unbalanced macro calls
|
||||
unclosed = None
|
||||
linecount = 1
|
||||
depth = 0
|
||||
startline = None
|
||||
depth = quotecount = 0
|
||||
for i in range(len(transformed)):
|
||||
if transformed[i] == '\n':
|
||||
linecount += 1
|
||||
elif transformed[i] == '{':
|
||||
if depth == 0:
|
||||
unclosed = linecount
|
||||
unclosed = startline = linecount
|
||||
quotecount = 0
|
||||
depth += 1
|
||||
elif transformed[i] == '"':
|
||||
quotecount += 1
|
||||
elif transformed[i] == '}':
|
||||
depth -= 1
|
||||
if depth == 0:
|
||||
unclosed = None
|
||||
if quotecount % 2:
|
||||
print >>sys.stderr, '"%s", line %d: unbalanced quote.' % (filename, startline)
|
||||
if unclosed:
|
||||
print >>sys.stderr, '"%s", line %d: unbalanced {.' % (filename, unclosed)
|
||||
# Return None if the transformation functions made no changes.
|
||||
|
|
Loading…
Add table
Reference in a new issue