| 6932 | |
| 6933 | |
| 6934 | static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) { |
| 6935 | int cont = 0; |
| 6936 | (void)(cont); /* avoid warnings when `cont' is not used */ |
| 6937 | save_and_next(ls); /* skip 2nd `[' */ |
| 6938 | if (currIsNewline(ls)) /* string starts with a newline? */ |
| 6939 | inclinenumber(ls); /* skip it */ |
| 6940 | for (;;) { |
| 6941 | switch (ls->current) { |
| 6942 | case EOZ: |
| 6943 | luaX_lexerror(ls, (seminfo) ? "unfinished long string" : |
| 6944 | "unfinished long comment", TK_EOS); |
| 6945 | break; /* to avoid warnings */ |
| 6946 | #if defined(LUA_COMPAT_LSTR) |
| 6947 | case '[': { |
| 6948 | if (skip_sep(ls) == sep) { |
| 6949 | save_and_next(ls); /* skip 2nd `[' */ |
| 6950 | cont++; |
| 6951 | #if LUA_COMPAT_LSTR == 1 |
| 6952 | if (sep == 0) |
| 6953 | luaX_lexerror(ls, "nesting of [[...]] is deprecated", '['); |
| 6954 | #endif |
| 6955 | } |
| 6956 | break; |
| 6957 | } |
| 6958 | #endif |
| 6959 | case ']': { |
| 6960 | if (skip_sep(ls) == sep) { |
| 6961 | save_and_next(ls); /* skip 2nd `]' */ |
| 6962 | #if defined(LUA_COMPAT_LSTR) && LUA_COMPAT_LSTR == 2 |
| 6963 | cont--; |
| 6964 | if (sep == 0 && cont >= 0) break; |
| 6965 | #endif |
| 6966 | goto endloop; |
| 6967 | } |
| 6968 | break; |
| 6969 | } |
| 6970 | case '\n': |
| 6971 | case '\r': { |
| 6972 | save(ls, '\n'); |
| 6973 | inclinenumber(ls); |
| 6974 | if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */ |
| 6975 | break; |
| 6976 | } |
| 6977 | default: { |
| 6978 | if (seminfo) save_and_next(ls); |
| 6979 | else next(ls); |
| 6980 | } |
| 6981 | } |
| 6982 | } endloop: |
| 6983 | if (seminfo) |
| 6984 | seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep), |
| 6985 | luaZ_bufflen(ls->buff) - 2*(2 + sep)); |
| 6986 | } |
| 6987 | |
| 6988 | |
| 6989 | static void read_string (LexState *ls, int del, SemInfo *seminfo) { |
no test coverage detected