MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / addquoted

Function addquoted

lib/lua/src/lstrlib.c:1122–1142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1120
1121
1122static 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/*

Callers 1

addliteralFunction · 0.85

Calls 1

luaL_addstringFunction · 0.85

Tested by

no test coverage detected