{"thread":{"id":"3671","subject":"[PATCH] ls-files: Don't require exclude files to end with a newline.","startedAt":"2006-03-18T10:27:45Z","lastAt":"2006-03-20T09:14:01Z","messageCount":3,"participants":["Alexandre Julliard","Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"17648","messageId":"8764mccaji.fsf@wine.dyndns.org","threadId":"3671","inReplyTo":null,"subject":"[PATCH] ls-files: Don't require exclude files to end with a newline.","fromName":"Alexandre Julliard","fromEmail":"julliard@winehq.org","sentAt":"2006-03-18T10:27:45Z","receivedAt":"2006-03-18T10:27:45Z","isPatch":true,"sender":{"key":"julliard@winehq.org","avatar":null},"body":"Without this patch, the last line of an exclude file is silently\nignored if it doesn't end with a newline.\n\nSigned-off-by: Alexandre Julliard <julliard@winehq.org>\n\n---\n\n ls-files.c |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\n9c5a78851bcf3b541364f818f6b397c29a8f4592\ndiff --git a/ls-files.c b/ls-files.c\nindex df25c8c..e42119c 100644\n--- a/ls-files.c\n+++ b/ls-files.c\n@@ -92,11 +92,12 @@ static int add_excludes_from_file_1(cons\n \t\tclose(fd);\n \t\treturn 0;\n \t}\n-\tbuf = xmalloc(size);\n+\tbuf = xmalloc(size+1);\n \tif (read(fd, buf, size) != size)\n \t\tgoto err;\n \tclose(fd);\n \n+\tbuf[size++] = '\\n';\n \tentry = buf;\n \tfor (i = 0; i < size; i++) {\n \t\tif (buf[i] == '\\n') {\n-- \n1.2.4.g5a1f-dirty\n\n-- \nAlexandre Julliard\njulliard@winehq.org\n"},{"id":"17675","messageId":"20060319212911.GD18185@pasky.or.cz","threadId":"3671","inReplyTo":"8764mccaji.fsf@wine.dyndns.org","subject":"Re: [PATCH] ls-files: Don't require exclude files to end with a newline.","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2006-03-19T21:29:11Z","receivedAt":"2006-03-19T21:29:11Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Sat, Mar 18, 2006 at 11:27:45AM CET, I got a letter\nwhere Alexandre Julliard <julliard@winehq.org> said that...\n> Without this patch, the last line of an exclude file is silently\n> ignored if it doesn't end with a newline.\n> \n> Signed-off-by: Alexandre Julliard <julliard@winehq.org>\n\n$ echo -en \"a\\nb\" | wc -l\n1\n\nIn UNIX, a line is a string terminated by a newline, therefore the blob\npast the last newline character is not really a line at all. ;-)\n\nPerhaps a warning might be in order. Why don't you just add the trailing\nnewline to the file?\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nRight now I am having amnesia and deja-vu at the same time.  I think\nI have forgotten this before.\n"},{"id":"17698","messageId":"87d5ghbhra.fsf@wine.dyndns.org","threadId":"3671","inReplyTo":"20060319212911.GD18185@pasky.or.cz","subject":"Re: [PATCH] ls-files: Don't require exclude files to end with a newline.","fromName":"Alexandre Julliard","fromEmail":"julliard@winehq.org","sentAt":"2006-03-20T09:14:01Z","receivedAt":"2006-03-20T09:14:01Z","isPatch":true,"sender":{"key":"julliard@winehq.org","avatar":null},"body":"Petr Baudis <pasky@suse.cz> writes:\n\n> Dear diary, on Sat, Mar 18, 2006 at 11:27:45AM CET, I got a letter\n> where Alexandre Julliard <julliard@winehq.org> said that...\n>> Without this patch, the last line of an exclude file is silently\n>> ignored if it doesn't end with a newline.\n>> \n>> Signed-off-by: Alexandre Julliard <julliard@winehq.org>\n>\n> $ echo -en \"a\\nb\" | wc -l\n> 1\n>\n> In UNIX, a line is a string terminated by a newline, therefore the blob\n> past the last newline character is not really a line at all. ;-)\n>\n> Perhaps a warning might be in order. Why don't you just add the trailing\n> newline to the file?\n\nOf course I can do that, but I think that if a user entered something\non the last line it's a safe bet they didn't mean for it to be\nignored; and since it's trivial to DTRT here, I don't see why we\nshouldn't.\n\n-- \nAlexandre Julliard\njulliard@winehq.org\n"}]}