]> ruderich.org/simon Gitweb - blhc/blhc.git/commitdiff
Use simpler regex to catch compiler commands.
authorSimon Ruderich <simon@ruderich.org>
Mon, 26 Mar 2012 01:37:38 +0000 (03:37 +0200)
committerSimon Ruderich <simon@ruderich.org>
Mon, 26 Mar 2012 01:37:38 +0000 (03:37 +0200)
bin/blhc

index a188c899d775fa742c55758cf260e44bae6690ea..7b228ec13acc2eaa44ca83ad1ce98aede4744265 100755 (executable)
--- a/bin/blhc
+++ b/bin/blhc
@@ -31,9 +31,16 @@ our $VERSION = '0.01';
 # CONSTANTS/VARIABLES
 
 # Regex to catch compiler commands.
-my $cc_regex = qr/(?:[a-z0-9_]+-(?:linux-|kfreebsd-)?gnu(?:eabi|eabihf)?-)?
-                  (?<!\.)(?:cc|gcc|g\+\+|c\+\+)
-                  (?:-[\d.]+)?/x;
+my $cc_regex = qr/
+    (?<!\.)(?:cc|gcc|g\+\+|c\+\+)
+    (?:-[\d.]+)?
+    /x;
+# Full regex which matches the complete compiler name. Used in a few places to
+# prevent false negatives.
+my $cc_regex_full = qr/
+    (?:[a-z0-9_]+-(?:linux-|kfreebsd-)?gnu(?:eabi|eabihf)?-)?
+    $cc_regex
+    /x;
 # Regex to catch (GCC) compiler warnings.
 my $warning_regex = qr/^(.+?):([0-9]+):[0-9]+: warning: (.+?) \[(.+?)\]$/;
 
@@ -518,10 +525,10 @@ FILE: foreach my $file (@ARGV) {
                         and $line =~ /^(?:checking|(?:C|c)onfigure:) /;
                 next if $line =~ /^\s*(?:Host\s+)?(?:C\s+)?
                                    (?:C|c)ompiler[\s.]*:?\s+
-                                   $cc_regex
+                                   $cc_regex_full
                                    (?:\s-std=[a-z0-9:+]+)?\s*$
                                  /xo
-                        or $line =~ /^\s*(?:- )?(?:HOST_)?(?:CC|CXX)\s*=\s*$cc_regex\s*$/o
+                        or $line =~ /^\s*(?:- )?(?:HOST_)?(?:CC|CXX)\s*=\s*$cc_regex_full\s*$/o
                         or $line =~ /^\s*-- Check for working (?:C|CXX) compiler: /
                         or $line =~ /^\s*(?:echo )?Using [A-Z_]+\s*=\s*/;
                 # `make` output.