Tk Source Code

Check-in [6f74cf37]
Login

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

Overview
Comment:proposed fix for bug-3486474
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | bug-3486474
Files: files | file ages | folders
SHA1: 6f74cf37d47277636825553974d4f586dccb35ca
User & Date: jan.nijtmans 2012-02-10 23:55:24
Context
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
2012-01-25
22:00
Bug-2433260: non-critical error in Tk_PhotoPutBlock check-in: a2b769a6 user: jan.nijtmans tags: core-8-4-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to doc/GetColor.3.

91
92
93
94
95
96
97
98

99
100
101
102
103
104
105
106
.TP 20
\fB#\fIRRRRGGGGBBBB\fR
A numeric specification of the red, green, and blue intensities
to use to display the color.  Each \fIR\fR, \fIG\fR, or \fIB\fR
represents a single hexadecimal digit.  The four forms permit
colors to be specified with 4-bit, 8-bit, 12-bit or 16-bit values.
When fewer than 16 bits are provided for each color, they represent
the most significant bits of the color.  For example, #3a7 is the

same as #3000a0007000.
.PP
.VS 8.1
\fBTk_AllocColorFromObj\fR returns a pointer to
an XColor structure;  the structure indicates the exact intensities of
the allocated color (which may differ slightly from those requested,
depending on the limitations of the screen) and a pixel value
that may be used to draw with the color in \fItkwin\fR.







|
>
|







91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
.TP 20
\fB#\fIRRRRGGGGBBBB\fR
A numeric specification of the red, green, and blue intensities
to use to display the color.  Each \fIR\fR, \fIG\fR, or \fIB\fR
represents a single hexadecimal digit.  The four forms permit
colors to be specified with 4-bit, 8-bit, 12-bit or 16-bit values.
When fewer than 16 bits are provided for each color, they represent
the most significant bits of the color, while the lower unfilled
bits will be repeatedly replicated from the available higher bits.
For example, #3a7 is the same as #3333aaaa7777.
.PP
.VS 8.1
\fBTk_AllocColorFromObj\fR returns a pointer to
an XColor structure;  the structure indicates the exact intensities of
the allocated color (which may differ slightly from those requested,
depending on the limitations of the screen) and a pixel value
that may be used to draw with the color in \fItkwin\fR.

Changes to generic/tkColor.c.

805
806
807
808
809
810
811























































	    Tcl_ListObjAppendElement(NULL, objPtr,
		    Tcl_NewIntObj(tkColPtr->objRefCount)); 
	    Tcl_ListObjAppendElement(NULL, resultPtr, objPtr);
	}
    }
    return resultPtr;
}






























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
	    Tcl_ListObjAppendElement(NULL, objPtr,
		    Tcl_NewIntObj(tkColPtr->objRefCount)); 
	    Tcl_ListObjAppendElement(NULL, resultPtr, objPtr);
	}
    }
    return resultPtr;
}

#ifndef __WIN32__
/* This function is not necessary for Win32,
 * since XParseColor already does the right thing */
