From d88890e2cf281a5562b726b9404a5b4603a92965 Mon Sep 17 00:00:00 2001 From: espie Date: Wed, 18 Oct 2006 18:05:31 +0000 Subject: [PATCH] Let qfile synch IO between read and write by using fflush, a bit like qt4 does. This is hidden behind a pimpl, so there's no ABI change. This should allow people to use QDataStream for input AND output with impunity. --- x11/qt3/Makefile | 6 +- x11/qt3/patches/patch-src_tools_qfile_cpp | 77 +++++++++++++++++++ .../patches/patch-src_tools_qfile_unix_cpp | 55 +++++++++++++ 3 files changed, 135 insertions(+), 3 deletions(-) create mode 100644 x11/qt3/patches/patch-src_tools_qfile_cpp create mode 100644 x11/qt3/patches/patch-src_tools_qfile_unix_cpp diff --git a/x11/qt3/Makefile b/x11/qt3/Makefile index 46440841816..dc31c9607ba 100644 --- a/x11/qt3/Makefile +++ b/x11/qt3/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.63 2006/09/18 10:21:49 espie Exp $ +# $OpenBSD: Makefile,v 1.64 2006/10/18 18:05:31 espie Exp $ # $FreeBSD: Makefile,v 1.33 1999/02/27 03:09:57 andreas Exp $ COMMENT= "C++ X11 GUI toolkit" @@ -11,9 +11,9 @@ PKGNAME= qt3-${VERSION} PKGNAME-mysql= qt3-mysql-${VERSION}p1 PKGNAME-postgresql= qt3-postgresql-${VERSION}p1 PKGNAME-examples= qt3-examples-${VERSION} -FULLPKGNAME= qt3-mt-${VERSION}p6${PKGDEBUG} +FULLPKGNAME= qt3-mt-${VERSION}p7${PKGDEBUG} FULLPKGNAME-html= qt3-html-${VERSION} -SHARED_LIBS= qt-mt 30.0 \ +SHARED_LIBS= qt-mt 30.1 \ qui 2.0 \ qui-mt 2.0 diff --git a/x11/qt3/patches/patch-src_tools_qfile_cpp b/x11/qt3/patches/patch-src_tools_qfile_cpp new file mode 100644 index 00000000000..c8f6c30834b --- /dev/null +++ b/x11/qt3/patches/patch-src_tools_qfile_cpp @@ -0,0 +1,77 @@ +$OpenBSD: patch-src_tools_qfile_cpp,v 1.1 2006/10/18 18:05:31 espie Exp $ +--- src/tools/qfile.cpp.orig Wed Oct 18 13:21:33 2006 ++++ src/tools/qfile.cpp Wed Oct 18 13:35:35 2006 +@@ -70,8 +70,13 @@ class QFilePrivate + { + public: + QString errorString; ++ int lastAccess; + }; + ++#define ACCESS_NONE -1 ++#define ACCESS_READ 0 ++#define ACCESS_WRITE 1 ++ + extern bool qt_file_access( const QString& fn, int t ); + + /*! +@@ -196,6 +201,7 @@ void QFile::init() + { + delete d; + d = new QFilePrivate; ++ d->lastAccess = ACCESS_NONE; + setFlags( IO_Direct ); + setStatus( IO_Ok ); + setErrorString( qt_fileerr_unknown ); +@@ -206,7 +212,6 @@ void QFile::init() + ext_f = FALSE; // not an external file handle + } + +- + /*! + \fn QString QFile::name() const + +@@ -375,6 +380,10 @@ Q_LONG QFile::readLine( char *p, Q_ULONG + if ( isRaw() ) { // raw file + nread = QIODevice::readLine( p, maxlen ); + } else { // buffered file ++ if (d->lastAccess == ACCESS_WRITE) { ++ ::fseek(fh, 0, SEEK_CUR); ++ d->lastAccess = ACCESS_READ; ++ } + p = fgets( p, maxlen, fh ); + if ( p ) { + nread = qstrlen( p ); +@@ -456,6 +465,10 @@ int QFile::getch() + char buf[1]; + ch = readBlock( buf, 1 ) == 1 ? buf[0] : EOF; + } else { // buffered file ++ if (d->lastAccess == ACCESS_WRITE) { ++ ::fseek(fh, 0, SEEK_CUR); ++ d->lastAccess = ACCESS_READ; ++ } + if ( (ch = getc( fh )) != EOF ) { + if ( !isSequentialAccess() ) + ioIndex++; +@@ -492,6 +505,10 @@ int QFile::putch( int ch ) + buf[0] = ch; + ch = writeBlock( buf, 1 ) == 1 ? ch : EOF; + } else { // buffered file ++ if (d->lastAccess == ACCESS_READ) { ++ ::fseek(fh, 0, SEEK_CUR); ++ d->lastAccess = ACCESS_WRITE; ++ } + if ( (ch = putc( ch, fh )) != EOF ) { + if ( !isSequentialAccess() ) + ioIndex++; +@@ -546,6 +563,10 @@ int QFile::ungetch( int ch ) + else + ch = EOF; + } else { // buffered file ++ if (d->lastAccess == ACCESS_WRITE) { ++ ::fseek(fh, 0, SEEK_CUR); ++ d->lastAccess = ACCESS_READ; ++ } + if ( (ch = ungetc(ch, fh)) != EOF ) { + if ( !isSequentialAccess() ) + ioIndex--; diff --git a/x11/qt3/patches/patch-src_tools_qfile_unix_cpp b/x11/qt3/patches/patch-src_tools_qfile_unix_cpp new file mode 100644 index 00000000000..9e37591446e --- /dev/null +++ b/x11/qt3/patches/patch-src_tools_qfile_unix_cpp @@ -0,0 +1,55 @@ +$OpenBSD: patch-src_tools_qfile_unix_cpp,v 1.1 2006/10/18 18:05:31 espie Exp $ +--- src/tools/qfile_unix.cpp.orig Wed Oct 18 13:23:15 2006 ++++ src/tools/qfile_unix.cpp Wed Oct 18 13:36:59 2006 +@@ -53,6 +53,17 @@ static inline int qt_open(const char *pa + #include + #include + ++class QFilePrivate ++{ ++public: ++ QString errorString; ++ int lastAccess; ++}; ++ ++#define ACCESS_NONE -1 ++#define ACCESS_READ 0 ++#define ACCESS_WRITE 1 ++ + extern const char* qt_fileerr_read; + + bool qt_file_access( const QString& fn, int t ) +@@ -522,6 +533,7 @@ bool QFile::at( Offset pos ) + #else + ok = ( ::fseek(fh, pos, SEEK_SET) == 0 ); + #endif ++ d->lastAccess = ACCESS_NONE; + } + if ( ok ) + #if defined(QT_LARGEFILE_SUPPORT) && !defined(QT_ABI_QT4) +@@ -590,6 +602,10 @@ Q_LONG QFile::readBlock( char *p, Q_ULON + setErrorStringErrno( errno ); + } + } else { // buffered file ++ if (d->lastAccess == ACCESS_WRITE) { ++ ::fseek(fh, 0, SEEK_CUR); ++ d->lastAccess = ACCESS_READ; ++ } + nread += fread( p, 1, len-nread, fh ); + if ( (uint)nread != len ) { + if ( ferror( fh ) || nread==0 ) { +@@ -641,8 +657,13 @@ Q_LONG QFile::writeBlock( const char *p, + Q_ULONG nwritten; // number of bytes written + if ( isRaw() ) // raw file + nwritten = ::write( fd, (void *)p, len ); +- else // buffered file ++ else { // buffered file ++ if (d->lastAccess == ACCESS_READ) { ++ ::fseek(fh, 0, SEEK_CUR); ++ d->lastAccess = ACCESS_WRITE; ++ } + nwritten = fwrite( p, 1, len, fh ); ++ } + if ( nwritten != len ) { // write error + if ( errno == ENOSPC ) // disk is full + setStatus( IO_ResourceError );