Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61962 - in branches/release/libs/program_options: . doc example src test
From: ghost_at_[hidden]
Date: 2010-05-14 02:55:17


Author: vladimir_prus
Date: 2010-05-14 02:55:15 EDT (Fri, 14 May 2010)
New Revision: 61962
URL: http://svn.boost.org/trac/boost/changeset/61962

Log:
Merge from trunk
Properties modified:
   branches/release/libs/program_options/ (props changed)
Text files modified:
   branches/release/libs/program_options/doc/tutorial.xml | 18 +++++++++---------
   branches/release/libs/program_options/example/Jamfile.v2 | 1 +
   branches/release/libs/program_options/example/multiple_sources.cpp | 2 +-
   branches/release/libs/program_options/src/options_description.cpp | 7 +++++--
   branches/release/libs/program_options/src/winmain.cpp | 6 +++++-
   branches/release/libs/program_options/test/options_description_test.cpp | 11 +++++++++++
   6 files changed, 32 insertions(+), 13 deletions(-)

Modified: branches/release/libs/program_options/doc/tutorial.xml
==============================================================================
--- branches/release/libs/program_options/doc/tutorial.xml (original)
+++ branches/release/libs/program_options/doc/tutorial.xml 2010-05-14 02:55:15 EDT (Fri, 14 May 2010)
@@ -77,13 +77,13 @@
   <para>It's now a good time to try compiling the code yourself, but if
     you're not yet ready, here's an example session:
 <screen>
-$<userinput>bin/gcc/debug/first</userinput>
+$ <userinput>bin/gcc/debug/first</userinput>
 Compression level was not set.
-$<userinput>bin/gcc/debug/first --help</userinput>
+$ <userinput>bin/gcc/debug/first --help</userinput>
 Allowed options:
   --help : produce help message
   --compression arg : set compression level
-$<userinput>bin/gcc/debug/first --compression 10</userinput>
+$ <userinput>bin/gcc/debug/first --compression 10</userinput>
 Compression level was set to 10.
     </screen>
   </para>
@@ -199,16 +199,16 @@
 
   <para>Here's an example session:
     <screen>
-$<userinput>bin/gcc/debug/options_description --help</userinput>
+$ <userinput>bin/gcc/debug/options_description --help</userinput>
 Usage: options_description [options]
 Allowed options:
   --help : produce help message
   --optimization arg : optimization level
   -I [ --include-path ] arg : include path
   --input-file arg : input file
-$bin/gcc/debug/options_description
+$ <userinput>bin/gcc/debug/options_description</userinput>
 Optimization level is 10
-$<userinput>bin/gcc/debug/options_description --optimization 4 -I foo a.cpp</userinput>
+$ <userinput>bin/gcc/debug/options_description --optimization 4 -I foo a.cpp</userinput>
 Include paths are: foo
 Input files are: a.cpp
 Optimization level is 4
@@ -308,10 +308,10 @@
 
     <para>Here's an example session:
 <screen>
-$<userinput>bin/gcc/debug/multiple_sources</userinput>
+$ <userinput>bin/gcc/debug/multiple_sources</userinput>
 Include paths are: /opt
 Optimization level is 1
-$<userinput>bin/gcc/debug/multiple_sources --help</userinput>
+$ <userinput>bin/gcc/debug/multiple_sources --help</userinput>
 Allows options:
 
 Generic options:
@@ -322,7 +322,7 @@
   --optimization n : optimization level
   -I [ --include-path ] path : include path
 
-$<userinput>bin/gcc/debug/multiple_sources --optimization=4 -I foo a.cpp b.cpp</userinput>
+$ <userinput>bin/gcc/debug/multiple_sources --optimization=4 -I foo a.cpp b.cpp</userinput>
 Include paths are: foo /opt
 Input files are: a.cpp b.cpp
 Optimization level is 4

Modified: branches/release/libs/program_options/example/Jamfile.v2
==============================================================================
--- branches/release/libs/program_options/example/Jamfile.v2 (original)
+++ branches/release/libs/program_options/example/Jamfile.v2 2010-05-14 02:55:15 EDT (Fri, 14 May 2010)
@@ -2,6 +2,7 @@
 project
     : requirements <library>../build//boost_program_options
       <hardcode-dll-paths>true
