| 225 | |
| 226 | |
| 227 | static void read_long_string (LexState *ls, SemInfo *seminfo, size_t sep) { |
| 228 | int cont = 0; |
| 229 | (void)(cont); /* avoid warnings when `cont' is not used */ |
| 230 | save_and_next(ls); /* skip 2nd `[' */ |
| 231 | if (currIsNewline(ls)) /* string starts with a newline? */ |
| 232 | inclinenumber(ls); /* skip it */ |
| 233 | for (;;) { |
| 234 | switch (ls->current) { |
| 235 | case EOZ: |
| 236 | luaX_lexerror(ls, (seminfo) ? "unfinished long string" : |
| 237 | "unfinished long comment", TK_EOS); |
| 238 | break; /* to avoid warnings */ |
| 239 | #if defined(LUA_COMPAT_LSTR) |
| 240 | case '[': { |
| 241 | if (skip_sep(ls) == sep) { |
| 242 | save_and_next(ls); /* skip 2nd `[' */ |
| 243 | cont++; |
| 244 | #if LUA_COMPAT_LSTR == 1 |
| 245 | if (sep == 0) |
| 246 | luaX_lexerror(ls, "nesting of [[...]] is deprecated", '['); |
| 247 | #endif |
| 248 | } |
| 249 | break; |
| 250 | } |
| 251 | #endif |
| 252 | case ']': { |
| 253 | if (skip_sep(ls) == sep) { |
| 254 | save_and_next(ls); /* skip 2nd `]' */ |
| 255 | #if defined(LUA_COMPAT_LSTR) && LUA_COMPAT_LSTR == 2 |
| 256 | cont--; |
| 257 | if (sep == 0 && cont >= 0) break; |
| 258 | #endif |
| 259 | goto endloop; |
| 260 | } |
| 261 | break; |
| 262 | } |
| 263 | case '\n': |
| 264 | case '\r': { |
| 265 | save(ls, '\n'); |
| 266 | inclinenumber(ls); |
| 267 | if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */ |
| 268 | break; |
| 269 | } |
| 270 | default: { |
| 271 | if (seminfo) save_and_next(ls); |
| 272 | else next(ls); |
| 273 | } |
| 274 | } |
| 275 | } endloop: |
| 276 | if (seminfo) |
| 277 | seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + sep, |
| 278 | luaZ_bufflen(ls->buff) - 2 * sep); |
| 279 | } |
| 280 | |
| 281 | |
| 282 | static void read_string (LexState *ls, int del, SemInfo *seminfo) { |
no test coverage detected