MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / read_string

Function read_string

extlibs/lua/src/llex.c:379–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

377
378
379static void read_string (LexState *ls, int del, SemInfo *seminfo) {
380 save_and_next(ls); /* keep delimiter (for error messages) */
381 while (ls->current != del) {
382 switch (ls->current) {
383 case EOZ:
384 lexerror(ls, "unfinished string", TK_EOS);
385 break; /* to avoid warnings */
386 case '\n':
387 case '\r':
388 lexerror(ls, "unfinished string", TK_STRING);
389 break; /* to avoid warnings */
390 case '\\': { /* escape sequences */
391 int c; /* final character to be saved */
392 save_and_next(ls); /* keep '\\' for error messages */
393 switch (ls->current) {
394 case 'a': c = '\a'; goto read_save;
395 case 'b': c = '\b'; goto read_save;
396 case 'f': c = '\f'; goto read_save;
397 case 'n': c = '\n'; goto read_save;
398 case 'r': c = '\r'; goto read_save;
399 case 't': c = '\t'; goto read_save;
400 case 'v': c = '\v'; goto read_save;
401 case 'x': c = readhexaesc(ls); goto read_save;
402 case 'u': utf8esc(ls); goto no_save;
403 case '\n': case '\r':
404 inclinenumber(ls); c = '\n'; goto only_save;
405 case '\\': case '\"': case '\'':
406 c = ls->current; goto read_save;
407 case EOZ: goto no_save; /* will raise an error next loop */
408 case 'z': { /* zap following span of spaces */
409 luaZ_buffremove(ls->buff, 1); /* remove '\\' */
410 next(ls); /* skip the 'z' */
411 while (lisspace(ls->current)) {
412 if (currIsNewline(ls)) inclinenumber(ls);
413 else next(ls);
414 }
415 goto no_save;
416 }
417 default: {
418 esccheck(ls, lisdigit(ls->current), "invalid escape sequence");
419 c = readdecesc(ls); /* digital escape '\ddd' */
420 goto only_save;
421 }
422 }
423 read_save:
424 next(ls);
425 /* go through */
426 only_save:
427 luaZ_buffremove(ls->buff, 1); /* remove '\\' */
428 save(ls, c);
429 /* go through */
430 no_save: break;
431 }
432 default:
433 save_and_next(ls);
434 }
435 }
436 save_and_next(ls); /* skip delimiter */

Callers 1

llexFunction · 0.85

Calls 8

lexerrorFunction · 0.85
readhexaescFunction · 0.85
utf8escFunction · 0.85
inclinenumberFunction · 0.85
esccheckFunction · 0.85
readdecescFunction · 0.85
saveFunction · 0.85
luaX_newstringFunction · 0.85

Tested by

no test coverage detected