changeset 13382:9d5e5da5a297

Everything compiles again.
author Jacob Dawid <jacob.dawid@googlemail.com>
date Sat, 09 Apr 2011 09:22:53 +0200
parents 7519e2efaf31
children 44e8f4823151
files gui//Quint.pro gui//src/Pty.cpp gui//src/kprocess.h gui//src/kprocess_p.h gui//src/kptydevice.cpp gui//src/kptydevice.h gui//src/kptyprocess.cpp gui//src/kptyprocess.h
diffstat 8 files changed, 231 insertions(+), 221 deletions(-) [+]
line wrap: on
line diff
--- a/gui//Quint.pro	Sat Apr 09 00:23:46 2011 +0200
+++ b/gui//Quint.pro	Sat Apr 09 09:22:53 2011 +0200
@@ -81,6 +81,6 @@
 LFLAGS = $$system(mkoctfile -p LFLAGS) \
          $$system(mkoctfile -p OCTAVE_LIBS) \
          $$system(mkoctfile -p LIBS)
-LIBS    += $$LFLAGS -loctave -loctinterp -lreadline
+LIBS    += $$LFLAGS -loctave -loctinterp -lreadline -lutil
 QMAKE_CXXFLAGS  += $$INCFLAGS
 
--- a/gui//src/Pty.cpp	Sat Apr 09 00:23:46 2011 +0200
+++ b/gui//src/Pty.cpp	Sat Apr 09 09:22:53 2011 +0200
@@ -19,7 +19,7 @@
 */
 
 // Own
-#include "kprocess.h"
+#include "kprocess_p.h"
 #include "kptyprocess.h"
 #include "Pty.h"
 
--- a/gui//src/kprocess.h	Sat Apr 09 00:23:46 2011 +0200
+++ b/gui//src/kprocess.h	Sat Apr 09 09:22:53 2011 +0200
@@ -25,8 +25,9 @@
 #include "kdecore_export.h"
 
 #include <QtCore/QProcess>
+class KProcess;
+class KProcessPrivate;
 
-class KProcessPrivate;
 
 /**
  * \class KProcess kprocess.h <KProcess>
@@ -337,5 +338,7 @@
     Q_PRIVATE_SLOT(d_func(), void _k_forwardStderr())
 };
 
+#include "kprocess_p.h"
+
 #endif
 
--- a/gui//src/kprocess_p.h	Sat Apr 09 00:23:46 2011 +0200
+++ b/gui//src/kprocess_p.h	Sat Apr 09 09:22:53 2011 +0200
@@ -21,9 +21,10 @@
 
 #ifndef KPROCESS_P_H
 #define KPROCESS_P_H
+class KProcess;
+class KProcessPrivate;
 
 #include "kprocess.h"
-
 class KProcessPrivate {
     Q_DECLARE_PUBLIC(KProcess)
 protected:
--- a/gui//src/kptydevice.cpp	Sat Apr 09 00:23:46 2011 +0200
+++ b/gui//src/kptydevice.cpp	Sat Apr 09 09:22:53 2011 +0200
@@ -57,177 +57,6 @@
 # define PTY_BYTES_AVAILABLE FIONREAD
 #endif
 
-#define KMAXINT ((int)(~0U >> 1))
-
-/////////////////////////////////////////////////////
-// Helper. Remove when QRingBuffer becomes public. //
-/////////////////////////////////////////////////////
-
-#include <QtCore/qbytearray.h>
-#include <QtCore/qlinkedlist.h>
-
-#define CHUNKSIZE 4096
-
-class KRingBuffer
-{
-public:
-    KRingBuffer()
-    {
-        clear();
-    }
-
-    void clear()
-    {
-        buffers.clear();
-        QByteArray tmp;
-        tmp.resize(CHUNKSIZE);
-        buffers << tmp;
-        head = tail = 0;
-        totalSize = 0;
-    }
-
-    inline bool isEmpty() const
-    {
-        return buffers.count() == 1 && !tail;
-    }
-
-    inline int size() const
-    {
-        return totalSize;
-    }
-
-    inline int readSize() const
-    {
-        return (buffers.count() == 1 ? tail : buffers.first().size()) - head;
-    }
-
-    inline const char *readPointer() const
-    {
-        Q_ASSERT(totalSize > 0);
-        return buffers.first().constData() + head;
-    }
-
-    void free(int bytes)
-    {
-        totalSize -= bytes;
-        Q_ASSERT(totalSize >= 0);
-
-        forever {
-            int nbs = readSize();
-
-            if (bytes < nbs) {
-                head += bytes;
-                if (head == tail && buffers.count() == 1) {
-                    buffers.first().resize(CHUNKSIZE);
-                    head = tail = 0;
-                }
-                break;
-            }
-
-            bytes -= nbs;
-            if (buffers.count() == 1) {
-                buffers.first().resize(CHUNKSIZE);
-                head = tail = 0;
-                break;
-            }
-
-            buffers.removeFirst();
-            head = 0;
-        }
-    }
-
-    char *reserve(int bytes)
-    {
-        totalSize += bytes;
-
-        char *ptr;
-        if (tail + bytes <= buffers.last().size()) {
-            ptr = buffers.last().data() + tail;
-            tail += bytes;
-        } else {
-            buffers.last().resize(tail);
-            QByteArray tmp;
-            tmp.resize(qMax(CHUNKSIZE, bytes));
-            ptr = tmp.data();
-            buffers << tmp;
-            tail = bytes;
-        }
-        return ptr;
-    }
-
-    // release a trailing part of the last reservation
-    inline void unreserve(int bytes)
-    {
-        totalSize -= bytes;
-        tail -= bytes;
-    }
-
-    inline void write(const char *data, int len)
-    {
-        memcpy(reserve(len), data, len);
-    }
-
-    // Find the first occurrence of c and return the index after it.
-    // If c is not found until maxLength, maxLength is returned, provided
-    // it is smaller than the buffer size. Otherwise -1 is returned.
-    int indexAfter(char c, int maxLength = KMAXINT) const
-    {
-        int index = 0;
-        int start = head;
-        QLinkedList<QByteArray>::ConstIterator it = buffers.begin();
-        forever {
-            if (!maxLength)
-                return index;
-            if (index == size())
-                return -1;
-            const QByteArray &buf = *it;
-            ++it;
-            int len = qMin((it == buffers.end() ? tail : buf.size()) - start,
-                           maxLength);
-            const char *ptr = buf.data() + start;
-            if (const char *rptr = (const char *)memchr(ptr, c, len))
-                return index + (rptr - ptr) + 1;
-            index += len;
-            maxLength -= len;
-            start = 0;
-        }
-    }
-
-    inline int lineSize(int maxLength = KMAXINT) const
-    {
-        return indexAfter('\n', maxLength);
-    }
-
-    inline bool canReadLine() const
-    {
-        return lineSize() != -1;
-    }
-
-    int read(char *data, int maxLength)
-    {
-        int bytesToRead = qMin(size(), maxLength);
-        int readSoFar = 0;
-        while (readSoFar < bytesToRead) {
-            const char *ptr = readPointer();
-            int bs = qMin(bytesToRead - readSoFar, readSize());
-            memcpy(data + readSoFar, ptr, bs);
-            readSoFar += bs;
-            free(bs);
-        }
-        return readSoFar;
-    }
-
-    int readLine(char *data, int maxLength)
-    {
-        return read(data, lineSize(qMin(maxLength, size())));
-    }
-
-private:
-    QLinkedList<QByteArray> buffers;
-    int head, tail;
-    int totalSize;
-};
-
 //////////////////
 // private data //
 //////////////////
@@ -247,30 +76,6 @@
 
 #define NO_INTR(ret,func) do { ret = func; } while (ret < 0 && errno == EINTR)
 
-struct KPtyDevicePrivate : public KPtyPrivate {
-    Q_DECLARE_PUBLIC(KPtyDevice)
-
-    KPtyDevicePrivate(KPty* parent) :
-        KPtyPrivate(parent),
-        emittedReadyRead(false), emittedBytesWritten(false),
-        readNotifier(0), writeNotifier(0)
-    {
-    }
-
-    bool _k_canRead();
-    bool _k_canWrite();
-
-    bool doWait(int msecs, bool reading);
-    void finishOpen(QIODevice::OpenMode mode);
-
-    bool emittedReadyRead;
-    bool emittedBytesWritten;
-    QSocketNotifier *readNotifier;
-    QSocketNotifier *writeNotifier;
-    KRingBuffer readBuffer;
-    KRingBuffer writeBuffer;
-};
-
 bool KPtyDevicePrivate::_k_canRead()
 {
     Q_Q(KPtyDevice);
--- a/gui//src/kptydevice.h	Sat Apr 09 00:23:46 2011 +0200
+++ b/gui//src/kptydevice.h	Sat Apr 09 09:22:53 2011 +0200
@@ -21,11 +21,13 @@
 #ifndef kptydev_h
 #define kptydev_h
 
+struct KPtyPrivate;
+struct KPtyDevicePrivate;
+
 #include "kpty.h"
-
+#include "kpty_p.h"
 #include <QtCore/QIODevice>
-
-struct KPtyDevicePrivate;
+#include <QSocketNotifier>
 
 #define Q_DECLARE_PRIVATE_MI(Class, SuperClass) \
     inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(SuperClass::d_ptr); } \
@@ -152,5 +154,200 @@
     Q_PRIVATE_SLOT(d_func(), bool _k_canWrite())
 };
 
+#define KMAXINT ((int)(~0U >> 1))
+
+/////////////////////////////////////////////////////
+// Helper. Remove when QRingBuffer becomes public. //
+/////////////////////////////////////////////////////
+
+#include <QtCore/qbytearray.h>
+#include <QtCore/qlinkedlist.h>
+
+#define CHUNKSIZE 4096
+
+class KRingBuffer
+{
+public:
+    KRingBuffer()
+    {
+        clear();
+    }
+
+    void clear()
+    {
+        buffers.clear();
+        QByteArray tmp;
+        tmp.resize(CHUNKSIZE);
+        buffers << tmp;
+        head = tail = 0;
+        totalSize = 0;
+    }
+
+    inline bool isEmpty() const
+    {
+        return buffers.count() == 1 && !tail;
+    }
+
+    inline int size() const
+    {
+        return totalSize;
+    }
+
+    inline int readSize() const
+    {
+        return (buffers.count() == 1 ? tail : buffers.first().size()) - head;
+    }
+
+    inline const char *readPointer() const
+    {
+        Q_ASSERT(totalSize > 0);
+        return buffers.first().constData() + head;
+    }
+
+    void free(int bytes)
+    {
+        totalSize -= bytes;
+        Q_ASSERT(totalSize >= 0);
+
+        forever {
+            int nbs = readSize();
+
+            if (bytes < nbs) {
+                head += bytes;
+                if (head == tail && buffers.count() == 1) {
+                    buffers.first().resize(CHUNKSIZE);
+                    head = tail = 0;
+                }
+                break;
+            }
+
+            bytes -= nbs;
+            if (buffers.count() == 1) {
+                buffers.first().resize(CHUNKSIZE);
+                head = tail = 0;
+                break;
+            }
+
+            buffers.removeFirst();
+            head = 0;
+        }
+    }
+
+    char *reserve(int bytes)
+    {
+        totalSize += bytes;
+
+        char *ptr;
+        if (tail + bytes <= buffers.last().size()) {
+            ptr = buffers.last().data() + tail;
+            tail += bytes;
+        } else {
+            buffers.last().resize(tail);
+            QByteArray tmp;
+            tmp.resize(qMax(CHUNKSIZE, bytes));
+            ptr = tmp.data();
+            buffers << tmp;
+            tail = bytes;
+        }
+        return ptr;
+    }
+
+    // release a trailing part of the last reservation
+    inline void unreserve(int bytes)
+    {
+        totalSize -= bytes;
+        tail -= bytes;
+    }
+
+    inline void write(const char *data, int len)
+    {
+        memcpy(reserve(len), data, len);
+    }
+
+    // Find the first occurrence of c and return the index after it.
+    // If c is not found until maxLength, maxLength is returned, provided
+    // it is smaller than the buffer size. Otherwise -1 is returned.
+    int indexAfter(char c, int maxLength = KMAXINT) const
+    {
+        int index = 0;
+        int start = head;
+        QLinkedList<QByteArray>::ConstIterator it = buffers.begin();
+        forever {
+            if (!maxLength)
+                return index;
+            if (index == size())
+                return -1;
+            const QByteArray &buf = *it;
+            ++it;
+            int len = qMin((it == buffers.end() ? tail : buf.size()) - start,
+                           maxLength);
+            const char *ptr = buf.data() + start;
+            if (const char *rptr = (const char *)memchr(ptr, c, len))
+                return index + (rptr - ptr) + 1;
+            index += len;
+            maxLength -= len;
+            start = 0;
+        }
+    }
+
+    inline int lineSize(int maxLength = KMAXINT) const
+    {
+        return indexAfter('\n', maxLength);
+    }
+
+    inline bool canReadLine() const
+    {
+        return lineSize() != -1;
+    }
+
+    int read(char *data, int maxLength)
+    {
+        int bytesToRead = qMin(size(), maxLength);
+        int readSoFar = 0;
+        while (readSoFar < bytesToRead) {
+            const char *ptr = readPointer();
+            int bs = qMin(bytesToRead - readSoFar, readSize());
+            memcpy(data + readSoFar, ptr, bs);
+            readSoFar += bs;
+            free(bs);
+        }
+        return readSoFar;
+    }
+
+    int readLine(char *data, int maxLength)
+    {
+        return read(data, lineSize(qMin(maxLength, size())));
+    }
+
+private:
+    QLinkedList<QByteArray> buffers;
+    int head, tail;
+    int totalSize;
+};
+
+struct KPtyDevicePrivate : public KPtyPrivate {
+    Q_DECLARE_PUBLIC(KPtyDevice)
+
+    KPtyDevicePrivate(KPty* parent) :
+        KPtyPrivate(parent),
+        emittedReadyRead(false), emittedBytesWritten(false),
+        readNotifier(0), writeNotifier(0)
+    {
+    }
+
+    bool _k_canRead();
+    bool _k_canWrite();
+
+    bool doWait(int msecs, bool reading);
+    void finishOpen(QIODevice::OpenMode mode);
+
+    bool emittedReadyRead;
+    bool emittedBytesWritten;
+    QSocketNotifier *readNotifier;
+    QSocketNotifier *writeNotifier;
+    KRingBuffer readBuffer;
+    KRingBuffer writeBuffer;
+};
+
 #endif
 
--- a/gui//src/kptyprocess.cpp	Sat Apr 09 00:23:46 2011 +0200
+++ b/gui//src/kptyprocess.cpp	Sat Apr 09 09:22:53 2011 +0200
@@ -20,7 +20,7 @@
     Boston, MA 02110-1301, USA.
 */
 #include "kptyprocess.h"
