From: gregnoel Date: Thu, 14 May 2009 06:35:37 +0000 (+0000) Subject: Issue 2410: Fix crash when using one-character identifiers in C and C++ macros. X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=922d068b9b55e1ff44223a11d9a6c0975db168bb;p=scons.git Issue 2410: Fix crash when using one-character identifiers in C and C++ macros. git-svn-id: http://scons.tigris.org/svn/scons/trunk@4198 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/engine/SCons/cpp.py b/src/engine/SCons/cpp.py index a1601648..47d664c1 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 1c83a130..252a0642 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 _ """