| 676 | |
| 677 | |
| 678 | static void add_s (MatchState *ms, luaL_Buffer *b, const char *s, |
| 679 | const char *e) { |
| 680 | size_t l, i; |
| 681 | const char *news = lua_tolstring(ms->L, 3, &l); |
| 682 | for (i = 0; i < l; i++) { |
| 683 | if (news[i] != L_ESC) |
| 684 | luaL_addchar(b, news[i]); |
| 685 | else { |
| 686 | i++; /* skip ESC */ |
| 687 | if (!isdigit(uchar(news[i]))) { |
| 688 | if (news[i] != L_ESC) |
| 689 | luaL_error(ms->L, "invalid use of " LUA_QL("%c") |
| 690 | " in replacement string", L_ESC); |
| 691 | luaL_addchar(b, news[i]); |
| 692 | } |
| 693 | else if (news[i] == '0') |
| 694 | luaL_addlstring(b, s, e - s); |
| 695 | else { |
| 696 | push_onecapture(ms, news[i] - '1', s, e); |
| 697 | luaL_addvalue(b); /* add capture to accumulated result */ |
| 698 | } |
| 699 | } |
| 700 | } |
| 701 | } |
| 702 | |
| 703 | |
| 704 | static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, |
no test coverage detected