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