Status
TkParseColor(display, map, spec, colorPtr)
    Display * display;		/* The display */
    Colormap map;			/* Color map */
    _Xconst char* spec;     /* String to be parsed */
    XColor * colorPtr;
{
    if (*spec == '#') {
    char buf[14];
    buf[0] = '#'; buf[13] = '\0';
	if (!spec[1] || !spec[2] || !spec[3]) {
	/* Not at least 3 hex digits, so invalid */
	return 0;
	} else if (!spec[4]) {
	/* Exactly 3 hex digits */
	buf[1] = buf[2] = buf[3] = buf[4] = spec[1];
	buf[5] = buf[6] = buf[7] = buf[8] = spec[2];
	buf[9] = buf[10] = buf[11] = buf[12] = spec[3];
	return XParseColor(display, map, buf, colorPtr);
	} else if (!spec[5]	|| !spec[6]) {
	/* Not at least 6 hex digits, so invalid */
	return 0;
	} else if (!spec[7]) {
	/* Exactly 6 hex digits */
	buf[1] = buf[3] = spec[1];
	buf[2] = buf[4] = spec[2];
	buf[5] = buf[7] = spec[3];
	buf[6] = buf[8] = spec[4];
	buf[9] = buf[11] = spec[5];
	buf[10] = buf[12] = spec[6];
	return XParseColor(display, map, buf, colorPtr);
	} else if (!spec[8] || !spec[9]) {
	/* Not at least 9 hex digits, so invalid */
	return 0;
	} else if (!spec[10]) {
	/* Exactly 9 hex digits */
	buf[1] = buf[4] = spec[1];
	buf[2] = spec[2];
	buf[3] = spec[3];
	buf[5] = buf[8] = spec[4];
	buf[6] = spec[5];
	buf[7] = spec[6];
	buf[9] = buf[12] = spec[7];
	buf[10] = spec[8];
	buf[11] = spec[9];
	return XParseColor(display, map, buf, colorPtr);
	}
    }
    return XParseColor(display, map, spec, colorPtr);
}
#endif /* __WIN32__ */

Changes to generic/tkCursor.c.

353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
    }

    /*
     * No suitable cursor exists yet.  Make one using the data
     * available and add it to the database.
     */

    if (XParseColor(dataKey.display, Tk_Colormap(tkwin), fg, &fgColor) == 0) {
	Tcl_AppendResult(interp, "invalid color name \"", fg, "\"",
		(char *) NULL);
	goto error;
    }
    if (XParseColor(dataKey.display, Tk_Colormap(tkwin), bg, &bgColor) == 0) {
	Tcl_AppendResult(interp, "invalid color name \"", bg, "\"",
		(char *) NULL);
	goto error;
    }

    cursorPtr = TkCreateCursorFromData(tkwin, source, mask, width, height,
	    xHot, yHot, fgColor, bgColor);







|




|







353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
    }

    /*
     * No suitable cursor exists yet.  Make one using the data
     * available and add it to the database.
     */

    if (TkParseColor(dataKey.display, Tk_Colormap(tkwin), fg, &fgColor) == 0) {
	Tcl_AppendResult(interp, "invalid color name \"", fg, "\"",
		(char *) NULL);
	goto error;
    }
    if (TkParseColor(dataKey.display, Tk_Colormap(tkwin), bg, &bgColor) == 0) {
	Tcl_AppendResult(interp, "invalid color name \"", bg, "\"",
		(char *) NULL);
	goto error;
    }

    cursorPtr = TkCreateCursorFromData(tkwin, source, mask, width, height,
	    xHot, yHot, fgColor, bgColor);

Changes to generic/tkImgBmap.c.

1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
     * background is transparent.  If the background is not transparent and
     * there is no background mask, then color the complete rectangle that
     * encloses the bitmap.  If there is a background mask, then only apply
     * color to the bits specified by the mask.
     */
    if ((masterPtr->bgUid != NULL) && (masterPtr->bgUid[0] != '\000')) {
	XColor color;
	XParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), masterPtr->bgUid,
		&color);
	if (Tk_PostscriptColor(interp, psinfo, &color) != TCL_OK) {
	    return TCL_ERROR;
	}
	if (masterPtr->maskData == NULL) {
	    Tcl_AppendResult(interp,
		"0 0 moveto 1 0 rlineto 0 1 rlineto -1 0 rlineto "
		"closepath fill\n", NULL);
	} else if (ImgBmapPsImagemask(interp, masterPtr->width,
		     masterPtr->height, masterPtr->maskData) != TCL_OK) {
	    return TCL_ERROR;
	}
    }

    /*
     * Draw the bitmap foreground, assuming there is one.
     */
    if ( (masterPtr->fgUid != NULL) && (masterPtr->data != NULL) ) {
	XColor color;
	XParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), masterPtr->fgUid,
		&color);
	if (Tk_PostscriptColor(interp, psinfo, &color) != TCL_OK) {
	    return TCL_ERROR;
	}
	if (ImgBmapPsImagemask(interp, masterPtr->width, masterPtr->height,
		masterPtr->data) != TCL_OK) {
	    return TCL_ERROR;
	}
    }
    return TCL_OK;
}







