summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--namedev_parse.c16
-rw-r--r--test/udev-test.pl16
-rw-r--r--udev_config.c8
3 files changed, 25 insertions, 15 deletions
diff --git a/namedev_parse.c b/namedev_parse.c
index 4bb1a97ce9..7e37833202 100644
--- a/namedev_parse.c
+++ b/namedev_parse.c
@@ -182,15 +182,13 @@ static int namedev_parse_rules(char *filename)
continue;
}
- /* empty line? */
- if (bufline[0] == '\0' || bufline[0] == '\n')
- continue;
-
/* eat the whitespace */
- while (isspace(bufline[0])) {
+ while ((count > 0) && isspace(bufline[0])) {
bufline++;
count--;
}
+ if (count == 0)
+ continue;
/* see if this is a comment */
if (bufline[0] == COMMENT_CHARACTER)
@@ -381,15 +379,13 @@ static int namedev_parse_permissions(char *filename)
continue;
}
- /* empty line? */
- if (bufline[0] == '\0' || bufline[0] == '\n')
- continue;
-
/* eat the whitespace */
- while (isspace(bufline[0])) {
+ while ((count > 0) && isspace(bufline[0])) {
bufline++;
count--;
}
+ if (count == 0)
+ continue;
/* see if this is a comment */
if (bufline[0] == COMMENT_CHARACTER)
diff --git a/test/udev-test.pl b/test/udev-test.pl
index 1e7c51e556..9feb28a7ba 100644
--- a/test/udev-test.pl
+++ b/test/udev-test.pl
@@ -161,6 +161,22 @@ KERNEL="ttyUSB0", NAME="visor"
EOF
},
{
+ desc => "Handle whitespace only lines (and replace kernel name)",
+ subsys => "tty",
+ devpath => "/class/tty/ttyUSB0",
+ exp_name => "whitespace" ,
+ conf => <<EOF
+
+
+
+ # this is a comment with whitespace before the comment
+KERNEL="ttyUSB0", NAME="whitespace"
+
+
+
+EOF
+ },
+ {
desc => "Handle empty lines in config file (and replace kernel name)",
subsys => "tty",
devpath => "/class/tty/ttyUSB0",
diff --git a/udev_config.c b/udev_config.c
index 20b6c75d32..ba2b3d2b88 100644
--- a/udev_config.c
+++ b/udev_config.c
@@ -161,15 +161,13 @@ static int parse_config_file(void)
continue;
}
- /* empty line? */
- if (bufline[0] == '\0' || bufline[0] == '\n')
- continue;
-
/* eat the whitespace */
- while (isspace(bufline[0])) {
+ while ((count > 0) && isspace(bufline[0])) {
bufline++;
count--;
}
+ if (count == 0)
+ continue;
/* see if this is a comment */
if (bufline[0] == COMMENT_CHARACTER)