This fixes situation when wmllint tried to add description=_"fireball"
to the following WML code:
[filter]
[filter_wml]
[not]
[attack]
name=fireball
[/attack]
[/not]
[/filter_wml]
[/filter]
Tags within [filter_wml] don't need to have all mandatory arguments
(like "description"), because:
1) they are temporary constructs and this description is never used,
2) such WML code expects that results will be filtered ONLY by name.
Adding description will remove results that have the same attack name
but different description.
The first bug happened when there were two or more square braces in a file name: only one expansion was performed, instead of all of them being applied at once.
The second bug happened when a square brace range had leading zeros: these were just removed, resulting in false positives.
The main reason for moving this to a separate function was to make the
per-event variables local to that function.
(cherry picked from commit 7e69da7f68)
The problem is that when parsing #textdomain directives, the parser
expects the directive to be at the start of the line. So if the directive
is preceded by spaces or tabs then it is treated as an attribute.
The solution is to strip all spaces and tabs on the left side of the
parsed line string when checking for #textdomain directive.
Closes#3951
The problem is that if we have a "#define" directive followed with an
empty line ending with a newline character then the parser presumes the
value is the newline character instead of the actual value (which is
located on a subsequent line).
The solution is that when parsing an empty line, if "self.in_string" is
False and "self.temp_key_nodes" is not None then we ignore the line
instead of parsing it with the "parse_outside_strings" function.
Closes#3947
When parsing binary data in the wmlparser3 script, a temporary file is
created and opened. The problem is that the temporary file is never
closed and in subsequent functions it is reopened.
The solution is first, create a list of temporary file paths to delete at
program’s exit. In the atexit’s registered cleaning function, all the
files in this list are deleted.
Then in the function that creates the temporary file, we simply close
the file after the binary data has been written in it.
Closes#3927
In the wml parser, when a node creation spans multiple lines, the code
doesn’t take in account that one of those line can contain a
#textdomain directive.
In the method “parse_outside_strings” (line 501), the code that
processes the #textdomain directive is inside an if block that is true
only if the node creation doesn’t span across multiple lines
(self.temp_key_nodes is null).
The solution implemented is that in the method “parse_outside_strings”
(line 501), the code that check if a line starts with #textdomain is
moved from inside the block that is true only if the node creation
doesn’t span across multiple lines and put in the method scope after
the first if block that checks if the line is empty.
The wml parser, when parsing the outside of a string that is
translatable, only assumed “spaces” characters could precede it. If
there are “tabs” characters the code parses the “_” character as an
attribute value.
The solution is to add a stripping code for “tabs” characters.
Code style updated based on recommendations from ProditorMagnus.
In global_sanity_check(), variables "unit_id" and "base_unit" can be
used before assignment. This happens, for example, in this WML file:
https://github.com/Dugy/Legend_of_the_Invincibles/blob/master/utils/amla.cfg#L65
... where there is a [/unit_type] tag without the matching [unit_type].
(these variables are normally initialized when [unit_type] is found)
* Fix addon manager crash if not finding the add-on
In the addon manager, there was no validation code for paths in the file
system for uploading addons. This fix adds validation at the parsing
level, so that the original code is left unchanged.
* Fixes for addon manager crash commit
Fixes include:
1. Spaces kept instead of tabs.
2. printf-style String Formatting is used since it seems to be compatible
with nearly all versions of Python.
3. A trailing line break was added to the formatted string.