+ <link>static
     ;
 
 exe first : first.cpp ;

Modified: branches/release/libs/program_options/example/multiple_sources.cpp
==============================================================================
--- branches/release/libs/program_options/example/multiple_sources.cpp (original)
+++ branches/release/libs/program_options/example/multiple_sources.cpp 2010-05-14 02:55:15 EDT (Fri, 14 May 2010)
@@ -79,7 +79,7 @@
         ifstream ifs(config_file.c_str());
         if (!ifs)
         {
- cout << "can not open config file: " << config_file << "\n";
+ cout << "can not open config file: " << config_file << "\n";
             return 0;
         }
         else

Modified: branches/release/libs/program_options/src/options_description.cpp
==============================================================================
--- branches/release/libs/program_options/src/options_description.cpp (original)
+++ branches/release/libs/program_options/src/options_description.cpp 2010-05-14 02:55:15 EDT (Fri, 14 May 2010)
@@ -306,6 +306,7 @@
                                       bool short_ignore_case) const
     {
         shared_ptr<option_description> found;
+ bool had_full_match = false;
         vector<string> approximate_matches;
         vector<string> full_matches;
         
@@ -323,15 +324,17 @@
             if (r == option_description::full_match)
             {
                 full_matches.push_back(m_options[i]->key(name));
+ found = m_options[i];
+ had_full_match = true;
             }
             else
             {
                 // FIXME: the use of 'key' here might not
                 // be the best approach.
                 approximate_matches.push_back(m_options[i]->key(name));
+ if (!had_full_match)
+ found = m_options[i];
             }
-
- found = m_options[i];
         }
         if (full_matches.size() > 1)
             boost::throw_exception(

Modified: branches/release/libs/program_options/src/winmain.cpp
==============================================================================
--- branches/release/libs/program_options/src/winmain.cpp (original)
+++ branches/release/libs/program_options/src/winmain.cpp 2010-05-14 02:55:15 EDT (Fri, 14 May 2010)
@@ -30,6 +30,7 @@
    
             std::string current;
             bool inside_quoted = false;
+ bool empty_quote = false;
             int backslash_count = 0;
             
             for(; i != e; ++i) {
@@ -38,6 +39,7 @@
                     // n/2 backslashes and is a quoted block delimiter
                     if (backslash_count % 2 == 0) {
                         current.append(backslash_count / 2, '\\');
+ empty_quote = inside_quoted && current.empty();
                         inside_quoted = !inside_quoted;
                         // '"' preceded by odd number (n) of backslashes generates
                         // (n-1)/2 backslashes and is literal quote.
@@ -59,6 +61,7 @@
                         // Space outside quoted section terminate the current argument
                         result.push_back(current);
                         current.resize(0);
+ empty_quote = false;
                         for(;i != e && isspace((unsigned char)*i); ++i)
                             ;
                         --i;
@@ -74,7 +77,7 @@
         
             // If we have non-empty 'current' or we're still in quoted
             // section (even if 'current' is empty), add the last token.
- if (!current.empty() || inside_quoted)
+ if (!current.empty() || inside_quoted || empty_quote)
                 result.push_back(current);
         }
         return result;
@@ -94,3 +97,4 @@
 
 }}
 #endif
+

Modified: branches/release/libs/program_options/test/options_description_test.cpp
==============================================================================
--- branches/release/libs/program_options/test/options_description_test.cpp (original)
+++ branches/release/libs/program_options/test/options_description_test.cpp 2010-05-14 02:55:15 EDT (Fri, 14 May 2010)
@@ -53,6 +53,17 @@
     BOOST_CHECK_EQUAL(desc.find("all", true).long_name(), "all");
     BOOST_CHECK_EQUAL(desc.find("all-ch", true).long_name(), "all-chroots");
 
+ options_description desc2;
+ desc2.add_options()
+ ("help", "display this message")
+ ("config", value<string>(), "config file name")
+ ("config-value", value<string>(), "single config value")
+ ;
+
+ BOOST_CHECK_EQUAL(desc2.find("config", true).long_name(), "config");
+ BOOST_CHECK_EQUAL(desc2.find("config-value", true).long_name(),
+ "config-value");
+
 
 // BOOST_CHECK(desc.count_approx("foo") == 1);
 // set<string> a = desc.approximations("f");


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