-#include "kprocess_p.h"
+#include "kprocess.h"
 
 //#include <kuser.h>
 #include "kptydevice.h"
@@ -32,23 +32,7 @@
 // private data //
 //////////////////
 
-struct KPtyProcessPrivate : KProcessPrivate {
-    KPtyProcessPrivate() :
-        ptyChannels(KPtyProcess::NoChannels),
-        addUtmp(false)
-    {
-    }
 
-    void _k_onStateChanged(QProcess::ProcessState newState)
-    {
-        if (newState == QProcess::NotRunning && addUtmp)
-            pty->logout();
-    }
-
-    KPtyDevice *pty;
-    KPtyProcess::PtyChannels ptyChannels;
-    bool addUtmp : 1;
-};
 
 KPtyProcess::KPtyProcess(QObject *parent) :
     KProcess(new KPtyProcessPrivate, parent)
--- a/gui//src/kptyprocess.h	Sat Apr 09 00:23:46 2011 +0200
+++ b/gui//src/kptyprocess.h	Sat Apr 09 09:22:53 2011 +0200
@@ -23,12 +23,14 @@
 #define KPTYPROCESS_H
 
 #include "kprocess.h"
-
+#include "kprocess_p.h"
+#include "kptydevice.h"
 #include "kpty_export.h"
 
 class KPtyDevice;
+class KPtyProcess;
+struct KPtyProcessPrivate;
 
-struct KPtyProcessPrivate;
 /**
  * This class extends KProcess by support for PTYs (pseudo TTYs).
  *
@@ -133,6 +135,24 @@
     Q_PRIVATE_SLOT(d_func(), void _k_onStateChanged(QProcess::ProcessState))
 };
 
+struct KPtyProcessPrivate : KProcessPrivate {
+    KPtyProcessPrivate() :
+        ptyChannels(KPtyProcess::NoChannels),
+        addUtmp(false)
+    {
+    }
+
+    void _k_onStateChanged(QProcess::ProcessState newState)
+    {
+        if (newState == QProcess::NotRunning && addUtmp)
+            pty->logout();
+    }
+
+    KPtyDevice *pty;
+    KPtyProcess::PtyChannels ptyChannels;
+    bool addUtmp : 1;
+};
+
 Q_DECLARE_OPERATORS_FOR_FLAGS(KPtyProcess::PtyChannels)
 
 #endif