MCPcopy Create free account
hub / github.com/F-Stack/f-stack / addquoted

Function addquoted

freebsd/contrib/openzfs/module/lua/lstrlib.c:844–866  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

842
843
844static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
845 size_t l;
846 const char *s = luaL_checklstring(L, arg, &l);
847 luaL_addchar(b, '"');
848 while (l--) {
849 if (*s == '"' || *s == '\\' || *s == '\n') {
850 luaL_addchar(b, '\\');
851 luaL_addchar(b, *s);
852 }
853 else if (*s == '\0' || iscntrl(uchar(*s))) {
854 char buff[10];
855 if (!isdigit(uchar(*(s+1))))
856 snprintf(buff, sizeof(buff), "\\%d", (int)uchar(*s));
857 else
858 snprintf(buff, sizeof(buff), "\\%03d", (int)uchar(*s));
859 luaL_addstring(b, buff);
860 }
861 else
862 luaL_addchar(b, *s);
863 s++;
864 }
865 luaL_addchar(b, '"');
866}
867
868static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
869 const char *p = strfrmt;

Callers 1

str_formatFunction · 0.70

Calls 4

isdigitFunction · 0.85
snprintfFunction · 0.85
luaL_checklstringFunction · 0.70
luaL_addstringFunction · 0.70

Tested by

no test coverage detected