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,
45
+ 10 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,3 ,4 ,3 ,3 , 11 ,6 ,6 ,6 ,5 ,8 ,8 ,8 ,8 ,8 ,8 ,8 ,8 ,8 ,8 ,8 ,
46
+
47
+ // The second part is a transition table that maps a combination
48
+ // of a state of the automaton and a character class to a state.
49
+ 0 ,12 ,24 ,36 ,60 ,96 ,84 ,12 ,12 ,12 ,48 ,72 , 12 ,12 ,12 ,12 ,12 ,12 ,12 ,12 ,12 ,12 ,12 ,12 ,
50
+ 12 , 0 ,12 ,12 ,12 ,12 ,12 , 0 ,12 , 0 ,12 ,12 , 12 ,24 ,12 ,12 ,12 ,12 ,12 ,24 ,12 ,24 ,12 ,12 ,
51
+ 12 ,12 ,12 ,12 ,12 ,12 ,12 ,24 ,12 ,12 ,12 ,12 , 12 ,24 ,12 ,12 ,12 ,12 ,12 ,12 ,12 ,24 ,12 ,12 ,
52
+ 12 ,12 ,12 ,12 ,12 ,12 ,12 ,36 ,12 ,36 ,12 ,12 , 12 ,36 ,12 ,12 ,12 ,12 ,12 ,36 ,12 ,36 ,12 ,12 ,
53
+ 12 ,36 ,12 ,12 ,12 ,12 ,12 ,12 ,12 ,12 ,12 ,12 ,
50
54
};
51
55
52
56
uint32_t inline
@@ -57,7 +61,7 @@ decode(uint32_t* state, uint32_t* codep, uint32_t byte) {
57
61
(byte & 0x3fu ) | (* codep << 6 ) :
58
62
(0xff >> type ) & (byte );
59
63
60
- * state = utf8d [256 + * state * 16 + type ];
64
+ * state = utf8d [256 + * state + type ];
61
65
return * state ;
62
66
}
63
67
0 commit comments