Branch: master

85995803 2015-01-11 23:54:08 Timothy Pearson
Automated update from Qt3
M src/tools/ntqstring.h
M src/tools/qstring.cpp
diff --git a/src/tools/ntqstring.h b/src/tools/ntqstring.h
index 4d473e0..e8381a0 100644
--- a/src/tools/ntqstring.h
+++ b/src/tools/ntqstring.h
@@ -4,6 +4,7 @@
 **
 ** Created : 920609
 **
+** Copyright (C) 2015 Timothy Pearson. All rights reserved.
 ** Copyright (C) 1992-2008 Trolltech ASA.  All rights reserved.
 **
 ** This file is part of the tools module of the TQt GUI Toolkit.
@@ -63,6 +64,9 @@
 #endif
 #endif
 
+#ifndef QT_NO_SPRINTF
+#include <stdarg.h>
+#endif
 
 /*****************************************************************************
   TQString class
@@ -454,6 +458,11 @@
         __attribute__ ((format (printf, 2, 3)))
 #endif
         ;
+    TQString    &vsprintf(const char *format, va_list ap)
+#if defined(Q_CC_GNU) && !defined(__INSURE__)
+        __attribute__ ((format (printf, 2, 0)))
+#endif
+        ;
 #endif
 
     int         find( TQChar c, int index=0, bool cs=TRUE ) const;
diff --git a/src/tools/qstring.cpp b/src/tools/qstring.cpp
index 67de503..2610a2c 100644
--- a/src/tools/qstring.cpp
+++ b/src/tools/qstring.cpp
@@ -4,6 +4,7 @@
 **
 ** Created : 920722
 **
+** Copyright (C) 2015 Timothy Pearson. All rights reserved.
 ** Copyright (C) 1992-2008 Trolltech ASA.  All rights reserved.
 **
 ** This file is part of the tools module of the TQt GUI Toolkit.
@@ -2604,18 +2605,26 @@
 */
 
 #ifndef QT_NO_SPRINTF
-TQString &TQString::sprintf( const char* cformat, ... )
+TQString &TQString::sprintf(const char *cformat, ...)
 {
-    TQLocale locale(TQLocale::C);
-
     va_list ap;
-    va_start( ap, cformat );
+    va_start(ap, cformat);
 
     if ( !cformat || !*cformat ) {
 	// TQt 1.x compat
 	*this = fromLatin1( "" );
 	return *this;
     }
+
+    TQString &s = vsprintf(cformat, ap);
+
+    va_end(ap);
+    return s;
+}
+
+TQString &TQString::vsprintf( const char* cformat, va_list ap )
+{
+    TQLocale locale(TQLocale::C);
 
     // Parse cformat
 
@@ -2933,7 +2942,6 @@
 	    result.append(subst.rightJustify(width));
     }
 
-    va_end(ap);
     *this = result;
 
     return *this;