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