| 6987 | |
| 6988 | |
| 6989 | static void read_string (LexState *ls, int del, SemInfo *seminfo) { |
| 6990 | save_and_next(ls); |
| 6991 | while (ls->current != del) { |
| 6992 | switch (ls->current) { |
| 6993 | case EOZ: |
| 6994 | luaX_lexerror(ls, "unfinished string", TK_EOS); |
| 6995 | continue; /* to avoid warnings */ |
| 6996 | case '\n': |
| 6997 | case '\r': |
| 6998 | luaX_lexerror(ls, "unfinished string", TK_STRING); |
| 6999 | continue; /* to avoid warnings */ |
| 7000 | case '\\': { |
| 7001 | int c; |
| 7002 | next(ls); /* do not save the `\' */ |
| 7003 | switch (ls->current) { |
| 7004 | case 'a': c = '\a'; break; |
| 7005 | case 'b': c = '\b'; break; |
| 7006 | case 'f': c = '\f'; break; |
| 7007 | case 'n': c = '\n'; break; |
| 7008 | case 'r': c = '\r'; break; |
| 7009 | case 't': c = '\t'; break; |
| 7010 | case 'v': c = '\v'; break; |
| 7011 | case '\n': /* go through */ |
| 7012 | case '\r': save(ls, '\n'); inclinenumber(ls); continue; |
| 7013 | case EOZ: continue; /* will raise an error next loop */ |
| 7014 | default: { |
| 7015 | if (!isdigit(ls->current)) |
| 7016 | save_and_next(ls); /* handles \\, \", \', and \? */ |
| 7017 | else { /* \xxx */ |
| 7018 | int i = 0; |
| 7019 | c = 0; |
| 7020 | do { |
| 7021 | c = 10*c + (ls->current-'0'); |
| 7022 | next(ls); |
| 7023 | } while (++i<3 && isdigit(ls->current)); |
| 7024 | if (c > UCHAR_MAX) |
| 7025 | luaX_lexerror(ls, "escape sequence too large", TK_STRING); |
| 7026 | save(ls, c); |
| 7027 | } |
| 7028 | continue; |
| 7029 | } |
| 7030 | } |
| 7031 | save(ls, c); |
| 7032 | next(ls); |
| 7033 | continue; |
| 7034 | } |
| 7035 | default: |
| 7036 | save_and_next(ls); |
| 7037 | } |
| 7038 | } |
| 7039 | save_and_next(ls); /* skip delimiter */ |
| 7040 | seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1, |
| 7041 | luaZ_bufflen(ls->buff) - 2); |
| 7042 | } |
| 7043 | |
| 7044 | |
| 7045 | static int llex (LexState *ls, SemInfo *seminfo) { |
no test coverage detected