#!/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 () { 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$encoded_file:$encoded_line) ; } elsif ( defined( $file ) && length( $file ) ) { $encoded_file = qq($preamble$encoded_file) ; } 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 = '
' unless $colspan || defined( $message ) ; $encoded_message = "$encoded_message" unless $colspan ; push( @output, "$encoded_file$encoded_message\n" ) ; } unless ( close( GCC ) ) { if ( length( $! ) ) { die "$! running '$gcc'" ; } elsif ( ! @output ) { die "'$gcc' returned $?\n" . join( '', @output ) ; } } print qq{ gcc -Wall $args } ; if ( @output ) { print qq{ } ; print @output, "
Output of 'gcc -Wall $args'
\n" ; } else { print "

'gcc -Wall $args' didn't complain." ; } print qq{ } ; 0 ;