BaseTools: Fix raw strings containing valid escape characters

Fixes raw regex strings that contain valid (and purposeful) escape
characters as they are being treated as individual characters rather
than the single escaped character they represent (i.e. '\t' is being
treated as a '\' and a 't' rather than a single tab character).

Signed-off-by: Joey Vagedes <joey.vagedes@gmail.com>
Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Reviewed-by: Yuwei Chen <yuwei.chen@intel.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
Joey Vagedes
2023-12-29 00:47:39 +08:00
committed by mergify[bot]
parent 7d055812cc
commit 6c488a2f39
3 changed files with 4 additions and 4 deletions

View File

@ -1926,4 +1926,4 @@ def CopyDict(ori_dict):
# Remove the c/c++ comments: // and /* */
#
def RemoveCComments(ctext):
return re.sub(r'//.*?\n|/\*.*?\*/', '\n', ctext, flags=re.S)
return re.sub('//.*?\n|/\\*.*?\\*/', '\n', ctext, flags=re.S)