Index: generic/nsfDebug.c =================================================================== diff -u -rbf951b5e794b88907333c62b9ebfdaf13c2f26dc -r714726da8aa70930a6f1f482e48ab98e4af0b88b --- generic/nsfDebug.c (.../nsfDebug.c) (revision bf951b5e794b88907333c62b9ebfdaf13c2f26dc) +++ generic/nsfDebug.c (.../nsfDebug.c) (revision 714726da8aa70930a6f1f482e48ab98e4af0b88b) @@ -58,8 +58,7 @@ *---------------------------------------------------------------------- */ -#define NSF_XSTR(x) NSF_STR(x) -#define NSF_STR(x) #x +#define NsfConfigStr(x) (NsfConfigEnabled(x) ? "1" : "0") void NsfReportVars(Tcl_Interp *interp) { @@ -70,28 +69,28 @@ Tcl_SetVar(interp, "::nsf::patchLevel", NSF_PATCHLEVEL, TCL_GLOBAL_ONLY); Tcl_SetVar(interp, "::nsf::config(development)", - NSF_XSTR(NsfConfigEnabled(NSF_DEVELOPMENT)), + NsfConfigStr(DEVELOPMENT), TCL_GLOBAL_ONLY); Tcl_SetVar(interp, "::nsf::config(memcount)", - NSF_XSTR(NsfConfigEnabled(NSF_MEM_COUNT)), + NsfConfigStr(MEM_COUNT), TCL_GLOBAL_ONLY); Tcl_SetVar(interp, "::nsf::config(memtrace)", - NSF_XSTR(NsfConfigEnabled(NSF_MEM_TRACE)), + NsfConfigStr(MEM_TRACE), TCL_GLOBAL_ONLY); Tcl_SetVar(interp, "::nsf::config(profile)", - NSF_XSTR(NsfConfigEnabled(NSF_PROFILE)), + NsfConfigStr(PROFILE), TCL_GLOBAL_ONLY); Tcl_SetVar(interp, "::nsf::config(dtrace)", - NSF_XSTR(NsfConfigEnabled(NSF_DTRACE)), + NsfConfigStr(DTRACE), TCL_GLOBAL_ONLY); Tcl_SetVar(interp, "::nsf::config(assertions)", - NSF_XSTR(NsfConfigEnabled(NSF_WITH_ASSERTIONS)), + NsfConfigStr(WITH_ASSERTIONS), TCL_GLOBAL_ONLY); } Index: generic/nsfInt.h =================================================================== diff -u -r453ad27418d60f0ab744ae4ac911bcd5e2505140 -r714726da8aa70930a6f1f482e48ab98e4af0b88b --- generic/nsfInt.h (.../nsfInt.h) (revision 453ad27418d60f0ab744ae4ac911bcd5e2505140) +++ generic/nsfInt.h (.../nsfInt.h) (revision 714726da8aa70930a6f1f482e48ab98e4af0b88b) @@ -334,20 +334,25 @@ /* The NsfConfigEnabled() macro allows for querying whether a - configuration macro (see above) is actually defined (and whether it - expands to 1). This macro can be used both in CPP expressions (e.g., - "#if NsfConfigEnabled(...)") and in C expressions (e.g., - "if(NsfConfigEnabled(...))") - - Adapted from https://plus.google.com/+LinusTorvalds/posts/9gntjh57dXt + configuration macro (NSF_*; see above) is actually defined (and + whether it expands to 1). This macro can be used both in CPP + expressions (e.g., "#if NsfConfigEnabled(...)") and in C expressions + (e.g., "if(NsfConfigEnabled(...))") */ -#define NsfConfigEnabled(macro) NsfConfigEnabled_(macro) -#define NsfMacroTest_1 , -#define NsfConfigEnabled_(value) NsfConfigEnabled__(NsfMacroTest_##value) -#define NsfConfigEnabled__(comma) NsfConfigEnabled___(comma 1, 0) -#define NsfConfigEnabled___(_, v, ...) v +#define NsfConfigEnabled__NOOP(...) +#define NsfConfigEnabled__open ( +#define NsfConfigEnabled__close ) +#define NsfConfigEnabled__caller(macro, args) macro args +#define NsfConfigEnabled__helper_1 NsfConfigEnabled__close NsfConfigEnabled__open 1 +#define NsfConfigEnabled__(x) (NsfConfigEnabled__caller(NsfConfigEnabled__NOOP, \ + NsfConfigEnabled__open \ + NsfConfigEnabled__helper_##x \ + NsfConfigEnabled__close) + 0) +#define NsfConfigEnabled_(x) NsfConfigEnabled__(x) +#define NsfConfigEnabled(x) NsfConfigEnabled_(NSF_##x) + /* * * Next Scripting Structures Index: tests/nsf-cmd.test =================================================================== diff -u -r275da34d3d7a874a451eced58242b738c8a37d1a -r714726da8aa70930a6f1f482e48ab98e4af0b88b --- tests/nsf-cmd.test (.../nsf-cmd.test) (revision 275da34d3d7a874a451eced58242b738c8a37d1a) +++ tests/nsf-cmd.test (.../nsf-cmd.test) (revision 714726da8aa70930a6f1f482e48ab98e4af0b88b) @@ -278,6 +278,15 @@ "/objectName/ ?-matnr /value/? ?-object-mixins /mixinreg .../? ?-object-filters /filterreg .../? ?-class /class/? ?/__initblock/?" } +nx::test case nsf-config-array { + ? {array exists ::nsf::config} 1 + set opts [list development memcount memtrace profile dtrace assertions] + foreach opt $opts { + ? [list info exists ::nsf::config($opt)] 1 + ? [list string is boolean $::nsf::config($opt)] 1 + } +} + # # Local variables: # mode: tcl