Commit | Line | Data |
---|---|---|
34e49164 C |
1 | #!/usr/bin/perl |
2 | # | |
3 | # ARGV: 0 = replacement text, 1 = file w. list of files | |
4 | # | |
5 | ||
6 | $debug = 0; | |
7 | $retain = 1; # 1 = retain old status | |
8 | ||
9 | #---------------------------------------------------------------------- | |
10 | $header = 0; # 0 = not seen header yet; 1 = seen beginning; 2 = seen end | |
11 | ||
12 | $currentfile = ""; | |
13 | $currentstatus = ""; | |
14 | $oldstatus = ""; | |
15 | @files = (); | |
16 | ||
17 | # Get replacement text | |
18 | $replace = shift; | |
19 | ||
20 | # Get files of interest | |
21 | open(FILES,shift); | |
22 | @files = <FILES>; | |
23 | close(FILES); | |
24 | ||
25 | # Remove file name suffixes | |
26 | foreach $_ (@files) { | |
27 | s/^([^.]+)\..+$/\1/; | |
28 | chop; | |
29 | print "--> added [$_]\n" if $debug; | |
30 | } | |
31 | ||
32 | # Process std. input | |
33 | while(<>) { | |
34 | ||
35 | # Find an ignore header | |
36 | if(/^-+$/) { | |
37 | $header = $header + 1; | |
38 | } | |
39 | ||
40 | # | |
41 | if($header > 1) { | |
42 | ||
43 | # Filename | |
44 | if(/^([0-9a-zA-Z_-]+)\.c\s*$/) { | |
45 | $currentfile = $1; | |
46 | $currentstatus = ""; | |
47 | print "--> currentfile: [$currentfile]\n" if $debug; | |
48 | } | |
49 | ||
50 | # Status code | |
51 | if(/^(\s+\*\s+)\[status\]([ \t\f]*)(\S*)$/) { | |
52 | $currentstatus = $3; | |
53 | ||
54 | print "--> $currentfile [$currentstatus]\n" if $debug; | |
55 | ||
56 | if(grep {/^$currentfile$/} @files) { | |
57 | s/^(\s+\*\s+\[status\])[ \t\f]*(.*)$/\1 $replace/; | |
58 | print "==>" if $debug; | |
59 | ||
60 | if($retain && ($currentstatus ne "")) { | |
61 | $oldstatus = " * [old-status] $currentstatus\n"; | |
62 | } | |
63 | } | |
64 | ||
65 | $currentfile =""; | |
66 | ||
67 | } | |
68 | ||
69 | } | |
70 | ||
71 | # | |
72 | print "$_"; | |
73 | ||
74 | if($oldstatus ne "") { | |
75 | print $oldstatus; | |
76 | $oldstatus = ""; | |
77 | } | |
78 | ||
79 | } |