From cd780b84a66d1490ed89a2952c269a2bba998624 Mon Sep 17 00:00:00 2001 From: Dave Beazley Date: Fri, 11 Apr 2003 16:33:17 +0000 Subject: [PATCH] patch to macros with no arguments (again). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4677 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Source/Preprocessor/cpp.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/SWIG/Source/Preprocessor/cpp.c b/SWIG/Source/Preprocessor/cpp.c index 27a3e10f5..12942c8a8 100644 --- a/SWIG/Source/Preprocessor/cpp.c +++ b/SWIG/Source/Preprocessor/cpp.c @@ -593,6 +593,11 @@ expand_macro(String_or_char *name, List *args) return 0; } + /* If the macro expects arguments, but none were supplied, we leave it in place */ + if (!args && (margs)) { + return NewString(name); + } + /* Copy the macro value */ ns = Copy(mvalue); copy_location(mvalue,ns); @@ -600,8 +605,6 @@ expand_macro(String_or_char *name, List *args) /* Tag the macro as being expanded. This is to avoid recursion in macro expansion */ - - temp = NewString(""); tempa = NewString(""); if (args && margs) { @@ -847,15 +850,13 @@ Preprocessor_replace(DOH *s) if (Getattr(m,"args")) { /* Yep. We need to go find the arguments and do a substitution */ args = find_args(s); + if (!Len(args)) { + Delete(args); + args = 0; + } } else { args = 0; } - if (args) { - /* List *nargs = evaluate_args(args); - Delete(args); - args = nargs; */ - } - e = expand_macro(id,args); if (e) { Printf(ns,"%s",e);