Skip to content

Commit

Permalink
Fixed regex escape warnings for class parser
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Apr 7, 2024
1 parent a3fb72a commit 83646ad
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions class_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
DEBUG = 0

# The pytsk3 version.
VERSION = "20231007"
VERSION = "20240407"

# These functions are used to manage library memory.
FREE = "aff4_free"
Expand Down Expand Up @@ -2315,8 +2315,8 @@ def write(self, out):


class Method(object):
default_re = re.compile("DEFAULT\(([A-Z_a-z0-9]+)\) =(.+);")
exception_re = re.compile("RAISES\(([^,]+),\s*([^\)]+)\) =(.+);")
default_re = re.compile(r"DEFAULT\(([A-Z_a-z0-9]+)\) =(.+);")
exception_re = re.compile(r"RAISES\(([^,]+),\s*([^\)]+)\) =(.+);")
typedefed_re = re.compile(r"struct (.+)_t \*")

def __init__(
Expand Down Expand Up @@ -4117,11 +4117,11 @@ class HeaderParser(lexer.SelfFeederMixIn):
["CCLASS", "END_CCLASS", "END_CCLASS,POP_STATE", None],

# Recognize struct definitions (With name)
["INITIAL", "([A-Z_a-z0-9 ]+)?struct\s+([A-Z_a-z0-9]+)\s+{",
["INITIAL", r"([A-Z_a-z0-9 ]+)?struct\s+([A-Z_a-z0-9]+)\s+{",
"PUSH_STATE,STRUCT_START", "STRUCT"],

# Without name (using typedef)
["INITIAL", "typedef\s+struct\s+{",
["INITIAL", r"typedef\s+struct\s+{",
"PUSH_STATE,TYPEDEF_STRUCT_START", "STRUCT"],

["STRUCT", r"^\s*([0-9A-Z_a-z ]+\s+\*?)\s*([A-Z_a-z0-9]+)(?:\[([A-Z_a-z0-9]+)\])?\s*;",
Expand All @@ -4131,13 +4131,13 @@ class HeaderParser(lexer.SelfFeederMixIn):
"STRUCT_ATTRIBUTE_PTR", None],

# Struct ended with typedef
["STRUCT", "}\s+([0-9A-Za-z_]+);", "POP_STATE,TYPEDEF_STRUCT_END", None],
["STRUCT", r"}\s+([0-9A-Za-z_]+);", "POP_STATE,TYPEDEF_STRUCT_END", None],
["STRUCT", "}", "POP_STATE,STRUCT_END", None],

# Handle recursive struct or union definition (At the moment
# we cant handle them at all)
["(RECURSIVE_)?STRUCT", "(struct|union)\s+([_A-Za-z0-9]+)?\s*{", "PUSH_STATE", "RECURSIVE_STRUCT"],
["RECURSIVE_STRUCT", "}\s+[0-9A-Za-z]+", "POP_STATE", None],
["(RECURSIVE_)?STRUCT", r"(struct|union)\s+([_A-Za-z0-9]+)?\s*{", "PUSH_STATE", "RECURSIVE_STRUCT"],
["RECURSIVE_STRUCT", r"}\s+[0-9A-Za-z]+", "POP_STATE", None],
["RECURSIVE_STRUCT", "};", "POP_STATE", None],

# Process enums (2 forms - named and typedefed)
Expand Down
4 changes: 2 additions & 2 deletions dpkg/changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pytsk3 (20231007-1) unstable; urgency=low
pytsk3 (20240407-1) unstable; urgency=low

* Auto-generated

-- Joachim Metz <joachim.metz@gmail.com> Sat, 07 Oct 2023 12:22:28 -0100
-- Joachim Metz <joachim.metz@gmail.com> Sun, 07 Apr 2024 10:22:07 -0100
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = pytsk3
version = 20231007
version = 20240407
description = Python bindings for the SleuthKit
long_description = Python bindings for the SleuthKit
author = Michael Cohen
Expand Down

0 comments on commit 83646ad

Please sign in to comment.