summaryrefslogtreecommitdiffstats
path: root/generic/tclLoad.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2020-11-03 15:32:46 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2020-11-03 15:32:46 (GMT)
commit8607752aa65f484ab844296ce90d2d2e5bfc2259 (patch)
tree645dfbaee93b71a5ba9a4458772d4b4719c83ae1 /generic/tclLoad.c
parent3b0ee42270085b039b75e2e27a3a145399a1bfac (diff)
downloadtcl-8607752aa65f484ab844296ce90d2d2e5bfc2259.zip
tcl-8607752aa65f484ab844296ce90d2d2e5bfc2259.tar.gz
tcl-8607752aa65f484ab844296ce90d2d2e5bfc2259.tar.bz2
Case-sensitive package names
Diffstat (limited to 'generic/tclLoad.c')
-rw-r--r--generic/tclLoad.c50
1 files changed, 20 insertions, 30 deletions
diff --git a/generic/tclLoad.c b/generic/tclLoad.c
index c143d0a..bea07ed 100644
--- a/generic/tclLoad.c
+++ b/generic/tclLoad.c
@@ -226,14 +226,8 @@ Tcl_LoadObjCmd(
Tcl_DStringAppend(&pkgName, packageName, -1);
TclDStringClear(&tmp);
Tcl_DStringAppend(&tmp, pkgPtr->packageName, -1);
- Tcl_UtfToLower(Tcl_DStringValue(&pkgName));
- Tcl_UtfToLower(Tcl_DStringValue(&tmp));
- if (strcmp(Tcl_DStringValue(&tmp),
- Tcl_DStringValue(&pkgName)) == 0) {
- namesMatch = 1;
- } else {
- namesMatch = 0;
- }
+ namesMatch = (strcmp(Tcl_DStringValue(&tmp),
+ Tcl_DStringValue(&pkgName)) == 0);
}
TclDStringClear(&pkgName);
@@ -359,27 +353,29 @@ Tcl_LoadObjCmd(
}
/*
- * Fix the capitalization in the package name so that the first
- * character is in caps (or title case) but the others are all
- * lower-case.
- */
-
- Tcl_DStringSetLength(&pkgName,
- Tcl_UtfToTitle(Tcl_DStringValue(&pkgName)));
-
- /*
- * Compute the names of the two initialization functions, based on the
+ * Compute the names of the initialization functions, based on the
* package name.
*/
TclDStringAppendDString(&initName, &pkgName);
- TclDStringAppendLiteral(&initName, "_Init");
- TclDStringAppendDString(&safeInitName, &pkgName);
+ Tcl_DStringSetLength(&initName,
+ Tcl_UtfToTitle(Tcl_DStringValue(&initName)));
+ while (strchr(Tcl_DStringValue(&initName), ':') != NULL) {
+ char *r;
+ p = Tcl_DStringValue(&initName);
+ r = strchr((char *)p, ':');
+ if ((r != NULL) && (r[1] == ':')) {
+ memmove(r, r+2, strlen(r+1));
+ }
+ Tcl_DStringSetLength(&initName, strlen(p));
+ }
+ TclDStringAppendDString(&safeInitName, &initName);
TclDStringAppendLiteral(&safeInitName, "_SafeInit");
- TclDStringAppendDString(&unloadName, &pkgName);
+ TclDStringAppendDString(&unloadName, &initName);
TclDStringAppendLiteral(&unloadName, "_Unload");
- TclDStringAppendDString(&safeUnloadName, &pkgName);
+ TclDStringAppendDString(&safeUnloadName, &initName);
TclDStringAppendLiteral(&safeUnloadName, "_SafeUnload");
+ TclDStringAppendLiteral(&initName, "_Init");
/*
* Call platform-specific code to load the package and find the two
@@ -663,14 +659,8 @@ Tcl_UnloadObjCmd(
Tcl_DStringAppend(&pkgName, packageName, -1);
TclDStringClear(&tmp);
Tcl_DStringAppend(&tmp, pkgPtr->packageName, -1);
- Tcl_UtfToLower(Tcl_DStringValue(&pkgName));
- Tcl_UtfToLower(Tcl_DStringValue(&tmp));
- if (strcmp(Tcl_DStringValue(&tmp),
- Tcl_DStringValue(&pkgName)) == 0) {
- namesMatch = 1;
- } else {
- namesMatch = 0;
- }
+ namesMatch = (strcmp(Tcl_DStringValue(&tmp),
+ Tcl_DStringValue(&pkgName)) == 0);
}
TclDStringClear(&pkgName);