MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / addquoted

Function addquoted

3rd/lua-5.4.3/src/lstrlib.c:1104–1124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1102
1103
1104static 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/*

Callers 1

addliteralFunction · 0.85

Calls 1

luaL_addstringFunction · 0.85

Tested by

no test coverage detected