chiark / gitweb /
[PATCH] namedev: skip backslashes only if followed by newline
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>
Sat, 26 Feb 2005 01:52:04 +0000 (02:52 +0100)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 06:39:48 +0000 (23:39 -0700)
Fix from: Hannes Reinecke <hare@suse.de>
namedev_parse is a bit overzealous when in comes to handling backspaces;
it always eats up backspaces regardless of anything beyond that. This
means it is impossible to enter '\t' in a rule. Quite a bit of fun when
you're trying to write regexps.

namedev_parse.c
test/udev-test.pl

index 7cd676c..02d8a65 100644 (file)
@@ -153,7 +153,7 @@ static int namedev_parse(const char *filename, void *data)
 
                /* skip backslash and newline from multi line rules */
                for (i = j = 0; i < count; i++) {
-                       if (bufline[i] == '\\' || bufline[i] == '\n')
+                       if (bufline[i] == '\\' && bufline[i+1] == '\n')
                                continue;
 
                        line[j++] = bufline[i];
index fe7b932..f442b16 100644 (file)
@@ -195,6 +195,15 @@ NAME="visor"
 EOF
        },
        {
+               desc            => "preserve backslashes, if they are not for a newline",
+               subsys          => "tty",
+               devpath         => "/class/tty/ttyUSB0",
+               exp_name        => "aaa",
+               conf            => <<EOF
+KERNEL="ttyUSB0", PROGRAM="/bin/echo -e \\101", RESULT="A", NAME="aaa"
+EOF
+       },
+       {
                desc            => "Handle stupid backslashed multi lines in config file (and replace kernel name)",
                subsys          => "tty",
                devpath         => "/class/tty/ttyUSB0",