catch old style flags and use strtol to decode from string
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 22 Dec 2006 16:39:04 +0000 (16:39 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 22 Dec 2006 16:39:04 +0000 (16:39 +0000)
git-svn-id: svn://localhost/ardour2/trunk@1247 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/pbd/enumwriter.cc

index c42cc3a5c242c13bb198539cf6b89f7e177f9228..d6c882e00a46ef0d6f40bcad8509577425852445 100644 (file)
@@ -18,6 +18,8 @@
     $Id$
 */
 
+#include <stdlib.h>
+
 #include <pbd/enumwriter.h>
 #include <pbd/error.h>
 #include <pbd/compose.h>
@@ -149,6 +151,12 @@ EnumWriter::read_bits (EnumRegistration& er, string str)
        bool found = false;
        string::size_type comma;
 
+       /* catch old-style hex numerics */
+
+       if (str.length() > 2 && str[0] == '0' && str[1] == 'x') {
+               return strtol (str.c_str(), (char **) 0, 16);
+       }
+
        do {
                
                comma = str.find_first_of (',');
@@ -182,6 +190,12 @@ EnumWriter::read_distinct (EnumRegistration& er, string str)
        vector<int>::iterator i;
        vector<string>::iterator s;
 
+       /* catch old-style hex numerics */
+
+       if (str.length() > 2 && str[0] == '0' && str[1] == 'x') {
+               return strtol (str.c_str(), (char **) 0, 16);
+       }
+
        for (i = er.values.begin(), s = er.names.begin(); i != er.values.end(); ++i, ++s) {
                if (str == (*s)) {
                        return (*i);