[Mesa-dev] [PATCH 3/3] mesa: Fix backward compatbility for XML parser

QuRyu quentin.liu.0415 at gmail.com
Thu Aug 17 02:20:56 UTC 2017


After changing the type of drirc values, the parser will be unable to
recognize xml files before the change. To achieve backward compatbility,
the parser is relaxed to recognize boolean type options with enum values.
---
 src/util/xmlconfig.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/util/xmlconfig.c b/src/util/xmlconfig.c
index d3f47ec..2999f24 100644
--- a/src/util/xmlconfig.c
+++ b/src/util/xmlconfig.c
@@ -317,8 +317,26 @@ parseValue(driOptionValue *v, driOptionType type, const XML_Char *string)
             v->_bool = true;
             tail = string + 4;
         }
-        else
-            return false;
+        else {
+            /** Some drirc options, such as pp_shalde, were formerly enum values.
+             *  Now that they have been turned into boolean values, to achieve 
+             *  backward compatbility relax the check here a little bit */
+            XML_Char *start = string; 
+            int value = strToI(string, &tail, 0);
+            if (tail == start) {
+                /* no enum value found  */
+                string = start; 
+                return false;
+            } else {
+                if (value == 1) 
+                    v->_bool = true;
+                else if (value == 0) 
+                    v->_bool = false;
+                else 
+                    return false; /* wrong value here */
+            }
+	}
+            
         break;
       case DRI_ENUM: /* enum is just a special integer */
       case DRI_INT:
-- 
2.7.4



More information about the mesa-dev mailing list