summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Bendersky <eliben@gmail.com>2016-10-10 06:57:53 -0700
committerEli Bendersky <eliben@gmail.com>2016-10-10 06:57:53 -0700
commitf0e7954063b1414e0756dbb7a7056b4017e57c4e (patch)
tree863995346d085cdc7c6e9905e70323c7898d227c
parent6db253a4715846a407ce17f9da7df44db475ac84 (diff)
downloadpycparser-f0e7954063b1414e0756dbb7a7056b4017e57c4e.tar.gz
Improve the behavior of pathological bad string literals a bit.
By making the first * non-greedy, performance is ~10-15% better; it still demonstrates pahological backtracking slowness (issue #61).
-rw-r--r--pycparser/c_lexer.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/pycparser/c_lexer.py b/pycparser/c_lexer.py
index b5a636c..c7443b8 100644
--- a/pycparser/c_lexer.py
+++ b/pycparser/c_lexer.py
@@ -221,7 +221,7 @@ class CLexer(object):
string_char = r"""([^"\\\n]|"""+escape_sequence+')'
string_literal = '"'+string_char+'*"'
wstring_literal = 'L'+string_literal
- bad_string_literal = '"'+string_char+'*'+bad_escape+string_char+'*"'
+ bad_string_literal = '"'+string_char+'*?'+bad_escape+string_char+'*"'
# floating constants (K&R2: A.2.5.3)
exponent_part = r"""([eE][-+]?[0-9]+)"""