From 2d548244bc07ab8faf2c9c1196958007c98ad4bf Mon Sep 17 00:00:00 2001 From: Greg Noel Date: Thu, 14 May 2009 06:35:37 +0000 Subject: Issue 2410: Fix crash when using one-character identifiers in C and C++ macros. --- src/engine/SCons/cpp.py | 4 ++-- src/engine/SCons/cppTests.py | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/cpp.py b/src/engine/SCons/cpp.py index a160164..47d664c 100644 --- a/src/engine/SCons/cpp.py +++ b/src/engine/SCons/cpp.py @@ -66,10 +66,10 @@ cpp_lines_dict = { # 2) The optional parentheses and arguments (if it's a function-like # macro, '' if it's not). # 3) The expansion value. - ('define',) : '\s+([_A-Za-z][_A-Za-z0-9_]+)(\([^)]*\))?\s*(.*)', + ('define',) : '\s+([_A-Za-z][_A-Za-z0-9_]*)(\([^)]*\))?\s*(.*)', # Fetch the #undefed keyword from a #undef line. - ('undef',) : '\s+([_A-Za-z][A-Za-z0-9_]+)', + ('undef',) : '\s+([_A-Za-z][A-Za-z0-9_]*)', } # Create a table that maps each individual C preprocessor directive to diff --git a/src/engine/SCons/cppTests.py b/src/engine/SCons/cppTests.py index 1c83a13..252a064 100644 --- a/src/engine/SCons/cppTests.py +++ b/src/engine/SCons/cppTests.py @@ -300,6 +300,10 @@ macro_function_input = """ /* Make sure we don't die if the expansion isn't a string. */ #define FUNC_INTEGER(x) 1 + +/* Make sure one-character names are recognized. */ +#define _(x) translate(x) +#undef _ """ -- cgit v0.12