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

Function scanformat

app/redis-6.2.6/deps/lua/src/lstrlib.c:725–744  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

723}
724
725static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
726 const char *p = strfrmt;
727 while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */
728 if ((size_t)(p - strfrmt) >= sizeof(FLAGS))
729 luaL_error(L, "invalid format (repeated flags)");
730 if (isdigit(uchar(*p))) p++; /* skip width */
731 if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
732 if (*p == '.') {
733 p++;
734 if (isdigit(uchar(*p))) p++; /* skip precision */
735 if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
736 }
737 if (isdigit(uchar(*p)))
738 luaL_error(L, "invalid format (width or precision too long)");
739 *(form++) = '%';
740 strncpy(form, strfrmt, p - strfrmt + 1);
741 form += p - strfrmt + 1;
742 *form = '\0';
743 return p;
744}
745
746
747static void addintlen (char *form) {

Callers 1

str_formatFunction · 0.70

Calls 4

strchrFunction · 0.85
isdigitFunction · 0.85
strncpyFunction · 0.85
luaL_errorFunction · 0.70

Tested by

no test coverage detected