From 0c6b6b89c3bc35a85aa1bef12ef4e6323085e4b3 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Mon, 26 Mar 2012 02:46:31 +0200 Subject: [PATCH] Strip trailing whitspace only when necessary. If we don't split a line we don't have to touch it. --- bin/blhc | 11 ++++++----- t/tests.t | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/bin/blhc b/bin/blhc index 5d408c3..2ae1150 100755 --- a/bin/blhc +++ b/bin/blhc @@ -471,12 +471,13 @@ while (my $line = <>) { # line. parse_line() is slow, only use it when necessary. my @line = (not $line =~ /;/) ? ($line) - : Text::ParseWords::parse_line(';', 1, $line); + : map { + # Ensure newline at the line end - necessary for correct + # parsing later. + $_ =~ s/\s+$//; + $_ .= "\n"; + } Text::ParseWords::parse_line(';', 1, $line); foreach $line (@line) { - # Add newline, drop all other whitespace at the end of a line. - $line =~ s/\s+$//; - $line .= "\n"; - if ($continuation) { $continuation = 0; diff --git a/t/tests.t b/t/tests.t index 406f4ea..fa40752 100644 --- a/t/tests.t +++ b/t/tests.t @@ -327,10 +327,10 @@ is_blhc 'bad-multiline', '', 8, CFLAGS missing (--param=ssp-buffer-size=4): gcc -g -O2 -fstack-protector -Wformat -Wformat-security -Werror=format-security\ -D_FORTIFY_SOURCE=2\ -c test-b.c CFLAGS missing (-Werror=format-security): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -D_FORTIFY_SOURCE=2 -c test-c.c LDFLAGS missing (-Wl,-z,relro): gcc -o\ test test-c.o test-a.o test-b.o\ -ltest -LDFLAGS missing (-Wl,-z,relro): gcc -o \ test test-c.o test-b.o test-a.o\ -CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security): gcc -o \ test test-b.o test-a.o test-c.c\ -CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -o \ test test-b.o test-a.o test-c.c\ -LDFLAGS missing (-Wl,-z,relro): gcc -o \ test test-b.o test-a.o test-c.c\ +LDFLAGS missing (-Wl,-z,relro): gcc -o \ test test-c.o test-b.o test-a.o\ +CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security): gcc -o \ test test-b.o test-a.o test-c.c\ +CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -o \ test test-b.o test-a.o test-c.c\ +LDFLAGS missing (-Wl,-z,relro): gcc -o \ test test-b.o test-a.o test-c.c\ CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -c test-a.c CFLAGS missing (-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security): gcc -D_FORTIFY_SOURCE=2 -c test-b.c CFLAGS missing (-Wformat-security -Werror=format-security): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -D_FORTIFY_SOURCE=2 -c test-a.c -- 2.45.2