|



















|











1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
     * background is transparent.  If the background is not transparent and
     * there is no background mask, then color the complete rectangle that
     * encloses the bitmap.  If there is a background mask, then only apply
     * color to the bits specified by the mask.
     */
    if ((masterPtr->bgUid != NULL) && (masterPtr->bgUid[0] != '\000')) {
	XColor color;
	TkParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), masterPtr->bgUid,
		&color);
	if (Tk_PostscriptColor(interp, psinfo, &color) != TCL_OK) {
	    return TCL_ERROR;
	}
	if (masterPtr->maskData == NULL) {
	    Tcl_AppendResult(interp,
		"0 0 moveto 1 0 rlineto 0 1 rlineto -1 0 rlineto "
		"closepath fill\n", NULL);
	} else if (ImgBmapPsImagemask(interp, masterPtr->width,
		     masterPtr->height, masterPtr->maskData) != TCL_OK) {
	    return TCL_ERROR;
	}
    }

    /*
     * Draw the bitmap foreground, assuming there is one.
     */
    if ( (masterPtr->fgUid != NULL) && (masterPtr->data != NULL) ) {
	XColor color;
	TkParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), masterPtr->fgUid,
		&color);
	if (Tk_PostscriptColor(interp, psinfo, &color) != TCL_OK) {
	    return TCL_ERROR;
	}
	if (ImgBmapPsImagemask(interp, masterPtr->width, masterPtr->height,
		masterPtr->data) != TCL_OK) {
	    return TCL_ERROR;
	}
    }
    return TCL_OK;
}

Changes to generic/tkImgPhoto.c.

1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
	    } else if (listArgc != dataWidth) {
		Tcl_AppendResult(interp, "all elements of color list must",
			" have the same number of elements", (char *) NULL);
		ckfree((char *) listArgv);
		break;
	    }
	    for (x = 0; x < dataWidth; ++x) {
		if (!XParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin),
			listArgv[x], &color)) {
		    Tcl_AppendResult(interp, "can't parse color \"",
			    listArgv[x], "\"", (char *) NULL);
		    break;
		}
		*pixelPtr++ = color.red >> 8;
		*pixelPtr++ = color.green >> 8;







|







1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
	    } else if (listArgc != dataWidth) {
		Tcl_AppendResult(interp, "all elements of color list must",
			" have the same number of elements", (char *) NULL);
		ckfree((char *) listArgv);
		break;
	    }
	    for (x = 0; x < dataWidth; ++x) {
		if (!TkParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin),
			listArgv[x], &color)) {
		    Tcl_AppendResult(interp, "can't parse color \"",
			    listArgv[x], "\"", (char *) NULL);
		    break;
		}
		*pixelPtr++ = color.red >> 8;
		*pixelPtr++ = color.green >> 8;

Changes to generic/tkInt.h.

1209
1210
1211
1212
1213
1214
1215







1216
1217
1218
1219
1220
1221
1222
EXTERN Tcl_ExitProc	TkFinalize;
EXTERN void		TkPrintPadAmount _ANSI_ARGS_((Tcl_Interp *interp,
			    char *buffer, int pad1, int pad2));
EXTERN int		TkParsePadAmount _ANSI_ARGS_((Tcl_Interp *interp,
			    Tk_Window tkwin, Tcl_Obj *objPtr,
			    int *pad1Ptr, int *pad2Ptr));
EXTERN int		TkpAlwaysShowSelection _ANSI_ARGS_((Tk_Window tkwin));








