MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / scanformat

Function scanformat

third-party/lua-5.2.4/src/lstrlib.c:857–876  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

855}
856
857static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
858 const char *p = strfrmt;
859 while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */
860 if ((size_t)(p - strfrmt) >= sizeof(FLAGS)/sizeof(char))
861 luaL_error(L, "invalid format (repeated flags)");
862 if (isdigit(uchar(*p))) p++; /* skip width */
863 if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
864 if (*p == '.') {
865 p++;
866 if (isdigit(uchar(*p))) p++; /* skip precision */
867 if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
868 }
869 if (isdigit(uchar(*p)))
870 luaL_error(L, "invalid format (width or precision too long)");
871 *(form++) = '%';
872 memcpy(form, strfrmt, (p - strfrmt + 1) * sizeof(char));
873 form += p - strfrmt + 1;
874 *form = '\0';
875 return p;
876}
877
878
879/*

Callers 1

str_formatFunction · 0.70

Calls 1

luaL_errorFunction · 0.70

Tested by

no test coverage detected