From b181fa6013d30a06b310b367caa5039435b085d0 Mon Sep 17 00:00:00 2001 From: NeilZar Date: Sat, 5 Jan 2019 03:10:40 +0100 Subject: [PATCH] Fix # command in sqf_validator.py (#6768) **When merged this pull request will:** - Fix the sqf validator to correctly detect the use of # as select or preprocessor command. --- tools/sqf_validator.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/sqf_validator.py b/tools/sqf_validator.py index c45f0f94f2..6686004ac4 100644 --- a/tools/sqf_validator.py +++ b/tools/sqf_validator.py @@ -48,6 +48,7 @@ def check_sqf_syntax(filepath): lastIsCurlyBrace = False checkForSemicolon = False + onlyWhitespace = True # Extra information so we know what line we find errors at lineNumber = 1 @@ -61,6 +62,7 @@ def check_sqf_syntax(filepath): checkForSemicolon = not re.search('findIf', content, re.IGNORECASE) if c == '\n': # Keeping track of our line numbers + onlyWhitespace = True # reset so we can see if # is for a preprocessor command lineNumber += 1 # so we can print accurate line number information when we detect a possible error if (isInString): # while we are in a string, we can ignore everything else, except the end of the string if (c == inStringType): @@ -84,7 +86,7 @@ def check_sqf_syntax(filepath): if (c == '"' or c == "'"): isInString = True inStringType = c - elif (c == '#'): + elif (c == '#' and onlyWhitespace): ignoreTillEndOfLine = True elif (c == '/'): checkIfInComment = True @@ -114,6 +116,9 @@ def check_sqf_syntax(filepath): print("ERROR: Tab detected at {0} Line number: {1}".format(filepath,lineNumber)) bad_count_file += 1 + if (c not in [' ', '\t', '\n']): + onlyWhitespace = False + if (checkForSemicolon): if (c not in [' ', '\t', '\n', '/']): # keep reading until no white space or comments checkForSemicolon = False