changeset 15668:f2b81e8a4ab5 draft

Added patched for Cygwin build from Marco Atzeri.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Sun, 27 May 2012 23:38:57 +0200
parents cda168383a83
children a8ff19a82906
files libqterminal/libqterminal.pro libqterminal/unix/kpty.cpp qterminal/qterminal.pro
diffstat 3 files changed, 28 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/libqterminal/libqterminal.pro
+++ b/libqterminal/libqterminal.pro
@@ -10,7 +10,7 @@
 
 unix {
 
-DEFINES 	+= HAVE_POSIX_OPENPT	    
+DEFINES 	+= HAVE_POSIX_OPENPT HAVE_PTY_H HAVE_OPENPTY
 #or DEFINES 	+= HAVE_GETPT
 
 HEADERS  = unix/BlockArray.h \
@@ -30,7 +30,7 @@
            unix/ScreenWindow.h \
            unix/TerminalCharacterDecoder.h \
            unix/Vt102Emulation.h \
-    	   unix/SelfListener.h \
+         unix/SelfListener.h \
            unix/TerminalModel.h \
            unix/TerminalView.h
 
@@ -46,23 +46,23 @@
            unix/ScreenWindow.cpp \
            unix/TerminalCharacterDecoder.cpp \
            unix/Vt102Emulation.cpp \
-    	   unix/SelfListener.cpp \
+         unix/SelfListener.cpp \
            unix/TerminalModel.cpp \
            unix/TerminalView.cpp
 }
 
 win32 {
 HEADERS  = win32/QTerminalColors.h \
-		   win32/QWinTerminalImpl.h
+       win32/QWinTerminalImpl.h
 
 SOURCES  = win32/QTerminalColors.cpp \
-		   win32/QWinTerminalImpl.cpp
+       win32/QWinTerminalImpl.cpp
 }
 
 win32-msvc* {
-	include(../msvc.pri)
+  include(../msvc.pri)
 }
 
 HEADERS  += QTerminal.h \
-		   QTerminal \
+       QTerminal \
     QTerminalInterface.h
--- a/libqterminal/unix/kpty.cpp
+++ b/libqterminal/unix/kpty.cpp
@@ -161,12 +161,14 @@
 {
 }
 
+#ifndef HAVE_OPENPTY
 bool KPtyPrivate::chownpty(bool)
 {
 //    return !QProcess::execute(KStandardDirs::findExe("kgrantpty"),
 //        QStringList() << (grant?"--grant":"--revoke") << QString::number(masterFd));
     return true;
 }
+#endif
 
 /////////////////////////////
 // public member functions //
@@ -220,7 +222,7 @@
   {
     d->masterFd = -1;
     d->slaveFd = -1;
-    qWarning(175) << "Can't open a pseudo teletype";
+    qWarning() << "Can't open a pseudo teletype";
     return false;
   }
   d->ttyName = ptsn;
@@ -303,14 +305,14 @@
               p = getgrnam("wheel");
             gid_t gid = p ? p->gr_gid : getgid ();
 
-            if (!chown(d->ttyName.data(), getuid(), gid)) {
+	    if (!chown(d->ttyName.data(), getuid(), gid)) {
 	      chmod(d->ttyName.data(), S_IRUSR|S_IWUSR|S_IWGRP);
 	    }
-          }
-          goto gotpty;
-        }
-        ::close(d->masterFd);
-        d->masterFd = -1;
+	  }
+	  goto gotpty;
+	}
+	::close(d->masterFd);
+	d->masterFd = -1;
       }
     }
   }
@@ -391,20 +393,24 @@
    if (d->masterFd < 0)
       return;
    closeSlave();
+   if (d->ownMaster) {
+#ifndef HAVE_OPENPTY
    // don't bother resetting unix98 pty, it will go away after closing master anyway.
    if (memcmp(d->ttyName.data(), "/dev/pts/", 9)) {
       if (!geteuid()) {
          struct stat st;
          if (!stat(d->ttyName.data(), &st)) {
             if (!chown(d->ttyName.data(), 0, st.st_gid == getgid() ? 0 : -1)) {
-	      chmod(d->ttyName.data(), S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
-	    }
+              chmod(d->ttyName.data(), S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
+            }
          }
       } else {
          fcntl(d->masterFd, F_SETFD, 0);
          d->chownpty(false);
       }
    }
+   #endif
+   }
    ::close(d->masterFd);
    d->masterFd = -1;
 }
--- a/qterminal/qterminal.pro
+++ b/qterminal/qterminal.pro
@@ -2,13 +2,14 @@
 
 QT += core gui
 
-SOURCES 	= main.cpp 
+SOURCES 	= main.cpp
 INCLUDEPATH 	= ../libqterminal
 
 win32 {
-	win32-msvc*: include(../msvc.pri)
-	LIBS += -L../libqterminal/$$LIBDIR_SUFFIX \
-		-lqterminal -luser32 -lkernel32
+  win32-msvc*: include(../msvc.pri)
+  LIBS += -L../libqterminal/$$LIBDIR_SUFFIX \
+    -lqterminal -luser32 -lkernel32
 } else {
-	LIBS += -L../libqterminal -lqterminal -lutil
+  DEFINES += HAVE_PTY_H HAVE_OPENPTY
+  LIBS += -L../libqterminal -lqterminal -lutil
 }