Changes On Branch bug-3fc3287497
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch bug-3fc3287497 Excluding Merge-Ins

This is equivalent to a diff from d0923796c9 to e99ba02756

2024-05-23
13:48
Fix [3fc3287497]: TclGetProcessGlobalValue encodes information twice on Windows check-in: 5de1d4a68b user: jan.nijtmans tags: core-8-6-branch
11:27
Better flag up the oo::Slot class in the docs, add missing method [28d6013ae6] check-in: 743169db55 user: dkf tags: core-8-6-branch
10:18
Possible fix for [3fc3287497]: TclGetProcessGlobalValue encodes information twice on Windows Closed-Leaf check-in: e99ba02756 user: jan.nijtmans tags: bug-3fc3287497
2024-05-22
22:24
.travis.yml is not used any more check-in: 918bf2ae16 user: jan.nijtmans tags: core-8-branch
22:15
.travis.yml is not used any more check-in: d0923796c9 user: jan.nijtmans tags: core-8-6-branch
10:22
cherry-pick [659ca0ae8da43a1e] for 8.6: don't need to invoke it in case if oPtr->selfCls is NULL check-in: 3ebb66feb1 user: sebres tags: core-8-6-branch

Changes to generic/tclUtil.c.
4208
4209
4210
4211
4212
4213
4214

4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228


4229
4230


4231
4232
4233
4234
4235
4236
4237
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232

4233
4234
4235
4236
4237
4238
4239
4240
4241







+














+
+

-
+
+







    Tcl_Obj *newValue,
    Tcl_Encoding encoding)
{
    const char *bytes;
    Tcl_HashTable *cacheMap;
    Tcl_HashEntry *hPtr;
    int dummy;
    Tcl_DString ds;

    Tcl_MutexLock(&pgvPtr->mutex);

    /*
     * Fill the global string value.
     */

    pgvPtr->epoch++;
    if (NULL != pgvPtr->value) {
	ckfree(pgvPtr->value);
    } else {
	Tcl_CreateExitHandler(FreeProcessGlobalValue, pgvPtr);
    }
    bytes = TclGetStringFromObj(newValue, &pgvPtr->numBytes);
    Tcl_UtfToExternalDString(encoding, bytes, pgvPtr->numBytes, &ds);
    pgvPtr->numBytes = Tcl_DStringLength(&ds);
    pgvPtr->value = (char *)ckalloc(pgvPtr->numBytes + 1);
    memcpy(pgvPtr->value, bytes, pgvPtr->numBytes + 1);
    memcpy(pgvPtr->value, Tcl_DStringValue(&ds), pgvPtr->numBytes + 1);
    Tcl_DStringFree(&ds);
    if (pgvPtr->encoding) {
	Tcl_FreeEncoding(pgvPtr->encoding);
    }
    pgvPtr->encoding = encoding;

    /*
     * Fill the local thread copy directly with the Tcl_Obj value to avoid
4265
4266
4267
4268
4269
4270
4271

4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283

4284
4285
4286
4287
4288
4289
4290
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287

4288
4289
4290
4291
4292
4293
4294
4295







+











-
+







TclGetProcessGlobalValue(
    ProcessGlobalValue *pgvPtr)
{
    Tcl_Obj *value = NULL;
    Tcl_HashTable *cacheMap;
    Tcl_HashEntry *hPtr;
    int epoch = pgvPtr->epoch;
    Tcl_DString newValue;

    if (pgvPtr->encoding) {
	Tcl_Encoding current = Tcl_GetEncoding(NULL, NULL);

	if (pgvPtr->encoding != current) {
	    /*
	     * The system encoding has changed since the global string value
	     * was saved. Convert the global value to be based on the new
	     * system encoding.
	     */

	    Tcl_DString native, newValue;
	    Tcl_DString native;

	    Tcl_MutexLock(&pgvPtr->mutex);
	    epoch = ++pgvPtr->epoch;
	    Tcl_UtfToExternalDString(pgvPtr->encoding, pgvPtr->value,
		    pgvPtr->numBytes, &native);
	    Tcl_ExternalToUtfDString(current, Tcl_DStringValue(&native),
	    Tcl_DStringLength(&native), &newValue);
4326
4327
4328
4329
4330
4331
4332
4333


4334
4335
4336



4337
4338
4339
4340
4341
4342
4343
4331
4332
4333
4334
4335
4336
4337

4338
4339
4340
4341

4342
4343
4344
4345
4346
4347
4348
4349
4350
4351







-
+
+


-
+
+
+







	    if (pgvPtr->value == NULL) {
		Tcl_Panic("PGV Initializer did not initialize");
	    }
	    Tcl_CreateExitHandler(FreeProcessGlobalValue, pgvPtr);
	}

	/*
	 * Store a copy of the shared value in our epoch-indexed cache.
	 * Store a copy of the shared value (but then in utf-8)
	 * in our epoch-indexed cache.
	 */

	value = Tcl_NewStringObj(pgvPtr->value, pgvPtr->numBytes);
	Tcl_ExternalToUtfDString(NULL, pgvPtr->value, pgvPtr->numBytes, &newValue);
	value = Tcl_NewStringObj(Tcl_DStringValue(&newValue), Tcl_DStringLength(&newValue));
	Tcl_DStringFree(&newValue);
	hPtr = Tcl_CreateHashEntry(cacheMap,
		INT2PTR(pgvPtr->epoch), &dummy);
	Tcl_MutexUnlock(&pgvPtr->mutex);
	Tcl_SetHashValue(hPtr, value);
	Tcl_IncrRefCount(value);
    }
    return (Tcl_Obj *)Tcl_GetHashValue(hPtr);
