MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / read_long_string

Function read_long_string

libraries/AP_Scripting/lua/src/llex.c:266–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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