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