MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / read_string

Function read_string

src/Chain/libraries/glua/llex.cpp:400–460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

llexFunction · 0.70

Calls 9

lexerrorFunction · 0.85
readhexaescFunction · 0.85
utf8escFunction · 0.85
inclinenumberFunction · 0.85
esccheckFunction · 0.85
readdecescFunction · 0.85
luaX_newstringFunction · 0.85
saveFunction · 0.70
nextFunction · 0.50

Tested by

no test coverage detected