Author: Armin Rigo <ar...@tunes.org> Branch: cmacros Changeset: r2237:247fc2ae6f64 Date: 2015-07-30 18:28 +0200 http://bitbucket.org/cffi/cffi/changeset/247fc2ae6f64/
Log: Replace long sequences of spaces with a single space diff --git a/cffi/cparser.py b/cffi/cparser.py --- a/cffi/cparser.py +++ b/cffi/cparser.py @@ -29,6 +29,7 @@ _r_ifdef = re.compile(r"^[ \t\r\f\v]*#\s*(if|elif|ifdef|ifndef|else|endif)" r"\b((?:[^\n\\]|\\.)*?)$", re.DOTALL | re.MULTILINE) +_r_multispaces = re.compile(r"\s+", re.MULTILINE) def _get_parser(): global _parser_cache @@ -150,6 +151,7 @@ flush() keyword = match.group(1) condition = match.group(2).replace('\\\n', '').strip() + condition = _r_multispaces.sub(' ', condition) if keyword == 'if': stack.append(condition) elif keyword == 'ifdef': @@ -160,9 +162,11 @@ condition1 = pop() stack.append('%s\x00(%s)' % (negate(condition1), condition)) elif keyword == 'else': + # 'condition' ignored here condition1 = pop() stack.append(negate(condition1)) elif keyword == 'endif': + # 'condition' ignored here pop() else: raise AssertionError(keyword) diff --git a/testing/cffi0/test_parsing.py b/testing/cffi0/test_parsing.py --- a/testing/cffi0/test_parsing.py +++ b/testing/cffi0/test_parsing.py @@ -247,10 +247,10 @@ '', None, None, - r'FOO FO\\O2', + r'FOO FO\\O2', None, None, - r'!(FOO FO\\O2) && (BARBAR2)', + r'!(FOO FO\\O2) && (BARBAR2)', None, '' ] _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit