mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-16 00:33:10 +00:00
[lit] Fix a shell parsing bug with ';' not separated by whitespace.
- Testing finds bugs, who knew. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174087 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a9da5c50e2
commit
63a08e09ae
@ -35,7 +35,7 @@ class ShLexer:
|
|||||||
if ('|' in chunk or '&' in chunk or
|
if ('|' in chunk or '&' in chunk or
|
||||||
'<' in chunk or '>' in chunk or
|
'<' in chunk or '>' in chunk or
|
||||||
"'" in chunk or '"' in chunk or
|
"'" in chunk or '"' in chunk or
|
||||||
'\\' in chunk):
|
';' in chunk or '\\' in chunk):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
self.pos = self.pos - 1 + len(chunk)
|
self.pos = self.pos - 1 + len(chunk)
|
||||||
@ -48,7 +48,7 @@ class ShLexer:
|
|||||||
str = c
|
str = c
|
||||||
while self.pos != self.end:
|
while self.pos != self.end:
|
||||||
c = self.look()
|
c = self.look()
|
||||||
if c.isspace() or c in "|&":
|
if c.isspace() or c in "|&;":
|
||||||
break
|
break
|
||||||
elif c in '><':
|
elif c in '><':
|
||||||
# This is an annoying case; we treat '2>' as a single token so
|
# This is an annoying case; we treat '2>' as a single token so
|
||||||
@ -250,9 +250,9 @@ class TestShLexer(unittest.TestCase):
|
|||||||
return list(ShLexer(str, *args, **kwargs).lex())
|
return list(ShLexer(str, *args, **kwargs).lex())
|
||||||
|
|
||||||
def test_basic(self):
|
def test_basic(self):
|
||||||
self.assertEqual(self.lex('a|b>c&d<e'),
|
self.assertEqual(self.lex('a|b>c&d<e;f'),
|
||||||
['a', ('|',), 'b', ('>',), 'c', ('&',), 'd',
|
['a', ('|',), 'b', ('>',), 'c', ('&',), 'd',
|
||||||
('<',), 'e'])
|
('<',), 'e', (';',), 'f'])
|
||||||
|
|
||||||
def test_redirection_tokens(self):
|
def test_redirection_tokens(self):
|
||||||
self.assertEqual(self.lex('a2>c'),
|
self.assertEqual(self.lex('a2>c'),
|
||||||
@ -342,5 +342,10 @@ class TestShParse(unittest.TestCase):
|
|||||||
'||',
|
'||',
|
||||||
Pipeline([Command(['c'], [])], False)))
|
Pipeline([Command(['c'], [])], False)))
|
||||||
|
|
||||||
|
self.assertEqual(self.parse('a; b'),
|
||||||
|
Seq(Pipeline([Command(['a'], [])], False),
|
||||||
|
';',
|
||||||
|
Pipeline([Command(['b'], [])], False)))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user