MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / scanformat

Function scanformat

src/Chain/libraries/glua/lstrlib.cpp:1015–1034  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1013}
1014
1015static 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/*

Callers 1

str_formatFunction · 0.85

Calls 1

luaL_errorFunction · 0.85

Tested by

no test coverage detected