Index: generic/nsf.c =================================================================== diff -u -N -r165e176da4993b45346e7a38d9405a5b0d80d4ec -r0ca1bf1c5b3e4a029e935e5f8a42221b61c0d747 --- generic/nsf.c (.../nsf.c) (revision 165e176da4993b45346e7a38d9405a5b0d80d4ec) +++ generic/nsf.c (.../nsf.c) (revision 0ca1bf1c5b3e4a029e935e5f8a42221b61c0d747) @@ -32936,7 +32936,7 @@ #ifdef NSF_BYTECODE NsfBytecodeInit(); #endif - NsfReportVars(interp); + NsfInitPkgConfig(interp); Tcl_AddInterpResolvers(interp,"nsf", (Tcl_ResolveCmdProc *)InterpColonCmdResolver, Index: generic/nsf.tcl =================================================================== diff -u -N -r09b4bca7c8d5c44f6be0b2c04ebfcdb7a58fd5ae -r0ca1bf1c5b3e4a029e935e5f8a42221b61c0d747 --- generic/nsf.tcl (.../nsf.tcl) (revision 09b4bca7c8d5c44f6be0b2c04ebfcdb7a58fd5ae) +++ generic/nsf.tcl (.../nsf.tcl) (revision 0ca1bf1c5b3e4a029e935e5f8a42221b61c0d747) @@ -220,6 +220,24 @@ set ::nsf::parameter::syntax(::nsf::__unset_unknown_args) "" set ::nsf::parameter::syntax(::nsf::exithandler) "?get?|?set /cmds/?|?unset?" + # + # Provide the build-time configuration settings via namespaced + # variables, for backward compatibility. + # + + if {[info commands ::nsf::pkgconfig] ne ""} { + + foreach c {version commit patchLevel} { + set ::nsf::$c [::nsf::pkgconfig get $c] + } + + foreach c {development memcount memtrace profile dtrace assertions} { + set ::nsf::config($c) [::nsf::pkgconfig get $c] + } + + unset -nocomplain c + + } } # Index: generic/nsfDebug.c =================================================================== diff -u -N -r5fb947bcc2841847055d78332effcece3d622010 -r0ca1bf1c5b3e4a029e935e5f8a42221b61c0d747 --- generic/nsfDebug.c (.../nsfDebug.c) (revision 5fb947bcc2841847055d78332effcece3d622010) +++ generic/nsfDebug.c (.../nsfDebug.c) (revision 0ca1bf1c5b3e4a029e935e5f8a42221b61c0d747) @@ -5,7 +5,9 @@ * * Copyright (C) 1999-2016 Gustaf Neumann (a, b) * Copyright (C) 1999-2007 Uwe Zdun (a, b) + * Copyright (C) 2016-2017 Stefan Sobernig (b) * + * * (a) University of Essen * Specification of Software Systems * Altendorferstrasse 97-101 @@ -42,57 +44,47 @@ #include "nsfInt.h" #include "nsfAccessInt.h" +#define NsfConfigStr(x) (NsfConfigEnabled(x) ? "1" : "0") +static Tcl_Config const cfg[] = { + {"version", NSF_VERSION}, + {"commit", NSF_COMMIT}, + {"commit", NSF_COMMIT}, + {"patchLevel", NSF_PATCHLEVEL}, + {"development", NsfConfigStr(DEVELOPMENT)}, + {"memcount", NsfConfigStr(MEM_COUNT)}, + {"memtrace", NsfConfigStr(MEM_TRACE)}, + {"profile", NsfConfigStr(PROFILE)}, + {"dtrace", NsfConfigStr(DTRACE)}, + {"assertions", NsfConfigStr(WITH_ASSERTIONS)}, + {NULL, NULL} +}; + /* *---------------------------------------------------------------------- - * NsfReportVars -- + * NsfInitPkgConfig -- * - * Report version numbers and configure options as Tcl variables. + * Registers NSF's build configuration according to TIP 59: + * https://core.tcl.tk/tips/doc/trunk/tip/59.md. This way, the build + * configuration is preserved in a non-destructible manner (from the script + * level, at least) and can be queried via a common interface: + * + * ::nsf::pkgconfig list + * ::nsf::pkgconfig get /key/ * * Results: * None. * - * Side effects: - * Setting Tcl variables + * Side effects: + * Creates the command ::nsf::pkgconfig, configuration data is + * stored within a dict associated with a given interp. * *---------------------------------------------------------------------- */ -#define NsfConfigStr(x) (NsfConfigEnabled(x) ? "1" : "0") - void -NsfReportVars(Tcl_Interp *interp) { - - nonnull_assert(interp != NULL); - - Tcl_SetVar(interp, "::nsf::version", NSF_VERSION, TCL_GLOBAL_ONLY); - Tcl_SetVar(interp, "::nsf::commit", NSF_COMMIT, TCL_GLOBAL_ONLY); - Tcl_SetVar(interp, "::nsf::patchLevel", NSF_PATCHLEVEL, TCL_GLOBAL_ONLY); - - Tcl_SetVar(interp, "::nsf::config(development)", - NsfConfigStr(DEVELOPMENT), - TCL_GLOBAL_ONLY); - - - Tcl_SetVar(interp, "::nsf::config(memcount)", - NsfConfigStr(MEM_COUNT), - TCL_GLOBAL_ONLY); - - Tcl_SetVar(interp, "::nsf::config(memtrace)", - NsfConfigStr(MEM_TRACE), - TCL_GLOBAL_ONLY); - - Tcl_SetVar(interp, "::nsf::config(profile)", - NsfConfigStr(PROFILE), - TCL_GLOBAL_ONLY); - - Tcl_SetVar(interp, "::nsf::config(dtrace)", - NsfConfigStr(DTRACE), - TCL_GLOBAL_ONLY); - - Tcl_SetVar(interp, "::nsf::config(assertions)", - NsfConfigStr(WITH_ASSERTIONS), - TCL_GLOBAL_ONLY); +NsfInitPkgConfig(Tcl_Interp *interp) { + Tcl_RegisterConfig(interp, "nsf", cfg, "iso8859-1"); } /* Index: generic/nsfInt.h =================================================================== diff -u -N -rf8b5f0a12aad6b9b6716b817455b64d53595c258 -r0ca1bf1c5b3e4a029e935e5f8a42221b61c0d747 --- generic/nsfInt.h (.../nsfInt.h) (revision f8b5f0a12aad6b9b6716b817455b64d53595c258) +++ generic/nsfInt.h (.../nsfInt.h) (revision 0ca1bf1c5b3e4a029e935e5f8a42221b61c0d747) @@ -1124,8 +1124,9 @@ EXTERN CONST char *NsfMethodName(Tcl_Obj *methodObj) nonnull(1) returns_nonnull; -EXTERN void NsfReportVars(Tcl_Interp *interp) +EXTERN void NsfInitPkgConfig(Tcl_Interp *interp) nonnull(1); + EXTERN void NsfDStringArgv(Tcl_DString *dsPtr, int objc, Tcl_Obj *CONST objv[]) nonnull(1) nonnull(3); Index: generic/predefined.h =================================================================== diff -u -N -ra6ad6a2890ddf47d82f3624eae90075400d8804b -r0ca1bf1c5b3e4a029e935e5f8a42221b61c0d747 --- generic/predefined.h (.../predefined.h) (revision a6ad6a2890ddf47d82f3624eae90075400d8804b) +++ generic/predefined.h (.../predefined.h) (revision 0ca1bf1c5b3e4a029e935e5f8a42221b61c0d747) @@ -92,6 +92,12 @@ "return $result}\n" "set ::nsf::parameter::syntax(::nsf::xotclnext) \"?--noArgs? ?/arg .../?\"\n" "set ::nsf::parameter::syntax(::nsf::__unset_unknown_args) \"\"\n" -"set ::nsf::parameter::syntax(::nsf::exithandler) \"?get?|?set /cmds/?|?unset?\"}\n" +"set ::nsf::parameter::syntax(::nsf::exithandler) \"?get?|?set /cmds/?|?unset?\"\n" +"if {[info commands ::nsf::pkgconfig] ne \"\"} {\n" +"foreach c {version commit patchLevel} {\n" +"set ::nsf::$c [::nsf::pkgconfig get $c]}\n" +"foreach c {development memcount memtrace profile dtrace assertions} {\n" +"set ::nsf::config($c) [::nsf::pkgconfig get $c]}\n" +"unset -nocomplain c}}\n" ""; Index: tests/summary.tcl =================================================================== diff -u -N -r3232e56d77cb2069265c52d89cd46583a49ecbe0 -r0ca1bf1c5b3e4a029e935e5f8a42221b61c0d747 --- tests/summary.tcl (.../summary.tcl) (revision 3232e56d77cb2069265c52d89cd46583a49ecbe0) +++ tests/summary.tcl (.../summary.tcl) (revision 0ca1bf1c5b3e4a029e935e5f8a42221b61c0d747) @@ -24,9 +24,9 @@ puts "\nRegression Test Summary of $opt(-title):" puts "\tEnvironment: Tcl $tcl_patchLevel, OS $tcl_platform(os) $tcl_platform(osVersion)\ machine $tcl_platform(machine) threaded [info exists tcl_platform(threaded)]." - puts "\tNSF [package req nsf] (commit $::nsf::commit) performed $tests tests in $files files, success $success, failures $failures in [expr {$ms / 1000.0}] seconds" + puts "\tNSF [package req nsf] (commit [::nsf::pkgconfig get commit]) performed $tests tests in $files files, success $success, failures $failures in [expr {$ms / 1000.0}] seconds" if {$failures == 0} { - puts "\tCongratulations, all tests of $opt(-title) passed in your installation of NSF [package req nsf] (commit $::nsf::commit)" + puts "\tCongratulations, all tests of $opt(-title) passed in your installation of NSF [package req nsf] (commit [::nsf::pkgconfig get commit])" } puts "" }