MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / read_long_string

Function read_long_string

extlibs/lua/src/llex.c:277–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

275
276
277static void read_long_string (LexState *ls, SemInfo *seminfo, size_t sep) {
278 int line = ls->linenumber; /* initial line (for error message) */
279 save_and_next(ls); /* skip 2nd '[' */
280 if (currIsNewline(ls)) /* string starts with a newline? */
281 inclinenumber(ls); /* skip it */
282 for (;;) {
283 switch (ls->current) {
284 case EOZ: { /* error */
285 const char *what = (seminfo ? "string" : "comment");
286 const char *msg = luaO_pushfstring(ls->L,
287 "unfinished long %s (starting at line %d)", what, line);
288 lexerror(ls, msg, TK_EOS);
289 break; /* to avoid warnings */
290 }
291 case ']': {
292 if (skip_sep(ls) == sep) {
293 save_and_next(ls); /* skip 2nd ']' */
294 goto endloop;
295 }
296 break;
297 }
298 case '\n': case '\r': {
299 save(ls, '\n');
300 inclinenumber(ls);
301 if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */
302 break;
303 }
304 default: {
305 if (seminfo) save_and_next(ls);
306 else next(ls);
307 }
308 }
309 } endloop:
310 if (seminfo)
311 seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + sep,
312 luaZ_bufflen(ls->buff) - 2 * sep);
313}
314
315
316static void esccheck (LexState *ls, int c, const char *msg) {

Callers 1

llexFunction · 0.85

Calls 6

inclinenumberFunction · 0.85
luaO_pushfstringFunction · 0.85
lexerrorFunction · 0.85
skip_sepFunction · 0.85
saveFunction · 0.85
luaX_newstringFunction · 0.85

Tested by

no test coverage detected