Fix modify_pc.py script to parse symbols in pc file properly 03/321203/1 accepted/tizen_unified accepted/tizen_unified_x tizen accepted/tizen/unified/20250318.072944 accepted/tizen/unified/20250509.015124 accepted/tizen/unified/x/20250318.211719 accepted/tizen/unified/x/20250509.034520
authorSangYoun Kwak <sy.kwak@samsung.com>
Mon, 17 Mar 2025 08:18:53 +0000 (17:18 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Mon, 17 Mar 2025 08:34:41 +0000 (17:34 +0900)
In the modify_pc.py script, regular expressions are used to parse
symbols and values. There are symbols separated from its value by a
colon(':') and by a equal sign('='). These two symbols are parsed by
regular expression but these regular expressions are incomplete since
content like below cannot be parsed properly.
  Cflags: -DAAAA=1 -DBBBB=...
In this case, it should be recognized as a colon symbol, which symbol is
"Cflags" and value is "-DAAAA=1 -DBBBB=...". But because of '=' in the
value, it was parsed as: symbol is "-DAAAA", value is "1 -DBBBB=...".

To resolve this bug issue, two anchors '^' and '$' are added to the
regular expression to represent the beginning and end of a string,
respectively.

Change-Id: I12b9b6eb2eba4142ac72ab7e01b6e428c7ed75d4
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
modify_pc.py

index c1ea980046d320fe706df4e6e8fffbd344ab4cac..c7171d6d853bbca055a8d000eb0da563e5ff5b7d 100755 (executable)
@@ -21,8 +21,8 @@ class UnknownVariableException(Exception):
 
 class PkgConfig:
     regex_comment = compile_regex("([^#]*)(#.*)?")
-    regex_assignment = compile_regex("\\s*([-_a-zA-Z0-9]+)\\s*=\\s*([^\\s]*)")
-    regex_declaration = compile_regex("\\s*([-_a-zA-Z0-9]+)\\s*:\\s*(.*)\\s*")
+    regex_assignment = compile_regex("^\\s*([-_a-zA-Z0-9]+)\\s*=\\s*([^\\s]*)$")
+    regex_declaration = compile_regex("^\\s*([-_a-zA-Z0-9]+)\\s*:\\s*(.*)\\s*$")
     regex_substitution = compile_regex("\\${([-_a-zA-Z0-9]+)}")
     regex_root_substitution = compile_regex("^-([a-zA-Z])/(.*)$")