chiark / gitweb /
don't report an error on overlong comment lines
authorKay Sievers <kay.sievers@suse.de>
Sun, 13 Aug 2006 02:23:16 +0000 (04:23 +0200)
committerKay Sievers <kay.sievers@suse.de>
Sun, 13 Aug 2006 02:23:16 +0000 (04:23 +0200)
test/udev-test.pl
udev_rules_parse.c

index 9a88d062715cc823f6c62956bdeb58af5f3a151e..63715ac093d77f742c4a01593ccd7195ecf87a6f 100755 (executable)
@@ -1498,6 +1498,18 @@ EOF
                rules           => <<EOF
 KERNEL="sda1", NAME=="no"
 KERNEL=="sda1", NAME="yes"
+EOF
+       },
+       {
+               desc            => "overlong comment line",
+               subsys          => "block",
+               devpath         => "/block/sda/sda1",
+               exp_name        => "yes",
+               rules           => <<EOF
+# 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
+   # 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
+KERNEL="sda1", NAME=="no"
+KERNEL=="sda1", NAME="yes"
 EOF
        },
 );
index 271de6f87968c4d8aa897e592248a9d6cf830944..8d69e74864310e5f584f2d490402b914aeb92dd2 100644 (file)
@@ -543,7 +543,7 @@ static int add_to_rules(struct udev_rules *rules, char *line, const char *filena
                        continue;
                }
 
-               err("unknown key '%s'", key);
+               err("unknown key '%s' in %s:%u", key, filename, lineno);
        }
 
        /* skip line if not any valid key was found */
@@ -603,11 +603,6 @@ static int parse_file(struct udev_rules *rules, const char *filename)
                cur += count+1;
                lineno++;
 
-               if (count >= sizeof(line)) {
-                       err("line too long, rule skipped '%s:%u'", filename, lineno);
-                       continue;
-               }
-
                /* eat the whitespace */
                while ((count > 0) && isspace(bufline[0])) {
                        bufline++;
@@ -620,7 +615,12 @@ static int parse_file(struct udev_rules *rules, const char *filename)
                if (bufline[0] == COMMENT_CHARACTER)
                        continue;
 
-               /* skip backslash and newline from multi line rules */
+               if (count >= sizeof(line)) {
+                       err("line too long, rule skipped '%s:%u'", filename, lineno);
+                       continue;
+               }
+
+               /* skip backslash and newline from multiline rules */
                for (i = j = 0; i < count; i++) {
                        if (bufline[i] == '\\' && bufline[i+1] == '\n')
                                continue;