$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: bdawes_at_[hidden]
Date: 2007-09-03 21:45:49
Author: bemandawes
Date: 2007-09-03 21:45:47 EDT (Mon, 03 Sep 2007)
New Revision: 39114
URL: http://svn.boost.org/trac/boost/changeset/39114
Log:
Change name() to return const char *, add two system_error ctors
Text files modified: 
   branches/libs/system/boost/system/error_code.hpp          |    29 +++++++++++++----------------           
   branches/libs/system/boost/system/system_error.hpp        |     4 ++++                                    
   branches/libs/system/system/doc/error_code.html           |     7 ++++++-                                 
   branches/libs/system/system/src/error_code.cpp            |    22 ++++++++++------------                  
   branches/libs/system/system/test/Jamfile.v2               |     3 +++                                     
   branches/libs/system/system/test/error_code_test.cpp      |    10 ++++++----                              
   branches/libs/system/system/test/error_code_user_test.cpp |    10 ++++------                              
   branches/libs/system/system/test/header_only_test.cpp     |     4 ++--                                    
   branches/libs/system/system/test/system_error_test.cpp    |     6 +++++-                                  
   9 files changed, 53 insertions(+), 42 deletions(-)
Modified: branches/libs/system/boost/system/error_code.hpp
==============================================================================
--- branches/libs/system/boost/system/error_code.hpp	(original)
+++ branches/libs/system/boost/system/error_code.hpp	2007-09-03 21:45:47 EDT (Mon, 03 Sep 2007)
@@ -19,6 +19,7 @@
 #include <boost/utility/enable_if.hpp>
 #include <ostream>
 #include <string>
+#include <cstring>
 #include <stdexcept>
 
 // TODO: undef these macros if not already defined
@@ -147,15 +148,15 @@
     {
     public:
       virtual ~error_category(){}
-      virtual const std::string & name() const;  // see implementation note below
-      virtual std::string message( int ev ) const;   // see implementation note below
+      virtual const char *    name() const;  // see implementation note below
+      virtual std::string     message( int ev ) const;   // see implementation note below
       virtual error_condition default_error_condition( int ev ) const;
       virtual bool equivalent( int code, const error_condition & condition ) const;
       virtual bool equivalent( const error_code & code, int condition ) const;
 
       bool operator==(const error_category & rhs) const { return this == &rhs; }
       bool operator!=(const error_category & rhs) const { return !(*this == rhs); }
-      bool operator<( const error_category & rhs ) const{ return name() < rhs.name(); }
+      bool operator<( const error_category & rhs ) const{ return std::strcmp(name(), rhs.name()) < 0; }
     };
 
     //  predefined error categories  -----------------------------------------//
@@ -390,10 +391,7 @@
     inline std::size_t hash_value( const error_code & ec )
     {
       return static_cast<std::size_t>(ec.value())
-        + (ec.category().name().size()
-            ? (static_cast<std::size_t>(ec.category().name()
-              [ec.category().name().size()-1]) << 16)
-            : 0);
+        + reinterpret_cast<std::size_t>(&ec.category());
     }
 
     //  make_* functions for posix::posix_errno  -----------------------------//
@@ -427,10 +425,9 @@
 
     //  error_category implementation note: VC++ 8.0 objects to name() and
     //  message() being pure virtual functions. Thus these implementations.
-    inline const std::string & error_category::name() const
+    inline const char * error_category::name() const
     { 
-      static std::string s("error: should never be called");
-      return s;
+      return "error: should never be called";
     }
 
     inline std::string error_category::message( int ev ) const
@@ -451,9 +448,9 @@
     //    a single category (system_category), even for POSIX-like operating
     //    systems that return some POSIX errno values and some native errno
     //    values. This code should not have to pay the cost of distinguishing
-    //    between categories, since it is not yet know if that is needed.
+    //    between categories, since it is not yet known if that is needed.
     //