/*
 * Unsupported commands.
 */
EXTERN int		TkUnsupported1ObjCmd _ANSI_ARGS_((
			    ClientData clientData, Tcl_Interp *interp,
			    int objc, Tcl_Obj *CONST objv[]));







>
>
>
>
>
>
>







1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
EXTERN Tcl_ExitProc	TkFinalize;
EXTERN void		TkPrintPadAmount _ANSI_ARGS_((Tcl_Interp *interp,
			    char *buffer, int pad1, int pad2));
EXTERN int		TkParsePadAmount _ANSI_ARGS_((Tcl_Interp *interp,
			    Tk_Window tkwin, Tcl_Obj *objPtr,
			    int *pad1Ptr, int *pad2Ptr));
EXTERN int		TkpAlwaysShowSelection _ANSI_ARGS_((Tk_Window tkwin));
#ifdef __WIN32__
#define TkParseColor XParseColor
#else
EXTERN Status TkParseColor _ANSI_ARGS_((Display * display,
				Colormap map, _Xconst char* spec,
				XColor * colorPtr));
#endif

/*
 * Unsupported commands.
 */
EXTERN int		TkUnsupported1ObjCmd _ANSI_ARGS_((
			    ClientData clientData, Tcl_Interp *interp,
			    int objc, Tcl_Obj *CONST objv[]));

Changes to mac/tkMacColor.c.

270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
	    
	    tkColPtr = (TkColor *) ckalloc(sizeof(TkColor));
	    tkColPtr->color = color;
	    return tkColPtr;
	}
    }
    
    if (XParseColor(display, colormap, name, &color) == 0) {
	return (TkColor *) NULL;
    }
    
    tkColPtr = (TkColor *) ckalloc(sizeof(TkColor));
    tkColPtr->color = color;

    return tkColPtr;







|







270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
	    
	    tkColPtr = (TkColor *) ckalloc(sizeof(TkColor));
	    tkColPtr->color = color;
	    return tkColPtr;
	}
    }
    
    if (TkParseColor(display, colormap, name, &color) == 0) {
	return (TkColor *) NULL;
    }
    
    tkColPtr = (TkColor *) ckalloc(sizeof(TkColor));
    tkColPtr->color = color;

    return tkColPtr;

Changes to macosx/tkMacOSXColor.c.

587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
		    | ((color.green >> 8) & 0xff)) << 8)
		    | ((color.blue  >> 8) & 0xff));
		goto validXColor;
	    }
	}
    }

    if (XParseColor(display, colormap, name, &color) == 0) {
	return (TkColor *) NULL;
    }

validXColor:
    tkColPtr = (TkColor *) ckalloc(sizeof(TkColor));
    tkColPtr->color = color;








|







587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
		    | ((color.green >> 8) & 0xff)) << 8)
		    | ((color.blue  >> 8) & 0xff));
		goto validXColor;
	    }
	}
    }

    if (TkParseColor(display, colormap, name, &color) == 0) {
	return (TkColor *) NULL;
    }

validXColor:
    tkColPtr = (TkColor *) ckalloc(sizeof(TkColor));
    tkColPtr->color = color;

Changes to unix/tkUnixColor.c.

