Skip to content
This repository has been archived by the owner on Oct 16, 2021. It is now read-only.

Commit

Permalink
Convert embedded quotes in strings correctly
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mmallick-ca committed Oct 14, 2017
1 parent d7f14d1 commit 039aa4e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tools/conversion_tool/ebcdic2ascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 039aa4e

Please sign in to comment.