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

Function read_long_string

Source/Misc/lua/src/lua.c:6934–6986  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6932
6933
6934static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) {
6935int cont = 0;
6936(void)(cont); /* avoid warnings when `cont' is not used */
6937save_and_next(ls); /* skip 2nd `[' */
6938if (currIsNewline(ls)) /* string starts with a newline? */
6939inclinenumber(ls); /* skip it */
6940for (;;) {
6941switch (ls->current) {
6942case EOZ:
6943luaX_lexerror(ls, (seminfo) ? "unfinished long string" :
6944"unfinished long comment", TK_EOS);
6945break; /* to avoid warnings */
6946#if defined(LUA_COMPAT_LSTR)
6947case '[': {
6948if (skip_sep(ls) == sep) {
6949save_and_next(ls); /* skip 2nd `[' */
6950cont++;
6951#if LUA_COMPAT_LSTR == 1
6952if (sep == 0)
6953luaX_lexerror(ls, "nesting of [[...]] is deprecated", '[');
6954#endif
6955}
6956break;
6957}
6958#endif
6959case ']': {
6960if (skip_sep(ls) == sep) {
6961save_and_next(ls); /* skip 2nd `]' */
6962#if defined(LUA_COMPAT_LSTR) && LUA_COMPAT_LSTR == 2
6963cont--;
6964if (sep == 0 && cont >= 0) break;
6965#endif
6966goto endloop;
6967}
6968break;
6969}
6970case '\n':
6971case '\r': {
6972save(ls, '\n');
6973inclinenumber(ls);
6974if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */
6975break;
6976}
6977default: {
6978if (seminfo) save_and_next(ls);
6979else next(ls);
6980}
6981}
6982} endloop:
6983if (seminfo)
6984seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep),
6985luaZ_bufflen(ls->buff) - 2*(2 + sep));
6986}
6987
6988
6989static void read_string (LexState *ls, int del, SemInfo *seminfo) {

Callers 1

llexFunction · 0.85

Calls 6

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

Tested by

no test coverage detected