MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / addquoted

Function addquoted

extlibs/lua/src/lstrlib.c:1101–1121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1099
1100
1101static 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/*

Callers 1

addliteralFunction · 0.85

Calls 1

luaL_addstringFunction · 0.85

Tested by

no test coverage detected