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