-    //  * Users wishing to write system-specific code should have enums for
+    //  * Users wishing to write system-specific code should be given enums for
     //    at least the common error cases.
     //
     //  * System specific code should fail at compile time if moved to another
@@ -492,7 +489,7 @@
 
 # elif defined(linux) || defined(__linux) || defined(__linux__)
 
-    namespace lnx  // linux obvious name preempted by its use as predefined macro
+    namespace Linux  // linux lowercase name preempted by use as predefined macro
     {
       enum linux_error
       {
@@ -549,12 +546,12 @@
         unattached = EUNATCH,
         unclean = EUCLEAN,
       };
-    }  // namespace lnx
+    }  // namespace Linux
 
-    template<> struct is_error_code_enum<lnx::linux_errno>
+    template<> struct is_error_code_enum<Linux::linux_errno>
       { static const bool value = true; };
 
-    inline error_code make_error_code(lnx::linux_error e)
+    inline error_code make_error_code(Linux::linux_error e)
       { return error_code( e, system_category ); }
 
 # endif
Modified: branches/libs/system/boost/system/system_error.hpp
==============================================================================
--- branches/libs/system/boost/system/system_error.hpp	(original)
+++ branches/libs/system/boost/system/system_error.hpp	2007-09-03 21:45:47 EDT (Mon, 03 Sep 2007)
@@ -22,11 +22,15 @@
     class system_error : public std::runtime_error
     {
     public:
+      system_error( error_code ec )
+          : std::runtime_error(""), m_error_code(ec) {}
       system_error( error_code ec, const std::string & what_arg )
           : std::runtime_error(what_arg), m_error_code(ec) {}
       system_error( int ev, const error_category & ecat,
         const std::string & what_arg )
           : std::runtime_error(what_arg), m_error_code(ev,ecat) {}
+      system_error( int ev, const error_category & ecat )
+          : std::runtime_error(""), m_error_code(ev,ecat) {}
 
       virtual ~system_error() throw() {}
 
Modified: branches/libs/system/system/doc/error_code.html
==============================================================================
--- branches/libs/system/system/doc/error_code.html	(original)
+++ branches/libs/system/system/doc/error_code.html	2007-09-03 21:45:47 EDT (Mon, 03 Sep 2007)
@@ -30,6 +30,11 @@
 an identifier for a 
 particular kind of error code. Users or 
 third-parties may add additional error categories.</p>
+<h2>Builds</h2>
+<p>The system library is required by default. If the preprocessor macro name 
+BOOST_ERROR_CODE_HEADER_ONLY is defined, no object library or shared/DLL library 
+is required. Only one translation unit may defined BOOST_ERROR_CODE_HEADER_ONLY, 
+otherwise symbols will be multiply defined.</p>
 <h2><a name="Synopsis">Synopsis</a></h2>
 <pre>namespace boost
 {
@@ -254,7 +259,7 @@
   Oleg Abrosimov.</p>
 <hr>
 <p>Last revised:
-<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->06 September, 2006<!--webbot bot="Timestamp" endspan i-checksum="39349" --></p>
+<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->30 August, 2007<!--webbot bot="Timestamp" endspan i-checksum="34727" --></p>
 <p>© Copyright Beman Dawes, 2006</p>
 <p>Distributed under the Boost Software License, Version 1.0. (See accompanying 
 file LICENSE_1_0.txt or copy at
Modified: branches/libs/system/system/src/error_code.cpp
==============================================================================
--- branches/libs/system/system/src/error_code.cpp	(original)
+++ branches/libs/system/system/src/error_code.cpp	2007-09-03 21:45:47 EDT (Mon, 03 Sep 2007)
@@ -201,17 +201,17 @@
   class posix_error_category : public error_category
   {
   public:
-    const std::string &   name() const;
-    std::string           message( int ev ) const;
+    const char *   name() const;
+    std::string    message( int ev ) const;
   };
 
   class system_error_category : public error_category
   {
   public:
-    const std::string &   name() const;
-    posix::posix_errno    posix( int ev ) const;
-    std::string           message( int ev ) const;
-    error_condition       default_error_condition( int ev ) const;
+    const char *        name() const;
+    posix::posix_errno  posix( int ev ) const;
+    std::string         message( int ev ) const;
+    error_condition     default_error_condition( int ev ) const;
   };
 
   const posix_error_category posix_category_const;
@@ -219,10 +219,9 @@
 
   //  posix_error_category implementation  ---------------------------------//
 
-  const std::string & posix_error_category::name() const
+  const char * posix_error_category::name() const
   {
-    static const std::string s( "POSIX" );
-    return s;
+    return "POSIX";
   }
 
   std::string posix_error_category::message( int ev ) const
@@ -290,10 +289,9 @@
   }
   //  system_error_category implementation  --------------------------------// 
 
-  const std::string & system_error_category::name() const
+  const char * system_error_category::name() const
   {
-    static const std::string s( "system" );
-    return s;
+    return "system";
   }
 
   posix_errno system_error_category::posix( int ev ) const
Modified: branches/libs/system/system/test/Jamfile.v2
==============================================================================
--- branches/libs/system/system/test/Jamfile.v2	(original)
+++ branches/libs/system/system/test/Jamfile.v2	2007-09-03 21:45:47 EDT (Mon, 03 Sep 2007)
@@ -38,4 +38,7 @@
             :  :  : <define>BOOST_SYSTEM_DYN_LINK 
                   : system_error_test_dll
          ]
+         [ run header_only_test.cpp
+           :  :  : <runtime-link>static <link>static
+         ]
          ;
Modified: branches/libs/system/system/test/error_code_test.cpp
==============================================================================
--- branches/libs/system/system/test/error_code_test.cpp	(original)
+++ branches/libs/system/system/test/error_code_test.cpp	2007-09-03 21:45:47 EDT (Mon, 03 Sep 2007)
@@ -10,7 +10,7 @@
 //----------------------------------------------------------------------------// 
 
 //  VC++ 8.0 warns on usage of certain Standard Library and API functions that
-//  can be cause buffer overruns or other possible security issues if misused.
+//  can cause buffer overruns or other possible security issues if misused.
 //  See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx
 //  But the wording of the warning is misleading and unsettling, there are no
 //  portable altersystem functions, and VC++ 8.0's own libraries use the
@@ -22,6 +22,8 @@
 #include <boost/system/error_code.hpp>
 #include <iostream>
 #include <sstream>
+#include <string>
+#include <cstring>
 #include <boost/cerrno.hpp>
 
 //  Although using directives are not the best programming practice, testing
@@ -68,7 +70,7 @@
   BOOST_CHECK( dec.category() == posix_category );
   BOOST_CHECK( ec == posix::success );
   BOOST_CHECK( ec.category() == system_category );
-  BOOST_CHECK( ec.category().name() == "system" );
+  BOOST_CHECK( std::strcmp( ec.category().name(), "system") == 0 );
   BOOST_CHECK( !(ec < error_code( 0, system_category )) );
   BOOST_CHECK( !(error_code( 0, system_category ) < ec) );
   BOOST_CHECK( ec < error_code( 1, system_category ) );
@@ -82,7 +84,7 @@
   BOOST_CHECK( dec.category() == posix_category );
   BOOST_CHECK( ec_0_system == posix::success );
   BOOST_CHECK( ec_0_system.category() == system_category );
-  BOOST_CHECK( ec_0_system.category().name() == "system" );
+  BOOST_CHECK( std::strcmp( ec_0_system.category().name(), "system") == 0 );
   check_ostream( ec_0_system, "system:0" );
 
   BOOST_CHECK( ec_0_system == ec );
@@ -106,7 +108,7 @@
   BOOST_CHECK( posix::permission_denied == dec );
   BOOST_CHECK( ec == posix::permission_denied );
   BOOST_CHECK( ec.category() == system_category );
-  BOOST_CHECK( ec.category().name() == "system" );
+  BOOST_CHECK( std::strcmp( ec.category().name(), "system") == 0 );
 
   // test the explicit make_error_code conversion for posix
   ec = make_error_code( posix::bad_message );
Modified: branches/libs/system/system/test/error_code_user_test.cpp
==============================================================================
--- branches/libs/system/system/test/error_code_user_test.cpp	(original)
+++ branches/libs/system/system/test/error_code_user_test.cpp	2007-09-03 21:45:47 EDT (Mon, 03 Sep 2007)
@@ -105,10 +105,9 @@
     class lib3_error_category_imp : public boost::system::error_category
     {
     public:
-      const std::string & name() const
+      const char * name() const
       {
-        static std::string s( "lib3" );
-        return s;
+        return "lib3";
       }
 
       boost::system::error_condition default_error_condition( int ev ) const
@@ -163,10 +162,9 @@
   class lib4_error_category_imp : public boost::system::error_category
   {
   public:
-    const std::string & name() const
+    const char * name() const
     {
-      static std::string s( "lib4" );
-      return s;
+      return "lib4";
     }
 
     boost::system::error_condition default_error_condition( int ev ) const
Modified: branches/libs/system/system/test/header_only_test.cpp
==============================================================================
--- branches/libs/system/system/test/header_only_test.cpp	(original)
+++ branches/libs/system/system/test/header_only_test.cpp	2007-09-03 21:45:47 EDT (Mon, 03 Sep 2007)
@@ -1,6 +1,6 @@
 //  error_code_test.cpp  -----------------------------------------------------//
 
-//  Copyright Beman Dawes 2006
+//  Copyright Beman Dawes 2007
 
 //  Distributed under the Boost Software License, Version 1.0. (See accompanying
 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -10,7 +10,7 @@
 //----------------------------------------------------------------------------// 
 
 //  VC++ 8.0 warns on usage of certain Standard Library and API functions that
-//  can be cause buffer overruns or other possible security issues if misused.
+//  can cause buffer overruns or other possible security issues if misused.
 //  See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx
 //  But the wording of the warning is misleading and unsettling, there are no
 //  portable altersystem functions, and VC++ 8.0's own libraries use the
Modified: branches/libs/system/system/test/system_error_test.cpp
==============================================================================
--- branches/libs/system/system/test/system_error_test.cpp	(original)
+++ branches/libs/system/system/test/system_error_test.cpp	2007-09-03 21:45:47 EDT (Mon, 03 Sep 2007)
@@ -10,7 +10,7 @@
 //----------------------------------------------------------------------------// 
 
 //  VC++ 8.0 warns on usage of certain Standard Library and API functions that
-//  can be cause buffer overruns or other possible security issues if misused.
+//  can cause buffer overruns or other possible security issues if misused.
 //  See http://msdn.microsoft.com/msdnmag/issues/05/05/SafeCandC/default.aspx
 //  But the wording of the warning is misleading and unsettling, there are no
 //  portable alternative functions, and VC++ 8.0's own libraries use the
@@ -59,12 +59,16 @@
   system_error se_1_m( 1, system_category, "se_1_m" ); 
   system_error se_0_nm( error_code(0, system_category), "" ); 
   system_error se_1_nm( 1, system_category, "" ); 
+  system_error se_0_nmx( error_code(0, system_category), "" ); 
+  system_error se_1_nmx( 1, system_category, "" ); 
   system_error se_1u_m( uvalue, system_category, "se_1u_m" );
 
   TEST( se_0_m, 0, "se_0_m" );
   TEST( se_1_m, 1, "se_1_m: Incorrect function" );
   TEST( se_0_nm, 0, "" );
   TEST( se_1_nm, 1, "Incorrect function" );
+  TEST( se_0_nmx, 0, "" );
+  TEST( se_1_nmx, 1, "Incorrect function" );
   TEST( se_1u_m, 1, "se_1u_m: Incorrect function" );