X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=namedev.c;h=dfeadee18a7e5100b1e3ff35ac67ec1e41cafc55;hp=9182ed1fdc7b8c4e8cf322df315b919541a75bf0;hb=d5f91372dd3241f8b4bbe2a99aaaeda541a76bad;hpb=ef672b3dc450846d540cf1a0519fe273bbd62e5f diff --git a/namedev.c b/namedev.c index 9182ed1fd..dfeadee18 100644 --- a/namedev.c +++ b/namedev.c @@ -525,6 +525,8 @@ attr_found: static int compare_sysfs_attribute(struct sysfs_class_device *class_dev, struct sysfs_device *sysfs_device, struct sysfs_pair *pair) { struct sysfs_attribute *tmpattr; + int i; + int len; if ((pair == NULL) || (pair->file[0] == '\0') || (pair->value == '\0')) return -ENODEV; @@ -533,6 +535,18 @@ static int compare_sysfs_attribute(struct sysfs_class_device *class_dev, struct if (tmpattr == NULL) return -ENODEV; + /* strip trailing whitespace of value, if not asked to match for it */ + if (! isspace(pair->value[strlen(pair->value)-1])) { + i = len = strlen(tmpattr->value); + while (i > 0 && isspace(tmpattr->value[i-1])) + i--; + if (i < len) { + tmpattr->value[i] = '\0'; + dbg("remove %i trailing whitespace chars from '%s'", + len - i, tmpattr->value); + } + } + dbg("compare attribute '%s' value '%s' with '%s'", pair->file, tmpattr->value, pair->value); if (strcmp_pattern(pair->value, tmpattr->value) != 0)