mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
Fix os.date() for wider libc strftime() compatibility.
Thanks to Jesper Lundgren.
This commit is contained in:
parent
c4f36ce565
commit
fc63c938b5
@ -205,12 +205,12 @@ LJLIB_CF(os_date)
|
||||
setboolfield(L, "isdst", stm->tm_isdst);
|
||||
} else if (*s) {
|
||||
SBuf *sb = &G(L)->tmpbuf;
|
||||
MSize sz = 0;
|
||||
MSize sz = 0, retry = 4;
|
||||
const char *q;
|
||||
for (q = s; *q; q++)
|
||||
sz += (*q == '%') ? 30 : 1; /* Overflow doesn't matter. */
|
||||
setsbufL(sb, L);
|
||||
for (;;) {
|
||||
while (retry--) { /* Limit growth for invalid format or empty result. */
|
||||
char *buf = lj_buf_need(sb, sz);
|
||||
size_t len = strftime(buf, sbufsz(sb), s, stm);
|
||||
if (len) {
|
||||
|
Loading…
Reference in New Issue
Block a user