Tk Source Code

Check-in [349169c6]
Login

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

Overview
Comment:let Tk_NameOfColor output a shorter color-name, when possible
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | bug-3486474
Files: files | file ages | folders
SHA1: 349169c6e72a71913bcc65f1d02376249ef5f388
User & Date: jan.nijtmans 2012-02-11 00:19:20
Context
2012-02-12
17:46
improved, faster implementations of XParseColor and TkParseColor Closed-Leaf check-in: acbeaf88 user: jan.nijtmans tags: bug-3486474
2012-02-11
00:19
let Tk_NameOfColor output a shorter color-name, when possible check-in: 349169c6 user: jan.nijtmans tags: bug-3486474
2012-02-10
23:55
proposed fix for bug-3486474 check-in: 6f74cf37 user: jan.nijtmans tags: bug-3486474
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tkColor.c.

371
372
373
374
375
376
377















378
379
380
381
382
383
384
	    (tkColPtr->type == TK_COLOR_BY_NAME)) {
	return tkColPtr->hashPtr->key.string;
    } else {
	ThreadSpecificData *tsdPtr = (ThreadSpecificData *) 
            Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
	sprintf(tsdPtr->rgbString, "#%04x%04x%04x", colorPtr->red, 
		colorPtr->green, colorPtr->blue);















	return tsdPtr->rgbString;
    }
}

/*
 *----------------------------------------------------------------------
 *







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
	    (tkColPtr->type == TK_COLOR_BY_NAME)) {
	return tkColPtr->hashPtr->key.string;
    } else {
	ThreadSpecificData *tsdPtr = (ThreadSpecificData *) 
            Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
	sprintf(tsdPtr->rgbString, "#%04x%04x%04x", colorPtr->red, 
		colorPtr->green, colorPtr->blue);
	/* If the string has the form #RSRSTUTUVWVW (where equal
	 * letters denote equal hexdigits) then this is
	 * equivalent to #RSTUVW. Then output the shorter form */
	if ((tsdPtr->rgbString[1] == tsdPtr->rgbString[3])
		&& (tsdPtr->rgbString[2] == tsdPtr->rgbString[4])
		&& (tsdPtr->rgbString[5] == tsdPtr->rgbString[7])
		&& (tsdPtr->rgbString[6] == tsdPtr->rgbString[8])
		&& (tsdPtr->rgbString[9] == tsdPtr->rgbString[11])
		&& (tsdPtr->rgbString[10] == tsdPtr->rgbString[12])) {
	    tsdPtr->rgbString[3] = tsdPtr->rgbString[5];
	    tsdPtr->rgbString[4] = tsdPtr->rgbString[6];
	    tsdPtr->rgbString[5] = tsdPtr->rgbString[9];
	    tsdPtr->rgbString[6] = tsdPtr->rgbString[10];
	    tsdPtr->rgbString[7] = '\0';
	}
	return tsdPtr->rgbString;
    }
}

/*
 *----------------------------------------------------------------------
 *