#!/bin/perl $tmp="c_list.txt"; open(FPW, ">>$tmp") || die("open fail $tmp\n"); open(FPR, $ARGV[0]) || die("open fail $ARGV[0]\n"); #0.rm c_depend.txt #1.find . -name "*.d" | xargs -n1 | xargs -i= perl ~/bin/c_depend.pl = #2. foreach x ( `find . -name "*.d"` ) #perl ~/bin/c_depend.pl $x #end #array of file suffix names @sfx_a = (); # Must be sorted based on suffix length push(@sfx_a, ".hpp"); push(@sfx_a, ".hxx"); push(@sfx_a, ".cpp"); push(@sfx_a, ".cxx"); push(@sfx_a, ".cc"); push(@sfx_a, ".c"); push(@sfx_a, ".h"); while(eof(FPR) != 1) { $line=; chomp($line); $line =~ s/\\//g; $line =~ s/^[ \t][ \t]*//g; foreach $sfx ( @sfx_a ) { #remove : after suffix (example file.h: -> file.h) ##$sfx_c=":"; ##&sfx_clean($line, $sfx, $sfx_c); $ix=1; while($ix >= 0) { $ix = index($line, $sfx); if($ix >= 0) { &get_N_rm_file($line, $ix, $sfx); } }#while }#foreach }#while close(FPR); close(FPW); $dbg_cnt =4; sub sfx_clean { my $s = $_[1] . $_[2]; my $l = length($_[0]) - length($_[2]); my $ix = index($_[0], $s); if($ix > 0) { #assume at least one char for prefix print FPW ("dbg $_[0]\n"); $_[0] = substr($_[0], 0, $l); print FPW ("dbg $_[0]\n"); } } sub get_N_rm_file { my $v_end = $_[1] + length($_[2]); for($i=$_[1]; $i > 0; $i--) { $c=substr($_[0], $i, 1); if($c eq " ") {$i++; last; } #print("dbg : $c\n"); }#for my $len = $v_end - $i; my $str = substr($_[0], $i, $len); print FPW ("$str\n"); $str=""; $i--; if($i > 0) { $str = substr($_[0], 0, $i); } if($len < $v_end) { $str = $str . " " . substr($_[0], $v_end); } #debug #print FPW ("line: $_[0]\n"); #print FPW ("str : $str\n"); #die("dbg\n\n"); $_[0] =$str; }