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