| 866 | } |
| 867 | |
| 868 | static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { |
| 869 | const char *p = strfrmt; |
| 870 | while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ |
| 871 | if ((size_t)(p - strfrmt) >= sizeof(FLAGS)/sizeof(char)) |
| 872 | luaL_error(L, "invalid format (repeated flags)"); |
| 873 | if (isdigit(uchar(*p))) p++; /* skip width */ |
| 874 | if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ |
| 875 | if (*p == '.') { |
| 876 | p++; |
| 877 | if (isdigit(uchar(*p))) p++; /* skip precision */ |
| 878 | if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ |
| 879 | } |
| 880 | if (isdigit(uchar(*p))) |
| 881 | luaL_error(L, "invalid format (width or precision too long)"); |
| 882 | *(form++) = '%'; |
| 883 | memcpy(form, strfrmt, (p - strfrmt + 1) * sizeof(char)); |
| 884 | form += p - strfrmt + 1; |
| 885 | *form = '\0'; |
| 886 | return p; |
| 887 | } |
| 888 | |
| 889 | |
| 890 | /* |
no test coverage detected