MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / read_string

Function read_string

third-party/lua-5.5.0/src/llex.c:404–464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

402
403
404static void read_string (LexState *ls, int del, SemInfo *seminfo) {
405 save_and_next(ls); /* keep delimiter (for error messages) */
406 while (ls->current != del) {
407 switch (ls->current) {
408 case EOZ:
409 lexerror(ls, "unfinished string", TK_EOS);
410 break; /* to avoid warnings */
411 case '\n':
412 case '\r':
413 lexerror(ls, "unfinished string", TK_STRING);
414 break; /* to avoid warnings */
415 case '\\': { /* escape sequences */
416 int c; /* final character to be saved */
417 save_and_next(ls); /* keep '\\' for error messages */
418 switch (ls->current) {
419 case 'a': c = '\a'; goto read_save;
420 case 'b': c = '\b'; goto read_save;
421 case 'f': c = '\f'; goto read_save;
422 case 'n': c = '\n'; goto read_save;
423 case 'r': c = '\r'; goto read_save;
424 case 't': c = '\t'; goto read_save;
425 case 'v': c = '\v'; goto read_save;
426 case 'x': c = readhexaesc(ls); goto read_save;
427 case 'u': utf8esc(ls); goto no_save;
428 case '\n': case '\r':
429 inclinenumber(ls); c = '\n'; goto only_save;
430 case '\\': case '\"': case '\'':
431 c = ls->current; goto read_save;
432 case EOZ: goto no_save; /* will raise an error next loop */
433 case 'z': { /* zap following span of spaces */
434 luaZ_buffremove(ls->buff, 1); /* remove '\\' */
435 next(ls); /* skip the 'z' */
436 while (lisspace(ls->current)) {
437 if (currIsNewline(ls)) inclinenumber(ls);
438 else next(ls);
439 }
440 goto no_save;
441 }
442 default: {
443 esccheck(ls, lisdigit(ls->current), "invalid escape sequence");
444 c = readdecesc(ls); /* digital escape '\ddd' */
445 goto only_save;
446 }
447 }
448 read_save:
449 next(ls);
450 /* go through */
451 only_save:
452 luaZ_buffremove(ls->buff, 1); /* remove '\\' */
453 save(ls, c);
454 /* go through */
455 no_save: break;
456 }
457 default:
458 save_and_next(ls);
459 }
460 }
461 save_and_next(ls); /* skip delimiter */

Callers 1

llexFunction · 0.70

Calls 8

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

Tested by

no test coverage detected