Fixing the FfmTerminal to run on JDK 22 and on Linux. by lahodaj · Pull Request #945 · jline/jline3 (original) (raw)

Added one more fix here:
bbe3c2a

the problem this is trying to fix is when (e.g.) the VINTR control character is set to some value (like 0):

        Attributes attrs = terminal.getAttributes();
        attrs.setControlChar(Attributes.ControlChar.VINTR, 0);
        terminal.setAttributes(attrs);

then the code attempts to write the value at the proper slot in the control characters array. And this works. But, on Linux, there is apparently no VDSUSP, and hence VDSUSP is never set by the code, so the value of that field is 0 (the default). And VINTR on Linux is also 0. So, after VINTR is written, this line is performed:

c_cc[VDSUSP] = (byte) t.getControlChar(Attributes.ControlChar.VDSUSP);

and that rewrites the value of VINTR with the value of t.getControlChar(Attributes.ControlChar.VDSUSP) (and something similar happens when reading the control characters from the array into Attributes). This then leads to an incorrect VINTR character, and misbehavior on Linux.

This change proposes to always set all the index variables for control characters, and just use -1 for those that don't exist on the given platform, and then not setting those/not reading those.