$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r54884 - in branches/release: boost/program_options/detail libs/program_options/example libs/program_options/src libs/program_options/test
From: ghost_at_[hidden]
Date: 2009-07-11 08:00:19
Author: vladimir_prus
Date: 2009-07-11 08:00:18 EDT (Sat, 11 Jul 2009)
New Revision: 54884
URL: http://svn.boost.org/trac/boost/changeset/54884
Log:
Merge from trunk
Text files modified: 
   branches/release/boost/program_options/detail/parsers.hpp             |     2 ++                                      
   branches/release/boost/program_options/detail/value_semantic.hpp      |    11 +++++------                             
   branches/release/libs/program_options/example/options_description.cpp |     2 +-                                      
   branches/release/libs/program_options/example/regex.cpp               |     2 +-                                      
   branches/release/libs/program_options/src/cmdline.cpp                 |    30 +++++++++++++++---------------          
   branches/release/libs/program_options/src/parsers.cpp                 |     8 +++++++-                                
   branches/release/libs/program_options/src/variables_map.cpp           |    13 ++++++++++++-                           
   branches/release/libs/program_options/test/unicode_test.cpp           |    10 +++++++---                              
   8 files changed, 50 insertions(+), 28 deletions(-)
Modified: branches/release/boost/program_options/detail/parsers.hpp
==============================================================================
--- branches/release/boost/program_options/detail/parsers.hpp	(original)
+++ branches/release/boost/program_options/detail/parsers.hpp	2009-07-11 08:00:18 EDT (Sat, 11 Jul 2009)
@@ -8,6 +8,8 @@
 
 #include <boost/program_options/detail/convert.hpp>
 
+#include <iterator>
+
 namespace boost { namespace program_options {
 
     namespace detail {
Modified: branches/release/boost/program_options/detail/value_semantic.hpp
==============================================================================
--- branches/release/boost/program_options/detail/value_semantic.hpp	(original)
+++ branches/release/boost/program_options/detail/value_semantic.hpp	2009-07-11 08:00:18 EDT (Sat, 11 Jul 2009)
@@ -55,13 +55,12 @@
         {
             static std::basic_string<charT> empty;
             if (v.size() > 1)
-                throw validation_error("multiple values not allowed");
-            if (v.size() == 1)
+                boost::throw_exception(validation_error("multiple values not allowed"));
+            else if (v.size() == 1)
                 return v.front();
-            else if (allow_empty)
-                return empty;
-            else
-                throw validation_error("at least one value required");
+            else if (!allow_empty)
+              boost::throw_exception(validation_error("at least one value required"));
+            return empty;
         }
 
         /* Throws multiple_occurrences if 'value' is not empty. */
Modified: branches/release/libs/program_options/example/options_description.cpp
==============================================================================
--- branches/release/libs/program_options/example/options_description.cpp	(original)
+++ branches/release/libs/program_options/example/options_description.cpp	2009-07-11 08:00:18 EDT (Sat, 11 Jul 2009)
@@ -77,7 +77,7 @@
 
         cout << "Listen port is " << portnum << "\n";                
     }
-    catch(exception& e)
+    catch(std::exception& e)
     {
         cout << e.what() << "\n";
         return 1;
Modified: branches/release/libs/program_options/example/regex.cpp
==============================================================================
--- branches/release/libs/program_options/example/regex.cpp	(original)
+++ branches/release/libs/program_options/example/regex.cpp	2009-07-11 08:00:18 EDT (Sat, 11 Jul 2009)
@@ -94,7 +94,7 @@
                  << vm["magic"].as<magic_number>().n << "\"\n";
         }
     }
-    catch(exception& e)
+    catch(std::exception& e)
     {
         cout << e.what() << "\n";
     }    
Modified: branches/release/libs/program_options/src/cmdline.cpp
==============================================================================
--- branches/release/libs/program_options/src/cmdline.cpp	(original)
+++ branches/release/libs/program_options/src/cmdline.cpp	2009-07-11 08:00:18 EDT (Sat, 11 Jul 2009)
@@ -152,7 +152,7 @@
             error = "style disallows all characters for short options";
 
         if (error)
-            throw invalid_command_line_style(error);
+            boost::throw_exception(invalid_command_line_style(error));
 
         // Need to check that if guessing and long disguise are enabled
         // -f will mean the same as -foo
@@ -196,24 +196,24 @@
 
         if (m_additional_parser)
             style_parsers.push_back(
-                bind(&cmdline::handle_additional_parser, this, _1));
+                boost::bind(&cmdline::handle_additional_parser, this, _1));
 
         if (m_style & allow_long)
             style_parsers.push_back(
-                bind(&cmdline::parse_long_option, this, _1));
+                boost::bind(&cmdline::parse_long_option, this, _1));
 
         if ((m_style & allow_long_disguise))
             style_parsers.push_back(
-                bind(&cmdline::parse_disguised_long_option, this, _1));
+                boost::bind(&cmdline::parse_disguised_long_option, this, _1));
 
         if ((m_style & allow_short) && (m_style & allow_dash_for_short))
             style_parsers.push_back(
-                bind(&cmdline::parse_short_option, this, _1));
+                boost::bind(&cmdline::parse_short_option, this, _1));
 
         if ((m_style & allow_short) && (m_style & allow_slash_for_short))
