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

Function scanformat

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

Source from the content-addressed store, hash-verified

866}
867
868static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
869 const char *p = strfrmt;
870 while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */
871 if ((size_t)(p - strfrmt) >= sizeof(FLAGS)/sizeof(char))
872 luaL_error(L, "invalid format (repeated flags)");
873 if (isdigit(uchar(*p))) p++; /* skip width */
874 if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
875 if (*p == '.') {
876 p++;
877 if (isdigit(uchar(*p))) p++; /* skip precision */
878 if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
879 }
880 if (isdigit(uchar(*p)))
881 luaL_error(L, "invalid format (width or precision too long)");
882 *(form++) = '%';
883 memcpy(form, strfrmt, (p - strfrmt + 1) * sizeof(char));
884 form += p - strfrmt + 1;
885 *form = '\0';
886 return p;
887}
888
889
890/*

Callers 1

str_formatFunction · 0.70

Calls 4

strchrFunction · 0.85
isdigitFunction · 0.85
luaL_errorFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected