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