| 169 | |
| 170 | |
| 171 | static const char *checkoption (lua_State *L, const char *conv, char *buff) { |
| 172 | static const char *const options[] = LUA_STRFTIMEOPTIONS; |
| 173 | unsigned int i; |
| 174 | for (i = 0; i < sizeof(options)/sizeof(options[0]); i += 2) { |
| 175 | if (*conv != '\0' && strchr(options[i], *conv) != NULL) { |
| 176 | buff[1] = *conv; |
| 177 | if (*options[i + 1] == '\0') { /* one-char conversion specifier? */ |
| 178 | buff[2] = '\0'; /* end buffer */ |
| 179 | return conv + 1; |
| 180 | } |
| 181 | else if (*(conv + 1) != '\0' && |
| 182 | strchr(options[i + 1], *(conv + 1)) != NULL) { |
| 183 | buff[2] = *(conv + 1); /* valid two-char conversion specifier */ |
| 184 | buff[3] = '\0'; /* end buffer */ |
| 185 | return conv + 2; |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | luaL_argerror(L, 1, |
| 190 | lua_pushfstring(L, "invalid conversion specifier '%%%s'", conv)); |
| 191 | return conv; /* to avoid warnings */ |
| 192 | } |
| 193 | |
| 194 | |
| 195 | static int os_date (lua_State *L) { |
no test coverage detected