]> ruderich.org/simon Gitweb - blhc/blhc.git/commitdiff
Don't split on ; in quotes.
authorSimon Ruderich <simon@ruderich.org>
Wed, 21 Mar 2012 23:20:08 +0000 (00:20 +0100)
committerSimon Ruderich <simon@ruderich.org>
Wed, 21 Mar 2012 23:20:08 +0000 (00:20 +0100)
Build.PL
bin/blhc
t/logs/bad-multiline
t/logs/good-multiline
t/tests.t

index 3edcfb80e32f44c9a37c8cff307828e020f5ff0d..051de8449e356329649ca0d42f8bf7d0963a2297 100644 (file)
--- a/Build.PL
+++ b/Build.PL
@@ -35,6 +35,7 @@ my $build = Module::Build->new(
                             'Getopt::Long' => 0,
                             'Pod::Usage' => 0,
                             'Term::ANSIColor' => 0,
                             'Getopt::Long' => 0,
                             'Pod::Usage' => 0,
                             'Term::ANSIColor' => 0,
+                            'Text::ParseWords' => 0,
                           },
 );
 $build->create_build_script;
                           },
 );
 $build->create_build_script;
index 3d5f73c054229f45146713f3a9a871142f79b047..e183027e22886699b7e4c66639ad77c12555034e 100755 (executable)
--- a/bin/blhc
+++ b/bin/blhc
@@ -23,6 +23,7 @@ use warnings;
 
 use Getopt::Long ();
 use Term::ANSIColor ();
 
 use Getopt::Long ();
 use Term::ANSIColor ();
+use Text::ParseWords ();
 
 our $VERSION = '0.01';
 
 
 our $VERSION = '0.01';
 
@@ -393,8 +394,10 @@ while (my $line = <>) {
     my $non_verbose = is_non_verbose_build($line);
 
     # One line may contain multiple commands (";"). Treat each one as single
     my $non_verbose = is_non_verbose_build($line);
 
     # One line may contain multiple commands (";"). Treat each one as single
-    # line.
-    my @line = split /(?<!\\);/, $line;
+    # line. parse_line() is slow, only use it when necessary.
+    my @line = (not $line =~ /;/)
+             ? ($line)
+             : Text::ParseWords::parse_line(';', 1, $line);
     foreach $line (@line) {
         # Add newline, drop all other whitespace at the end of a line.
         $line =~ s/\s+$//;
     foreach $line (@line) {
         # Add newline, drop all other whitespace at the end of a line.
         $line =~ s/\s+$//;
index ff7a82630f4edccf44fc11ee9df903449e33080f..e7c179b0823537824d8a1affd7a7a6c918cb8226 100644 (file)
@@ -40,3 +40,6 @@ else
     echo bad; \
 fi; \
 gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=1 -c test-b.c
     echo bad; \
 fi; \
 gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=1 -c test-b.c
+
+gcc -c test.c `echo -g -O2 -fstack-protector --param=ssp-buffer-size=4 echo -Wformat -Wformat-security -Werror=format-security | sed 's/.../; s/.../'` -o test.o
+gcc -c test.c `echo -g -O2 -fstack-protector --param=ssp-buffer-size=4 echo -Wformat -Wformat-security -Werror=format-security | sed "s/.../; s/.../"` -o test.o
index 39bba6b1b27dedc85c7b6ecc6a3918db02663ae7..24a684f15a6f0f5e9cbeed24dbfa03df76b8f68b 100644 (file)
@@ -38,3 +38,6 @@ gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-securit
 gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-b.c
 # Escaped ";" - not really useful, just to check it works.
 gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security \; -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.c
 gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-b.c
 # Escaped ";" - not really useful, just to check it works.
 gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security \; -Werror=format-security -D_FORTIFY_SOURCE=2 -c test-a.c
+
+gcc -c test.c `echo -g -O2 -fstack-protector --param=ssp-buffer-size=4 echo -Wformat -Wformat-security -Werror=format-security | sed 's/.../; s/.../'` -D_FORTIFY_SOURCE=2 -o test.o
+gcc -c test.c `echo -g -O2 -fstack-protector --param=ssp-buffer-size=4 echo -Wformat -Wformat-security -Werror=format-security | sed "s/.../; s/.../"` -D_FORTIFY_SOURCE=2 -o test.o
index d754c64f858d323d6fdf0acf3421ca74b53270a5..2e31fddc1fa49146bd66d092530463386accf278 100644 (file)
--- a/t/tests.t
+++ b/t/tests.t
@@ -331,6 +331,8 @@ CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 --param=ssp-buffer-size=4 -Wf
 CFLAGS missing (-g -O2 --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security):  \ gcc -D_FORTIFY_SOURCE=2 -fstack-protector -c test-b.c
 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security \; -Werror=format-security -D_FORTIFY_SOURCE=1 -c test-a.c
 CPPFLAGS missing (-D_FORTIFY_SOURCE=2):  \ gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=1 -c test-b.c
 CFLAGS missing (-g -O2 --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security):  \ gcc -D_FORTIFY_SOURCE=2 -fstack-protector -c test-b.c
 CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security \; -Werror=format-security -D_FORTIFY_SOURCE=1 -c test-a.c
 CPPFLAGS missing (-D_FORTIFY_SOURCE=2):  \ gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=1 -c test-b.c
+CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c test.c `echo -g -O2 -fstack-protector --param=ssp-buffer-size=4 echo -Wformat -Wformat-security -Werror=format-security | sed \'s/.../; s/.../\'` -o test.o
+CPPFLAGS missing (-D_FORTIFY_SOURCE=2): gcc -c test.c `echo -g -O2 -fstack-protector --param=ssp-buffer-size=4 echo -Wformat -Wformat-security -Werror=format-security | sed "s/.../; s/.../"` -o test.o
 ';
 
 is_blhc 'bad-library', '--all', 8,
 ';
 
 is_blhc 'bad-library', '--all', 8,