MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxCharSetStrings

Function fxCharSetStrings

xs/sources/xsre.c:1199–1313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1197}
1198
1199void* fxCharSetStrings(txPatternParser* parser)
1200{
1201 txCharSet* result = C_NULL;
1202 txString buffer = C_NULL;
1203 txInteger bufferSize = 0;
1204 txString* strings = C_NULL;
1205 txInteger stringCount = 0;
1206 txInteger offset, size, length, character;
1207 txString string;
1208
1209 fxPatternParserNext(parser);
1210 if (parser->character != '{')
1211 fxPatternParserError(parser, gxErrors[mxInvalidEscape]);
1212
1213 offset = parser->offset;
1214 fxPatternParserNext(parser);
1215 length = 0;
1216 for (;;) {
1217 if (parser->character == C_EOF)
1218 fxPatternParserError(parser, gxErrors[mxInvalidEscape]);
1219 if ((parser->character == '}') || (parser->character == '|')) {
1220 if (length > 1) {
1221 bufferSize++;
1222 stringCount++;
1223 }
1224 if (parser->character == '}')
1225 break;
1226 length = 0;
1227 fxPatternParserNext(parser);
1228 }
1229 else {
1230 if (parser->character == '\\') {
1231 fxPatternParserNext(parser);
1232 fxPatternParserEscape(parser, 1);
1233 }
1234 character = parser->character;
1235 if (parser->flags & XS_REGEXP_I)
1236 character = fxCharCaseCanonicalize(character, 1);
1237 bufferSize += fxUTF8Length(character); // no surrogate
1238 length++;
1239 fxPatternParserNext(parser);
1240 }
1241 }
1242
1243 result = fxPatternParserCreateTerm(parser, sizeof(txCharSet), fxCharSetMeasure);
1244 result->stringCount = 0;
1245 result->strings = C_NULL;
1246 result->characters[0] = 0;
1247 if (bufferSize > 0) {
1248 buffer = fxPatternParserCreateChunk(parser, bufferSize);
1249 }
1250 if (stringCount > 0) {
1251 strings = fxPatternParserCreateChunk(parser, stringCount * sizeof(txString));
1252 stringCount = 0;
1253 }
1254
1255 parser->offset = offset;
1256 fxPatternParserNext(parser);

Callers 1

fxCharSetOperandFunction · 0.85

Calls 10

fxPatternParserNextFunction · 0.85
fxPatternParserErrorFunction · 0.85
fxPatternParserEscapeFunction · 0.85
fxCharCaseCanonicalizeFunction · 0.85
fxUTF8LengthFunction · 0.85
fxCharSetCombineFunction · 0.85
fxCharSetSingleFunction · 0.85
fxUTF8EncodeFunction · 0.85

Tested by

no test coverage detected