First post, by kjliew
I don't remember if I have shared this information somewhere. Since this place has folks interested in DJGPP DOS32 programming, let archive the info here.
At some point in time when DJGPP improved its libc for being more POSIX compliant by adding programmable keys for SIGQUIT and SIGINT, it broke the keyboard handling by reading the scancode every time regardless if the STATUS byte matched the keys. The old keyboard handler only read the scancode when the STATUS byte matched the key. So then every DJGPP compiled codes would potentially exhibit erroneous keyboard behavior such as the bug below.
For eg. VIM editor DOS32 version is unusable after version 5.8 because of this issue. Key strokes were frequently dropped or recorded twice.
The patch fixes the issue and restores the behavior of old keyboard handler.
--- orig/src/libc/go32/exceptn.S 2002-12-21 21:08:39.000000000 -0800
+++ ./exceptn.S 2020-01-18 18:37:27.397176800 -0800
@@ -337,6 +337,15 @@
orb $2,%ah /* If RShift is set, set LShift as well */
+ movb %ah,%al
+ andb %cs:___djgpp_sigint_mask, %ah /* Mask off irrelevant bits */
+ cmpb %cs:___djgpp_sigint_key+1, %ah /* Test for SIGINT */
+ je 60f
+ movb %al,%ah
+ andb %cs:___djgpp_sigquit_mask, %ah /* Mask off irrelevant bits */
+ cmpb %cs:___djgpp_sigquit_key+1, %ah /* Test for SIGQUIT*/
+ jne Lkbd_chain
inb $0x60,%al /* Read the scan code */
movb %ah,%bh /* Save KB status */
The toolchain can be fixed easily by replacing the object file in libc with GNU ar.
$ i686-pc-msdosdjgpp-gcc -c -o exceptn.o exceptn.S
$ i686-pc-msdosdjgpp-ar ru /opt/djgpp/i686-pc-msdosdjgpp/lib/libc.a exceptn.o
There is no need the rebuild the toolchain. Once the toolchain is fixed, DJGPP application can be recompiled to replace the faulty keyboard handler.