From 2de53852436287ca9c97b41636e38df538506625 Mon Sep 17 00:00:00 2001 From: andreas_kupries Date: Mon, 9 Jun 2003 22:48:32 +0000 Subject: * generic/tcl.decls: Ported the changes from the * generic/tcl.h: 'tip-59-implementation' branch into the CVS * generic/tclBasic.c: head. Regenerated stub table. Regenerated * generic/tclInt.h: the configure's scripts, with help from Joe * generic/tclDecls.h English. * generic/tclStubInit.c: * generic/tclConfig.c: * generic/tclPkgConfig.c: * unix/Makefile.in: * unix/configure.in: The changes in the windows section are not * unix/tcl.m4: yet committed, they await feedback from * unix/mkLinks: David Gravereaux. * doc/RegConfig.3: * mac/tclMacPkgConfig.c: * tests/config.test: --- ChangeLog | 50 +++++++ doc/RegConfig.3 | 123 +++++++++++++++++ generic/tcl.decls | 8 +- generic/tcl.h | 12 +- generic/tclBasic.c | 10 +- generic/tclConfig.c | 365 +++++++++++++++++++++++++++++++++++++++++++++++++ generic/tclDecls.h | 12 +- generic/tclInt.h | 4 +- generic/tclPkgConfig.c | 122 +++++++++++++++++ generic/tclStubInit.c | 3 +- mac/tclMacPkgConfig.c | 107 +++++++++++++++ tests/config.test | 81 +++++++++++ unix/Makefile.in | 36 ++++- unix/configure | 48 ++++++- unix/configure.in | 8 +- unix/mkLinks | 4 + unix/tcl.m4 | 32 +++++ 17 files changed, 1013 insertions(+), 12 deletions(-) create mode 100644 doc/RegConfig.3 create mode 100644 generic/tclConfig.c create mode 100644 generic/tclPkgConfig.c create mode 100644 mac/tclMacPkgConfig.c create mode 100644 tests/config.test diff --git a/ChangeLog b/ChangeLog index b2597ff..6a84a8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2003-06-09 Andreas Kupries + + * generic/tcl.decls: Ported the changes from the + * generic/tcl.h: 'tip-59-implementation' branch into the CVS + * generic/tclBasic.c: head. Regenerated stub table. Regenerated + * generic/tclInt.h: the configure's scripts, with help from Joe + * generic/tclDecls.h English. + * generic/tclStubInit.c: + * generic/tclConfig.c: + * generic/tclPkgConfig.c: + * unix/Makefile.in: + * unix/configure.in: The changes in the windows section are not + * unix/tcl.m4: yet committed, they await feedback from + * unix/mkLinks: David Gravereaux. + * doc/RegConfig.3: + * mac/tclMacPkgConfig.c: + * tests/config.test: + 2003-06-09 Don Porter * string.test (string-4.15): Added test for [string first] bug @@ -5166,6 +5184,13 @@ own realpath implementation, but this will at least quiet purify for now. +2002-04-05 Daniel Steffen + + * TIP 59 Merge ... + + * mac/tclMacPkgConfig.c: Added Mac implementation of pkgconfig. + * tests/config.test: fixed failing tests. + 2002-04-05 Don Porter * generic/tclCmdMZ.c (Tcl_SubstObj): @@ -6075,6 +6100,31 @@ * generic/regc_locale.c (casecmp): slight performance improvement. +2002-02-05 Andreas Kupries + + * TIP 59 Merge ... + + * tests/config.test: Added a testsuite for pkgconfig. + + * unix/mkLinks: Regenerated. + * doc/RegConfig.3: Added documentation for the new public API + function. + + * This commit addresses the following topics from the comments at + SF item 507083: + + @ Reformatted to 72 columns per line (mostly). Some character + strings (Panic messages) are still longer. + + @ Better panic messages. + + @ Allocation of wrapper uses sizeof(Tcl_Obj*) instead of sizeof + (char*). + + @ Terminate array with either "" or NULL. + + @ Changed to use ckalloc/ckfree instead of Tcl_Alloc/Tcl_Free. + 2002-02-05 Don Porter * library/http/http.tcl: diff --git a/doc/RegConfig.3 b/doc/RegConfig.3 new file mode 100644 index 0000000..14d17d8 --- /dev/null +++ b/doc/RegConfig.3 @@ -0,0 +1,123 @@ +'\" +'\" Copyright (c) 2002 Andreas Kupries +'\" +'\" See the file "license.terms" for information on usage and redistribution +'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. +'\" +'\" RCS: @(#) $Id: RegConfig.3,v 1.2 2003/06/09 22:49:13 andreas_kupries Exp $ +.so man.macros +.TH Tcl_RegisterConfig 3 8.4 Tcl "Tcl Library Procedures" +.BS +'\" Note: do not modify the .SH NAME line immediately below! +.SH NAME +Tcl_RegisterConfig \- procedures to register embedded configuration information. +.SH SYNOPSIS +.nf +\fB#include \fR +.sp +void +\fBTcl_RegisterConfig\fR(\fIinterp,pkgName,configuration,valEncoding\fR) +.sp +.SH ARGUMENTS +.AP Tcl_Interp *interp in + +Refers to the interpreter the embedded configuration information is +registered for. Must not be NULL. + +.AP "CONST char" *pkgName in + +Contains the name of the package registering the embedded +configuration as ASCII string. This means that this information is in +UTF-8 too. Must not be NULL. + +.AP Tcl_Config *configuration in + +Refers to an array of Tcl_Config entries containing the information +embedded in the binary library. Must not be NULL. The end of the array +is signaled by either a key identical to NULL, or a key refering to +the empty string. + +.AP "CONST char" *valEncoding in + +Contains the name of the encoding used to store the configuration +values as ASCII string. This means that this information is in UTF-8 +too. Must not be NULL. + +.BE + +.SH DESCRIPTION +.PP +The function described here has its base in TIP 59 and provides +extensions with support for the embedding of configuration +information into their binary library and the generation of a +tcl-level interface for querying this information. +.PP +To embed configuration information into their binary library an +extension has to define a non-volatile array of Tcl_Config entries in +one if its source files and then call \fBTcl_RegisterConfig\fR to +register that information. +.PP +\fBTcl_RegisterConfig\fR takes four arguments; first, a reference to +the interpreter we are registering the information with, second, the +name of the package registering its configuration information, third, +a pointer to an array of structures, and fourth a string declaring the +encoding used by the configuration values. +.PP +The string \fIvalEncoding\fR contains the name of an encoding known to +Tcl. All these names are use only characters in the ASCII subset of +UTF-8 and are thus implicity in the UTF-8 encoding. It is expected +that keys are legible english text and therefore using the ASCII +subset of UTF-8. In other words, they are expected to be in UTF-8 +too. The values associated with the keys can be any string +however. For these the contents of \fIvalEncoding\fR define which +encoding was used to represent the characters of the strings. +.PP +Each element of the \fIconfiguration\fR array refers to two strings +containing the key and the value associated with that key. The end of +the array is signaled by either an empty key or a key identical to +NULL. The function makes \fBno\fR copy of the \fIconfiguration\fR +array. This means that the caller has to make sure that the memory +holding this array is never released. This is the meaning behind the +word \fBnon-volatile\fR used earlier. The easiest way to accomplish +this is to define a global static array of Tcl_Config entries. See the +file "generic/tclPkgConfig.c" in the sources of the tcl core for an +example. +.PP +When called \fBTcl_RegisterConfig\fR will +.IP (1) +create a namespace having the provided \fIpkgName\fR, if not yet +existing. +.IP (2) +create the command \fBpkgconfig\fR in that namespace and link it to +the provided information so that the keys from _configuration_ and +their associated values can be retrieved through calls to +\fBpkgconfig\fR. +.PP +The command \fBpkgconfig\fR will provide two subcommands, \fBlist\fR +and \fBget\fR: +.RS +.TP +::\fIpkgName\fR::\fBpkgconfig\fR list +Returns a list containing the names of all defined keys. +.TP +::\fIpkgName\fR::\fBpkgconfig\fR get \fIkey\fR +Returns the configuration value associated with the specified +\fIkey\fR. +.RE + +.SH TCL_CONFIG + +The \fBTcl_Config\fR structure contains the following fields: +.PP +.CS + typedef struct Tcl_Config { + CONST char* key; + CONST char* value; + } Tcl_Config; +.CE + +'\" No cross references yet. +'\" .SH "SEE ALSO" + +.SH KEYWORDS +embedding, configuration, bianry library diff --git a/generic/tcl.decls b/generic/tcl.decls index 7fcb4c6..0f8935d 100644 --- a/generic/tcl.decls +++ b/generic/tcl.decls @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: tcl.decls,v 1.97 2003/05/13 10:16:16 mistachkin Exp $ +# RCS: @(#) $Id: tcl.decls,v 1.98 2003/06/09 22:48:32 andreas_kupries Exp $ library tcl @@ -1797,6 +1797,12 @@ declare 504 generic { Tcl_Obj *Tcl_DbNewDictObj(CONST char *file, int line) } +# New export due to TIP#59 +declare 505 generic { + void Tcl_RegisterConfig (Tcl_Interp* interp, CONST char* pkgName, Tcl_Config* configuration, \ + CONST char* valEncoding) +} + ############################################################################## # Define the platform specific public Tcl interface. These functions are diff --git a/generic/tcl.h b/generic/tcl.h index 5885e15..6c87307 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tcl.h,v 1.157 2003/04/16 23:33:43 dgp Exp $ + * RCS: @(#) $Id: tcl.h,v 1.158 2003/06/09 22:48:32 andreas_kupries Exp $ */ #ifndef _TCL @@ -2196,6 +2196,16 @@ typedef struct Tcl_Parse { */ typedef unsigned short Tcl_UniChar; +/* TIP #59: The following structure is used in calls + * 'Tcl_RegisterConfig' to provide the system with the embedded + * configuration data. + */ + +typedef struct Tcl_Config { + CONST char* key; /* Configuration key to register. ASCII encoded, thus UTF-8 */ + CONST char* value; /* The value associated with the key. System encoding */ +} Tcl_Config; + /* * Deprecated Tcl procedures: diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 0fc1e59..68dd065 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclBasic.c,v 1.82 2003/05/12 20:15:28 dgp Exp $ + * RCS: @(#) $Id: tclBasic.c,v 1.83 2003/06/09 22:48:32 andreas_kupries Exp $ */ #include "tclInt.h" @@ -599,6 +599,14 @@ Tcl_CreateInterp() #endif Tcl_InitStubs(interp, TCL_VERSION, 1); + /* + * TIP #59: Make embedded configuration information + * available. This makes use of a public API call + * (Tcl_RegisterConfig) and thus requires that the global stub + * table is initialized. + */ + + TclInitEmbeddedConfigurationInformation (interp); return interp; } diff --git a/generic/tclConfig.c b/generic/tclConfig.c new file mode 100644 index 0000000..5b03c98 --- /dev/null +++ b/generic/tclConfig.c @@ -0,0 +1,365 @@ +/* + * tclConfig.c -- + * + * This file provides the facilities which allow Tcl and other packages + * to embed configuration information into their binary libraries. + * + * Copyright (c) 2002 Andreas Kupries + * + * See the file "license.terms" for information on usage and redistribution + * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * + * RCS: @(#) $Id: tclConfig.c,v 1.2 2003/06/09 22:48:32 andreas_kupries Exp $ + */ + +#include "tclInt.h" + + + +/* + * Internal structure to hold embedded configuration information. + * + * Our structure is a two-level dictionary associated with the + * 'interp'. The first level is keyed with the package name and maps + * to the dictionary for that package. The package dictionary is keyed + * with metadata keys and maps to the metadata value for that + * key. This is package specific. The metadata values are in UTF8, + * converted from the external representation given to us by the + * caller. + */ + +#define ASSOC_KEY "Package About Dict" + +/* + * Static functions in this file: + */ + +static int +QueryConfigObjCmd _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp, int objc, struct Tcl_Obj * CONST * objv)); + +static void +QueryConfigDelete _ANSI_ARGS_((ClientData clientData)); + +static Tcl_Obj* +GetConfigDict _ANSI_ARGS_((Tcl_Interp* interp)); + +static void +ConfigDictDeleteProc _ANSI_ARGS_((ClientData clientData, + Tcl_Interp *interp)); + +/* + *---------------------------------------------------------------------- + * + * Tcl_RegisterConfig -- + * + * See TIP#59 for details on what this procedure does. + * + * Results: + * None. + * + * Side effects: + * Creates namespace and cfg query command in it as per TIP #59. + * + *---------------------------------------------------------------------- + */ + +void +Tcl_RegisterConfig (interp, pkgName, configuration, valEncoding) + Tcl_Interp* interp; /* Interpreter the configuration + * command is registered in. */ + CONST char* pkgName; /* Name of the package registering + * the embedded configuration. ASCII, + * thus in UTF-8 too. */ + Tcl_Config* configuration; /* Embedded configuration */ + CONST char* valEncoding; /* Name of the encoding used to + * store the configuration values, + * ASCII, thus UTF-8 */ +{ + Tcl_Encoding venc = Tcl_GetEncoding (NULL, valEncoding); + Tcl_Obj* pDB = GetConfigDict (interp); + Tcl_Obj* pkg = Tcl_NewStringObj (pkgName, -1); + Tcl_Obj* pkgDict; + Tcl_DString cmdName; + Tcl_Config* cfg; + int res; + + /* + * Phase I: Adding the provided information to the internal + * database of package meta data. + * + * Phase II: Create a command for querying this database, specific + * to the package registerting its configuration. This is the + * approved interface in TIP 59. In the future a more general + * interface should be done, as followup to TIP 59. Simply because + * our database is now general across packages, and not a + * structure tied to one package. + */ + + /* Note, the created command will have a reference through its clientdata */ + Tcl_IncrRefCount (pkg); + + /* Retrieve package specific configuration ... */ + + res = Tcl_DictObjGet (interp, pDB, pkg, &pkgDict); + if ((TCL_OK != res) || (pkgDict == NULL)) { + pkgDict = Tcl_NewDictObj (); + } else if (Tcl_IsShared (pkgDict)) { + pkgDict = Tcl_DuplicateObj (pkgDict); + } + + /* Extend the package configuration ... */ + + for (cfg = configuration; + (cfg->key != (CONST char*) NULL) && (cfg->key [0] != '\0') ; + cfg++) { + + Tcl_DString conv; + CONST char* convValue = Tcl_ExternalToUtfDString (venc, cfg->value, -1, &conv); + + /* + * We know that the keys are in ASCII/UTF-8, so for them is no + * conversion required. + */ + + Tcl_DictObjPut (interp, pkgDict, + Tcl_NewStringObj (cfg->key, -1), + Tcl_NewStringObj (convValue, -1)); + Tcl_DStringFree (&conv); + } + + /* Write the changes back into the overall database */ + + Tcl_DictObjPut (interp, pDB, pkg, pkgDict); + + /* + * Now create the interface command for retrieval of the package + * information. + */ + + Tcl_DStringInit (&cmdName); + Tcl_DStringAppend (&cmdName, "::", -1); + Tcl_DStringAppend (&cmdName, pkgName, -1); + + /* The incomplete command name is the name of the namespace to + * place it in. + */ + + if ((Tcl_Namespace*) NULL == Tcl_FindNamespace(interp, + Tcl_DStringValue (&cmdName), NULL, TCL_GLOBAL_ONLY)) { + + if ((Tcl_Namespace*) NULL == Tcl_CreateNamespace (interp, + Tcl_DStringValue (&cmdName), (ClientData) NULL, + (Tcl_NamespaceDeleteProc *) NULL)) { + + Tcl_Panic ("%s.\n%s %s", Tcl_GetStringResult(interp), + "Tcl_RegisterConfig: Unable to create namespace for", + "package configuration."); + } + } + + Tcl_DStringAppend (&cmdName, "::pkgconfig", -1); + + if ((Tcl_Command) NULL == Tcl_CreateObjCommand (interp, + Tcl_DStringValue (&cmdName), QueryConfigObjCmd, + (ClientData) pkg, QueryConfigDelete)) { + + Tcl_Panic ("%s %s", "Tcl_RegisterConfig: Unable to create query", + "command for package configuration"); + } + + Tcl_DStringFree (&cmdName); +} + +/* + *---------------------------------------------------------------------- + * + * QueryConfigObjCmd -- + * + * Implementation of "::::pkgconfig", the command to + * query configuration information embedded into a binary library. + * + * Results: + * A standard tcl result. + * + * Side effects: + * See the manual for what this command does. + * + *---------------------------------------------------------------------- + */ + +static int +QueryConfigObjCmd (clientData, interp, objc, objv) + ClientData clientData; + Tcl_Interp *interp; + int objc; + struct Tcl_Obj * CONST * objv; +{ + Tcl_Obj* pkgName = (Tcl_Obj*) clientData; + Tcl_Obj* pDB; + Tcl_Obj* pkgDict; + Tcl_Obj* val; + Tcl_DictSearch s; + int n, i, res, done, index; + Tcl_Obj* key; + Tcl_Obj** vals; + + static CONST char *subcmdStrings[] = { + "get", "list", NULL + }; + enum subcmds { + CFG_GET, CFG_LIST + }; + + if ((objc < 2) || (objc > 3)) { + Tcl_WrongNumArgs (interp, 0, NULL, "list | get key"); + return TCL_ERROR; + } + if (Tcl_GetIndexFromObj(interp, objv[1], subcmdStrings, + "subcommand", 0, &index) != TCL_OK) { + return TCL_ERROR; + } + + pDB = GetConfigDict (interp); + res = Tcl_DictObjGet (interp, pDB, pkgName, &pkgDict); + if ((res != TCL_OK) || (pkgDict == NULL)) { + /* Maybe a panic is better, because the package data has to be present */ + Tcl_SetObjResult (interp, Tcl_NewStringObj ("package not known", -1)); + return TCL_ERROR; + } + + switch ((enum subcmds) index) { + case CFG_GET: + if (objc != 3) { + Tcl_WrongNumArgs (interp, 0, NULL, "get key"); + return TCL_ERROR; + } + + res = Tcl_DictObjGet (interp, pkgDict, objv [2], &val); + if ((res != TCL_OK) || (val == NULL)) { + Tcl_SetObjResult (interp, Tcl_NewStringObj ("key not known", -1)); + return TCL_ERROR; + } + + Tcl_SetObjResult (interp, val); + return TCL_OK; + + + case CFG_LIST: + if (objc != 2) { + Tcl_WrongNumArgs (interp, 0, NULL, "list"); + return TCL_ERROR; + } + + Tcl_DictObjSize (interp, pkgDict, &n); + if (n == 0) { + Tcl_SetObjResult (interp, Tcl_NewListObj (0, NULL)); + return TCL_OK; + } + + vals = (Tcl_Obj**) ckalloc (n * sizeof (Tcl_Obj*)); + + for (i = 0, Tcl_DictObjFirst(interp, pkgDict, &s, &key, NULL, &done); + !done; + Tcl_DictObjNext (&s, &key, NULL, &done), i++) { + if (done) break; + vals [i] = key; + } + Tcl_DictObjDone (&s); + + Tcl_SetObjResult (interp, Tcl_NewListObj (n, vals)); + ckfree ((char*) vals); + + return TCL_OK; + + default: + Tcl_Panic ("QueryConfigObjCmd: Unknown subcommand to 'pkgconfig'. This can't happen"); + break; + } + return TCL_ERROR; +} + +/* + *------------------------------------------------------------------------- + * + * QueryConfigDelete -- + * + * Command delete procedure. Cleans up after the configuration query + * command when it is deleted by the user or during finalization. + * + * Results: + * None. + * + * Side effects: + * Deallocates all non-transient memory allocated by Tcl_RegisterConfig. + * + *------------------------------------------------------------------------- + */ + +static void +QueryConfigDelete (clientData) + ClientData clientData; +{ + Tcl_Obj* pkgName = (Tcl_Obj*) clientData; + Tcl_DecrRefCount (pkgName); +} + +/* + *------------------------------------------------------------------------- + * + * GetConfigDict -- + * + * Retrieve the package metadata database from the interpreter. + * Initializes it, if not present yet. + * + * Results: + * A Tcl_Obj reference + * + * Side effects: + * May allocate a Tcl_Obj. + * + *------------------------------------------------------------------------- + */ + +static Tcl_Obj* +GetConfigDict (interp) + Tcl_Interp* interp; +{ + Tcl_Obj* pDB = Tcl_GetAssocData (interp, ASSOC_KEY, NULL); + + if (pDB == (Tcl_Obj*) NULL) { + pDB = Tcl_NewDictObj (); + Tcl_IncrRefCount (pDB); + Tcl_SetAssocData (interp, ASSOC_KEY, ConfigDictDeleteProc, pDB); + } + + return pDB; +} + +/* + *---------------------------------------------------------------------- + * + * ConfigDictDeleteProc -- + * + * This procedure is associated with the "Package About dict" assoc data + * for an interpreter; it is invoked when the interpreter is + * deleted in order to free the information assoicated with any + * pending error reports. + * + * Results: + * None. + * + * Side effects: + * The package metadata database is freed. + * + *---------------------------------------------------------------------- + */ + +static void +ConfigDictDeleteProc(clientData, interp) + ClientData clientData; /* Pointer to Tcl_Obj. */ + Tcl_Interp *interp; /* Interpreter being deleted. */ +{ + Tcl_Obj* pDB = (Tcl_Obj*) clientData; + Tcl_DecrRefCount (pDB); +} diff --git a/generic/tclDecls.h b/generic/tclDecls.h index e8eb34a..b4ea365 100644 --- a/generic/tclDecls.h +++ b/generic/tclDecls.h @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclDecls.h,v 1.95 2003/05/13 10:16:16 mistachkin Exp $ + * RCS: @(#) $Id: tclDecls.h,v 1.96 2003/06/09 22:48:32 andreas_kupries Exp $ */ #ifndef _TCLDECLS @@ -1606,6 +1606,11 @@ EXTERN Tcl_Obj * Tcl_NewDictObj _ANSI_ARGS_((void)); /* 504 */ EXTERN Tcl_Obj * Tcl_DbNewDictObj _ANSI_ARGS_((CONST char * file, int line)); +/* 505 */ +EXTERN void Tcl_RegisterConfig _ANSI_ARGS_((Tcl_Interp* interp, + CONST char* pkgName, + Tcl_Config* configuration, + CONST char* valEncoding)); typedef struct TclStubHooks { struct TclPlatStubs *tclPlatStubs; @@ -2170,6 +2175,7 @@ typedef struct TclStubs { int (*tcl_DictObjRemoveKeyList) _ANSI_ARGS_((Tcl_Interp * interp, Tcl_Obj * dictPtr, int keyc, Tcl_Obj *CONST * keyv)); /* 502 */ Tcl_Obj * (*tcl_NewDictObj) _ANSI_ARGS_((void)); /* 503 */ Tcl_Obj * (*tcl_DbNewDictObj) _ANSI_ARGS_((CONST char * file, int line)); /* 504 */ + void (*tcl_RegisterConfig) _ANSI_ARGS_((Tcl_Interp* interp, CONST char* pkgName, Tcl_Config* configuration, CONST char* valEncoding)); /* 505 */ } TclStubs; #ifdef __cplusplus @@ -4230,6 +4236,10 @@ extern TclStubs *tclStubsPtr; #define Tcl_DbNewDictObj \ (tclStubsPtr->tcl_DbNewDictObj) /* 504 */ #endif +#ifndef Tcl_RegisterConfig +#define Tcl_RegisterConfig \ + (tclStubsPtr->tcl_RegisterConfig) /* 505 */ +#endif #endif /* defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) */ diff --git a/generic/tclInt.h b/generic/tclInt.h index c440202..02987c2 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclInt.h,v 1.127 2003/05/05 20:54:40 dgp Exp $ + * RCS: @(#) $Id: tclInt.h,v 1.128 2003/06/09 22:48:32 andreas_kupries Exp $ */ #ifndef _TCLINT @@ -1648,6 +1648,8 @@ EXTERN int TclGlob _ANSI_ARGS_((Tcl_Interp *interp, int globFlags, Tcl_GlobTypeData* types)); EXTERN void TclInitAlloc _ANSI_ARGS_((void)); EXTERN void TclInitDbCkalloc _ANSI_ARGS_((void)); +EXTERN void TclInitEmbeddedConfigurationInformation + _ANSI_ARGS_((Tcl_Interp *interp)); EXTERN void TclInitEncodingSubsystem _ANSI_ARGS_((void)); EXTERN void TclInitIOSubsystem _ANSI_ARGS_((void)); EXTERN void TclInitNamespaceSubsystem _ANSI_ARGS_((void)); diff --git a/generic/tclPkgConfig.c b/generic/tclPkgConfig.c new file mode 100644 index 0000000..06070ef --- /dev/null +++ b/generic/tclPkgConfig.c @@ -0,0 +1,122 @@ +/* + * tclPkgConfig.c -- + * + * This file contains the configuration information to + * embed into the tcl binary library. + * + * Copyright (c) 2002 Andreas Kupries + * + * See the file "license.terms" for information on usage and redistribution + * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * + * RCS: @(#) $Id: tclPkgConfig.c,v 1.2 2003/06/09 22:48:33 andreas_kupries Exp $ + */ + +/* Note, the definitions in this module are influenced by the + * following C preprocessor macros: + * + * OSCMa = shortcut for "old style configuration macro activates" + * NSCMdt = shortcut for "new style configuration macro declares that" + * + * - TCL_THREADS OSCMa compilation as threaded core. + * - TCL_MEM_DEBUG OSCMa memory debugging. + * - TCL_COMPILE_DEBUG OSCMa debugging of bytecode compiler. + * - TCL_COMPILE_STATS OSCMa bytecode compiler statistics. + * + * - TCL_CFG_DO64BIT NSCMdt tcl is compiled for a 64bit system. + * - TCL_CFG_DEBUG NSCMdt tcl is compiled with symbol info on. + * - TCL_CFG_OPTIMIZED NSCMdt tcl is compiled with cc optimizations on. + * - TCL_CFG_PROFILED NSCMdt tcl is compiled with profiling info. + * + * - CFG_RUNTIME_* Paths to various stuff at runtime. + * - CFG_INSTALL_* Paths to various stuff at installation time. + * + * - TCL_CFGVAL_ENCODING string containing the encoding used for the + * configuration values. + */ + +#include "tclInt.h" + + + +/* Use C preprocessor statements to define the various values for the + * embedded configuration information. */ + +#ifdef TCL_THREADS +# define CFG_THREADED "1" +#else +# define CFG_THREADED "0" +#endif +#ifdef TCL_MEM_DEBUG +# define CFG_MEMDEBUG "1" +#else +# define CFG_MEMDEBUG "0" +#endif +#ifdef TCL_COMPILE_DEBUG +# define CFG_COMPILE_DEBUG "1" +#else +# define CFG_COMPILE_DEBUG "0" +#endif +#ifdef TCL_COMPILE_STATS +# define CFG_COMPILE_STATS "1" +#else +# define CFG_COMPILE_STATS "0" +#endif +#ifdef TCL_CFG_DO64BIT +# define CFG_64 "1" +#else +# define CFG_64 "0" +#endif +#ifdef TCL_CFG_DEBUG +# define CFG_DEBUG "1" +#else +# define CFG_DEBUG "0" +#endif +#ifdef TCL_CFG_OPTIMIZED +# define CFG_OPTIMIZED "1" +#else +# define CFG_OPTIMIZED "0" +#endif +#ifdef TCL_CFG_PROFILED +# define CFG_PROFILED "1" +#else +# define CFG_PROFILED "0" +#endif + +static Tcl_Config cfg [] = { + {"debug", CFG_DEBUG}, + {"threaded", CFG_THREADED}, + {"profiled", CFG_PROFILED}, + {"64bit", CFG_64}, + {"optimized", CFG_OPTIMIZED}, + {"mem_debug", CFG_MEMDEBUG}, + {"compile_debug", CFG_COMPILE_DEBUG}, + {"compile_stats", CFG_COMPILE_STATS}, + + /* Runtime paths to various stuff */ + + {"libdir,runtime", CFG_RUNTIME_LIBDIR}, + {"bindir,runtime", CFG_RUNTIME_BINDIR}, + {"scriptdir,runtime", CFG_RUNTIME_SCRDIR}, + {"includedir,runtime", CFG_RUNTIME_INCDIR}, + {"docdir,runtime", CFG_RUNTIME_DOCDIR}, + + /* Installation paths to various stuff */ + + {"libdir,install", CFG_INSTALL_LIBDIR}, + {"bindir,install", CFG_INSTALL_BINDIR}, + {"scriptdir,install", CFG_INSTALL_SCRDIR}, + {"includedir,install", CFG_INSTALL_INCDIR}, + {"docdir,install", CFG_INSTALL_DOCDIR}, + + /* Last entry, closes the array */ + {NULL, NULL} +}; + +void +TclInitEmbeddedConfigurationInformation (interp) + Tcl_Interp* interp; /* Interpreter the configuration + * command is registered in. */ +{ + Tcl_RegisterConfig (interp, "tcl", cfg, TCL_CFGVAL_ENCODING); +} diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 6bd10ef..60fdcf3 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclStubInit.c,v 1.84 2003/05/14 19:21:23 das Exp $ + * RCS: @(#) $Id: tclStubInit.c,v 1.85 2003/06/09 22:48:33 andreas_kupries Exp $ */ #include "tclInt.h" @@ -944,6 +944,7 @@ TclStubs tclStubs = { Tcl_DictObjRemoveKeyList, /* 502 */ Tcl_NewDictObj, /* 503 */ Tcl_DbNewDictObj, /* 504 */ + Tcl_RegisterConfig, /* 505 */ }; /* !END!: Do not edit above this line. */ diff --git a/mac/tclMacPkgConfig.c b/mac/tclMacPkgConfig.c new file mode 100644 index 0000000..6b28d3e --- /dev/null +++ b/mac/tclMacPkgConfig.c @@ -0,0 +1,107 @@ +/* + * tclMacPkgConfig.c -- + * + * This file contains the Mac configuration information to + * embed into the tcl binary library. + * + * Copyright (c) 2002 Daniel Steffen + * + * See the file "license.terms" for information on usage and redistribution + * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * + * RCS: @(#) $Id: tclMacPkgConfig.c,v 1.2 2003/06/09 22:49:29 andreas_kupries Exp $ + */ + +#include "tclInt.h" + +#ifdef __MWERKS__ + +/* define DEBUG/OPTIMIZED macros depending on the value of + * Metrowerks specific precompiler functions. + * (traceback is for PPC, macsbug for 68k) */ +# if __option(traceback) || __option(macsbug) +# define TCL_CFG_DEBUG +# else +# define TCL_CFG_OPTIMIZED +# endif + +/* define PROFILED macros depending depending on the value of + * Metrowerks specific precompiler functions. */ +# if __option(profile) +# define TCL_CFG_PROFILED +# endif + +#else + +# ifdef TCL_DEBUG +# define TCL_CFG_DEBUG +# else +# define TCL_CFG_OPTIMIZED +# endif + +#endif + +/* the CFG_*DIR values need to be built up dynamically at runtime + * because the name of the Macintosh Extension directory on a user's + * system is not known at build time */ +#define CFG_RUNTIME_PREFIX "${::env(EXT_FOLDER)}Tool Command Language" +#define CFG_RUNTIME_LIBDIR CFG_RUNTIME_PREFIX +#define CFG_RUNTIME_BINDIR CFG_RUNTIME_PREFIX +#define CFG_RUNTIME_SCRDIR CFG_RUNTIME_PREFIX":tcl"TCL_VERSION +#define CFG_RUNTIME_INCDIR CFG_RUNTIME_PREFIX +#define CFG_RUNTIME_DOCDIR CFG_RUNTIME_PREFIX +#define CFG_INSTALL_LIBDIR CFG_RUNTIME_LIBDIR +#define CFG_INSTALL_BINDIR CFG_RUNTIME_BINDIR +#define CFG_INSTALL_SCRDIR CFG_RUNTIME_SCRDIR +#define CFG_INSTALL_INCDIR CFG_RUNTIME_INCDIR +#define CFG_INSTALL_DOCDIR CFG_RUNTIME_DOCDIR + +/* use system encoding */ +#define TCL_CFGVAL_ENCODING NULL + +/* We want to include tclPkgConfig.c to get the remaining CFG_* macros + * and the cfg array declaration, but need our own definition of + * TclInitEmbeddedConfigurationInformation, so we rename this routine + * for the duration of the inclusion and declare it static */ +static void TclUnusedInitEmbeddedConfigurationInformation + _ANSI_ARGS_((Tcl_Interp *interp)); +#define TclInitEmbeddedConfigurationInformation \ + TclUnusedInitEmbeddedConfigurationInformation +#include "tclPkgConfig.c" +#undef TclInitEmbeddedConfigurationInformation + + +void +TclInitEmbeddedConfigurationInformation (interp) + Tcl_Interp* interp; /* Interpreter the configuration + * command is registered in. */ +{ + Tcl_Config *cfgp; + Tcl_Obj *valObj, *substObj; + char *subst; + int len; + + valObj = Tcl_NewObj(); + + /* Call Tcl_SubstObj on all values in the cfg array and replace + * the existing value by the result if any substitution has + * occurred. This is needed because on the Mac the CFG_*DIR + * macros contain variables that are not known until runtime */ + for (cfgp = cfg; + (cfgp->key != (CONST char*) NULL) && (cfgp->key [0] != '\0') ; + cfgp++) + { + Tcl_SetStringObj(valObj, cfgp->value, -1); + substObj = Tcl_SubstObj(interp, valObj, TCL_SUBST_VARIABLES); + if( substObj ) { + subst = Tcl_GetStringFromObj(substObj, &len); + if ( strcmp(cfgp->value, subst) ) + cfgp->value = strcpy(ckalloc((unsigned)len+1), subst); + Tcl_DecrRefCount(substObj); + } + } + + Tcl_DecrRefCount(valObj); + + Tcl_RegisterConfig (interp, "tcl", cfg, TCL_CFGVAL_ENCODING); +} diff --git a/tests/config.test b/tests/config.test new file mode 100644 index 0000000..c1fa524 --- /dev/null +++ b/tests/config.test @@ -0,0 +1,81 @@ +# -*- tcl -*- +# Commands covered: pkgconfig +# +# This file contains a collection of tests for one or more of the Tcl +# built-in commands. Sourcing this file into Tcl runs the tests and +# generates output for errors. No output means no errors were found. +# +# Copyright (c) 1991-1993 The Regents of the University of California. +# Copyright (c) 1994-1996 Sun Microsystems, Inc. +# Copyright (c) 1998-1999 by Scriptics Corporation. +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# +# RCS: @(#) $Id: config.test,v 1.2 2003/06/09 22:49:44 andreas_kupries Exp $ + +if {[lsearch [namespace children] ::tcltest] == -1} { + package require tcltest + namespace import -force ::tcltest::* +} + +test pkgconfig-1.1 {query keys} { + lsort [::tcl::pkgconfig list] +} {64bit bindir,install bindir,runtime compile_debug compile_stats debug docdir,install docdir,runtime includedir,install includedir,runtime libdir,install libdir,runtime mem_debug optimized profiled scriptdir,install scriptdir,runtime threaded} + +test pkgconfig-1.2 {query keys multiple times} { + string compare [::tcl::pkgconfig list] [::tcl::pkgconfig list] +} 0 + +test pkgconfig-1.3 {query value multiple times} { + string compare \ + [::tcl::pkgconfig get bindir,install] \ + [::tcl::pkgconfig get bindir,install] +} 0 + + +test pkgconfig-2.0 {error: missing subcommand} { + catch {::tcl::pkgconfig} msg + set msg +} {wrong # args: should be "list | get key"} + +test pkgconfig-2.1 {error: illegal subcommand} { + catch {::tcl::pkgconfig foo} msg + set msg +} {bad subcommand "foo": must be get or list} + +test pkgconfig-2.2 {error: list with arguments} { + catch {::tcl::pkgconfig list foo} msg + set msg +} {wrong # args: should be "list"} + +test pkgconfig-2.3 {error: get without arguments} { + catch {::tcl::pkgconfig get} msg + set msg +} {wrong # args: should be "get key"} + +test pkgconfig-2.4 {error: query unknown key} { + catch {::tcl::pkgconfig get foo} msg + set msg +} {key not known} + +test pkgconfig-2.5 {error: query with to many arguments} { + catch {::tcl::pkgconfig get foo bar} msg + set msg +} {wrong # args: should be "list | get key"} + +# cleanup +::tcltest::cleanupTests +return + + + + + + + + + + + + diff --git a/unix/Makefile.in b/unix/Makefile.in index 74bcc21..0973b85 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -5,7 +5,7 @@ # "autoconf" program (constructs like "@foo@" will get replaced in the # actual Makefile. # -# RCS: @(#) $Id: Makefile.in,v 1.127 2003/05/16 17:00:30 kennykb Exp $ +# RCS: @(#) $Id: Makefile.in,v 1.128 2003/06/09 22:48:51 andreas_kupries Exp $ VERSION = @TCL_VERSION@ MAJOR_VERSION = @TCL_MAJOR_VERSION@ @@ -304,13 +304,13 @@ XTTEST_OBJS = xtTestInit.o tclTest.o tclTestObj.o tclTestProcBodyObj.o \ GENERIC_OBJS = regcomp.o regexec.o regfree.o regerror.o tclAlloc.o \ tclAsync.o tclBasic.o tclBinary.o tclCkalloc.o tclClock.o \ tclCmdAH.o tclCmdIL.o tclCmdMZ.o tclCompCmds.o tclCompExpr.o \ - tclCompile.o tclDate.o tclDictObj.o tclEncoding.o \ + tclCompile.o tclConfig.o tclDate.o tclDictObj.o tclEncoding.o \ tclEnv.o tclEvent.o tclExecute.o tclFCmd.o tclFileName.o tclGet.o \ tclHash.o tclHistory.o tclIndexObj.o tclInterp.o tclIO.o tclIOCmd.o \ tclIOGT.o tclIOSock.o tclIOUtil.o tclLink.o tclListObj.o \ tclLiteral.o tclLoad.o tclMain.o tclNamesp.o tclNotify.o \ tclObj.o tclPanic.o tclParse.o tclParseExpr.o tclPathObj.o tclPipe.o \ - tclPkg.o tclPosixStr.o tclPreserve.o tclProc.o tclRegexp.o \ + tclPkg.o tclPkgConfig.o tclPosixStr.o tclPreserve.o tclProc.o tclRegexp.o \ tclResolve.o tclResult.o tclScan.o tclStringObj.o tclThread.o \ tclThreadAlloc.o tclThreadJoin.o tclStubInit.o tclStubLib.o \ tclTimer.o tclUtf.o tclUtil.o tclVar.o @@ -352,6 +352,7 @@ GENERIC_SRCS = \ $(GENERIC_DIR)/tclCompCmds.c \ $(GENERIC_DIR)/tclCompExpr.c \ $(GENERIC_DIR)/tclCompile.c \ + $(GENERIC_DIR)/tclConfig.c \ $(GENERIC_DIR)/tclDate.c \ $(GENERIC_DIR)/tclDictObj.c \ $(GENERIC_DIR)/tclEncoding.c \ @@ -383,6 +384,7 @@ GENERIC_SRCS = \ $(GENERIC_DIR)/tclPathObj.c \ $(GENERIC_DIR)/tclPipe.c \ $(GENERIC_DIR)/tclPkg.c \ + $(GENERIC_DIR)/tclPkgConfig.c \ $(GENERIC_DIR)/tclPosixStr.c \ $(GENERIC_DIR)/tclPreserve.c \ $(GENERIC_DIR)/tclProc.c \ @@ -838,6 +840,9 @@ tclCompExpr.o: $(GENERIC_DIR)/tclCompExpr.c tclCompile.o: $(GENERIC_DIR)/tclCompile.c $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclCompile.c +tclConfig.o: $(GENERIC_DIR)/tclConfig.c + $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclConfig.c + tclDictObj.o: $(GENERIC_DIR)/tclDictObj.c $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclDictObj.c @@ -958,6 +963,31 @@ tclPipe.o: $(GENERIC_DIR)/tclPipe.c tclPkg.o: $(GENERIC_DIR)/tclPkg.c $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclPkg.c +# TIP #59, embedding of configuration information into the binary library. +# +# Part of Tcl's configuration information are the paths where it was +# installed and where it will look for its libraries (which can be +# different). We derive this information from the variables which can +# be overridden by the user. As every path can be configured +# separately we do not remember one general prefix/exec_prefix but all +# the different paths individually. + +tclPkgConfig.o: $(GENERIC_DIR)/tclPkgConfig.c + $(CC) -c $(CC_SWITCHES) \ + -DCFG_INSTALL_LIBDIR=\"$(LIB_INSTALL_DIR)\" \ + -DCFG_INSTALL_BINDIR=\"$(BIN_INSTALL_DIR)\" \ + -DCFG_INSTALL_SCRDIR=\"$(SCRIPT_INSTALL_DIR)\" \ + -DCFG_INSTALL_INCDIR=\"$(INCLUDE_INSTALL_DIR)\" \ + -DCFG_INSTALL_DOCDIR=\"$(MAN_INSTALL_DIR)\" \ + \ + -DCFG_RUNTIME_LIBDIR=\"$(libdir)\" \ + -DCFG_RUNTIME_BINDIR=\"$(bindir)\" \ + -DCFG_RUNTIME_SCRDIR=\"$(TCL_LIBRARY)\" \ + -DCFG_RUNTIME_INCDIR=\"$(includedir)\" \ + -DCFG_RUNTIME_DOCDIR=\"$(mandir)\" \ + \ + $(GENERIC_DIR)/tclPkgConfig.c + tclPosixStr.o: $(GENERIC_DIR)/tclPosixStr.c $(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tclPosixStr.c diff --git a/unix/configure b/unix/configure index a7732ba..490d1b2 100755 --- a/unix/configure +++ b/unix/configure @@ -852,6 +852,11 @@ Optional Features: --enable-symbols build with debugging symbols --disable-symbols --enable-framework package shared libraries in frameworks --disable-framework +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-encoding encoding for configuration values + Some influential environment variables: CC C compiler command CFLAGS C compiler flags @@ -2103,12 +2108,12 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (exit $ac_status); }; }; then for ac_declaration in \ ''\ - '#include ' \ 'extern "C" void std::exit (int) throw (); using std::exit;' \ 'extern "C" void std::exit (int); using std::exit;' \ 'extern "C" void exit (int) throw ();' \ 'extern "C" void exit (int);' \ - 'void exit (int);' + 'void exit (int);' \ + '#include ' do cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" @@ -3369,6 +3374,30 @@ echo "${ECHO_T}no (default)" >&6 #------------------------------------------------------------------------ +# Embedded configuration information, encoding to use for the values, TIP #59 +#------------------------------------------------------------------------ + + + +# Check whether --with-encoding or --without-encoding was given. +if test "${with_encoding+set}" = set; then + withval="$with_encoding" + with_tcencoding=${withval} +fi; + + if test x"${with_tcencoding}" != x ; then + cat >>confdefs.h <<_ACEOF +#define TCL_CFGVAL_ENCODING "${with_tcencoding}" +_ACEOF + + else + cat >>confdefs.h <<\_ACEOF +#define TCL_CFGVAL_ENCODING "iso8859-1" +_ACEOF + + fi + +#------------------------------------------------------------------------ # If we're using GCC, see if the compiler understands -pipe. If so, use it. # It makes compiling go faster. (This is only a performance feature.) #------------------------------------------------------------------------ @@ -12340,6 +12369,13 @@ echo "${ECHO_T}$found" >&6 echo "$as_me: WARNING: \"64bit support being disabled -- don\'t know magic for this platform\"" >&2;} fi + if test "$do64bit" = "yes" -a "$do64bit_ok" = "yes" ; then + cat >>confdefs.h <<\_ACEOF +#define TCL_CFG_DO64BIT 1 +_ACEOF + + fi + # Step 4: If pseudo-static linking is in use (see K. B. Kenny, "Dynamic # Loading for Tcl -- What Became of It?". Proc. 2nd Tcl/Tk Workshop, # New Orleans, LA, Computerized Processes Unlimited, 1994), then we need @@ -12691,6 +12727,10 @@ fi; DBGX="" echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 + cat >>confdefs.h <<\_ACEOF +#define TCL_CFG_OPTIMIZED 1 +_ACEOF + else CFLAGS_DEFAULT='$(CFLAGS_DEBUG)' LDFLAGS_DEFAULT='$(LDFLAGS_DEBUG)' @@ -12702,6 +12742,10 @@ echo "${ECHO_T}yes (standard debugging)" >&6 fi + cat >>confdefs.h <<\_ACEOF +#define TCL_CFG_DEBUG 1 +_ACEOF + if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then cat >>confdefs.h <<\_ACEOF diff --git a/unix/configure.in b/unix/configure.in index c538308..2fa70f2 100644 --- a/unix/configure.in +++ b/unix/configure.in @@ -3,7 +3,7 @@ dnl This file is an input file used by the GNU "autoconf" program to dnl generate the file "configure", which is run during Tcl installation dnl to configure the system for the local environment. # -# RCS: @(#) $Id: configure.in,v 1.109 2003/05/14 19:21:29 das Exp $ +# RCS: @(#) $Id: configure.in,v 1.110 2003/06/09 22:48:52 andreas_kupries Exp $ AC_INIT(../generic/tcl.h) AC_PREREQ(2.57) @@ -53,6 +53,12 @@ AC_HAVE_HEADERS(unistd.h limits.h) SC_ENABLE_THREADS #------------------------------------------------------------------------ +# Embedded configuration information, encoding to use for the values, TIP #59 +#------------------------------------------------------------------------ + +SC_TCL_CFG_ENCODING + +#------------------------------------------------------------------------ # If we're using GCC, see if the compiler understands -pipe. If so, use it. # It makes compiling go faster. (This is only a performance feature.) #------------------------------------------------------------------------ diff --git a/unix/mkLinks b/unix/mkLinks index db78f2e..ee5a5fe 100644 --- a/unix/mkLinks +++ b/unix/mkLinks @@ -1090,6 +1090,10 @@ if test -r RecordEval.3; then rm -f Tcl_RecordAndEval.3 Tcl_RecordAndEval.3.* ln $S RecordEval.3$Z Tcl_RecordAndEval.3$Z fi +if test -r RegConfig.3; then + rm -f Tcl_RegisterConfig.3 + ln RegConfig.3 Tcl_RegisterConfig.3 +fi if test -r RegExp.3; then rm -f RegExp.3.* $ZIP RegExp.3 diff --git a/unix/tcl.m4 b/unix/tcl.m4 index 03418d2..b747142 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -501,6 +501,7 @@ AC_DEFUN(SC_ENABLE_SYMBOLS, [ LDFLAGS_DEFAULT='$(LDFLAGS_OPTIMIZE)' DBGX="" AC_MSG_RESULT([no]) + AC_DEFINE(TCL_CFG_OPTIMIZED) else CFLAGS_DEFAULT='$(CFLAGS_DEBUG)' LDFLAGS_DEFAULT='$(LDFLAGS_DEBUG)' @@ -511,6 +512,7 @@ AC_DEFUN(SC_ENABLE_SYMBOLS, [ fi AC_SUBST(CFLAGS_DEFAULT) AC_SUBST(LDFLAGS_DEFAULT) + AC_DEFINE(TCL_CFG_DEBUG) if test "$tcl_ok" = "mem" -o "$tcl_ok" = "all"; then AC_DEFINE(TCL_MEM_DEBUG) @@ -1564,6 +1566,10 @@ dnl AC_CHECK_TOOL(AR, ar) AC_MSG_WARN("64bit support being disabled -- don\'t know magic for this platform") fi + if test "$do64bit" = "yes" -a "$do64bit_ok" = "yes" ; then + AC_DEFINE(TCL_CFG_DO64BIT) + fi + # Step 4: If pseudo-static linking is in use (see K. B. Kenny, "Dynamic # Loading for Tcl -- What Became of It?". Proc. 2nd Tcl/Tk Workshop, # New Orleans, LA, Computerized Processes Unlimited, 1994), then we need @@ -2465,3 +2471,29 @@ AC_DEFUN(SC_TCL_64BIT_FLAGS, [ fi AC_MSG_RESULT(${tcl_cv_type_off64_t}) fi]) + +#-------------------------------------------------------------------- +# SC_TCL_CFG_ENCODING TIP #59 +# +# Declare the encoding to use for embedded configuration information. +# +# Arguments: +# None. +# +# Results: +# Might append to the following vars: +# DEFS (implicit) +# +# Will define the following vars: +# TCL_CFGVAL_ENCODING +# +#-------------------------------------------------------------------- + +AC_DEFUN(SC_TCL_CFG_ENCODING, [ + AC_ARG_WITH(encoding, [ --with-encoding encoding for configuration values], with_tcencoding=${withval}) + + if test x"${with_tcencoding}" != x ; then + AC_DEFINE_UNQUOTED(TCL_CFGVAL_ENCODING,"${with_tcencoding}") + else + AC_DEFINE(TCL_CFGVAL_ENCODING,"iso8859-1") + fi]) -- cgit v0.12