From 039aa4efa2b1dfdd072fb089bf8ba0a938bb7f61 Mon Sep 17 00:00:00 2001 From: Muntasir Mallick Date: Fri, 13 Oct 2017 23:11:07 -0400 Subject: [PATCH] Convert embedded quotes in strings correctly The regular expression which identifies strings literals in source can not handle the case when a quote character is embedded in the string. For example "Convert \"this\"" would not convert correctly due to the embedded \" characters in the string. In order to avoid this situation we can preprocess all the escape sequences in the source prior to trying to identify string and character literals. --- tools/conversion_tool/ebcdic2ascii.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/conversion_tool/ebcdic2ascii.py b/tools/conversion_tool/ebcdic2ascii.py index 36e15c1dfadf..c176ec724708 100755 --- a/tools/conversion_tool/ebcdic2ascii.py +++ b/tools/conversion_tool/ebcdic2ascii.py @@ -195,7 +195,7 @@ def convert_to_ascii(filenames, unicode_encode, skip_print_strings, \ # main loop which identifies and encodes literals with hex escape sequences for line in Source: - + # logic for line continuations; appends the lines if prev_line is not None: line = prev_line + line @@ -223,6 +223,9 @@ def convert_to_ascii(filenames, unicode_encode, skip_print_strings, \ # if it isn't to be skipped if not skip_line and not include_line: + #convert all the escape sequences first + line = re.sub(ESCAPE_RE, EncodeEscapeSeq, line); + tokens_of_interest = re.split(SPLIT_RE, line) tokens_of_interest = filter(None, tokens_of_interest)