| 723 | } |
| 724 | |
| 725 | static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { |
| 726 | const char *p = strfrmt; |
| 727 | while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */ |
| 728 | if ((size_t)(p - strfrmt) >= sizeof(FLAGS)) |
| 729 | luaL_error(L, "invalid format (repeated flags)"); |
| 730 | if (isdigit(uchar(*p))) p++; /* skip width */ |
| 731 | if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ |
| 732 | if (*p == '.') { |
| 733 | p++; |
| 734 | if (isdigit(uchar(*p))) p++; /* skip precision */ |
| 735 | if (isdigit(uchar(*p))) p++; /* (2 digits at most) */ |
| 736 | } |
| 737 | if (isdigit(uchar(*p))) |
| 738 | luaL_error(L, "invalid format (width or precision too long)"); |
| 739 | *(form++) = '%'; |
| 740 | strncpy(form, strfrmt, p - strfrmt + 1); |
| 741 | form += p - strfrmt + 1; |
| 742 | *form = '\0'; |
| 743 | return p; |
| 744 | } |
| 745 | |
| 746 | |
| 747 | static void addintlen (char *form) { |
no test coverage detected