Fix os.date() broken by d38d10a3.

This commit is contained in:
Mike Pall 2013-04-24 11:22:52 +02:00
parent 39e53e8c4c
commit 7c28448730

View File

@ -187,7 +187,7 @@ LJLIB_CF(os_date)
#endif #endif
} }
if (stm == NULL) { /* Invalid date? */ if (stm == NULL) { /* Invalid date? */
setnilV(L->top-1); setnilV(L->top++);
} else if (strcmp(s, "*t") == 0) { } else if (strcmp(s, "*t") == 0) {
lua_createtable(L, 0, 9); /* 9 = number of fields */ lua_createtable(L, 0, 9); /* 9 = number of fields */
setfield(L, "sec", stm->tm_sec); setfield(L, "sec", stm->tm_sec);
@ -210,14 +210,14 @@ LJLIB_CF(os_date)
char *buf = lj_buf_need(sb, sz); char *buf = lj_buf_need(sb, sz);
size_t len = strftime(buf, sbufsz(sb), s, stm); size_t len = strftime(buf, sbufsz(sb), s, stm);
if (len) { if (len) {
setstrV(L, L->top-1, lj_str_new(L, buf, len)); setstrV(L, L->top++, lj_str_new(L, buf, len));
lj_gc_check(L); lj_gc_check(L);
break; break;
} }
sz += (sz|1); sz += (sz|1);
} }
} else { } else {
setstrV(L, L->top-1, &G(L)->strempty); setstrV(L, L->top++, &G(L)->strempty);
} }
return 1; return 1;
} }