Sfoglia il codice sorgente

Kernel+LibC: Default to 8-bit characters in TTY

Some ports (like `bc` with history enabled) sensibly set the termios
character size to 8 bits.

Previously, we left the character size value (given by the bitmask
CSIZE) as zero by default (meaning 5 bits per character), and returned
ENOTIMPL whenever someone modified it. This was dumb.
Daniel Bertalan 3 anni fa
parent
commit
5f6030b13c
2 ha cambiato i file con 6 aggiunte e 6 eliminazioni
  1. 5 5
      Kernel/TTY/TTY.cpp
  2. 1 1
      Userland/Libraries/LibC/sys/ttydefaults.h

+ 5 - 5
Kernel/TTY/TTY.cpp

@@ -438,12 +438,12 @@ KResult TTY::set_termios(const termios& t)
         }
     }
 
+    if ((m_termios.c_cflag & CSIZE) != CS8) {
+        dbgln("FIXME: Character sizes other than 8 bits are not supported");
+        rc = ENOTIMPL;
+    }
+
     static constexpr FlagDescription unimplemented_cflags[] = {
-        { CSIZE, "CSIZE" },
-        { CS5, "CS5" },
-        { CS6, "CS6" },
-        { CS7, "CS7" },
-        { CS8, "CS8" },
         { CSTOPB, "CSTOPB" },
         { CREAD, "CREAD" },
         { PARENB, "PARENB" },

+ 1 - 1
Userland/Libraries/LibC/sys/ttydefaults.h

@@ -11,7 +11,7 @@
 #define TTYDEF_LFLAG_NOECHO (ISIG | ICANON)
 #define TTYDEF_LFLAG_ECHO (TTYDEF_LFLAG_NOECHO | ECHO | ECHOE | ECHOK | ECHONL)
 #define TTYDEF_LFLAG TTYDEF_LFLAG_ECHO
-#define TTYDEF_CFLAG (0)
+#define TTYDEF_CFLAG (CS8)
 #define TTYDEF_SPEED (B9600)
 
 #define CTRL(c) (c & 0x1F)