diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-11-14 15:44:18 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-11-14 15:44:18 (GMT) |
commit | 6911c598992be928b62051c70e01041ec3ef0e8c (patch) | |
tree | 0e2781ab275f44c196a9c420a55f4aaae373e954 /generic/tclConfig.c | |
parent | 284b205a9a4c6d334b4f752ea17018f610a960bb (diff) | |
download | tcl-6911c598992be928b62051c70e01041ec3ef0e8c.zip tcl-6911c598992be928b62051c70e01041ec3ef0e8c.tar.gz tcl-6911c598992be928b62051c70e01041ec3ef0e8c.tar.bz2 |
Experiment: make ::tcl::pkgconfig more forgiving when the requested encoding cannot be found.
Diffstat (limited to 'generic/tclConfig.c')
-rw-r--r-- | generic/tclConfig.c | 75 |
1 files changed, 39 insertions, 36 deletions
diff --git a/generic/tclConfig.c b/generic/tclConfig.c index a4ba71a..6795203 100644 --- a/generic/tclConfig.c +++ b/generic/tclConfig.c @@ -78,6 +78,8 @@ Tcl_RegisterConfig( Tcl_DString cmdName; const Tcl_Config *cfg; Tcl_Encoding venc = Tcl_GetEncoding(NULL, valEncoding); + Tcl_Obj *pkgDict, *pDB; + QCCD *cdPtr = ckalloc(sizeof(QCCD)); cdPtr->interp = interp; @@ -99,55 +101,56 @@ Tcl_RegisterConfig( Tcl_IncrRefCount(cdPtr->pkg); /* - * For venc == NULL aka bogus encoding we skip the step setting up the - * dictionaries visible at Tcl level. I.e. they are not filled + * For venc == NULL aka bogus encoding we fall back to "iso8859-1" */ - if (venc != NULL) { - Tcl_Obj *pkgDict, *pDB = GetConfigDict(interp); - - /* - * Retrieve package specific configuration... - */ + if (venc == NULL) { + venc = Tcl_GetEncoding("iso8859-1", valEncoding);; + } - if (Tcl_DictObjGet(interp, pDB, cdPtr->pkg, &pkgDict) != TCL_OK - || (pkgDict == NULL)) { - pkgDict = Tcl_NewDictObj(); - } else if (Tcl_IsShared(pkgDict)) { - pkgDict = Tcl_DuplicateObj(pkgDict); - } + pDB = GetConfigDict(interp); - /* - * Extend the package configuration... - */ + /* + * Retrieve package specific configuration... + */ - for (cfg=configuration ; cfg->key!=NULL && cfg->key[0]!='\0' ; cfg++) { - Tcl_DString conv; - const char *convValue = - Tcl_ExternalToUtfDString(venc, cfg->value, -1, &conv); + if (Tcl_DictObjGet(interp, pDB, cdPtr->pkg, &pkgDict) != TCL_OK + || (pkgDict == NULL)) { + pkgDict = Tcl_NewDictObj(); + } else if (Tcl_IsShared(pkgDict)) { + pkgDict = Tcl_DuplicateObj(pkgDict); + } - /* - * We know that the keys are in ASCII/UTF-8, so for them is no - * conversion required. - */ + /* + * Extend the package configuration... + */ - Tcl_DictObjPut(interp, pkgDict, Tcl_NewStringObj(cfg->key, -1), - Tcl_NewStringObj(convValue, -1)); - Tcl_DStringFree(&conv); - } + for (cfg=configuration ; cfg->key!=NULL && cfg->key[0]!='\0' ; cfg++) { + Tcl_DString conv; + const char *convValue = + Tcl_ExternalToUtfDString(venc, cfg->value, -1, &conv); /* - * We're now done with the encoding, so drop it. + * We know that the keys are in ASCII/UTF-8, so for them is no + * conversion required. */ - Tcl_FreeEncoding(venc); + Tcl_DictObjPut(interp, pkgDict, Tcl_NewStringObj(cfg->key, -1), + Tcl_NewStringObj(convValue, -1)); + Tcl_DStringFree(&conv); + } - /* - * Write the changes back into the overall database. - */ + /* + * We're now done with the encoding, so drop it. + */ - Tcl_DictObjPut(interp, pDB, cdPtr->pkg, pkgDict); - } + Tcl_FreeEncoding(venc); + + /* + * Write the changes back into the overall database. + */ + + Tcl_DictObjPut(interp, pDB, cdPtr->pkg, pkgDict); /* * Now create the interface command for retrieval of the package |