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

Function read_long_string

lib/lua/src/llex.c:225–277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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