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

Function read_string

third-party/lua-5.3.5/src/llex.c:366–426  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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