quixe icon indicating copy to clipboard operation
quixe copied to clipboard

Possible compile_string() bug

Open erkyrath opened this issue 2 years ago • 2 comments

Described in thread: https://intfiction.org/t/help-fixing-everybody-dies-so-its-playable-online/51346

When iosys is zero, printing a string should silently do nothing. Instead it maybe generates a Glk "stream not set" error?

A couple of places seem to generate glk_put_jstring() calls without checking iosys:

oputil_flush_string() stream_string() accel_func_map error cases

erkyrath avatar May 28 '22 03:05 erkyrath

Now I'm thinking that it's not compile_string() after all. Looks like msww was correct in the thread that stream_string() should check iosys.

erkyrath avatar May 29 '22 00:05 erkyrath

The problem turned out to be more subtle than either of us... I think it's fixed now.

accel_func_map errors now only print if iosys is 2. (I have made the same change in glulxe.)

In oputil_flush_string() and stream_string(), we don't need to check iosys. We're printing text buffered for the Glk stream. But we do need to check if the buffered text is empty. The compile_string() layer returns "" if nothing was printed to Glk at all, and we need to not crash in that case.

erkyrath avatar May 30 '22 02:05 erkyrath