summaryrefslogtreecommitdiff
path: root/local/html-textfile-fix.pl
blob: b72075b5bd3f5a7ee33ecb8e2308a819c3d8330e (plain)
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
#!/usr/bin/perl
use File::Copy;
#
# This program adds some HTML entities to the text files.  This will help prevent
# missing characters when including text documents in HTML.
#
# Written by:     Alex Burger
# Date:           December 29th, 2005
# 
@files = qw"
CHANGES
ERRATA
INSTALL
NEWS
PORTING
README
README.agent-mibs
README.agentx
README.aix
README.hpux11
README.irix
README.krb5
README.mib2c
README.mibs
README.osX
README.Panasonic_AM3X.txt
README.smux
README.snmpv3
README.solaris
README.thread
README.tru64
README.win32
TODO
perl/AnyData_SNMP/README
perl/default_store/README
perl/OID/README
perl/SNMP/README
perl/TrapReceiver/README
";


foreach my $file (@files) {
  open (FILEIN, $file) || die "Could not open file \'$file\' for reading. $!";
  open (FILEOUT, ">$file.new") || die "Could not open file \'$file.new\' for writing. $!";
  
  while ($line = <FILEIN>) {
    $line =~ s/&(?!lt|gt|quot|amp)/\&amp;/g;
    $line =~ s/</\&lt;/g;
    $line =~ s/>/\&gt;/g;
    $line =~ s/\"/\&quot;/g;
    print FILEOUT "$line";
  }
  close FILE;

  if (! (move ("$file", "$file.old"))) {
    die "Could not move $file to $file.old\n";
  }
  if (! (move ("$file.new", "$file"))) {
    die "Could not move $file.new to $file\n";
  }
}