aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiklas Claesson <nicke.claesson@gmail.com>2018-04-19 17:58:38 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2018-04-21 22:57:19 +0300
commitcb0960a91e1b250a00c0a1e4a40b7e86bc70a97d (patch)
tree923f5ed0f5930e16d497d20d77608827ce44df95
parent74404db469bc37fbe184cc708a19ccbe58bf83df (diff)
downloadmeson-cb0960a91e1b250a00c0a1e4a40b7e86bc70a97d.zip
meson-cb0960a91e1b250a00c0a1e4a40b7e86bc70a97d.tar.gz
meson-cb0960a91e1b250a00c0a1e4a40b7e86bc70a97d.tar.bz2
Remove escaping for triple-quoted strings
Fixes #3429
-rw-r--r--mesonbuild/mparser.py16
-rw-r--r--test cases/common/42 string operations/meson.build8
2 files changed, 4 insertions, 20 deletions
diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py
index 9e43065..8cef377 100644
--- a/mesonbuild/mparser.py
+++ b/mesonbuild/mparser.py
@@ -28,18 +28,6 @@ ESCAPE_SEQUENCE_SINGLE_RE = re.compile(r'''
| \\[\\'abfnrtv] # Single-character escapes
)''', re.UNICODE | re.VERBOSE)
-# This is the regex for the supported escape sequences of a multiline string
-# literal, like '''abc\x00'''. The only difference is that single quote (')
-# doesn't require escaping.
-ESCAPE_SEQUENCE_MULTI_RE = re.compile(r'''
- ( \\U........ # 8-digit hex escapes
- | \\u.... # 4-digit hex escapes
- | \\x.. # 2-digit hex escapes
- | \\[0-7]{1,3} # Octal escapes
- | \\N\{[^}]+\} # Unicode characters by name
- | \\[\\abfnrtv] # Single-character escapes
- )''', re.UNICODE | re.VERBOSE)
-
class MesonUnicodeDecodeError(MesonException):
def __init__(self, match):
super().__init__("%s" % match)
@@ -187,10 +175,6 @@ This will become a hard error in a future Meson release.""", self.getline(line_s
elif tid == 'multiline_string':
tid = 'string'
value = match_text[3:-3]
- try:
- value = ESCAPE_SEQUENCE_MULTI_RE.sub(decode_match, value)
- except MesonUnicodeDecodeError as err:
- raise MesonException("Failed to parse escape sequence: '{}' in string:\n{}".format(err.match, match_text))
lines = match_text.split('\n')
if len(lines) > 1:
lineno += len(lines) - 1
diff --git a/test cases/common/42 string operations/meson.build b/test cases/common/42 string operations/meson.build
index 1c289eb..9dfa866 100644
--- a/test cases/common/42 string operations/meson.build
+++ b/test cases/common/42 string operations/meson.build
@@ -78,14 +78,14 @@ assert('"1.1.20"'.strip('".') == '1.1.20', '". badly stripped')
assert('"1.1.20" '.strip('" ') == '1.1.20', '". badly stripped')
bs_c = '''\c'''
-bs_bs_c = '''\\\c'''
+bs_bs_c = '''\\c'''
nl = '''
'''
-bs_n = '''\\n'''
+bs_n = '''\n'''
bs_nl = '''\
'''
-bs_bs_n = '''\\\\n'''
-bs_bs_nl = '''\\\\
+bs_bs_n = '''\\n'''
+bs_bs_nl = '''\\
'''
assert('\c' == bs_c, 'Single backslash broken')