Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Patch from Christian Werner, for evaluation |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | rfe-6c0d7aec67 |
Files: | files | file ages | folders |
SHA1: |
050a13caf65cb80433c66bab5db0ab98 |
User & Date: | jan.nijtmans 2016-09-16 07:49:21 |
Context
2016-09-16
| ||
12:17 | Rename TkUtfToUniChar32 to TkUtfToUniChar2, and various simplifications needing less #ifdef's check-in: 5dd9f682 user: jan.nijtmans tags: rfe-6c0d7aec67 | |
07:49 | Patch from Christian Werner, for evaluation check-in: 050a13ca user: jan.nijtmans tags: rfe-6c0d7aec67 | |
2016-09-10
| ||
09:08 | Fixed [eb26817783] - listbox-13.3 fails on Linux check-in: c084d13c user: fvogel tags: trunk | |
Changes
Changes to generic/tkEntry.c.
︙ | ︙ | |||
1922 1923 1924 1925 1926 1927 1928 | /* * If we're displaying a special character instead of the value of the * entry, recompute the displayString. */ if (entryPtr->showChar != NULL) { | < > > > > > > > | 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 | /* * If we're displaying a special character instead of the value of the * entry, recompute the displayString. */ if (entryPtr->showChar != NULL) { char buf[4]; int size; /* * Normalize the special character so we can safely duplicate it in * the display string. If we didn't do this, then two malformed * characters might end up looking like one valid UTF character in the * resulting string. */ #if TCL_UTF_MAX == 4 int ch; TkUtfToUniChar32(entryPtr->showChar, &ch); #else Tcl_UniChar ch; Tcl_UtfToUniChar(entryPtr->showChar, &ch); #endif size = Tcl_UniCharToUtf(ch, buf); entryPtr->numDisplayBytes = entryPtr->numChars * size; p = ckalloc(entryPtr->numDisplayBytes + 1); entryPtr->displayString = p; for (i = entryPtr->numChars; --i >= 0; ) { |
︙ | ︙ | |||
3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 | Tcl_DString *dsPtr) /* Dynamic string in which to append new * command. */ { int spaceNeeded, cvtFlags; /* Used to substitute string as proper Tcl * list element. */ int number, length; register const char *string; Tcl_UniChar ch; char numStorage[2*TCL_INTEGER_SPACE]; while (1) { if (*before == '\0') { break; } /* | > > > > | 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 | Tcl_DString *dsPtr) /* Dynamic string in which to append new * command. */ { int spaceNeeded, cvtFlags; /* Used to substitute string as proper Tcl * list element. */ int number, length; register const char *string; #if TCL_UTF_MAX == 4 int ch; #else Tcl_UniChar ch; #endif char numStorage[2*TCL_INTEGER_SPACE]; while (1) { if (*before == '\0') { break; } /* |
︙ | ︙ | |||
3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 | /* * There's a percent sequence here. Process it. */ before++; /* skip over % */ if (*before != '\0') { before += Tcl_UtfToUniChar(before, &ch); } else { ch = '%'; } if (type == VALIDATE_BUTTON) { /* * -command %-substitution */ | > > > > | 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 | /* * There's a percent sequence here. Process it. */ before++; /* skip over % */ if (*before != '\0') { #if TCL_UTF_MAX == 4 before += TkUtfToUniChar32(before, &ch); #else before += Tcl_UtfToUniChar(before, &ch); #endif } else { ch = '%'; } if (type == VALIDATE_BUTTON) { /* * -command %-substitution */ |
︙ | ︙ |
Changes to generic/tkFont.c.
︙ | ︙ | |||
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | switch ((enum options) index) { case FONT_ACTUAL: { int skip, result, n; const char *s; Tk_Font tkfont; Tcl_Obj *optPtr, *charPtr, *resultPtr; int uniChar = 0; const TkFontAttributes *faPtr; TkFontAttributes fa; /* * Params 0 and 1 are 'font actual'. Param 2 is the font name. 3-4 may * be '-displayof $window' */ | > > > > | 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | switch ((enum options) index) { case FONT_ACTUAL: { int skip, result, n; const char *s; Tk_Font tkfont; Tcl_Obj *optPtr, *charPtr, *resultPtr; #if TCL_UTF_MAX == 4 int uniChar = 0; #else Tcl_UniChar uniChar = 0; #endif const TkFontAttributes *faPtr; TkFontAttributes fa; /* * Params 0 and 1 are 'font actual'. Param 2 is the font name. 3-4 may * be '-displayof $window' */ |
︙ | ︙ | |||
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 | } /* * The 'charPtr' arg must be a single Unicode. */ if (charPtr != NULL) { if (Tcl_GetCharLength(charPtr) != 1) { resultPtr = Tcl_NewStringObj( "expected a single character but got \"", -1); Tcl_AppendLimitedToObj(resultPtr, Tcl_GetString(charPtr), -1, 40, "..."); Tcl_AppendToObj(resultPtr, "\"", -1); Tcl_SetObjResult(interp, resultPtr); Tcl_SetErrorCode(interp, "TK", "VALUE", "FONT_SAMPLE", NULL); return TCL_ERROR; } uniChar = Tcl_GetUniChar(charPtr, 0); } /* * Find the font. */ tkfont = Tk_AllocFontFromObj(interp, tkwin, objv[2]); | > > > > > > > > > > > > > > > | 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 | } /* * The 'charPtr' arg must be a single Unicode. */ if (charPtr != NULL) { #if TCL_UTF_MAX == 4 Tcl_UniChar *ucPtr; #endif if (Tcl_GetCharLength(charPtr) != 1) { resultPtr = Tcl_NewStringObj( "expected a single character but got \"", -1); Tcl_AppendLimitedToObj(resultPtr, Tcl_GetString(charPtr), -1, 40, "..."); Tcl_AppendToObj(resultPtr, "\"", -1); Tcl_SetObjResult(interp, resultPtr); Tcl_SetErrorCode(interp, "TK", "VALUE", "FONT_SAMPLE", NULL); return TCL_ERROR; } #if TCL_UTF_MAX == 4 ucPtr = Tcl_GetUnicodeFromObj(charPtr, NULL); uniChar = *ucPtr; if (((uniChar & 0xFC00) == 0xD800) && (ucPtr[1] != 0x000)) { if ((ucPtr[1] & 0xFC00) == 0xDC00) { uniChar = ((uniChar & 0x3FF) << 10) + (ucPtr[1] & 0x3FF); uniChar += 0x10000; } } #else uniChar = Tcl_GetUniChar(charPtr, 0); #endif } /* * Find the font. */ tkfont = Tk_AllocFontFromObj(interp, tkwin, objv[2]); |
︙ | ︙ | |||
1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 | } else if (strcasecmp(family, "AvantGarde") == 0) { family = "AvantGarde"; } else if (strcasecmp(family, "ZapfChancery") == 0) { family = "ZapfChancery"; } else if (strcasecmp(family, "ZapfDingbats") == 0) { family = "ZapfDingbats"; } else { Tcl_UniChar ch; /* * Inline, capitalize the first letter of each word, lowercase the * rest of the letters in each word, and then take out the spaces * between the words. This may make the DString shorter, which is safe * to do. */ Tcl_DStringAppend(dsPtr, family, -1); src = dest = Tcl_DStringValue(dsPtr) + len; upper = 1; for (; *src != '\0'; ) { while (isspace(UCHAR(*src))) { /* INTL: ISO space */ src++; upper = 1; } src += Tcl_UtfToUniChar(src, &ch); if (upper) { ch = (Tcl_UniChar) Tcl_UniCharToUpper(ch); upper = 0; } else { ch = (Tcl_UniChar) Tcl_UniCharToLower(ch); } dest += Tcl_UniCharToUtf(ch, dest); | > > > > > > > > | 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 | } else if (strcasecmp(family, "AvantGarde") == 0) { family = "AvantGarde"; } else if (strcasecmp(family, "ZapfChancery") == 0) { family = "ZapfChancery"; } else if (strcasecmp(family, "ZapfDingbats") == 0) { family = "ZapfDingbats"; } else { #if TCL_UTF_MAX == 4 int ch; #else Tcl_UniChar ch; #endif /* * Inline, capitalize the first letter of each word, lowercase the * rest of the letters in each word, and then take out the spaces * between the words. This may make the DString shorter, which is safe * to do. */ Tcl_DStringAppend(dsPtr, family, -1); src = dest = Tcl_DStringValue(dsPtr) + len; upper = 1; for (; *src != '\0'; ) { while (isspace(UCHAR(*src))) { /* INTL: ISO space */ src++; upper = 1; } #if TCL_UTF_MAX == 4 src += TkUtfToUniChar32(src, &ch); #else src += Tcl_UtfToUniChar(src, &ch); #endif if (upper) { ch = (Tcl_UniChar) Tcl_UniCharToUpper(ch); upper = 0; } else { ch = (Tcl_UniChar) Tcl_UniCharToLower(ch); } dest += Tcl_UniCharToUtf(ch, dest); |
︙ | ︙ | |||
3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 | TextLayout *layoutPtr = (TextLayout *) layout; LayoutChunk *chunkPtr = layoutPtr->chunks; int baseline = chunkPtr->y; Tcl_Obj *psObj = Tcl_NewObj(); int i, j, len; const char *p, *glyphname; char uindex[5], c, *ps; Tcl_UniChar ch; Tcl_AppendToObj(psObj, "[(", -1); for (i = 0; i < layoutPtr->numChunks; i++, chunkPtr++) { if (baseline != chunkPtr->y) { Tcl_AppendToObj(psObj, ")]\n[(", -1); baseline = chunkPtr->y; } | > > > > | 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 | TextLayout *layoutPtr = (TextLayout *) layout; LayoutChunk *chunkPtr = layoutPtr->chunks; int baseline = chunkPtr->y; Tcl_Obj *psObj = Tcl_NewObj(); int i, j, len; const char *p, *glyphname; char uindex[5], c, *ps; #if TCL_UTF_MAX == 4 int ch; #else Tcl_UniChar ch; #endif Tcl_AppendToObj(psObj, "[(", -1); for (i = 0; i < layoutPtr->numChunks; i++, chunkPtr++) { if (baseline != chunkPtr->y) { Tcl_AppendToObj(psObj, ")]\n[(", -1); baseline = chunkPtr->y; } |
︙ | ︙ | |||
3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 | /* * INTL: We only handle symbols that have an encoding as a glyph * from the standard set defined by Adobe. The rest get punted. * Eventually this should be revised to handle more sophsticiated * international postscript fonts. */ p += Tcl_UtfToUniChar(p, &ch); if ((ch == '(') || (ch == ')') || (ch == '\\') || (ch < 0x20)) { /* * Tricky point: the "03" is necessary in the sprintf below, * so that a full three digits of octal are always generated. * Without the "03", a number following this sequence could be * interpreted by Postscript as part of this sequence. */ | > > > > | 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 | /* * INTL: We only handle symbols that have an encoding as a glyph * from the standard set defined by Adobe. The rest get punted. * Eventually this should be revised to handle more sophsticiated * international postscript fonts. */ #if TCL_UTF_MAX == 4 p += TkUtfToUniChar32(p, &ch); #else p += Tcl_UtfToUniChar(p, &ch); #endif if ((ch == '(') || (ch == ')') || (ch == '\\') || (ch < 0x20)) { /* * Tricky point: the "03" is necessary in the sprintf below, * so that a full three digits of octal are always generated. * Without the "03", a number following this sequence could be * interpreted by Postscript as part of this sequence. */ |
︙ | ︙ | |||
3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 | } /* * This character doesn't belong to the ASCII character set, so we * use the full glyph name. */ sprintf(uindex, "%04X", ch); /* endianness? */ glyphname = Tcl_GetVar2(interp, "::tk::psglyphs", uindex, 0); if (glyphname) { ps = Tcl_GetStringFromObj(psObj, &len); if (ps[len-1] == '(') { /* * In-place edit. Ewww! */ ps[len-1] = '/'; } else { Tcl_AppendToObj(psObj, ")/", -1); } Tcl_AppendToObj(psObj, glyphname, -1); Tcl_AppendToObj(psObj, "(", -1); } else { /* * No known mapping for the character into the space of * PostScript glyphs. Ignore it. :-( */ #ifdef TK_DEBUG_POSTSCRIPT_OUTPUT fprintf(stderr, "Warning: no mapping to PostScript " "glyphs for \\u%04x\n", ch); #endif } } | > > > > > > | 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 | } /* * This character doesn't belong to the ASCII character set, so we * use the full glyph name. */ #if TCL_UTF_MAX > 3 if (ch > 0xffff) { goto noMapping; } #endif sprintf(uindex, "%04X", ch); /* endianness? */ glyphname = Tcl_GetVar2(interp, "::tk::psglyphs", uindex, 0); if (glyphname) { ps = Tcl_GetStringFromObj(psObj, &len); if (ps[len-1] == '(') { /* * In-place edit. Ewww! */ ps[len-1] = '/'; } else { Tcl_AppendToObj(psObj, ")/", -1); } Tcl_AppendToObj(psObj, glyphname, -1); Tcl_AppendToObj(psObj, "(", -1); } else { /* * No known mapping for the character into the space of * PostScript glyphs. Ignore it. :-( */ noMapping: ; #ifdef TK_DEBUG_POSTSCRIPT_OUTPUT fprintf(stderr, "Warning: no mapping to PostScript " "glyphs for \\u%04x\n", ch); #endif } } |
︙ | ︙ |
Changes to generic/tkInt.h.
︙ | ︙ | |||
1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 | MODULE_SCOPE Status TkParseColor (Display * display, Colormap map, const char* spec, XColor * colorPtr); #endif #ifdef HAVE_XFT MODULE_SCOPE void TkUnixSetXftClipRegion(TkRegion clipRegion); #endif /* * Unsupported commands. */ MODULE_SCOPE int TkUnsupported1ObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, | > > > > | 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 | MODULE_SCOPE Status TkParseColor (Display * display, Colormap map, const char* spec, XColor * colorPtr); #endif #ifdef HAVE_XFT MODULE_SCOPE void TkUnixSetXftClipRegion(TkRegion clipRegion); #endif #if TCL_UTF_MAX == 4 MODULE_SCOPE int TkUtfToUniChar32(const char *src, int *chPtr); #endif /* * Unsupported commands. */ MODULE_SCOPE int TkUnsupported1ObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, |
︙ | ︙ |
Changes to generic/tkText.c.
︙ | ︙ | |||
4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 | Tcl_Obj *stringPtr) /* Description of the tab stops. See the text * manual entry for details. */ { int objc, i, count; Tcl_Obj **objv; TkTextTabArray *tabArrayPtr; TkTextTab *tabPtr; Tcl_UniChar ch; double prevStop, lastStop; /* * Map these strings to TkTextTabAlign values. */ static const char *const tabOptionStrings[] = { "left", "right", "center", "numeric", NULL }; | > > > > | 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 | Tcl_Obj *stringPtr) /* Description of the tab stops. See the text * manual entry for details. */ { int objc, i, count; Tcl_Obj **objv; TkTextTabArray *tabArrayPtr; TkTextTab *tabPtr; #if TCL_UTF_MAX == 4 int ch; #else Tcl_UniChar ch; #endif double prevStop, lastStop; /* * Map these strings to TkTextTabAlign values. */ static const char *const tabOptionStrings[] = { "left", "right", "center", "numeric", NULL }; |
︙ | ︙ | |||
4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 | continue; } /* * There may be a more efficient way of getting this. */ Tcl_UtfToUniChar(Tcl_GetString(objv[i+1]), &ch); if (!Tcl_UniCharIsAlpha(ch)) { continue; } i += 1; if (Tcl_GetIndexFromObjStruct(interp, objv[i], tabOptionStrings, sizeof(char *), "tab alignment", 0, &index) != TCL_OK) { | > > > > | 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 | continue; } /* * There may be a more efficient way of getting this. */ #if TCL_UTF_MAX == 4 TkUtfToUniChar32(Tcl_GetString(objv[i+1]), &ch); #else Tcl_UtfToUniChar(Tcl_GetString(objv[i+1]), &ch); #endif if (!Tcl_UniCharIsAlpha(ch)) { continue; } i += 1; if (Tcl_GetIndexFromObjStruct(interp, objv[i], tabOptionStrings, sizeof(char *), "tab alignment", 0, &index) != TCL_OK) { |
︙ | ︙ |
Changes to generic/tkTextIndex.c.
︙ | ︙ | |||
2294 2295 2296 2297 2298 2299 2300 2301 | COUNT_DISPLAY_INDICES); } segPtr = TkTextIndexToSeg(indexPtr, &offset); while (1) { int chSize = 1; if (segPtr->typePtr == &tkTextCharType) { Tcl_UniChar ch; | > > > > < > | 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 | COUNT_DISPLAY_INDICES); } segPtr = TkTextIndexToSeg(indexPtr, &offset); while (1) { int chSize = 1; if (segPtr->typePtr == &tkTextCharType) { #if TCL_UTF_MAX == 4 int ch; chSize = TkUtfToUniChar32(segPtr->body.chars + offset, &ch); #else Tcl_UniChar ch; chSize = Tcl_UtfToUniChar(segPtr->body.chars + offset, &ch); #endif if (!Tcl_UniCharIsWordChar(ch)) { break; } firstChar = 0; } offset += chSize; indexPtr->byteIndex += chSize; |
︙ | ︙ | |||
2339 2340 2341 2342 2343 2344 2345 2346 | */ segPtr = TkTextIndexToSeg(indexPtr, &offset); while (1) { int chSize = 1; if (segPtr->typePtr == &tkTextCharType) { Tcl_UniChar ch; | > > > > < > | 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 | */ segPtr = TkTextIndexToSeg(indexPtr, &offset); while (1) { int chSize = 1; if (segPtr->typePtr == &tkTextCharType) { #if TCL_UTF_MAX == 4 int ch; TkUtfToUniChar32(segPtr->body.chars + offset, &ch); #else Tcl_UniChar ch; Tcl_UtfToUniChar(segPtr->body.chars + offset, &ch); #endif if (!Tcl_UniCharIsWordChar(ch)) { break; } if (offset > 0) { chSize = (segPtr->body.chars + offset - Tcl_UtfPrev(segPtr->body.chars + offset, segPtr->body.chars)); |
︙ | ︙ |
Changes to generic/tkUtil.c.
︙ | ︙ | |||
1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 | event.virtual.name = Tk_GetUid(eventName); if (detail != NULL) { event.virtual.user_data = detail; } Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL); } /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 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 1301 1302 1303 | event.virtual.name = Tk_GetUid(eventName); if (detail != NULL) { event.virtual.user_data = detail; } Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL); } #if TCL_UTF_MAX == 4 /* *--------------------------------------------------------------------------- * * TkUtfToUniChar32 -- * * Copied from Tcl_UtfToUniChar but using int instead of Tcl_UniChar! * * Extract the Tcl_UniChar represented by the UTF-8 string. Bad UTF-8 * sequences are converted to valid Tcl_UniChars and processing * continues. Equivalent to Plan 9 chartorune(). * * The caller must ensure that the source buffer is long enough that this * routine does not run off the end and dereference non-existent memory * looking for trail bytes. If the source buffer is known to be '\0' * terminated, this cannot happen. Otherwise, the caller should call * Tcl_UtfCharComplete() before calling this routine to ensure that * enough bytes remain in the string. * * Results: * *chPtr is filled with the Tcl_UniChar, and the return value is the * number of bytes from the UTF-8 string that were consumed. * * Side effects: * None. * *--------------------------------------------------------------------------- */ int TkUtfToUniChar32( const char *src, /* The UTF-8 string. */ int *chPtr) /* Filled with the Tcl_UniChar represented by * the UTF-8 string. */ { int byte; /* * Unroll 1 to 3 byte UTF-8 sequences, use loop to handle longer ones. */ byte = *((unsigned char *) src); if (byte < 0xC0) { /* * Handles properly formed UTF-8 characters between 0x01 and 0x7F. * Also treats \0 and naked trail bytes 0x80 to 0xBF as valid * characters representing themselves. */ *chPtr = byte; return 1; } else if (byte < 0xE0) { if ((src[1] & 0xC0) == 0x80) { /* * Two-byte-character lead-byte followed by a trail-byte. */ *chPtr = ((byte & 0x1F) << 6) | (src[1] & 0x3F); return 2; } /* * A two-byte-character lead-byte not followed by trail-byte * represents itself. */ } else if (byte < 0xF0) { if (((src[1] & 0xC0) == 0x80) && ((src[2] & 0xC0) == 0x80)) { /* * Three-byte-character lead byte followed by two trail bytes. */ *chPtr = ((byte & 0x0F) << 12) | ((src[1] & 0x3F) << 6) | (src[2] & 0x3F); return 3; } /* * A three-byte-character lead-byte not followed by two trail-bytes * represents itself. */ } else if (byte < 0xF8) { if (((src[1] & 0xC0) == 0x80) && ((src[2] & 0xC0) == 0x80) && ((src[3] & 0xC0) == 0x80)) { /* * Four-byte-character lead byte followed by three trail bytes. */ *chPtr = ((byte & 0x0E) << 18) | ((src[1] & 0x3F) << 12) | ((src[2] & 0x3F) << 6) | (src[3] & 0x3F); return 4; } /* * A three-byte-character lead-byte not followed by two trail-bytes * represents itself. */ } *chPtr = byte; return 1; } #endif /* * Local Variables: * mode: c * c-basic-offset: 4 * fill-column: 78 * End: */ |
Changes to generic/ttk/ttkEntry.c.
︙ | ︙ | |||
278 279 280 281 282 283 284 | * of (the first character in the string) 'showChar'. * Used to compute the displayString if -show is non-NULL. */ static char *EntryDisplayString(const char *showChar, int numChars) { char *displayString, *p; int size; | < > > > > > > > | 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | * of (the first character in the string) 'showChar'. * Used to compute the displayString if -show is non-NULL. */ static char *EntryDisplayString(const char *showChar, int numChars) { char *displayString, *p; int size; char buf[4]; #if TCL_UTF_MAX == 4 int ch; TkUtfToUniChar32(showChar, &ch); #else Tcl_UniChar ch; Tcl_UtfToUniChar(showChar, &ch); #endif size = Tcl_UniCharToUtf(ch, buf); p = displayString = ckalloc(numChars * size + 1); while (numChars--) { memcpy(p, buf, size); p += size; } |
︙ | ︙ | |||
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | VREASON reason, /* Reason for change */ Tcl_DString *dsPtr) /* Result of %-substitutions */ { int spaceNeeded, cvtFlags; int number, length; const char *string; int stringLength; Tcl_UniChar ch; char numStorage[2*TCL_INTEGER_SPACE]; while (*template) { /* Find everything up to the next % character and append it * to the result string. */ string = Tcl_UtfFindFirst(template, '%'); | > > > > | 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | VREASON reason, /* Reason for change */ Tcl_DString *dsPtr) /* Result of %-substitutions */ { int spaceNeeded, cvtFlags; int number, length; const char *string; int stringLength; #if TCL_UTF_MAX == 4 int ch; #else Tcl_UniChar ch; #endif char numStorage[2*TCL_INTEGER_SPACE]; while (*template) { /* Find everything up to the next % character and append it * to the result string. */ string = Tcl_UtfFindFirst(template, '%'); |
︙ | ︙ | |||
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | template = string; } /* There's a percent sequence here. Process it. */ ++template; /* skip over % */ if (*template != '\0') { template += Tcl_UtfToUniChar(template, &ch); } else { ch = '%'; } stringLength = -1; switch (ch) { case 'd': /* Type of call that caused validation */ | > > > > | 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | template = string; } /* There's a percent sequence here. Process it. */ ++template; /* skip over % */ if (*template != '\0') { #if TCL_UTF_MAX == 4 template += TkUtfToUniChar32(template, &ch); #else template += Tcl_UtfToUniChar(template, &ch); #endif } else { ch = '%'; } stringLength = -1; switch (ch) { case 'd': /* Type of call that caused validation */ |
︙ | ︙ |
Changes to unix/tkUnixFont.c.
︙ | ︙ | |||
31 32 33 34 35 36 37 | * character existence metrics, used to determine if a screen font can display * a given Unicode character. * * Under Unix, there are three attributes that uniquely identify a "font * family": the foundry, face name, and charset. */ | > | | > > > | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | * character existence metrics, used to determine if a screen font can display * a given Unicode character. * * Under Unix, there are three attributes that uniquely identify a "font * family": the foundry, face name, and charset. */ #if TCL_UTF_MAX > 3 #define FONTMAP_SHIFT 12 #define FONTMAP_PAGES (1 << (21 - FONTMAP_SHIFT)) #else #define FONTMAP_SHIFT 10 #define FONTMAP_PAGES (1 << (sizeof(Tcl_UniChar)*8 - FONTMAP_SHIFT)) #endif #define FONTMAP_BITSPERPAGE (1 << FONTMAP_SHIFT) typedef struct FontFamily { struct FontFamily *nextPtr; /* Next in list of all known font families. */ int refCount; /* How many SubFonts are referring to this * FontFamily. When the refCount drops to * zero, this FontFamily may be freed. */ |
︙ | ︙ |
Changes to unix/tkUnixRFont.c.
︙ | ︙ | |||
50 51 52 53 54 55 56 57 58 59 60 61 62 63 | * the information isn't retrievable from the GC. */ typedef struct ThreadSpecificData { Region clipRegion; /* The clipping region, or None. */ } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; /* * Package initialization: * Nothing to do here except register the fact that we're using Xft in * the TIP 59 configuration database. */ | > > > > > > | 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | * the information isn't retrievable from the GC. */ typedef struct ThreadSpecificData { Region clipRegion; /* The clipping region, or None. */ } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; #if TCL_UTF_MAX == 4 #define UtfToUniChar(src, chPtr) TkUtfToUniChar32(src, chPtr) #else #define UtfToUniChar(src, chPtr) Tcl_UtfToUniChar(src, chPtr) #endif /* * Package initialization: * Nothing to do here except register the fact that we're using Xft in * the TIP 59 configuration database. */ |
︙ | ︙ | |||
664 665 666 667 668 669 670 671 672 | int len = 0; #endif /* DEBUG_FONTSEL */ curX = 0; curByte = 0; sawNonSpace = 0; while (numBytes > 0) { Tcl_UniChar unichar; | > > > > | | 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 | int len = 0; #endif /* DEBUG_FONTSEL */ curX = 0; curByte = 0; sawNonSpace = 0; while (numBytes > 0) { #if TCL_UTF_MAX == 4 int unichar; #else Tcl_UniChar unichar; #endif clen = UtfToUniChar(source, &unichar); c = (FcChar32) unichar; if (clen <= 0) { /* * This can't happen (but see #1185640) */ |
︙ | ︙ |
Changes to win/tkWinFont.c.
︙ | ︙ | |||
22 23 24 25 26 27 28 | * instance of this structure. The most important shared property is the * character existence metrics, used to determine if a screen font can display * a given Unicode character. * * Under Windows, a "font family" is uniquely identified by its face name. */ | > | | > > | > | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | * instance of this structure. The most important shared property is the * character existence metrics, used to determine if a screen font can display * a given Unicode character. * * Under Windows, a "font family" is uniquely identified by its face name. */ #if TCL_UTF_MAX > 3 #define FONTMAP_SHIFT 12 #define FONTMAP_PAGES (1 << (21 - FONTMAP_SHIFT)) #else #define FONTMAP_SHIFT 10 #define FONTMAP_PAGES (1 << (sizeof(Tcl_UniChar)*8 - FONTMAP_SHIFT)) #endif #define FONTMAP_BITSPERPAGE (1 << FONTMAP_SHIFT) typedef struct FontFamily { struct FontFamily *nextPtr; /* Next in list of all known font families. */ size_t refCount; /* How many SubFonts are referring to this * FontFamily. When the refCount drops to * zero, this FontFamily may be freed. */ |
︙ | ︙ | |||
225 226 227 228 229 230 231 232 233 234 235 236 237 238 | static void ReleaseFont(WinFont *fontPtr); static inline void ReleaseSubFont(SubFont *subFontPtr); static int SeenName(const char *name, Tcl_DString *dsPtr); static inline HFONT SelectFont(HDC hdc, WinFont *fontPtr, SubFont *subFontPtr, double angle); static inline void SwapLong(PULONG p); static inline void SwapShort(USHORT *p); static int CALLBACK WinFontCanUseProc(ENUMLOGFONT *lfPtr, NEWTEXTMETRIC *tmPtr, int fontType, LPARAM lParam); static int CALLBACK WinFontExistProc(ENUMLOGFONT *lfPtr, NEWTEXTMETRIC *tmPtr, int fontType, LPARAM lParam); static int CALLBACK WinFontFamilyEnumProc(ENUMLOGFONT *lfPtr, | > > > > > | 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | static void ReleaseFont(WinFont *fontPtr); static inline void ReleaseSubFont(SubFont *subFontPtr); static int SeenName(const char *name, Tcl_DString *dsPtr); static inline HFONT SelectFont(HDC hdc, WinFont *fontPtr, SubFont *subFontPtr, double angle); static inline void SwapLong(PULONG p); static inline void SwapShort(USHORT *p); #if TCL_UTF_MAX == 4 #define UtfToUniChar(src, chPtr) TkUtfToUniChar32(src, chPtr) #else #define UtfToUniChar(src, chPtr) Tcl_UtfToUniChar(src, chPtr) #endif static int CALLBACK WinFontCanUseProc(ENUMLOGFONT *lfPtr, NEWTEXTMETRIC *tmPtr, int fontType, LPARAM lParam); static int CALLBACK WinFontExistProc(ENUMLOGFONT *lfPtr, NEWTEXTMETRIC *tmPtr, int fontType, LPARAM lParam); static int CALLBACK WinFontFamilyEnumProc(ENUMLOGFONT *lfPtr, |
︙ | ︙ | |||
824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 | int *lengthPtr) /* Filled with x-location just after the * terminating character. */ { HDC hdc; HFONT oldFont; WinFont *fontPtr; int curX, moretomeasure; Tcl_UniChar ch; SIZE size; FontFamily *familyPtr; Tcl_DString runString; SubFont *thisSubFontPtr, *lastSubFontPtr; const char *p, *end, *next = NULL, *start; if (numBytes == 0) { | > > > > | 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 | int *lengthPtr) /* Filled with x-location just after the * terminating character. */ { HDC hdc; HFONT oldFont; WinFont *fontPtr; int curX, moretomeasure; #if TCL_UTF_MAX == 4 int ch; #else Tcl_UniChar ch; #endif SIZE size; FontFamily *familyPtr; Tcl_DString runString; SubFont *thisSubFontPtr, *lastSubFontPtr; const char *p, *end, *next = NULL, *start; if (numBytes == 0) { |
︙ | ︙ | |||
855 856 857 858 859 860 861 | */ moretomeasure = 0; curX = 0; start = source; end = start + numBytes; for (p = start; p < end; ) { | | | 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 | */ moretomeasure = 0; curX = 0; start = source; end = start + numBytes; for (p = start; p < end; ) { next = p + UtfToUniChar(p, &ch); thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr); if (thisSubFontPtr != lastSubFontPtr) { familyPtr = lastSubFontPtr->familyPtr; Tcl_UtfToExternalDString(familyPtr->encoding, start, (int) (p - start), &runString); size.cx = 0; familyPtr->getTextExtentPoint32Proc(hdc, |
︙ | ︙ | |||
917 918 919 920 921 922 923 | char buf[16]; int dstWrote; int lastSize = 0; familyPtr = lastSubFontPtr->familyPtr; Tcl_DStringInit(&runString); for (p = start; p < end; ) { | | | 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 | char buf[16]; int dstWrote; int lastSize = 0; familyPtr = lastSubFontPtr->familyPtr; Tcl_DStringInit(&runString); for (p = start; p < end; ) { next = p + UtfToUniChar(p, &ch); Tcl_UtfToExternal(NULL, familyPtr->encoding, p, (int) (next - p), 0, NULL, buf, sizeof(buf), NULL, &dstWrote, NULL); Tcl_DStringAppend(&runString,buf,dstWrote); size.cx = 0; familyPtr->getTextExtentPoint32Proc(hdc, (TCHAR *) Tcl_DStringValue(&runString), |
︙ | ︙ | |||
966 967 968 969 970 971 972 973 974 975 976 977 978 | if ((flags & TK_WHOLE_WORDS) && (p < end)) { /* * Scan the string for the last word break and than repeat the whole * procedure without the maxLength limit or any flags. */ const char *lastWordBreak = NULL; Tcl_UniChar ch2; end = p; p = source; ch = ' '; while (p < end) { | > > > > | | 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 | if ((flags & TK_WHOLE_WORDS) && (p < end)) { /* * Scan the string for the last word break and than repeat the whole * procedure without the maxLength limit or any flags. */ const char *lastWordBreak = NULL; #if TCL_UTF_MAX == 4 int ch2; #else Tcl_UniChar ch2; #endif end = p; p = source; ch = ' '; while (p < end) { next = p + UtfToUniChar(p, &ch2); if ((ch != ' ') && (ch2 == ' ')) { lastWordBreak = p; } p = next; ch = ch2; } |
︙ | ︙ | |||
1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 | * following string. */ const char *source, /* Potentially multilingual UTF-8 string. */ int numBytes, /* Length of string in bytes. */ int x, int y, /* Coordinates at which to place origin of * string when drawing. */ double angle) { Tcl_UniChar ch; SIZE size; HFONT oldFont; FontFamily *familyPtr; Tcl_DString runString; const char *p, *end, *next; SubFont *lastSubFontPtr, *thisSubFontPtr; TEXTMETRICA tm; lastSubFontPtr = &fontPtr->subFontArray[0]; oldFont = SelectFont(hdc, fontPtr, lastSubFontPtr, angle); GetTextMetricsA(hdc, &tm); end = source + numBytes; for (p = source; p < end; ) { | > > > > | | 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 | * following string. */ const char *source, /* Potentially multilingual UTF-8 string. */ int numBytes, /* Length of string in bytes. */ int x, int y, /* Coordinates at which to place origin of * string when drawing. */ double angle) { #if TCL_UTF_MAX == 4 int ch; #else Tcl_UniChar ch; #endif SIZE size; HFONT oldFont; FontFamily *familyPtr; Tcl_DString runString; const char *p, *end, *next; SubFont *lastSubFontPtr, *thisSubFontPtr; TEXTMETRICA tm; lastSubFontPtr = &fontPtr->subFontArray[0]; oldFont = SelectFont(hdc, fontPtr, lastSubFontPtr, angle); GetTextMetricsA(hdc, &tm); end = source + numBytes; for (p = source; p < end; ) { next = p + UtfToUniChar(p, &ch); thisSubFontPtr = FindSubFontForChar(fontPtr, ch, &lastSubFontPtr); if (thisSubFontPtr != lastSubFontPtr) { if (p > source) { familyPtr = lastSubFontPtr->familyPtr; Tcl_UtfToExternalDString(familyPtr->encoding, source, (int) (p - source), &runString); familyPtr->textOutProc(hdc, x-(tm.tmOverhang/2), y, |
︙ | ︙ | |||
2184 2185 2186 2187 2188 2189 2190 | SubFont *subFontPtr, /* Contains font mapping cache to be * updated. */ int row) /* Index of the page to be loaded into the * cache. */ { FontFamily *familyPtr; Tcl_Encoding encoding; | | | 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 | SubFont *subFontPtr, /* Contains font mapping cache to be * updated. */ int row) /* Index of the page to be loaded into the * cache. */ { FontFamily *familyPtr; Tcl_Encoding encoding; char src[TCL_UTF_MAX], buf[16]; USHORT *startCount, *endCount; int i, j, bitOffset, end, segCount; subFontPtr->fontMap[row] = ckalloc(FONTMAP_BITSPERPAGE / 8); memset(subFontPtr->fontMap[row], 0, FONTMAP_BITSPERPAGE / 8); familyPtr = subFontPtr->familyPtr; |
︙ | ︙ |
Changes to win/tkWinKey.c.
︙ | ︙ | |||
109 110 111 112 113 114 115 | unichar <<= 8; unichar |= keyEv->trans_chars[0] & 0xff; len = Tcl_UniCharToUtf((Tcl_UniChar) unichar, buf); Tcl_DStringAppend(dsPtr, buf, len); } else if (keyEv->send_event == -3) { | < | | 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | unichar <<= 8; unichar |= keyEv->trans_chars[0] & 0xff; len = Tcl_UniCharToUtf((Tcl_UniChar) unichar, buf); Tcl_DStringAppend(dsPtr, buf, len); } else if (keyEv->send_event == -3) { char buf[XMaxTransChars]; int len; /* * Special case for WM_UNICHAR. */ len = Tcl_UniCharToUtf(keyEv->keycode, buf); if ((keyEv->keycode <= 0xffff) || (len > 3)) { Tcl_DStringAppend(dsPtr, buf, len); } else { Tcl_UniCharToUtf(((keyEv->keycode - 0x10000) >> 10) | 0xd800, buf); Tcl_DStringAppend(dsPtr, buf, 3); Tcl_UniCharToUtf(((keyEv->keycode - 0x10000) & 0x3ff) | 0xdc00, buf); Tcl_DStringAppend(dsPtr, buf, 3); } |
︙ | ︙ |