Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58746 - trunk/boost/test/impl
From: eric_at_[hidden]
Date: 2010-01-06 03:53:55


Author: eric_niebler
Date: 2010-01-06 03:53:54 EST (Wed, 06 Jan 2010)
New Revision: 58746
URL: http://svn.boost.org/trac/boost/changeset/58746

Log:
remove dependence on non-standard va_copy macro
Text files modified:
   trunk/boost/test/impl/test_tools.ipp | 27 +++++++++++----------------
   1 files changed, 11 insertions(+), 16 deletions(-)

Modified: trunk/boost/test/impl/test_tools.ipp
==============================================================================
--- trunk/boost/test/impl/test_tools.ipp (original)
+++ trunk/boost/test/impl/test_tools.ipp 2010-01-06 03:53:54 EST (Wed, 06 Jan 2010)
@@ -33,6 +33,8 @@
 #include <cctype>
 #include <cwchar>
 #include <stdexcept>
+#include <vector>
+#include <utility>
 #include <ios>
 
 // !! should we use #include <cstdarg>
@@ -198,20 +200,20 @@
     }
 
     case CHECK_PRED_WITH_ARGS: {
- va_list args_copy;
+ std::vector< std::pair<char const*, lazy_ostream const*> > args_copy;
+ args_copy.reserve( num_args );
+ for( std::size_t i = 0; i < num_args; ++i ) {
+ char const* desc = va_arg( args, char const* );
+ lazy_ostream const* value = va_arg( args, lazy_ostream const* );
+ args_copy.push_back( std::make_pair( desc, value ) );
+ }
 
-#ifdef va_copy
- va_copy( args_copy, args );
-#else
- args_copy = args;
-#endif
         os << prefix << assertion_descr;
 
         // print predicate call description
         os << "( ";
         for( std::size_t i = 0; i < num_args; ++i ) {
- os << va_arg( args, char const* );
- va_arg( args, lazy_ostream const* ); // skip argument value;
+ os << args_copy[i].first;
             
             if( i != num_args-1 )
                 os << ", ";
@@ -219,12 +221,9 @@
         os << " )" << suffix;
                         
         if( tl != PASS ) {
- args = args_copy;
-
             os << " for ( ";
             for( std::size_t i = 0; i < num_args; ++i ) {
- va_arg( args, char const* ); // skip argument description;
- os << *va_arg( args, lazy_ostream const* );
+ os << *args_copy[i].second;
                 
                 if( i != num_args-1 )
                     os << ", ";
@@ -232,10 +231,6 @@
             os << " )";
         }
 
-#ifdef va_copy
- va_end( args_copy );
-#endif
-
         if( !pr.has_empty_message() )
             os << ". " << pr.message();
         break;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk