fix bug 2 (for Lua.5.3.3) reported on www.lua.org/bugs.html

This commit is contained in:
salazar 2016-09-08 02:55:50 +00:00
parent 03a5d4850a
commit 36b38267b2

View File

@ -1,4 +1,4 @@
/* $NetBSD: loslib.c,v 1.6 2016/09/08 02:21:31 salazar Exp $ */
/* $NetBSD: loslib.c,v 1.7 2016/09/08 02:55:50 salazar Exp $ */
/*
** Id: loslib.c,v 1.64 2016/04/18 13:06:55 roberto Exp
@ -262,8 +262,9 @@ static int getfield (lua_State *L, const char *key, int d, int delta) {
static const char *checkoption (lua_State *L, const char *conv, char *buff) {
const char *option;
int oplen = 1;
for (option = LUA_STRFTIMEOPTIONS; *option != '\0'; option += oplen) {
if (*option == '|') /* next block? */
int convlen = (int)strlen(conv);
for (option = LUA_STRFTIMEOPTIONS; *option != '\0' && oplen <= convlen; option += oplen) {
if (*option == '|') /* next block? */
oplen++; /* next length */
else if (memcmp(conv, option, oplen) == 0) { /* match? */
memcpy(buff, conv, oplen); /* copy valid option to buffer */