164
165
166
167
168
169
170
171
172
173
174
175
176
177
178

	    if (XLookupColor(display, colormap, buf, &color, &screen) == 0) {
		return (TkColor *) NULL;
	    }
	    FindClosestColor(tkwin, &screen, &color);
	}
    } else {
	if (XParseColor(display, colormap, buf, &color) == 0) {
	    return (TkColor *) NULL;
	}
	if (XAllocColor(display, colormap, &color) != 0) {
	    DeleteStressedCmap(display, colormap);
	} else {
	    FindClosestColor(tkwin, &color, &color);
	}







|







164
165
166
167
168
169
170
171
172
173
174
175
176
177
178

	    if (XLookupColor(display, colormap, buf, &color, &screen) == 0) {
		return (TkColor *) NULL;
	    }
	    FindClosestColor(tkwin, &screen, &color);
	}
    } else {
	if (TkParseColor(display, colormap, buf, &color) == 0) {
	    return (TkColor *) NULL;
	}
	if (XAllocColor(display, colormap, &color) != 0) {
	    DeleteStressedCmap(display, colormap);
	} else {
	    FindClosestColor(tkwin, &color, &color);
	}

Changes to unix/tkUnixCursor.c.

190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
	    }
	}
	maskIndex = namePtr->shape + 1;
	if (argc == 1) {
	    fg.red = fg.green = fg.blue = 0;
	    bg.red = bg.green = bg.blue = 65535;
	} else {
	    if (XParseColor(display, Tk_Colormap(tkwin), argv[1],
		    &fg) == 0) {
		Tcl_AppendResult(interp, "invalid color name \"", argv[1],
			"\"", (char *) NULL);
		goto cleanup;
	    }
	    if (argc == 2) {
		bg.red = bg.green = bg.blue = 0;
		maskIndex = namePtr->shape;
	    } else {
		if (XParseColor(display, Tk_Colormap(tkwin), argv[2],
			&bg) == 0) {
		    Tcl_AppendResult(interp, "invalid color name \"", argv[2],
			    "\"", (char *) NULL);
		    goto cleanup;
		}
	    }
	}







|









|







190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
	    }
	}
	maskIndex = namePtr->shape + 1;
	if (argc == 1) {
	    fg.red = fg.green = fg.blue = 0;
	    bg.red = bg.green = bg.blue = 65535;
	} else {
	    if (TkParseColor(display, Tk_Colormap(tkwin), argv[1],
		    &fg) == 0) {
		Tcl_AppendResult(interp, "invalid color name \"", argv[1],
			"\"", (char *) NULL);
		goto cleanup;
	    }
	    if (argc == 2) {
		bg.red = bg.green = bg.blue = 0;
		maskIndex = namePtr->shape;
	    } else {
		if (TkParseColor(display, Tk_Colormap(tkwin), argv[2],
			&bg) == 0) {
		    Tcl_AppendResult(interp, "invalid color name \"", argv[2],
			    "\"", (char *) NULL);
		    goto cleanup;
		}
	    }
	}
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
	}
	if ((xHot < 0) || (yHot < 0) || (xHot >= width) || (yHot >= height)) {
	    Tcl_AppendResult(interp, "bad hot spot in bitmap file \"",
		    &argv[0][1], "\"", (char *) NULL);
	    goto cleanup;
	}
	if (argc == 2) {
	    if (XParseColor(display, Tk_Colormap(tkwin), argv[1],
		    &fg) == 0) {
		Tcl_AppendResult(interp, "invalid color name \"",
			argv[1], "\"", (char *) NULL);
		goto cleanup;
	    }
	    cursor = XCreatePixmapCursor(display, source, source,
		    &fg, &fg, (unsigned) xHot, (unsigned) yHot);







|







258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
	}
	if ((xHot < 0) || (yHot < 0) || (xHot >= width) || (yHot >= height)) {
	    Tcl_AppendResult(interp, "bad hot spot in bitmap file \"",
		    &argv[0][1], "\"", (char *) NULL);
	    goto cleanup;
	}
	if (argc == 2) {
	    if (TkParseColor(display, Tk_Colormap(tkwin), argv[1],
		    &fg) == 0) {
		Tcl_AppendResult(interp, "invalid color name \"",
			argv[1], "\"", (char *) NULL);
		goto cleanup;
	    }
	    cursor = XCreatePixmapCursor(display, source, source,
		    &fg, &fg, (unsigned) xHot, (unsigned) yHot);
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
	    }
	    if ((maskWidth != width) && (maskHeight != height)) {
		Tcl_SetResult(interp,
			"source and mask bitmaps have different sizes",
			TCL_STATIC);
		goto cleanup;
	    }
	    if (XParseColor(display, Tk_Colormap(tkwin), argv[2],
		    &fg) == 0) {
		Tcl_AppendResult(interp, "invalid color name \"", argv[2],
			"\"", (char *) NULL);
		goto cleanup;
	    }
	    if (XParseColor(display, Tk_Colormap(tkwin), argv[3],
		    &bg) == 0) {
		Tcl_AppendResult(interp, "invalid color name \"", argv[3],
			"\"", (char *) NULL);
		goto cleanup;
	    }
	    cursor = XCreatePixmapCursor(display, source, mask,
		    &fg, &bg, (unsigned) xHot, (unsigned) yHot);







