Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Canonicalize()

void System.Text.RegularExpressions.RegexCharClass.Canonicalize ( )
inlineprivate

Definition at line 1107 of file RegexCharClass.cs.

1108 {
1110 if (rangelist == null)
1111 {
1112 return;
1113 }
1114 if (rangelist.Count > 1)
1115 {
1116 rangelist.Sort((SingleRange x, SingleRange y) => x.First.CompareTo(y.First));
1117 bool flag = false;
1118 int num = 0;
1119 int num2 = 1;
1120 while (true)
1121 {
1122 char last = rangelist[num].Last;
1123 while (true)
1124 {
1125 if (num2 == rangelist.Count || last == '\uffff')
1126 {
1127 flag = true;
1128 break;
1129 }
1130 SingleRange singleRange;
1131 SingleRange singleRange2 = (singleRange = rangelist[num2]);
1132 if (singleRange2.First > last + 1)
1133 {
1134 break;
1135 }
1136 if (last < singleRange.Last)
1137 {
1138 last = singleRange.Last;
1139 }
1140 num2++;
1141 }
1142 rangelist[num] = new SingleRange(rangelist[num].First, last);
1143 num++;
1144 if (flag)
1145 {
1146 break;
1147 }
1148 if (num < num2)
1149 {
1150 rangelist[num] = rangelist[num2];
1151 }
1152 num2++;
1153 }
1154 rangelist.RemoveRange(num, rangelist.Count - num);
1155 }
1156 if (_negate || _subtractor != null || (_categories != null && _categories.Length != 0))
1157 {
1158 return;
1159 }
1160 if (rangelist.Count == 2)
1161 {
1162 if (rangelist[0].First == '\0' && rangelist[0].Last == (ushort)(rangelist[1].First - 2) && rangelist[1].Last == '\uffff')
1163 {
1164 char c = (char)(rangelist[0].Last + 1);
1165 rangelist.RemoveAt(1);
1166 rangelist[0] = new SingleRange(c, c);
1167 _negate = true;
1168 }
1169 }
1170 else
1171 {
1172 if (rangelist.Count != 1)
1173 {
1174 return;
1175 }
1176 if (rangelist[0].First == '\0')
1177 {
1178 if (rangelist[0].Last == '\ufffe')
1179 {
1180 rangelist[0] = new SingleRange('\uffff', '\uffff');
1181 _negate = true;
1182 }
1183 }
1184 else if (rangelist[0].First == '\u0001' && rangelist[0].Last == '\uffff')
1185 {
1186 rangelist[0] = new SingleRange('\0', '\0');
1187 _negate = true;
1188 }
1189 }
1190 }

References System.Text.RegularExpressions.RegexCharClass._categories, System.Text.RegularExpressions.RegexCharClass._negate, System.Text.RegularExpressions.RegexCharClass._rangelist, System.Text.RegularExpressions.RegexCharClass._subtractor, System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Text.RegularExpressions.RegexCharClass.SingleRange.First, and System.Text.StringBuilder.Length.

Referenced by System.Text.RegularExpressions.RegexCharClass.ToStringClass().