allow qtextstream to serialize long long integers out.

For completion, qt3 should also serialize long long in, but that's
a more intrusive change, and it's not really needed to keep existing
things compiling.

Obviously, this code is totally different and 64 bits capable in qt4.

this fixes the build of kdepim3 post 64 bits time_t.

problem noticed by sthen@.
This commit is contained in:
espie 2013-04-29 10:44:43 +00:00
parent 43a0a4e0be
commit 5524073408
4 changed files with 110 additions and 19 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.105 2013/03/11 11:46:15 espie Exp $
# $OpenBSD: Makefile,v 1.106 2013/04/29 10:44:43 espie Exp $
COMMENT-main= C++ X11 GUI toolkit
COMMENT-examples= examples and tutorial for qt3
@ -18,7 +18,7 @@ PKGNAME-sqlite2= qt3-sqlite2-${VERSION}
REVISION-mysql= 4
REVISION-postgresql= 4
REVISION-main= 6
REVISION-main= 7
REVISION-html= 1
REVISION-examples= 1
REVISION-sqlite2= 4

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-src_kernel_qpngio_cpp,v 1.3 2011/07/08 20:36:09 naddy Exp $
--- src/kernel/qpngio.cpp.orig Mon Jul 4 12:10:21 2011
+++ src/kernel/qpngio.cpp Mon Jul 4 12:17:43 2011
$OpenBSD: patch-src_kernel_qpngio_cpp,v 1.4 2013/04/29 10:44:43 espie Exp $
--- src/kernel/qpngio.cpp.orig Fri Feb 2 15:01:15 2007
+++ src/kernel/qpngio.cpp Sat Apr 27 10:56:50 2013
@@ -43,6 +43,7 @@
#include "qiodevice.h"
@ -9,7 +9,7 @@ $OpenBSD: patch-src_kernel_qpngio_cpp,v 1.3 2011/07/08 20:36:09 naddy Exp $
#ifdef Q_OS_TEMP
@@ -131,9 +132,24 @@ void setup_qt( QImage& image, png_structp png_ptr, png
@@ -123,9 +124,24 @@ void setup_qt( QImage& image, png_structp png_ptr, png
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
0, 0, 0);
@ -35,7 +35,7 @@ $OpenBSD: patch-src_kernel_qpngio_cpp,v 1.3 2011/07/08 20:36:09 naddy Exp $
png_set_invert_mono( png_ptr );
png_read_update_info( png_ptr, info_ptr );
if (!image.create( width, height, 1, 2, QImage::BigEndian ))
@@ -167,7 +183,7 @@ void setup_qt( QImage& image, png_structp png_ptr, png
@@ -159,7 +175,7 @@ void setup_qt( QImage& image, png_structp png_ptr, png
image.setColor( i, qRgba(c,c,c,0xff) );
}
if ( png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) ) {
@ -44,7 +44,7 @@ $OpenBSD: patch-src_kernel_qpngio_cpp,v 1.3 2011/07/08 20:36:09 naddy Exp $
if (g < ncols) {
image.setAlphaBuffer(TRUE);
image.setColor(g, image.color(g) & RGB_MASK);
@@ -176,7 +192,7 @@ void setup_qt( QImage& image, png_structp png_ptr, png
@@ -168,7 +184,7 @@ void setup_qt( QImage& image, png_structp png_ptr, png
}
} else if ( color_type == PNG_COLOR_TYPE_PALETTE
&& png_get_valid(png_ptr, info_ptr, PNG_INFO_PLTE)
@ -53,7 +53,7 @@ $OpenBSD: patch-src_kernel_qpngio_cpp,v 1.3 2011/07/08 20:36:09 naddy Exp $
{
// 1-bit and 8-bit color
if ( bit_depth != 1 )
@@ -184,28 +200,28 @@ void setup_qt( QImage& image, png_structp png_ptr, png
@@ -176,28 +192,28 @@ void setup_qt( QImage& image, png_structp png_ptr, png
png_read_update_info( png_ptr, info_ptr );
png_get_IHDR(png_ptr, info_ptr,
&width, &height, &bit_depth, &color_type, 0, 0, 0);
@ -92,7 +92,7 @@ $OpenBSD: patch-src_kernel_qpngio_cpp,v 1.3 2011/07/08 20:36:09 naddy Exp $
0xff
)
);
@@ -292,7 +308,7 @@ void read_png_image(QImageIO* iio)
@@ -284,7 +300,7 @@ void read_png_image(QImageIO* iio)
return;
}
@ -101,7 +101,7 @@ $OpenBSD: patch-src_kernel_qpngio_cpp,v 1.3 2011/07/08 20:36:09 naddy Exp $
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
iio->setStatus(-4);
return;
@@ -477,7 +493,7 @@ bool QPNGImageWriter::writeImage(const QImage& image,
@@ -469,7 +485,7 @@ bool QPNGImageWriter::writeImage(const QImage& image,
return FALSE;
}
@ -110,7 +110,7 @@ $OpenBSD: patch-src_kernel_qpngio_cpp,v 1.3 2011/07/08 20:36:09 naddy Exp $
png_destroy_write_struct(&png_ptr, &info_ptr);
return FALSE;
}
@@ -499,10 +515,15 @@ bool QPNGImageWriter::writeImage(const QImage& image,
@@ -491,10 +507,15 @@ bool QPNGImageWriter::writeImage(const QImage& image,
png_set_write_fn(png_ptr, (void*)this, qpiw_write_fn, qpiw_flush_fn);
@ -126,7 +126,7 @@ $OpenBSD: patch-src_kernel_qpngio_cpp,v 1.3 2011/07/08 20:36:09 naddy Exp $
png_set_IHDR(png_ptr, info_ptr, image.width(), image.height(),
image.depth() == 1 ? 1 : 8 /* per channel */,
@@ -512,11 +533,12 @@ bool QPNGImageWriter::writeImage(const QImage& image,
@@ -504,11 +525,12 @@ bool QPNGImageWriter::writeImage(const QImage& image,
: PNG_COLOR_TYPE_RGB
: PNG_COLOR_TYPE_PALETTE, 0, 0, 0);
@ -143,7 +143,7 @@ $OpenBSD: patch-src_kernel_qpngio_cpp,v 1.3 2011/07/08 20:36:09 naddy Exp $
if (image.depth() == 1 && image.bitOrder() == QImage::LittleEndian)
png_set_packswap(png_ptr);
@@ -530,11 +552,14 @@ bool QPNGImageWriter::writeImage(const QImage& image,
@@ -522,11 +544,14 @@ bool QPNGImageWriter::writeImage(const QImage& image,
png_set_PLTE(png_ptr, info_ptr, palette, num_palette);
int* trans = new int[num_palette];
int num_trans = 0;
@ -161,7 +161,7 @@ $OpenBSD: patch-src_kernel_qpngio_cpp,v 1.3 2011/07/08 20:36:09 naddy Exp $
if (image.hasAlphaBuffer()) {
trans[i] = rgb >> 24;
if (trans[i] < 255) {
@@ -542,6 +567,7 @@ bool QPNGImageWriter::writeImage(const QImage& image,
@@ -534,6 +559,7 @@ bool QPNGImageWriter::writeImage(const QImage& image,
}
}
}
@ -169,7 +169,7 @@ $OpenBSD: patch-src_kernel_qpngio_cpp,v 1.3 2011/07/08 20:36:09 naddy Exp $
if (num_trans) {
copy_trans = new png_byte[num_trans];
for (int i=0; i<num_trans; i++)
@@ -552,7 +578,10 @@ bool QPNGImageWriter::writeImage(const QImage& image,
@@ -544,7 +570,10 @@ bool QPNGImageWriter::writeImage(const QImage& image,
}
if ( image.hasAlphaBuffer() ) {
@ -181,7 +181,7 @@ $OpenBSD: patch-src_kernel_qpngio_cpp,v 1.3 2011/07/08 20:36:09 naddy Exp $
}
// Swap ARGB to RGBA (normal PNG format) before saving on
@@ -1038,7 +1067,7 @@ int QPNGFormat::decode(QImage& img, QImageConsumer* co
@@ -1030,7 +1059,7 @@ int QPNGFormat::decode(QImage& img, QImageConsumer* co
return -1;
}
@ -190,7 +190,7 @@ $OpenBSD: patch-src_kernel_qpngio_cpp,v 1.3 2011/07/08 20:36:09 naddy Exp $
png_destroy_read_struct(&png_ptr, &info_ptr, 0);
image = 0;
return -1;
@@ -1065,7 +1094,7 @@ int QPNGFormat::decode(QImage& img, QImageConsumer* co
@@ -1057,7 +1086,7 @@ int QPNGFormat::decode(QImage& img, QImageConsumer* co
if ( !png_ptr ) return 0;
@ -199,7 +199,7 @@ $OpenBSD: patch-src_kernel_qpngio_cpp,v 1.3 2011/07/08 20:36:09 naddy Exp $
png_destroy_read_struct(&png_ptr, &info_ptr, 0);
image = 0;
state = MovieStart;
@@ -1125,7 +1154,7 @@ void QPNGFormat::end(png_structp png, png_infop info)
@@ -1117,7 +1146,7 @@ void QPNGFormat::end(png_structp png, png_infop info)
consumer->frameDone(QPoint(offx,offy),r);
consumer->end();
state = FrameStart;

View File

@ -0,0 +1,70 @@
$OpenBSD: patch-src_tools_qtextstream_cpp,v 1.1 2013/04/29 10:44:43 espie Exp $
--- src/tools/qtextstream.cpp.orig Sat Apr 27 11:30:52 2013
+++ src/tools/qtextstream.cpp Sat Apr 27 11:35:44 2013
@@ -192,6 +192,7 @@
#define I_SHORT 0x0010
#define I_INT 0x0020
#define I_LONG 0x0030
+#define I_LONGLONG 0x0040
#define I_TYPE_MASK 0x00f0
#define I_BASE_2 QTS::bin
@@ -1859,7 +1860,8 @@ QTextStream &QTextStream::operator<<( char c )
return *this;
}
-QTextStream &QTextStream::output_int( int format, ulong n, bool neg )
+QTextStream &QTextStream::output_int( int format, unsigned long long n,
+ bool neg )
{
static const char hexdigits_lower[] = "0123456789abcdef";
static const char hexdigits_upper[] = "0123456789ABCDEF";
@@ -1876,6 +1878,7 @@ QTextStream &QTextStream::output_int( int format, ulon
case I_SHORT: len=16; break;
case I_INT: len=sizeof(int)*8; break;
case I_LONG: len=32; break;
+ case I_LONGLONG: len=64; break;
default: len = 0;
}
p = &buf[74]; // go reverse order
@@ -1922,7 +1925,7 @@ QTextStream &QTextStream::output_int( int format, ulon
p = &buf[74];
*p = '\0';
if ( neg )
- n = (ulong)(-(long)n);
+ n = (unsigned long long)(-(long long)n);
do {
*--p = ((int)(n%10)) + '0';
n /= 10;
@@ -2036,6 +2039,31 @@ QTextStream &QTextStream::operator<<( signed long i )
QTextStream &QTextStream::operator<<( unsigned long i )
{
return output_int( I_LONG | I_UNSIGNED, i, FALSE );
+}
+
+/*!
+ \overload
+
+ Writes a \c long long \c int \a i to the stream and returns a reference
+ to the stream.
+*/
+
+QTextStream &QTextStream::operator<<( signed long long i )
+{
+ return output_int( I_LONGLONG | I_SIGNED, i, i < 0 );
+}
+
+
+/*!
+ \overload
+
+ Writes an \c unsigned \c long \c int \a i to the stream and
+ returns a reference to the stream.
+*/
+
+QTextStream &QTextStream::operator<<( unsigned long long i )
+{
+ return output_int( I_LONGLONG | I_UNSIGNED, i, FALSE );
}

View File

@ -0,0 +1,21 @@
$OpenBSD: patch-src_tools_qtextstream_h,v 1.1 2013/04/29 10:44:44 espie Exp $
--- src/tools/qtextstream.h.orig Sat Apr 27 11:28:31 2013
+++ src/tools/qtextstream.h Sat Apr 27 11:30:45 2013
@@ -99,6 +99,8 @@ class Q_EXPORT QTextStream // text stream class (pu
QTextStream &operator<<( unsigned int );
QTextStream &operator<<( signed long );
QTextStream &operator<<( unsigned long );
+ QTextStream &operator<<( signed long long );
+ QTextStream &operator<<( unsigned long long );
QTextStream &operator<<( float );
QTextStream &operator<<( double );
QTextStream &operator<<( const char* );
@@ -152,7 +154,7 @@ class Q_EXPORT QTextStream // text stream class (pu
private:
long input_int();
void init();
- QTextStream &output_int( int, ulong, bool );
+ QTextStream &output_int( int, unsigned long long, bool );
QIODevice *dev;
int fflags;