| 979 | |
| 980 | |
| 981 | static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { |
| 982 | const char *p = strfrmt; |
| 983 | while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ |
| 984 | if ((size_t)(p - strfrmt) >= sizeof(FLAGS)/sizeof(char)) |
| 985 | luaL_error(L, "invalid format (repeated flags)"); |
| 986 | if (isdigit(uchar(*p))) p++; /* skip width */ |
| 987 | if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ |
| 988 | if (*p == '.') { |
| 989 | p++; |
| 990 | if (isdigit(uchar(*p))) p++; /* skip precision */ |
| 991 | if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ |
| 992 | } |
| 993 | if (isdigit(uchar(*p))) |
| 994 | luaL_error(L, "invalid format (width or precision too long)"); |
| 995 | *(form++) = '%'; |
| 996 | memcpy(form, strfrmt, ((p - strfrmt) + 1) * sizeof(char)); |
| 997 | form += (p - strfrmt) + 1; |
| 998 | *form = '\0'; |
| 999 | return p; |
| 1000 | } |
| 1001 | |
| 1002 | |
| 1003 | /* |
no test coverage detected