[cfe-commits] r77957 - in /cfe/trunk/utils/test: ShUtil.py TestRunner.py
Daniel Dunbar
daniel at zuster.org
Sun Aug 2 22:29:23 PDT 2009
Author: ddunbar
Date: Mon Aug 3 00:29:22 2009
New Revision: 77957
URL: http://llvm.org/viewvc/llvm-project?rev=77957&view=rev
Log:
lit: Don't treat '\' as an escape in unquoted strings, on Win32. This turns out
to not be a very good idea.
Modified:
cfe/trunk/utils/test/ShUtil.py
cfe/trunk/utils/test/TestRunner.py
Modified: cfe/trunk/utils/test/ShUtil.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/test/ShUtil.py?rev=77957&r1=77956&r2=77957&view=diff
==============================================================================
--- cfe/trunk/utils/test/ShUtil.py (original)
+++ cfe/trunk/utils/test/ShUtil.py Mon Aug 3 00:29:22 2009
@@ -2,14 +2,12 @@
import Util
-# FIXME: It would be nice to at least match a few other things like `...`, $(
-# ... ), $VAR, etc., if only so we can nicely say "we don't support this".
-
class ShLexer:
- def __init__(self, data):
+ def __init__(self, data, win32Escapes = False):
self.data = data
self.pos = 0
self.end = len(data)
+ self.win32Escapes = win32Escapes
def eat(self):
c = self.data[self.pos]
@@ -67,8 +65,8 @@
return (tok[0], num)
elif c == '"':
self.eat()
- str += self.lex_arg_quoted('"')
- elif c == '\\':
+ str += self.lex_arg_quoted('"')
+ elif not self.win32Escapes and c == '\\':
# Outside of a string, '\\' escapes everything.
self.eat()
if self.pos == self.end:
@@ -211,9 +209,9 @@
(other.lhs, other.op, other.rhs))
class ShParser:
- def __init__(self, data):
+ def __init__(self, data, win32Escapes = False):
self.data = data
- self.tokens = ShLexer(data).lex()
+ self.tokens = ShLexer(data, win32Escapes = win32Escapes).lex()
def lex(self):
try:
@@ -294,8 +292,8 @@
import unittest
class TestShLexer(unittest.TestCase):
- def lex(self, str):
- return list(ShLexer(str).lex())
+ def lex(self, str, *args, **kwargs):
+ return list(ShLexer(str, *args, **kwargs).lex())
def test_basic(self):
self.assertEqual(self.lex('a|b>c&d<e'),
@@ -323,6 +321,8 @@
["a b", "a\\b"])
self.assertEqual(self.lex(""" "" "" """),
["", ""])
+ self.assertEqual(self.lex(""" a\\ b """, win32Escapes = True),
+ ['a\\', 'b'])
class TestShParse(unittest.TestCase):
def parse(self, str):
Modified: cfe/trunk/utils/test/TestRunner.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/test/TestRunner.py?rev=77957&r1=77956&r2=77957&view=diff
==============================================================================
--- cfe/trunk/utils/test/TestRunner.py (original)
+++ cfe/trunk/utils/test/TestRunner.py Mon Aug 3 00:29:22 2009
@@ -110,7 +110,8 @@
return exitCode
def executeScriptInternal(cfg, commands, cwd):
- cmd = ShUtil.ShParser(' &&\n'.join(commands)).parse()
+ cmd = ShUtil.ShParser(' &&\n'.join(commands),
+ kSystemName == 'Windows').parse()
results = []
try:
More information about the cfe-commits
mailing list