wmllint: Fix abnormal behavior on #ifver/#ifnver...

...directives creating false positives

See also: http://forums.wesnoth.org/viewtopic.php?f=21&t=34779
This commit is contained in:
Ignacio R. Morelle 2011-09-13 23:04:21 +00:00
parent 0f1c29df42
commit d64927bf9c
2 changed files with 9 additions and 2 deletions

View file

@ -15,6 +15,7 @@ Version 1.9.9+svn:
ON_DIFFICULTY4, TURNS4, GOLD4, INCOME4, and ATTACK_DEPTH4.
* Miscellaneous and bug fixes:
* Fixed compilation on all Debian architectures (Debian bug #636193)
* Fixed handling of #ifver and #ifnver preprocessor directives in wmllint
Version 1.9.9:
* AI:

View file

@ -53,7 +53,7 @@ def isDirective(elem):
"Identify things that shouldn't be indented."
if isinstance(elem, WmlIterator):
elem = elem.element
for prefix in ("#ifdef", "#ifndef", "#ifhave", "#ifnhave", "#else", "#endif", "#define", "#enddef", "#undef"):
for prefix in ("#ifdef", "#ifndef", "#ifhave", "#ifnhave", "#ifver", "#ifnver", "#else", "#endif", "#define", "#enddef", "#undef"):
if elem.startswith(prefix):
return True
return False
@ -216,11 +216,13 @@ Important Attributes:
keys: either "key=" or ("key1=", "key2=") for multi-assignment
key= - does not affect the scope
key1,key2= - multi-assignment returns multiple elements
directives: one of "#ifdef", "#ifndef", "#ifhave", "#ifnhave", "#else", "#endif", "#define", "#enddef"
directives: one of "#ifdef", "#ifndef", "#ifhave", "#ifnhave", "#ifver", "#ifnver", "#else", "#endif", "#define", "#enddef"
#ifdef - opens a scope
#ifndef - opens a scope
#ifhave - opens a scope
#ifnhave - opens a scope
#ifver - opens a scope
#ifnver - opens a scope
#else - closes a scope, also opens a new scope
#endif - closes a scope
#define - opens a scope
@ -261,6 +263,10 @@ Important Attributes:
return (['#ifhave'],)*2
elif text.startswith('#ifnhave'):
return (['#ifnhave'],)*2
elif text.startswith('#ifver'):
return (['#ifver'],)*2
elif text.startswith('#ifnver'):
return (['#ifnver'],)*2
elif text.startswith('#else'):
if not self.closeScope(self.scopes, '#else'):
self.printScopeError('#else')