MCPcopy Create free account
hub / github.com/DFHack/dfhack / read_long_string

Function read_long_string

depends/lua/src/llex.c:267–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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