| 842 | |
| 843 | |
| 844 | static void addquoted (lua_State *L, luaL_Buffer *b, int arg) { |
| 845 | size_t l; |
| 846 | const char *s = luaL_checklstring(L, arg, &l); |
| 847 | luaL_addchar(b, '"'); |
| 848 | while (l--) { |
| 849 | if (*s == '"' || *s == '\\' || *s == '\n') { |
| 850 | luaL_addchar(b, '\\'); |
| 851 | luaL_addchar(b, *s); |
| 852 | } |
| 853 | else if (*s == '\0' || iscntrl(uchar(*s))) { |
| 854 | char buff[10]; |
| 855 | if (!isdigit(uchar(*(s+1)))) |
| 856 | snprintf(buff, sizeof(buff), "\\%d", (int)uchar(*s)); |
| 857 | else |
| 858 | snprintf(buff, sizeof(buff), "\\%03d", (int)uchar(*s)); |
| 859 | luaL_addstring(b, buff); |
| 860 | } |
| 861 | else |
| 862 | luaL_addchar(b, *s); |
| 863 | s++; |
| 864 | } |
| 865 | luaL_addchar(b, '"'); |
| 866 | } |
| 867 | |
| 868 | static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { |
| 869 | const char *p = strfrmt; |
no test coverage detected