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