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 7cd676c390dd7c900e685980238d8cf73dcbddff..02d8a6520c50fe3302cea0055e7a8f2bbfe62136 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 fe7b932669e824d7eb29b0bf05fdd9c8da125922..f442b162ec31cf5ff314480b269284ec5ff30e13 100644 (file)
@@ -192,6 +192,15 @@ EOF
 KERNEL="ttyUSB0", \\
 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
        },
        {