** 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. */
| 1223 | ** 'precision' signals whether to accept a precision. |
| 1224 | */ |
| 1225 | static 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 | /* |
no test coverage detected