|





|







281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
	    }
	    if ((maskWidth != width) && (maskHeight != height)) {
		Tcl_SetResult(interp,
			"source and mask bitmaps have different sizes",
			TCL_STATIC);
		goto cleanup;
	    }
	    if (TkParseColor(display, Tk_Colormap(tkwin), argv[2],
		    &fg) == 0) {
		Tcl_AppendResult(interp, "invalid color name \"", argv[2],
			"\"", (char *) NULL);
		goto cleanup;
	    }
	    if (TkParseColor(display, Tk_Colormap(tkwin), argv[3],
		    &bg) == 0) {
		Tcl_AppendResult(interp, "invalid color name \"", argv[3],
			"\"", (char *) NULL);
		goto cleanup;
	    }
	    cursor = XCreatePixmapCursor(display, source, mask,
		    &fg, &bg, (unsigned) xHot, (unsigned) yHot);

Changes to win/tkWinColor.c.

197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
     * Check to see if it is a system color or an X color string.  If the
     * color is found, allocate a new WinColor and store the XColor and the
     * system color index.
     */

    if (((strncasecmp(name, "system", 6) == 0)
	    && FindSystemColor(name+6, &color, &index))
	    || XParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), name,
		    &color)) {
	winColPtr = (WinColor *) ckalloc(sizeof(WinColor));
	winColPtr->info.color = color;
	winColPtr->index = index;

	XAllocColor(Tk_Display(tkwin), Tk_Colormap(tkwin),
		&winColPtr->info.color);







|







197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
     * Check to see if it is a system color or an X color string.  If the
     * color is found, allocate a new WinColor and store the XColor and the
     * system color index.
     */

    if (((strncasecmp(name, "system", 6) == 0)
	    && FindSystemColor(name+6, &color, &index))
	    || TkParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin), name,
		    &color)) {
	winColPtr = (WinColor *) ckalloc(sizeof(WinColor));
	winColPtr->info.color = color;
	winColPtr->index = index;

	XAllocColor(Tk_Display(tkwin), Tk_Colormap(tkwin),
		&winColPtr->info.color);

Changes to xlib/xcolors.c.

878
879
880
881
882
883
884
885
886
887





888








889
890
















891
892
893

894








895














896

897
898
899
900
901
902
903
904
905
906
907
908
909
XParseColor(display, map, spec, colorPtr)
    Display *display;
    Colormap map;
    const char* spec;
    XColor *colorPtr;
{
    if (spec[0] == '#') {
	char fmt[16];
	int i, red, green, blue;






	if ((i = (int) strlen(spec+1))%3) {








	    return 0;
	}
















	i /= 3;

	sprintf(fmt, "%%%dx%%%dx%%%dx", i, i, i);

	if (sscanf(spec+1, fmt, &red, &green, &blue) != 3) {








	    return 0;














	}

	colorPtr->red = (((unsigned short) red) << (4 * (4 - i)))
	    | ((unsigned short) red);
	colorPtr->green = (((unsigned short) green) << (4 * (4 - i)))
	    | ((unsigned short) green);
	colorPtr->blue = (((unsigned short) blue) << (4 * (4 - i)))
	    | ((unsigned short) blue);
    } else {
	if (!FindColor(spec, colorPtr)) {
	    return 0;
	}
    }
    colorPtr->pixel = TkpGetPixel(colorPtr);
    colorPtr->flags = DoRed|DoGreen|DoBlue;







|
<

>
>
>
>
>
|
>
>
>
>
>
>
>
>
|
<
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
<
>
|
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
|
<
|
<
|
<







878
879
880
881
882
883
884
885

886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901

902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919

920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947

948

949

950
951
952
953
954
955
956
XParseColor(display, map, spec, colorPtr)
    Display *display;
    Colormap map;
    const char* spec;
    XColor *colorPtr;
{
    if (spec[0] == '#') {
    char rstr[5], gstr[5], bstr[5];


    if (!isxdigit((unsigned char) spec[1])
	    || !isxdigit((unsigned char) spec[2])
	    || !isxdigit((unsigned char) spec[3])) {
	/* Not at least 3 hex digits, so invalid */
	return 0;
    } else if (!spec[4]) {
	/* Exactly 3 hex digits */
	rstr[0] = rstr[1] = rstr[2] = rstr[3] = spec[1];
	gstr[0] = gstr[1] = gstr[2] = gstr[3] = spec[2];
	bstr[0] = bstr[1] = bstr[2] = bstr[3] = spec[3];
    } else if (!isxdigit((unsigned char) spec[4])
	    || !isxdigit((unsigned char) spec[5])
	    || !isxdigit((unsigned char) spec[6])) {
	/* Not at least 6 hex digits, so invalid */
	return 0;

    } else if (!spec[7]) {
	/* Exactly 6 hex digits */
	rstr[0] = rstr[2] = spec[1];
	rstr[1] = rstr[3] = spec[2];
	gstr[0] = gstr[2] = spec[3];
	gstr[1] = gstr[3] = spec[4];
	bstr[0] = bstr[2] = spec[5];
	bstr[1] = bstr[3] = spec[6];
    } else if (!isxdigit((unsigned char) spec[7])
	    || !isxdigit((unsigned char) spec[8])
	    || !isxdigit((unsigned char) spec[9])) {
	/* Not at least 9 hex digits, so invalid */
	return 0;
    } else if (!spec[10]) {
	/* Exactly 9 hex digits */
	rstr[0] = rstr[3] = spec[1];
	rstr[1] = spec[2];
	rstr[2] = spec[3];

	gstr[0] = gstr[3] = spec[4];
	gstr[1] = spec[5];
	gstr[2] = spec[6];
	bstr[0] = bstr[3] = spec[7];
	bstr[1] = spec[8];
	bstr[2] = spec[9];
    } else if (!isxdigit((unsigned char) spec[10])
	    || !isxdigit((unsigned char) spec[11])
	    || !isxdigit((unsigned char) spec[12]) || spec[13]) {
	/* Not exactly 12 hex digits, so invalid */
	return 0;
    } else {
	/* Exactly 12 hex digits */
	rstr[0] = spec[1];
	rstr[1] = spec[2];
	rstr[2] = spec[3];
	rstr[3] = spec[4];
	gstr[0] = spec[5];
	gstr[1] = spec[6];
	gstr[2] = spec[7];
	gstr[3] = spec[8];
	bstr[0] = spec[9];
	bstr[1] = spec[10];
	bstr[2] = spec[11];
	bstr[3] = spec[12];
    }
    rstr[4] = gstr[4] = bstr[4] = '\0';
    colorPtr->red = strtol(rstr, NULL, 16);

    colorPtr->green = strtol(gstr, NULL, 16);

    colorPtr->blue = strtol(bstr, NULL, 16);

    } else {
	if (!FindColor(spec, colorPtr)) {
	    return 0;
	}
    }
    colorPtr->pixel = TkpGetPixel(colorPtr);
    colorPtr->flags = DoRed|DoGreen|DoBlue;