Diff
Not logged in

Differences From Artifact [8f5fe9844f]:

To Artifact [123d9496d9]:


60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

87




88
89
90
91
92
93
94
60
61
62
63
64
65
66











67
68
69
70
71
72
73
74
75
76

77
78
79
80
81
82
83
84
85
86
87







-
-
-
-
-
-
-
-
-
-
-









+
-
+
+
+
+







 */

static const unsigned char totalBytes[256] = {
    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,
    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,
    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,
    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,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1
};

static const unsigned char complete[256] = {
    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,
    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,
#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,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 > 3
    4,4,4,4,4,
	4,4,4,4,4,
#else
    1,1,1,1,1,
#endif
    1,1,1,1,1,1,1,1,1,1,1
};

/*
 * Functions used only in this module.
 */

554
555
556
557
558
559
560
561

562
563
564
565
566
567
568
547
548
549
550
551
552
553

554
555
556
557
558
559
560
561







-
+








int
Tcl_UtfCharComplete(
    const char *src,		/* String to check if first few bytes contain
				 * a complete UTF-8 character. */
    int length)			/* Length of above string in bytes. */
{
    return length >= complete[(unsigned char)*src];
    return length >= totalBytes[(unsigned char)*src];
}

/*
 *---------------------------------------------------------------------------
 *
 * Tcl_NumUtfChars --
 *
602
603
604
605
606
607
608
609

610
611
612
613
614
615
616
617
618
619
620

621
622
623
624
625
626
627
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







-
+










-
+







	    i++;
#else
	    i += 1 + ((next - src) > 3);
#endif
	    src = next;
	}
    } else {
	register const char *endPtr = src + length - /*TCL_UTF_MAX*/ 4;
	register const char *endPtr = src + length - TCL_UTF_MAX;

	while (src < endPtr) {
	    next = TclUtfNext(src);
#if TCL_UTF_MAX > 4
	    i++;
#else
	    i += 1 + ((next - src) > 3);
#endif
	    src = next;
	}
	endPtr += /*TCL_UTF_MAX*/ 4;
	endPtr += TCL_UTF_MAX;
	while ((src < endPtr) && Tcl_UtfCharComplete(src, endPtr - src)) {
	    next = TclUtfNext(src);
#if TCL_UTF_MAX > 4
	    i++;
#else
	    i += 1 + ((next - src) > 3);
#endif
891
892
893
894
895
896
897
898

899
900
901

902
903
904
905



906

907
908
909
910
911
912
913
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







-
+


-
+



-
+
+
+

+







	     * and exit this loop before we run past the start of the string.
	     */
	    return fallback;
	}

	/* Continue the search backwards... */
	look--;
    } while (trailBytesSeen < /* was TCL_UTF_MAX */ 4);
    } while (trailBytesSeen < TCL_UTF_MAX);

    /*
     * We've seen 4 (was TCL_UTF_MAX) trail bytes, so we know there will not be a
     * We've seen TCL_UTF_MAX trail bytes, so we know there will not be a
     * properly formed byte sequence to find, and we can stop looking,
     * accepting the fallback.
     */

#if TCL_UTF_MAX < 4
    return src - TCL_UTF_MAX;
#else
    return fallback;
#endif
}

/*
 *---------------------------------------------------------------------------
 *
 * Tcl_UniCharAtIndex --
 *