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