| 906 | |
| 907 | |
| 908 | static void addquoted (luaL_Buffer *b, const char *s, size_t len) { |
| 909 | luaL_addchar(b, '"'); |
| 910 | while (len--) { |
| 911 | if (*s == '"' || *s == '\\' || *s == '\n') { |
| 912 | luaL_addchar(b, '\\'); |
| 913 | luaL_addchar(b, *s); |
| 914 | } |
| 915 | else if (iscntrl(uchar(*s))) { |
| 916 | char buff[10]; |
| 917 | if (!isdigit(uchar(*(s+1)))) |
| 918 | l_sprintf(buff, sizeof(buff), "\\%d", (int)uchar(*s)); |
| 919 | else |
| 920 | l_sprintf(buff, sizeof(buff), "\\%03d", (int)uchar(*s)); |
| 921 | luaL_addstring(b, buff); |
| 922 | } |
| 923 | else |
| 924 | luaL_addchar(b, *s); |
| 925 | s++; |
| 926 | } |
| 927 | luaL_addchar(b, '"'); |
| 928 | } |
| 929 | |
| 930 | |
| 931 | /* |
no test coverage detected