Closed realjackwang closed 2 years ago
Thanks for the report. I have a potential fix for birds with guns that needs some more regression testing but hopefully will make it into the next release. I wasn't aware of a crash in Pico & Chill, so I will take a look at that one.
The birds with guns fix I came up was to basically put part of the old Lua 5.1 and lower nested comments code back in read_long_string (llex.c). So from: https://www.lua.org/source/5.1/llex.c.html#read_long_string <--- that's a mess, but you only have to add a few lines to our version to make it work. So mine ended up like:
static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) { int cont = 0; save_and_next(ls); /* skip 2nd `[' */ if (currIsNewline(ls)) /* string starts with a newline? */ inclinenumber(ls); /* skip it */ for (;;) { switch (ls->current) { case EOZ: lexerror(ls, (seminfo) ? "unfinished long string" : "unfinished long comment", TK_EOS); break; /* to avoid warnings */ case '[': { save_and_next(ls); if (ls->current == '[') { save_and_next(ls); /* skip 2nd `[' */ cont++; } break; } case ']': { if (skip_sep(ls) == sep) { save_and_next(ls); /* skip 2nd `]' */ cont--; if (cont >= 0) break; goto endloop; } break; } case '\n': case '\r': { save(ls, '\n'); inclinenumber(ls); if (!seminfo) luaZ_resetbuffer(ls->buff); /* avoid wasting space */ break; } default: { if (seminfo) save_and_next(ls); else next(ls); } } } endloop: if (seminfo) seminfo->ts = luaX_newstring(ls, luaZ_buffer(ls->buff) + (2 + sep), luaZ_bufflen(ls->buff) - 2*(2 + sep)); }
^ Additional lines added in bold
birds with guns is a pretty good test suite as it uses long strings/comments through out. So the fact that it works with that (and everything else I've tried) - makes me think this is good.
So this is pretty similar to the fix I had attempted earlier (see https://github.com/jtothebell/z8lua/commit/60bf3fd7a314f5dea3082fc4b020f05613e9ef9f), but both do have regressions for some carts like https://www.lexaloffle.com/bbs/?pid=37199 and https://www.lexaloffle.com/bbs/?pid=53256 which work prior to this change but then fail afterward because apparently Pico-8 allows multiple long comment opening symbols without their corresponding close (treats them as single line comments if they don't have a close it looks like to me)
That being said, from my test suite of carts it looks like it is a net gain in compatibility and seems to be worth including at least for the time being.
With the newest version. some of the games works, but some didn't.
this game can get into the command line, but said Error loading cart lua: https://www.lexaloffle.com/bbs/cposts/bi/birdswithguns-3.p8.png
this game crashed directly: https://www.lexaloffle.com/bbs/cposts/pi/picochill-1.p8.png