| 300 | |
| 301 | |
| 302 | static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) { |
| 303 | int line = ls->linenumber; /* initial line (for error message) */ |
| 304 | save_and_next(ls); /* skip 2nd '[' */ |
| 305 | if (currIsNewline(ls)) /* string starts with a newline? */ |
| 306 | inclinenumber(ls); /* skip it */ |
| 307 | for (;;) { |
| 308 | switch (ls->current) { |
| 309 | case EOZ: { /* error */ |
| 310 | const char *what = (seminfo ? "string" : "comment"); |
| 311 | const char *msg = luaO_pushfstring(ls->L, |
| 312 | "unfinished long %s (starting at line %d)", what, line); |
| 313 | lexerror(ls, msg, TK_EOS); |
| 314 | break; /* to avoid warnings */ |
| 315 | } |
| 316 | case ']': { |
| 317 | if (skip_sep(ls) == sep) { |
| 318 | save_and_next(ls); /* skip 2nd ']' */ |
| 319 | goto endloop; |
| 320 | } |
| 321 | break; |
| 322 | } |
| 323 | case '\n': case '\r': { |
| 324 | save(ls, '\n'); |
| 325 | inclinenumber(ls); |
| 326 | if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */ |
| 327 | break; |
| 328 | } |
| 329 | default: { |
| 330 | if (seminfo) save_and_next(ls); |
| 331 | else next(ls); |
| 332 | } |
| 333 | } |
| 334 | } endloop: |
| 335 | if (seminfo) |
| 336 | seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep), |
| 337 | luaZ_bufflen(ls->buff) - 2*(2 + sep)); |
| 338 | } |
| 339 | |
| 340 | |
| 341 | static void esccheck (LexState *ls, int c, const char *msg) { |
no test coverage detected