@@ -9,8 +9,12 @@ namespace SimdUnicode
9
9
public static class UTF8
10
10
{
11
11
12
- public unsafe static byte * RewindAndValidateWithErrors ( int priorBytes , byte * buf , int len )
12
+ public unsafe static byte * RewindAndValidateWithErrors ( int priorBytes , byte * buf , int len , ref int utf16CodeUnitCountAdjustment , ref int scalarCountAdjustment )
13
13
{
14
+
15
+ int TempUtf16CodeUnitCountAdjustment = 0 ;
16
+ int TempScalarCountAdjustment = 0 ;
17
+
14
18
int howFarBack = priorBytes ;
15
19
int extraLen = 0 ;
16
20
bool foundLeadingBytes = false ;
@@ -27,13 +31,20 @@ public static class UTF8
27
31
}
28
32
if ( ! foundLeadingBytes )
29
33
{
34
+ utf16CodeUnitCountAdjustment += TempUtf16CodeUnitCountAdjustment ;
35
+ scalarCountAdjustment += TempScalarCountAdjustment ;
30
36
return buf - howFarBack ;
31
37
}
32
38
39
+ // TODO : fix Count handling here
40
+
33
41
34
42
// Now buf points to the start of a UTF-8 sequence or the start of the buffer.
35
43
// Validate from this new start point with the adjusted length.
36
- byte * invalidByte = GetPointerToFirstInvalidByteScalar ( buf , len + extraLen , out int utf16CodeUnitCountAdjustment , out int scalarCountAdjustment ) ;
44
+ byte * invalidByte = GetPointerToFirstInvalidByteScalar ( buf , len + extraLen , out TempUtf16CodeUnitCountAdjustment , out TempScalarCountAdjustment ) ;
45
+
46
+ utf16CodeUnitCountAdjustment += TempUtf16CodeUnitCountAdjustment ;
47
+ scalarCountAdjustment += TempScalarCountAdjustment ;
37
48
38
49
return invalidByte ;
39
50
}
@@ -516,7 +527,7 @@ public unsafe static void AdjustForSkippedBytes(byte* pInputBuffer,// int skippe
516
527
{
517
528
518
529
// TODO/think about : this path iss not explicitly tested
519
- Console . WriteLine ( "----Checkpoint 1:All ASCII need rewind" ) ;
530
+ // Console.WriteLine("----Checkpoint 1:All ASCII need rewind");
520
531
utf16CodeUnitCountAdjustment = TempUtf16CodeUnitCountAdjustment ;
521
532
scalarCountAdjustment = TempScalarCountAdjustment ;
522
533
@@ -636,7 +647,7 @@ public unsafe static void AdjustForSkippedBytes(byte* pInputBuffer,// int skippe
636
647
if ( ! Avx2 . TestZ ( prevIncomplete , prevIncomplete ) )
637
648
{
638
649
639
- Console . WriteLine ( "----Checkpoint 2:SIMD rewind" ) ;
650
+ // Console.WriteLine("----Checkpoint 2:SIMD rewind");
640
651
// We have an unterminated sequence.
641
652
processedLength -= 3 ;
642
653
for ( int k = 0 ; k < 3 ; k ++ )
@@ -669,7 +680,7 @@ public unsafe static void AdjustForSkippedBytes(byte* pInputBuffer,// int skippe
669
680
if ( processedLength < inputLength )
670
681
{
671
682
672
- Console . WriteLine ( "----Process remaining Scalar" ) ;
683
+ // Console.WriteLine("----Process remaining Scalar");
673
684
int overlapCount = 0 ;
674
685
675
686
// // We need to possibly backtrack to the start of the last code point
0 commit comments