#!/usr/bin/perl -w
#
# gcclint for Safari
# Copyright (c) 1999 by Barrie Slaymaker, rbs@telerama.com
#
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the README file.
#
use strict ;
use File::Basename ;
use HTML::Entities qw( encode_entities ) ;
my $progname = basename( $0 ) ;
my $args = '"' . join( '" "', @ARGV ) . '"' ;
my $gcc = "gcc -c -Wall $args" ;
open( GCC, "$gcc 2>&1 |" ) or
die "$!: running '$gcc'" ;
my @output ;
my @gcc_output ;
while (<GCC>) {
my ( $preamble, $file, $line, $message ) =
m/^(.*?)([^\s:]+):(?:(\d+):)?\s+(.*)/ ;
my $encoded_preamble ;
$encoded_preamble = encode_entities( $preamble )
if defined $preamble ;
my $encoded_file ;
$encoded_file = encode_entities( $file )
if defined $file ;
my $encoded_line ;
$encoded_line = encode_entities( $line )
if defined $line ;
if ( defined( $line ) && length( $line ) ) {
$encoded_file = qq($encoded_preamble<A HREF="$file#line$line">$encoded_file:$encoded_line</A>) ;
}
elsif ( defined( $file ) && length( $file ) ) {
$encoded_file = qq($preamble<A HREF="$file">$encoded_file</A>) ;
}
else {
$encoded_file = encode_entities( $_ ) ;
}
my $encoded_message ;
$encoded_message = encode_entities( $message )
if defined( $message ) ;
my $colspan = '' ;
$colspan = qq{ COLSPAN="2"}
if ( ! defined( $message ) || ! length( $message ) ) &&
( defined( $preamble ) && length( $preamble ) ) ;
$encoded_message = '<BR>' unless $colspan || defined( $message ) ;
$encoded_message = "<TD>$encoded_message</TD>" unless $colspan ;
push( @output, "<TR><TD$colspan>$encoded_file</TD>$encoded_message</TR>\n" ) ;
}
unless ( close( GCC ) ) {
if ( length( $! ) ) {
die "$! running '$gcc'" ;
}
elsif ( ! @output ) {
die "'$gcc' returned $?\n" . join( '', @output ) ;
}
}
print qq{<HTML>
<HEAD>
<TITLE>gcc -Wall $args</TITLE>
</HEAD>
<BODY>
} ;
if ( @output ) {
print qq{<TABLE>
<TR><TH COLSPAN="2">Output of 'gcc -Wall $args'</TH></TR>
} ;
print @output, "</TABLE>\n" ;
}
else {
print "<P><B>'gcc -Wall $args' didn't complain.</B>" ;
}
print qq{</BODY>
</HTML>
} ;
0 ;
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #4 | 186 | Barrie Slaymaker |
Made gcclint a tiny bit more robust in dealing with gcc's output and return codes. |
||
| #3 | 168 | Barrie Slaymaker | Added YAPC paper, slides | ||
| #2 | 165 | Barrie Slaymaker | Applied Greg KH's license patch. | ||
| #1 | 162 | Barrie Slaymaker | First code & documentation checkin |