MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / scanformat

Function scanformat

libraries/AP_Scripting/lua/src/lstrlib.c:988–1007  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

986
987
988static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
989 const char *p = strfrmt;
990 while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */
991 if ((size_t)(p - strfrmt) >= sizeof(FLAGS)/sizeof(char))
992 luaL_error(L, "invalid format (repeated flags)");
993 if (isdigit(uchar(*p))) p++; /* skip width */
994 if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
995 if (*p == '.') {
996 p++;
997 if (isdigit(uchar(*p))) p++; /* skip precision */
998 if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
999 }
1000 if (isdigit(uchar(*p)))
1001 luaL_error(L, "invalid format (width or precision too long)");
1002 *(form++) = '%';
1003 memcpy(form, strfrmt, ((p - strfrmt) + 1) * sizeof(char));
1004 form += (p - strfrmt) + 1;
1005 *form = '\0';
1006 return p;
1007}
1008
1009
1010/*

Callers 1

str_formatFunction · 0.85

Calls 2

luaL_errorFunction · 0.85
memcpyFunction · 0.85

Tested by

no test coverage detected