| 1120 | |
| 1121 | |
| 1122 | static void addquoted (luaL_Buffer *b, const char *s, size_t len) { |
| 1123 | luaL_addchar(b, '"'); |
| 1124 | while (len--) { |
| 1125 | if (*s == '"' || *s == '\\' || *s == '\n') { |
| 1126 | luaL_addchar(b, '\\'); |
| 1127 | luaL_addchar(b, *s); |
| 1128 | } |
| 1129 | else if (iscntrl(uchar(*s))) { |
| 1130 | char buff[10]; |
| 1131 | if (!isdigit(uchar(*(s+1)))) |
| 1132 | l_sprintf(buff, sizeof(buff), "\\%d", (int)uchar(*s)); |
| 1133 | else |
| 1134 | l_sprintf(buff, sizeof(buff), "\\%03d", (int)uchar(*s)); |
| 1135 | luaL_addstring(b, buff); |
| 1136 | } |
| 1137 | else |
| 1138 | luaL_addchar(b, *s); |
| 1139 | s++; |
| 1140 | } |
| 1141 | luaL_addchar(b, '"'); |
| 1142 | } |
| 1143 | |
| 1144 | |
| 1145 | /* |
no test coverage detected