-            style_parsers.push_back(bind(&cmdline::parse_dos_option, this, _1));
+            style_parsers.push_back(boost::bind(&cmdline::parse_dos_option, this, _1));
 
-        style_parsers.push_back(bind(&cmdline::parse_terminator, this, _1));
+        style_parsers.push_back(boost::bind(&cmdline::parse_terminator, this, _1));
 
         vector<option> result;
         while(!args.empty())
@@ -326,8 +326,8 @@
                 if (opt.position_key != -1) {
                     if (position >= m_positional->max_total_count())
                     {
-                        throw too_many_positional_options_error(
-                            "too many positional options");
+                        boost::throw_exception(too_many_positional_options_error(
+                                               "too many positional options"));
                     }
                     opt.string_key = m_positional->name_for_position(position);
                     ++position;
@@ -380,8 +380,8 @@
         if (present_tokens >= min_tokens)
         {
             if (!opt.value.empty() && max_tokens == 0) {
-                throw invalid_command_line_syntax(opt.string_key,
-                    invalid_command_line_syntax::extra_parameter);                                                                
+                boost::throw_exception(invalid_command_line_syntax(opt.string_key,
+                                             invalid_command_line_syntax::extra_parameter));
             }
             
             // If an option wants, at minimum, N tokens, we grab them
@@ -406,8 +406,8 @@
         }
         else
         {
-            throw invalid_command_line_syntax(opt.string_key,
-                invalid_command_line_syntax::missing_parameter); 
+            boost::throw_exception(invalid_command_line_syntax(opt.string_key,
+                                            invalid_command_line_syntax::missing_parameter)); 
 
         }
     }
@@ -427,8 +427,8 @@
                 name = tok.substr(2, p-2);
                 adjacent = tok.substr(p+1);
                 if (adjacent.empty())
-                    throw invalid_command_line_syntax(name,
-                      invalid_command_line_syntax::empty_adjacent_parameter);
+                    boost::throw_exception( invalid_command_line_syntax(name,
+                                                      invalid_command_line_syntax::empty_adjacent_parameter));
             }
             else
             {
Modified: branches/release/libs/program_options/src/parsers.cpp
==============================================================================
--- branches/release/libs/program_options/src/parsers.cpp	(original)
+++ branches/release/libs/program_options/src/parsers.cpp	2009-07-11 08:00:18 EDT (Sat, 11 Jul 2009)
@@ -67,10 +67,16 @@
             woption result;
             result.string_key = opt.string_key;
             result.position_key = opt.position_key;
+            result.unregistered = opt.unregistered;
             
             std::transform(opt.value.begin(), opt.value.end(),
                            back_inserter(result.value),
-                           bind(from_utf8, _1));
+                           boost::bind(from_utf8, _1));
+
+            std::transform(opt.original_tokens.begin(), 
+                           opt.original_tokens.end(),
+                           back_inserter(result.original_tokens),
+                           boost::bind(from_utf8, _1));
             return result;
         }
     }
Modified: branches/release/libs/program_options/src/variables_map.cpp
==============================================================================
--- branches/release/libs/program_options/src/variables_map.cpp	(original)
+++ branches/release/libs/program_options/src/variables_map.cpp	2009-07-11 08:00:18 EDT (Sat, 11 Jul 2009)
@@ -74,11 +74,13 @@
             try {
                 d.semantic()->parse(v.value(), options.options[i].value, utf8);
             }
+#ifndef BOOST_NO_EXCEPTIONS
             catch(validation_error& e)
             {
                 e.set_option_name(name);
                 throw;
             }
+#endif
             v.m_value_semantic = d.semantic();
             
             // The option is not composing, and the value is explicitly
@@ -133,7 +135,16 @@
              k != vm.end(); 
              ++k) 
         {
-            k->second.m_value_semantic->notify(k->second.value());
+            /* Users might wish to use variables_map to store their own values
+               that are not parsed, and therefore will not have value_semantics
+               defined. Do no crash on such values. In multi-module programs,
+               one module might add custom values, and the 'notify' function
+               will be called after that, so we check that value_sematics is 
+               not NULL. See:
+                   https://svn.boost.org/trac/boost/ticket/2782
+            */
+            if (k->second.m_value_semantic)
+                k->second.m_value_semantic->notify(k->second.value());
         }               
     }
 
Modified: branches/release/libs/program_options/test/unicode_test.cpp
==============================================================================
--- branches/release/libs/program_options/test/unicode_test.cpp	(original)
+++ branches/release/libs/program_options/test/unicode_test.cpp	2009-07-11 08:00:18 EDT (Sat, 11 Jul 2009)
@@ -34,9 +34,13 @@
     args.push_back(L"--foo=\x044F");
 
     variables_map vm;
-    store(wcommand_line_parser(args).options(desc).run(), vm);
-
-    BOOST_CHECK(vm["foo"].as<wstring>() == L"\x044F");           
+    basic_parsed_options<wchar_t> parsed = 
+        wcommand_line_parser(args).options(desc).run();
+    store(parsed, vm);
+
+    BOOST_CHECK(vm["foo"].as<wstring>() == L"\x044F");
+    BOOST_CHECK(parsed.options[0].original_tokens.size() == 1);
+    BOOST_CHECK(parsed.options[0].original_tokens[0] == L"--foo=\x044F");
 }
 
 // Test that unicode input is property converted into