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

Function read_long_string

engine/lua/src/lua/llex.c:229–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227
228
229static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) {
230 int cont = 0;
231 (void)(cont); /* avoid warnings when `cont' is not used */
232 save_and_next(ls); /* skip 2nd `[' */
233 if (currIsNewline(ls)) /* string starts with a newline? */
234 inclinenumber(ls); /* skip it */
235 for (;;) {
236 switch (ls->current) {
237 case EOZ:
238 luaX_lexerror(ls, (seminfo) ? "unfinished long string" :
239 "unfinished long comment", TK_EOS);
240 break; /* to avoid warnings */
241#if defined(LUA_COMPAT_LSTR)
242 case '[': {
243 if (skip_sep(ls) == sep) {
244 save_and_next(ls); /* skip 2nd `[' */
245 cont++;
246#if LUA_COMPAT_LSTR == 1
247 if (sep == 0)
248 luaX_lexerror(ls, "nesting of [[...]] is deprecated", '[');
249#endif
250 }
251 break;
252 }
253#endif
254 case ']': {
255 if (skip_sep(ls) == sep) {
256 save_and_next(ls); /* skip 2nd `]' */
257#if defined(LUA_COMPAT_LSTR) && LUA_COMPAT_LSTR == 2
258 cont--;
259 if (sep == 0 && cont >= 0) break;
260#endif
261 goto endloop;
262 }
263 break;
264 }
265 case '\n':
266 case '\r': {
267 save(ls, '\n');
268 inclinenumber(ls);
269 if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */
270 break;
271 }
272 default: {
273 if (seminfo) save_and_next(ls);
274 else next(ls);
275 }
276 }
277 } endloop:
278 if (seminfo)
279 seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep),
280 luaZ_bufflen(ls->buff) - 2*(2 + sep));
281}
282
283
284static void read_string (LexState *ls, int del, SemInfo *seminfo) {

Callers 1

llexFunction · 0.85

Calls 5

inclinenumberFunction · 0.85
luaX_lexerrorFunction · 0.85
skip_sepFunction · 0.85
saveFunction · 0.85
luaX_newstringFunction · 0.85

Tested by

no test coverage detected