[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    [Patch] KPTY and CTRL() macro -> use CFOO constants?
From:       Ed Schouten <ed () 80386 ! nl>
Date:       2008-06-27 13:32:06
Message-ID: 20080627133206.GD93496 () hoeg ! nl
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


Hello KDE folks,

I am one of the lucky *ahum* developers who took the responsibility of
maintaining the FreeBSD TTY layer. I could go on for ages about the nice
set of patches that I'm planning to integrate, but that would need a
mailing list of its own. ;-)

Like many other operating systems, FreeBSD has the CTRL() macro, which
allows the following conversion:

	CTRL('c')	-> 0x03

Because this translation is broken by design (you need the translation
to be performed on uppercase characters to be correct), I changed the
FreeBSD version to both accept uppercase and lowercase forms.
Unfortunately, this broke kdelibs3, because kdelibs3 seems to pass
values to CTRL() that are not very usual.

This is the patch that I propose. Most operating systems already have
constants such as CINTR, CKILL, CERASE, etc. We'd better use these.

%%%
--- kdecore/kpty.cpp
+++ kdecore/kpty.cpp
@@ -127,10 +127,15 @@
 #include <kdebug.h>
 #include <kstandarddirs.h>	// locate
 
-// not defined on HP-UX for example
-#ifndef CTRL
-# define CTRL(x) ((x) & 037)
-#endif
+#ifndef CINTR
+#define CINTR	0x03
+#endif
+#ifndef CQUIT
+#define CQUIT	0x1c
+#endif
+#ifndef CERASE
+#define CERASE	0x7f
+#endif
 
 #define TTY_GROUP "tty"
 
@@ -333,9 +339,9 @@
     ttmode.c_iflag |= IUTF8;
 #endif
 
-  ttmode.c_cc[VINTR] = CTRL('C' - '@');
-  ttmode.c_cc[VQUIT] = CTRL('\\' - '@');
-  ttmode.c_cc[VERASE] = 0177;
+  ttmode.c_cc[VINTR] = CINTR;
+  ttmode.c_cc[VQUIT] = CQUIT;
+  ttmode.c_cc[VERASE] = CERASE;
 
   _tcsetattr(d->slaveFd, &ttmode);
 
%%%

Is there any chance that this patch can be integrated into KDE? I heard
this code is also present in KDE4. Thanks!

Apart from the change above, I noticed kdelibs3 doesn't really follow
standard practices to allocate PTY's. Most operating systems nowadays
have the openpty() routine to allocate them, but it would even be better
to use the posix_openpt() routine. Unfortunately I'm not a KDE user, so
I can't be of much help here, I guess.

Yours,
-- 
 Ed Schouten <ed@80386.nl>
 WWW: http://80386.nl/

[Attachment #5 (application/pgp-signature)]

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic