33#
44#
55#
6- # Copyright (c) 2001-2002,
6+ # Copyright (c) 2001-2002,
77# George C. Necula <[email protected] >88# Scott McPeak <[email protected] >991010# All rights reserved.
11- #
11+ #
1212# Redistribution and use in source and binary forms, with or without
1313# modification, are permitted provided that the following conditions are
1414# met:
@@ -61,19 +61,18 @@ sub printHelp {
6161Patch include files
6262Usage: patcher [options] args
6363
64- options:
64+ options:
6565 --help Prints this help message
6666 --verbose Prints a lot of information about what is being done
67- --mode=xxx What tool to emulate:
67+ --mode=xxx What tool to emulate:
6868 GNUCC - GNU CC
69- EDG - EDG front end
7069
7170 --dest=xxx The destination directory. Will make one if it does not exist
7271 --patch=xxx Patch file (can be specified multiple times)
7372
7473 --ufile=xxx A user-include file to be patched (treated as \# include "xxx")
7574 --sfile=xxx A system-include file to be patched (treated as \# include <xxx>)
76-
75+
7776 --clean Remove all files in the destination directory
7877 --skipmissing Skip patches for files whose original cannot be found
7978 --dumpversion Print the version name used for the current compiler
@@ -161,7 +160,7 @@ foreach $file (@{$option{ufile}}) {
161160}
162161foreach $file (@{$option {sfile }}) {
163162 &patchOneFile($file , 1);
164- }
163+ }
165164
166165# Now check whether we have used all the patches
167166my $hadError = 0;
@@ -187,7 +186,7 @@ foreach my $patch (@patches) {
187186 next ;
188187 }
189188 # It was not in a group and was not optional
190- if (! defined $patch -> {USED }) {
189+ if (! defined $patch -> {USED }) {
191190 $hadError = 1;
192191 print " Non-optional patch was not used:\n\t from $patch ->{PATCHFILE} at $patch ->{PATCHLINENO}\n " ;
193192 next ;
@@ -196,12 +195,12 @@ foreach my $patch (@patches) {
196195exit $hadError ;
197196
198197
199- # ############ SUBROUTINES
198+ # ############ SUBROUTINES
200199sub findCompilerVersion {
201200 $cname = " " ;
202201 $cversion = 0;
203202 $cname = " GNU CC" ;
204- open (VER, " $: :cc -dumpversion $ppargs |" )
203+ open (VER, " $: :cc -dumpversion $ppargs |" )
205204 || die " Cannot start $cname " ;
206205 while (<VER>) {
207206 # sm: had to modify this to match "egcs-2.91.66", which is
@@ -224,9 +223,6 @@ sub lineDirective {
224223 if ($option {mode } eq " GNUCC" ) {
225224 return " #line $lineno \" $fileName \"\n " ;
226225 }
227- if ($option {mode } eq " EDG" ) {
228- return " # $lineno \" $fileName \"\n " ;
229- }
230226 die " lineDirective: invalid mode" ;
231227}
232228
@@ -240,7 +236,7 @@ sub patchOneFile {
240236 open (TOPREPROC, " >$preprocfile .c" ) || die " Cannot open preprocessor file" ;
241237 print TOPREPROC " #include $fname1 \n " ;
242238 close (TOPREPROC);
243- # Do not test for error while running the preprocessor because the
239+ # Do not test for error while running the preprocessor because the
244240 # error might be due to an #error directive
245241 my $preproccmd = " " ;
246242 if ($option {mode } eq " GNUCC" ) {
@@ -250,7 +246,7 @@ sub patchOneFile {
250246 $preproccmd .= " 2>/dev/null" ;
251247 }
252248 } else { die " Invalid --mode" ; }
253-
249+
254250 # Now scan the resulting file and get the real name of the file
255251 my $absname = " " ;
256252 open (PPOUT, " <$preprocfile .i" ) || die " Cannot find $preprocfile .i" ;
@@ -363,7 +359,7 @@ sub preparePatchFile {
363359 my $current_pattern = [];
364360 my @all_patterns = ();
365361 if ($_ =~ m | ^===| ) {
366- if (! defined $valueflags {ateof } &&
362+ if (! defined $valueflags {ateof } &&
367363 ! defined $valueflags {atsof }) {
368364 die " A pattern is missing in $pFile " ;
369365 }
@@ -397,8 +393,8 @@ sub preparePatchFile {
397393 my $replacement = " " ;
398394 # If we have more than one non-optional pattern with no group
399395 # specified, then create a group
400- if (@all_patterns > 1 &&
401- ! defined $valueflags {group } &&
396+ if (@all_patterns > 1 &&
397+ ! defined $valueflags {group } &&
402398 ! defined $valueflags {optional }) {
403399 $valueflags {group } = $pFile . " _$patchStartLine " ;
404400 }
@@ -439,7 +435,7 @@ sub preparePatchFile {
439435 die " Cannot close patch file $pFile \n " ;
440436 print " Loaded patches from $pFile \n " ;
441437 # print Dumper(\@patches); die "Here\n";
442-
438+
443439}
444440
445441sub trimSpaces {
@@ -480,7 +476,7 @@ sub applyPatches {
480476 $patch -> {USE } = 1;
481477 my $infile = $patch -> {FLAGS }-> {file };
482478 if (defined $infile && $in !~ m |$infile $ | ) {
483- # print "Will not use patch ",
479+ # print "Will not use patch ",
484480# &lineDirective($patch->{PATCHFILE},$patch->{PATCHLINENO});
485481 $patch -> {USE } = 0;
486482 next ;
@@ -492,15 +488,15 @@ sub applyPatches {
492488 next ;
493489 }
494490 # Disable also (for now) the patches that must be applied at EOF
495- if (defined $patch -> {FLAGS }-> {ateof } ||
491+ if (defined $patch -> {FLAGS }-> {ateof } ||
496492 defined $patch -> {FLAGS }-> {atsof } ||
497493 defined $patch -> {FLAGS }-> {disabled } ) {
498494 $patch -> {USE } = 0;
499495 push @eof_patches , $patch ;
500496 }
501-
497+
502498 }
503-
499+
504500 open (OUT, " >$out " ) || die " Cannot open patch output file $out " ;
505501 open (IN, " <$in " ) || die " Cannot open patch input file $in " ;
506502
0 commit comments