MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / scanformat

Function scanformat

extlibs/lua/src/lstrlib.c:1189–1208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1187
1188
1189static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
1190 const char *p = strfrmt;
1191 while (*p != '\0' && strchr(L_FMTFLAGS, *p) != NULL) p++; /* skip flags */
1192 if ((size_t)(p - strfrmt) >= sizeof(L_FMTFLAGS)/sizeof(char))
1193 luaL_error(L, "invalid format (repeated flags)");
1194 if (isdigit(uchar(*p))) p++; /* skip width */
1195 if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
1196 if (*p == '.') {
1197 p++;
1198 if (isdigit(uchar(*p))) p++; /* skip precision */
1199 if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
1200 }
1201 if (isdigit(uchar(*p)))
1202 luaL_error(L, "invalid format (width or precision too long)");
1203 *(form++) = '%';
1204 memcpy(form, strfrmt, ((p - strfrmt) + 1) * sizeof(char));
1205 form += (p - strfrmt) + 1;
1206 *form = '\0';
1207 return p;
1208}
1209
1210
1211/*

Callers 1

str_formatFunction · 0.85

Calls 1

luaL_errorFunction · 0.85

Tested by

no test coverage detected