| 278 | |
| 279 | |
| 280 | static void read_long_string (LexState *ls, SemInfo *seminfo, size_t sep) { |
| 281 | int line = ls->linenumber; /* initial line (for error message) */ |
| 282 | save_and_next(ls); /* skip 2nd '[' */ |
| 283 | if (currIsNewline(ls)) /* string starts with a newline? */ |
| 284 | inclinenumber(ls); /* skip it */ |
| 285 | for (;;) { |
| 286 | switch (ls->current) { |
| 287 | case EOZ: { /* error */ |
| 288 | const char *what = (seminfo ? "string" : "comment"); |
| 289 | const char *msg = luaO_pushfstring(ls->L, |
| 290 | "unfinished long %s (starting at line %d)", what, line); |
| 291 | lexerror(ls, msg, TK_EOS); |
| 292 | break; /* to avoid warnings */ |
| 293 | } |
| 294 | case ']': { |
| 295 | if (skip_sep(ls) == sep) { |
| 296 | save_and_next(ls); /* skip 2nd ']' */ |
| 297 | goto endloop; |
| 298 | } |
| 299 | break; |
| 300 | } |
| 301 | case '\n': case '\r': { |
| 302 | save(ls, '\n'); |
| 303 | inclinenumber(ls); |
| 304 | if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */ |
| 305 | break; |
| 306 | } |
| 307 | default: { |
| 308 | if (seminfo) save_and_next(ls); |
| 309 | else next(ls); |
| 310 | } |
| 311 | } |
| 312 | } endloop: |
| 313 | if (seminfo) |
| 314 | seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + sep, |
| 315 | luaZ_bufflen(ls->buff) - 2 * sep); |
| 316 | } |
| 317 | |
| 318 | |
| 319 | static void esccheck (LexState *ls, int c, const char *msg) { |
no test coverage detected