#!/usr/local/bin/perl ############################################################################## # PRINT OUT THE MAIN LOOPING STRUCTURE ############################################################################## print <\$outfile") || die "Can't open \$outfile for output: \$!\\n" ; EOF ############################################################################# # ADD THE INCLUDE STATEMENT FOR EACH HEADER FILE BEING PROCESSED ############################################################################# foreach $arg (@ARGV) { print <) { EOF while (<>) { # split the macro definition into in name and value if(/\s*#define\s*(\w*)\s*(\S.*\S)\s*$/) { $macro = $1 ; $value = $2 ; @pieces = split(/(\W)/,$value) ; foreach $piece (@pieces) { if($value_of{$piece}) { $piece = $value_of{$piece} ; } } #join the pieces back together $value = join("",@pieces) ; #set the macro value $value_of{$macro} = $value ; #escape every character for safety @chars = split(//,$value) ; foreach $char (@chars) { if($char =~ /[^\|bBnnrtfdDwWsS0-9xcea]/) { $char = "\\$char" ; } } $value = join("",@chars) ; unshift(@output," s/$value/$macro/gi ;\n") ; } } print @output ; print <