| 1013 | } |
| 1014 | |
| 1015 | static const char *scanformat(lua_State *L, const char *strfrmt, char *form) { |
| 1016 | const char *p = strfrmt; |
| 1017 | while (*p != '\0' && strchr(FLAGS, *p) != nullptr) p++; /* skip flags */ |
| 1018 | if ((size_t)(p - strfrmt) >= sizeof(FLAGS) / sizeof(char)) |
| 1019 | luaL_error(L, "invalid format (repeated flags)"); |
| 1020 | if (isdigit(uchar(*p))) p++; /* skip width */ |
| 1021 | if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ |
| 1022 | if (*p == '.') { |
| 1023 | p++; |
| 1024 | if (isdigit(uchar(*p))) p++; /* skip precision */ |
| 1025 | if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ |
| 1026 | } |
| 1027 | if (isdigit(uchar(*p))) |
| 1028 | luaL_error(L, "invalid format (width or precision too long)"); |
| 1029 | *(form++) = '%'; |
| 1030 | memcpy(form, strfrmt, ((p - strfrmt) + 1) * sizeof(char)); |
| 1031 | form += (p - strfrmt) + 1; |
| 1032 | *form = '\0'; |
| 1033 | return p; |
| 1034 | } |
| 1035 | |
| 1036 | |
| 1037 | /* |
no test coverage detected