| 270 | |
| 271 | |
| 272 | static const char *checkoption (lua_State *L, const char *conv, |
| 273 | ptrdiff_t convlen, char *buff) { |
| 274 | const char *option = LUA_STRFTIMEOPTIONS; |
| 275 | int oplen = 1; /* length of options being checked */ |
| 276 | for (; *option != '\0' && oplen <= convlen; option += oplen) { |
| 277 | if (*option == '|') /* next block? */ |
| 278 | oplen++; /* will check options with next length (+1) */ |
| 279 | else if (memcmp(conv, option, oplen) == 0) { /* match? */ |
| 280 | memcpy(buff, conv, oplen); /* copy valid option to buffer */ |
| 281 | buff[oplen] = '\0'; |
| 282 | return conv + oplen; /* return next item */ |
| 283 | } |
| 284 | } |
| 285 | luaL_argerror(L, 1, |
| 286 | lua_pushfstring(L, "invalid conversion specifier '%%%s'", conv)); |
| 287 | return conv; /* to avoid warnings */ |
| 288 | } |
| 289 | |
| 290 | |
| 291 | static time_t l_checktime (lua_State *L, int arg) { |
no test coverage detected