| 1099 | |
| 1100 | |
| 1101 | static void addquoted (luaL_Buffer *b, const char *s, size_t len) { |
| 1102 | luaL_addchar(b, '"'); |
| 1103 | while (len--) { |
| 1104 | if (*s == '"' || *s == '\\' || *s == '\n') { |
| 1105 | luaL_addchar(b, '\\'); |
| 1106 | luaL_addchar(b, *s); |
| 1107 | } |
| 1108 | else if (iscntrl(uchar(*s))) { |
| 1109 | char buff[10]; |
| 1110 | if (!isdigit(uchar(*(s+1)))) |
| 1111 | l_sprintf(buff, sizeof(buff), "\\%d", (int)uchar(*s)); |
| 1112 | else |
| 1113 | l_sprintf(buff, sizeof(buff), "\\%03d", (int)uchar(*s)); |
| 1114 | luaL_addstring(b, buff); |
| 1115 | } |
| 1116 | else |
| 1117 | luaL_addchar(b, *s); |
| 1118 | s++; |
| 1119 | } |
| 1120 | luaL_addchar(b, '"'); |
| 1121 | } |
| 1122 | |
| 1123 | |
| 1124 | /* |
no test coverage detected