diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-08-01 05:52:04 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-08-01 05:52:04 +0000 |
commit | 1661066e58e04d2ecc5dbfaeca7f1514c129c8a0 (patch) | |
tree | 981ed8b930d933f562e3e9e4d13bc106cb4afde5 /clang | |
parent | e65f4de30decd39cb9b6c37f2a952cccaa278b1f (diff) | |
download | bcm5719-llvm-1661066e58e04d2ecc5dbfaeca7f1514c129c8a0.tar.gz bcm5719-llvm-1661066e58e04d2ecc5dbfaeca7f1514c129c8a0.zip |
lit: Fix two sh lexing bugs.
- '\\\\' inside a "..." string becomes '\\'.
- The '<' token wasn't being recognized.
llvm-svn: 77777
Diffstat (limited to 'clang')
-rw-r--r-- | clang/utils/test/ShUtil.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/clang/utils/test/ShUtil.py b/clang/utils/test/ShUtil.py index 3878f5961de..76d3f585b1a 100644 --- a/clang/utils/test/ShUtil.py +++ b/clang/utils/test/ShUtil.py @@ -2,6 +2,9 @@ import itertools 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): self.data = data @@ -82,9 +85,12 @@ class ShLexer: self.data) return str c = self.eat() - if c != delim: + if c == '"': # + str += '"' + elif c == '\\': str += '\\' - str += c + else: + str += '\\' + c else: str += c Util.warning("missing quote character in %r" % self.data) @@ -135,6 +141,7 @@ class ShLexer: return ('<&',) if self.maybe_eat('>'): return ('<<',) + return (c,) return self.lex_arg(c) @@ -282,8 +289,9 @@ class TestShLexer(unittest.TestCase): return list(ShLexer(str).lex()) def test_basic(self): - self.assertEqual(self.lex('a|b>c&d'), - ['a', ('|',), 'b', ('>',), 'c', ('&',), 'd']) + self.assertEqual(self.lex('a|b>c&d<e'), + ['a', ('|',), 'b', ('>',), 'c', ('&',), 'd', + ('<',), 'e']) def test_redirection_tokens(self): self.assertEqual(self.lex('a2>c'), @@ -298,6 +306,8 @@ class TestShLexer(unittest.TestCase): ['hello"world']) self.assertEqual(self.lex(""" "hello\\'world" """), ["hello\\'world"]) + self.assertEqual(self.lex(""" "hello\\\\world" """), + ["hello\\world"]) self.assertEqual(self.lex(""" he"llo wo"rld """), ["hello world"]) |