Be more careful about escaping in python REs

This commit is contained in:
Martin Mathieson 2024-07-12 14:48:31 +00:00
parent 483e3394cf
commit d6f8580675
3 changed files with 5 additions and 5 deletions

View File

@ -193,9 +193,9 @@ static const value_string cql_direction_names[] = {
};
typedef enum {
CQL_BATCH_FLAG_SERIAL_CONSISTENCY = 0x10,
CQL_BATCH_FLAG_DEFAULT_TIMESTAMP = 0x020,
CQL_BATCH_FLAG_WITH_NAME_FOR_VALUES = 0x040
CQL_BATCH_FLAG_SERIAL_CONSISTENCY = 0x10,
CQL_BATCH_FLAG_DEFAULT_TIMESTAMP = 0x20,
CQL_BATCH_FLAG_WITH_NAME_FOR_VALUES = 0x40
} cql_batch_flags;
typedef enum {

View File

@ -280,7 +280,7 @@ def removeContractions(code_string):
def removeComments(code_string):
code_string = re.sub(re.compile(r"/\*.*?\*/", re.DOTALL), "" , code_string) # C-style comment
# Avoid matching // where it is allowed, e.g., https://www... or file:///...
code_string = re.sub(re.compile(r"(?<!:)(?<!/)(?<!\")(?<!"")(?<!\"\s\s)(?<!file:/)(?<!\,\s)//.*?\n" ) ,"" , code_string) # C++-style comment
code_string = re.sub(re.compile(r"(?<!:)(?<!/)(?<!\")(?<!\")(?<!\"\s\s)(?<!file:/)(?<!\,\s)//.*?\n" ) ,"" , code_string) # C++-style comment
return code_string
def getCommentWords(code_string):

View File

@ -499,7 +499,7 @@ def checkFile(filename, common_tfs, look_for_common=False, check_value_strings=F
with open(filename, 'r') as f:
contents = f.read()
for c in common_tfs:
m = re.search(r'TFS\(\s*\&' + c + '\s*\)', contents)
m = re.search(r'TFS\(\s*\&' + c + r'\s*\)', contents)
if m:
if not c in common_usage:
common_usage[c] = 1