]> err.no Git - systemd/commitdiff
fix symlink values separated by multiple spaces
authorKay Sievers <kay.sievers@suse.de>
Thu, 7 Jul 2005 21:43:13 +0000 (23:43 +0200)
committerKay Sievers <kay.sievers@suse.de>
Thu, 7 Jul 2005 21:43:13 +0000 (23:43 +0200)
Signed-off-by: Kay Sievers <kay.sievers@suse.de>
test/udev-test.pl
udev_rules.c

index 6fbc23e55737259ba136101d06c29971b5e3dbde..873780d70af521552850c7eeae893026a5546914 100755 (executable)
@@ -799,6 +799,17 @@ EOF
                exp_target      => "ttyUSB0",
                rules           => <<EOF
 KERNEL=="ttyUSB[0-9]*", NAME="ttyUSB%n", SYMLINK="symlink1-%n symlink2-%k symlink3-%b"
+EOF
+       },
+       {
+               desc            => "multiple symlinks with a lot of s p a c e s",
+               subsys          => "tty",
+               devpath         => "/class/tty/ttyUSB0",
+               exp_name        => "one",
+               not_exp_name    => " ",
+               exp_target      => "ttyUSB0",
+               rules           => <<EOF
+KERNEL=="ttyUSB[0-9]*", NAME="ttyUSB%n", SYMLINK="  one     two        "
 EOF
        },
        {
index 41855eb9d7d0a63b50e24ae9ad42c2f8d09f7fd7..a25c2e90a8bc196b6f3a44a219b339a01505c74b 100644 (file)
@@ -958,16 +958,22 @@ int udev_rules_get_name(struct udev_rules *rules, struct udevice *udev, struct s
 
                                /* add multiple symlinks separated by spaces */
                                pos = temp;
-                               next = strchr(temp, ' ');
+                               while (isspace(pos[0]))
+                                       pos++;
+                               next = strchr(pos, ' ');
                                while (next) {
                                        next[0] = '\0';
                                        info("add symlink '%s'", pos);
                                        name_list_add(&udev->symlink_list, pos, 0);
+                                       while (isspace(next[1]))
+                                               next++;
                                        pos = &next[1];
                                        next = strchr(pos, ' ');
                                }
-                               info("add symlink '%s'", pos);
-                               name_list_add(&udev->symlink_list, pos, 0);
+                               if (pos[0] != '\0') {
+                                       info("add symlink '%s'", pos);
+                                       name_list_add(&udev->symlink_list, pos, 0);
+                               }
                        }
 
                        /* set name, later rules with name set will be ignored */