MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / checkformat

Function checkformat

lib/lua/src/lstrlib.c:1225–1238  ·  view source on GitHub ↗

** Check whether a conversion specification is valid. When called, ** first character in 'form' must be '%' and last character must ** be a valid conversion specifier. 'flags' are the accepted flags; ** 'precision' signals whether to accept a precision. */

Source from the content-addressed store, hash-verified

1223** 'precision' signals whether to accept a precision.
1224*/
1225static void checkformat (lua_State *L, const char *form, const char *flags,
1226 int precision) {
1227 const char *spec = form + 1; /* skip '%' */
1228 spec += strspn(spec, flags); /* skip flags */
1229 if (*spec != '0') { /* a width cannot start with '0' */
1230 spec = get2digits(spec); /* skip width */
1231 if (*spec == '.' && precision) {
1232 spec++;
1233 spec = get2digits(spec); /* skip precision */
1234 }
1235 }
1236 if (!isalpha(uchar(*spec))) /* did not go to the end? */
1237 luaL_error(L, "invalid conversion specification: '%s'", form);
1238}
1239
1240
1241/*

Callers 1

str_formatFunction · 0.85

Calls 2

get2digitsFunction · 0.85
luaL_errorFunction · 0.85

Tested by

no test coverage detected