| 276 | |
| 277 | |
| 278 | static void read_string (LexState *ls, int del, SemInfo *seminfo) { |
| 279 | save_and_next(ls); |
| 280 | while (ls->current != del) { |
| 281 | switch (ls->current) { |
| 282 | case EOZ: |
| 283 | luaX_lexerror(ls, "unfinished string", TK_EOS); |
| 284 | continue; /* to avoid warnings */ |
| 285 | case '\n': |
| 286 | case '\r': |
| 287 | luaX_lexerror(ls, "unfinished string", TK_STRING); |
| 288 | continue; /* to avoid warnings */ |
| 289 | case '\\': { |
| 290 | int c; |
| 291 | next(ls); /* do not save the `\' */ |
| 292 | switch (ls->current) { |
| 293 | case 'a': c = '\a'; break; |
| 294 | case 'b': c = '\b'; break; |
| 295 | case 'f': c = '\f'; break; |
| 296 | case 'n': c = '\n'; break; |
| 297 | case 'r': c = '\r'; break; |
| 298 | case 't': c = '\t'; break; |
| 299 | case 'v': c = '\v'; break; |
| 300 | case '\n': /* go through */ |
| 301 | case '\r': save(ls, '\n'); inclinenumber(ls); continue; |
| 302 | case EOZ: continue; /* will raise an error next loop */ |
| 303 | default: { |
| 304 | if (!isdigit(ls->current)) |
| 305 | save_and_next(ls); /* handles \\, \", \', and \? */ |
| 306 | else { /* \xxx */ |
| 307 | int i = 0; |
| 308 | c = 0; |
| 309 | do { |
| 310 | c = 10*c + (ls->current-'0'); |
| 311 | next(ls); |
| 312 | } while (++i<3 && isdigit(ls->current)); |
| 313 | if (c > UCHAR_MAX) |
| 314 | luaX_lexerror(ls, "escape sequence too large", TK_STRING); |
| 315 | save(ls, c); |
| 316 | } |
| 317 | continue; |
| 318 | } |
| 319 | } |
| 320 | save(ls, c); |
| 321 | next(ls); |
| 322 | continue; |
| 323 | } |
| 324 | default: |
| 325 | save_and_next(ls); |
| 326 | } |
| 327 | } |
| 328 | save_and_next(ls); /* skip delimiter */ |
| 329 | seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + 1, |
| 330 | luaZ_bufflen(ls->buff) - 2); |
| 331 | } |
| 332 | |
| 333 | |
| 334 | static int llex (LexState *ls, SemInfo *seminfo) { |
no test coverage detected