Changes to win/tclWinSock.c.
363
364
365
366
367
368
369
370


371

372
373
374



375
376
377
378
379
380
381
382
383
384
385
386
387



388
389

390
391
392
393
394
395
396

397
398
399
400
401
402
403
363
364
365
366
367
368
369

370
371
372
373
374


375
376
377
378
379
380
381
382
383
384
385





386
387
388


389



390
391
392

393
394
395
396
397
398
399
400







-
+
+

+

-
-
+
+
+








-
-
-
-
-
+
+
+
-
-
+
-
-
-



-
+







{
    WCHAR wbuf[256];
    DWORD length = sizeof(wbuf)/sizeof(WCHAR);
    Tcl_DString ds;

    if (GetComputerNameExW(ComputerNamePhysicalDnsFullyQualified, wbuf, &length) != 0) {
	/*
	 * Convert string from native to UTF then change to lowercase.
	 * Convert string from WCHAR to utf-8, then change to lowercase,
	 * then to system encoding.
	 */
	Tcl_DString inDs;

	Tcl_UtfToLower(Tcl_WinTCharToUtf((TCHAR *)wbuf, -1, &ds));

	Tcl_UtfToLower(Tcl_WinTCharToUtf((TCHAR *)wbuf, -1, &inDs));
	Tcl_UtfToExternalDString(NULL, Tcl_DStringValue(&inDs), -1, &ds);
	Tcl_DStringFree(&inDs);
    } else {
	Tcl_DStringInit(&ds);
	if (TclpHasSockets(NULL) == TCL_OK) {
	    /*
	     * The buffer size of 256 is recommended by the MSDN page that
	     * documents gethostname() as being always adequate.
	     */

	    Tcl_DString inDs;

	    Tcl_DStringInit(&inDs);
	    Tcl_DStringSetLength(&inDs, 256);
	    if (gethostname(Tcl_DStringValue(&inDs),
	    Tcl_DStringInit(&ds);
	    Tcl_DStringSetLength(&ds, 256);
	    gethostname(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
		    Tcl_DStringLength(&inDs)) == 0) {
		Tcl_ExternalToUtfDString(NULL, Tcl_DStringValue(&inDs),
	    Tcl_DStringSetLength(&ds, strlen(Tcl_DStringValue(&ds)));
			-1, &ds);
	    }
	    Tcl_DStringFree(&inDs);
	}
    }

    *encodingPtr = Tcl_GetEncoding(NULL, "utf-8");
    *encodingPtr = Tcl_GetEncoding(NULL, NULL);
    *lengthPtr = Tcl_DStringLength(&ds);
    *valuePtr = (char *)ckalloc(*lengthPtr + 1);
    memcpy(*valuePtr, Tcl_DStringValue(&ds), *lengthPtr + 1);
    Tcl_DStringFree(&ds);
}

/*