File: mknewyear

package info (click to toggle)
dosemu 1.4.0%2Bsvn.1999-2
  • links: PTS
  • area: contrib
  • in suites: squeeze
  • size: 15,552 kB
  • ctags: 22,600
  • sloc: ansic: 136,915; asm: 4,107; sh: 1,606; perl: 1,411; makefile: 974; tcl: 599; awk: 404; yacc: 300; lex: 157
file content (64 lines) | stat: -rwxr-xr-x 1,174 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#! /usr/bin/perl

$newyear = "2007";
$filelistname = "";

$i = 0;

while ($ARGV[$i] ne "") {
  if ($ARGV[$i] eq "-y") {
    $i++;
    if ($ARGV[$i] ne "") {
      $newyear = $ARGV[$i];
      $i++;
    }
  }
  if ($ARGV[$i] eq "-f") {
    $i++;
    if ($ARGV[$i] ne "") {
      $filelistname = $ARGV[$i];
      $i++;
    }
  }
}

print "building file list ...\n";
if ($filelistname eq "") {
  @files = `grep -l '(C) Copyright 1992,' \`find -type f -perm -u=w\``;
}
else {
  @files = `grep -l '(C) Copyright 1992,' \`cat $filelistname\``;
}
print "...Ok, now processing\n";

$total = 0;

#foreach $i (@files) {print "$i";} exit;

foreach $i (@files) {
  chop $i;
  $total++;
  print "processing $i\n";
  open(FIN, "<$i") || die "Can't open $i";
  open(FOUT, ">$i.new") || die "Can't open $i.new";
  $changed_it = 0;
  LINE: while (<FIN>) {
     $line = $_;
     if (/\(C\) Copyright 1992,[^0-9]+([0-9]+)\s+the\s+\"DOSEMU/) {
       $line =~ s/$1/$newyear/;
       $changed_it = 1;
     }
     print FOUT "$line";
  }
  close(FOUT);
  close(FIN);
  if ($changed_it) {
    `mv $i.new $i`;
  }
  else {
    `rm -f $i.new`;
     $total--;
  }
}

print "$total files converted\n";