From: kay.sievers@vrfy.org Date: Sat, 26 Feb 2005 01:52:04 +0000 (+0100) Subject: [PATCH] namedev: skip backslashes only if followed by newline X-Git-Tag: 054~2 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=77313cd0d13ed3682f25c745f71f648292b28215 [PATCH] namedev: skip backslashes only if followed by newline Fix from: Hannes Reinecke 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. --- diff --git a/namedev_parse.c b/namedev_parse.c index 7cd676c39..02d8a6520 100644 --- a/namedev_parse.c +++ b/namedev_parse.c @@ -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]; diff --git a/test/udev-test.pl b/test/udev-test.pl index fe7b93266..f442b162e 100644 --- a/test/udev-test.pl +++ b/test/udev-test.pl @@ -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 => <