Diff
Not logged in

Differences From Artifact [d778cb9e8c]:

To Artifact [7949e6dbc9]:


78
79
80
81
82
83
84
85

86
87
88
89
90
91
92
78
79
80
81
82
83
84

85
86
87
88
89
90
91
92







-
+







#if TCL_UTF_MAX > 4
    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
#else /* Tcl_UtfCharComplete() might point to 2nd byte of valid 4-byte sequence */
    3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
    3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
#endif
    2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
    2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
    3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
#if TCL_UTF_MAX > 4
    4,4,4,4,4,
#else
    3,3,3,3,3, /* Tcl_UtfCharComplete() only checks TCL_UTF_MAX bytes */
#endif
    1,1,1,1,1,1,1,1,1,1,1
585
586
587
588
589
590
591

592
593


594
595
596
597
598
599
600
601
602
603

604
605

606
607

608
609
610

611
612
613
614
615

616
617
618
619
620
621
622
585
586
587
588
589
590
591
592


593
594
595
596
597
598
599
600
601
602
603

604
605
606
607
608

609
610
611

612
613
614
615
616

617
618
619
620
621
622
623
624







+
-
-
+
+









-
+


+

-
+


-
+




-
+








int
Tcl_NumUtfChars(
    register const char *src,	/* The UTF-8 string to measure. */
    int length)			/* The length of the string in bytes, or -1
				 * for strlen(string). */
{
    Tcl_UniChar ch = 0;
    register int i = 0;

    int i = 0;
 
    /*
     * The separate implementations are faster.
     *
     * Since this is a time-sensitive function, we also do the check for the
     * single-byte char case specially.
     */

    if (length < 0) {
	while ((*src != '\0') && (i < INT_MAX)) {
	    src = TclUtfNext(src);
	    src += Tcl_UtfToUniChar(src, &ch);
	    i++;
	}
	if (i < 0) i = INT_MAX; /* Bug [2738427] */
    } else {
	register const char *endPtr = src + length - TCL_UTF_MAX;
	const char *endPtr = src + length - TCL_UTF_MAX;

	while (src < endPtr) {
	    src = TclUtfNext(src);
	    src += Tcl_UtfToUniChar(src, &ch);
	    i++;
	}
	endPtr += TCL_UTF_MAX;
	while ((src < endPtr) && Tcl_UtfCharComplete(src, endPtr - src)) {
	    src = TclUtfNext(src);
	    src += Tcl_UtfToUniChar(src, &ch);
	    i++;
	}
	if (src < endPtr) {
	    i += endPtr - src;
	}
    }
    return i;
954
955
956
957
958
959
960
961

962
963
964
965
966
967
968
956
957
958
959
960
961
962

963
964
965
966
967
968
969
970







-
+







 */

const char *
Tcl_UtfAtIndex(
    register const char *src,	/* The UTF-8 string. */
    register int index)		/* The position of the desired character. */
{
#if 0
#if 1
/* The Tcl 8.6 implementation */
    Tcl_UniChar ch = 0;
    int len = 0;

    while (index-- > 0) {
	len = TclUtfToUniChar(src, &ch);
	src += len;