summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2008-06-05 17:44:18 +0000
committered <ed@FreeBSD.org>2008-06-05 17:44:18 +0000
commit82f26711e22fa85a3c2538b63306cd6dade76d08 (patch)
tree9ba8afbe2558a91b90bf8e0e97c07882246de800 /sys
parente9bd8b71f988d35b3cf464cd9c694a3e5afcc6d4 (diff)
downloadFreeBSD-src-82f26711e22fa85a3c2538b63306cd6dade76d08.zip
FreeBSD-src-82f26711e22fa85a3c2538b63306cd6dade76d08.tar.gz
Fix faulty character to control-character conversion for CTRL().
The CTRL() macro seems to perform character to control-character conversion (i.e. 'A' to 0x01) to lowercase characters. This is actually not valid. If we use lowercase characters, conversions such as CTRL('\\') and CTRL('?') will result to invalid conversions. Because we must still support old source code that uses CTRL() (bad!), we make CTRL() accept both forms. When the character is a lowercase character, we perform the old style conversion. Approved by: philip (mentor)
Diffstat (limited to 'sys')
-rw-r--r--sys/sys/ttydefaults.h39
1 files changed, 23 insertions, 16 deletions
diff --git a/sys/sys/ttydefaults.h b/sys/sys/ttydefaults.h
index d21dddf..5813bda 100644
--- a/sys/sys/ttydefaults.h
+++ b/sys/sys/ttydefaults.h
@@ -56,25 +56,32 @@
/*
* Control Character Defaults
*/
-#define CTRL(x) (x&037)
-#define CEOF CTRL('d')
+/*
+ * XXX: A lot of code uses lowercase characters, but control-character
+ * conversion is actually only valid when applied to uppercase
+ * characters. We just treat lowercase characters as if they were
+ * inserted as uppercase.
+ */
+#define CTRL(x) ((x) >= 'a' && (x) <= 'z' ? \
+ ((x) - 'a' + 1) : (((x) - 'A' + 1) & 0x7f))
+#define CEOF CTRL('D')
#define CEOL 0xff /* XXX avoid _POSIX_VDISABLE */
-#define CERASE 0177
-#define CERASE2 CTRL('h')
-#define CINTR CTRL('c')
-#define CSTATUS CTRL('t')
-#define CKILL CTRL('u')
+#define CERASE CTRL('?')
+#define CERASE2 CTRL('H')
+#define CINTR CTRL('C')
+#define CSTATUS CTRL('T')
+#define CKILL CTRL('U')
#define CMIN 1
-#define CQUIT 034 /* FS, ^\ */
-#define CSUSP CTRL('z')
+#define CQUIT CTRL('\\')
+#define CSUSP CTRL('Z')
#define CTIME 0
-#define CDSUSP CTRL('y')
-#define CSTART CTRL('q')
-#define CSTOP CTRL('s')
-#define CLNEXT CTRL('v')
-#define CDISCARD CTRL('o')
-#define CWERASE CTRL('w')
-#define CREPRINT CTRL('r')
+#define CDSUSP CTRL('Y')
+#define CSTART CTRL('Q')
+#define CSTOP CTRL('S')
+#define CLNEXT CTRL('V')
+#define CDISCARD CTRL('O')
+#define CWERASE CTRL('W')
+#define CREPRINT CTRL('R')
#define CEOT CEOF
/* compat */
#define CBRK CEOL
OpenPOWER on IntegriCloud