| 1187 | |
| 1188 | |
| 1189 | static 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 | /* |
no test coverage detected