Update of /cvsroot/boost/boost/libs/program_options/src
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv32219/src

Modified Files:
        options_description.cpp 
Log Message:
Fix #898. Two approximate matches followed by an exact match
no longer cause an ambiguity to be reported.


Index: options_description.cpp
===================================================================
RCS file: 
/cvsroot/boost/boost/libs/program_options/src/options_description.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- options_description.cpp     28 Jun 2007 07:05:50 -0000      1.19
+++ options_description.cpp     11 Jul 2007 19:07:44 -0000      1.20
@@ -258,7 +258,8 @@
     options_description::find_nothrow(const std::string& name, 
                                       bool approx) const
     {
-        int found = -1;
+        shared_ptr<option_description> found;
+        vector<string> approximate_matches;
         // We use linear search because matching specified option
         // name with the declared option name need to take care about
         // case sensitivity and trailing '*' and so we can't use simple map.
@@ -284,25 +285,16 @@
                 return m_options[i].get();                
             }
 
-            if (found != -1)
-            {
-                vector<string> alts;
-                // FIXME: the use of 'key' here might not
-                // be the best approach.
-                alts.push_back(m_options[found]->key(name));
-                alts.push_back(m_options[i]->key(name));
-                boost::throw_exception(ambiguous_option(name, alts));
-            }
-            else
-            {
-                found = i;
-            }
-        }
-        if (found != -1) {
-            return m_options[found].get();
-        } else {
-            return 0;
+            found = m_options[i];
+            // FIXME: the use of 'key' here might not
+            // be the best approach.
+            approximate_matches.push_back(m_options[i]->key(name));
         }
+        if (approximate_matches.size() > 1)
+            boost::throw_exception(
+                ambiguous_option(name, approximate_matches));
+        else
+            return found.get();
     }
 
     BOOST_PROGRAM_OPTIONS_DECL


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs

Reply via email to