MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / read_string

Function read_string

Source/Misc/lua/src/lua.c:6989–7042  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6987
6988
6989static void read_string (LexState *ls, int del, SemInfo *seminfo) {
6990save_and_next(ls);
6991while (ls->current != del) {
6992switch (ls->current) {
6993case EOZ:
6994luaX_lexerror(ls, "unfinished string", TK_EOS);
6995continue; /* to avoid warnings */
6996case '\n':
6997case '\r':
6998luaX_lexerror(ls, "unfinished string", TK_STRING);
6999continue; /* to avoid warnings */
7000case '\\': {
7001int c;
7002next(ls); /* do not save the `\' */
7003switch (ls->current) {
7004case 'a': c = '\a'; break;
7005case 'b': c = '\b'; break;
7006case 'f': c = '\f'; break;
7007case 'n': c = '\n'; break;
7008case 'r': c = '\r'; break;
7009case 't': c = '\t'; break;
7010case 'v': c = '\v'; break;
7011case '\n': /* go through */
7012case '\r': save(ls, '\n'); inclinenumber(ls); continue;
7013case EOZ: continue; /* will raise an error next loop */
7014default: {
7015if (!isdigit(ls->current))
7016save_and_next(ls); /* handles \\, \", \', and \? */
7017else { /* \xxx */
7018int i = 0;
7019c = 0;
7020do {
7021c = 10*c + (ls->current-'0');
7022next(ls);
7023} while (++i<3 && isdigit(ls->current));
7024if (c > UCHAR_MAX)
7025luaX_lexerror(ls, "escape sequence too large", TK_STRING);
7026save(ls, c);
7027}
7028continue;
7029}
7030}
7031save(ls, c);
7032next(ls);
7033continue;
7034}
7035default:
7036save_and_next(ls);
7037}
7038}
7039save_and_next(ls); /* skip delimiter */
7040seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1,
7041luaZ_bufflen(ls->buff) - 2);
7042}
7043
7044
7045static int llex (LexState *ls, SemInfo *seminfo) {

Callers 1

llexFunction · 0.85

Calls 5

luaX_lexerrorFunction · 0.85
nextFunction · 0.85
inclinenumberFunction · 0.85
luaX_newstringFunction · 0.85
saveFunction · 0.70

Tested by

no test coverage detected