hal: Branch 'hal-0_5_9-branch'

David Zeuthen david at kemper.freedesktop.org
Thu Apr 12 12:40:55 PDT 2007


 doc/spec/hal-spec-fdi-files.xml |    8 ++++----
 hald/device_info.c              |   31 ++++++++++++++++---------------
 2 files changed, 20 insertions(+), 19 deletions(-)

New commits:
diff-tree 485f9aa6780690d915a13d813bc753501a3c899e (from 7ce45a77001031a0d7777d7e1e5269256791b6f1)
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Apr 12 15:39:06 2007 -0400

    fix contains_not fdi-directive
    
    This patch fixes the contains_not FDI file directive/rule to return true (let
    the match not fail) if the property is not set on the device. This allow to
    have this rule:
    
           <match key="info.addons" contains_not="hald-addon-input">
             <append key="info.addons" type="strlist">hald-addon-input</append>
           </match>
    
    Without this patch this fails if info.addons is not already set. With the
    change it would match if:
    * info.addons is not available
    or
    * info.addons contains no string 'hald-addon-input'

diff --git a/doc/spec/hal-spec-fdi-files.xml b/doc/spec/hal-spec-fdi-files.xml
index a51e5f5..1fdb8d6 100644
--- a/doc/spec/hal-spec-fdi-files.xml
+++ b/doc/spec/hal-spec-fdi-files.xml
@@ -156,10 +156,10 @@
           <para>
             <literal>contains_not</literal> - can only be used with strlist (string list) 
 	    and string properties.
-            For a string list this match if the given string is not match any of the
-            item of the list for a string this match of the property not contains the
-	    (sub-)string. You can use this attribute to construct if/else blocks together 
-	    with e.g. <literal>contains</literal>.
+            For a string list this match if the given string not match any of the
+            item of the list (or the property is not set for the device). For a string  
+	    this match of the property not contains the (sub-)string. You can use this 
+	    attribute to construct if/else blocks together with e.g. <literal>contains</literal>.
           </para>
         </listitem>
         <listitem>
diff --git a/hald/device_info.c b/hald/device_info.c
index 8355011..3b9cf7b 100644
--- a/hald/device_info.c
+++ b/hald/device_info.c
@@ -447,27 +447,28 @@ handle_match (struct rule *rule, HalDevi
 	{
 		dbus_bool_t contains = FALSE;
 
-		if (hal_device_property_get_type (d, prop_to_check) == HAL_PROPERTY_TYPE_STRING) {
-			if (hal_device_has_property (d, prop_to_check)) {
+		if (hal_device_has_property (d, prop_to_check) && value != NULL) {
+
+			if (hal_device_property_get_type (d, prop_to_check) == HAL_PROPERTY_TYPE_STRING) {
 				const char *haystack;
 
 				haystack = hal_device_property_get_string (d, prop_to_check);
-				if (value != NULL && haystack != NULL &&  (strstr(haystack, value) != NULL))
-					contains = TRUE;
-			}
-		} else if (hal_device_property_get_type (d, prop_to_check) == HAL_PROPERTY_TYPE_STRLIST && value != NULL) {
-			HalDeviceStrListIter iter;
-			for (hal_device_property_strlist_iter_init (d, prop_to_check, &iter);
-			     hal_device_property_strlist_iter_is_valid (&iter);
-			     hal_device_property_strlist_iter_next (&iter)) {
-				const char *str = hal_device_property_strlist_iter_get_value (&iter);
-				if (strcmp (str, value) == 0) {
+				if (haystack != NULL &&  (strstr(haystack, value) != NULL))
 					contains = TRUE;
-					break;
+			} else if (hal_device_property_get_type (d, prop_to_check) == HAL_PROPERTY_TYPE_STRLIST) {
+				HalDeviceStrListIter iter;
+				for (hal_device_property_strlist_iter_init (d, prop_to_check, &iter);
+				     hal_device_property_strlist_iter_is_valid (&iter);
+				     hal_device_property_strlist_iter_next (&iter)) {
+					const char *str = hal_device_property_strlist_iter_get_value (&iter);
+					if (strcmp (str, value) == 0) {
+						contains = TRUE;
+						break;
+					}
 				}
+			} else {
+				return FALSE;
 			}
-		} else {
-			return FALSE;
 		}
 	
 		if (rule->type_match == MATCH_CONTAINS) {	


More information about the hal-commit mailing list