/usr/share/deal.II/scripts/validate-xrefs.pl is in libdeal.ii-dev 6.3.1-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | # $Id: validate-xrefs.pl 21144 2010-06-02 16:23:31Z bangerth $
# Check whether references in HTML files are valid or
# point to non-existing files/links/etc
#
# Author: Wolfgang Bangerth, Guido Kanschat 2000, 2004
# set this to 1 if you want verbose output
$debug = 0;
$startdir = `pwd`;
chop $startdir;
foreach $filename (@ARGV)
{
chdir $startdir || die "Could not change dir to $startdir\n";
open IN, $filename
or die "---Can't open file `$filename'\n";
print "File: $filename\n" if $debug;
if ($filename =~ m!(.+)/([^/]+)!)
{
chdir $1;
$filename = $2;
}
while (<IN>) {
# save the entire line for simpler grepping when an error
# occurs
$this_line = $_;
# if line ends with an = character, the concatenate it with the next
# one
while ( /=\s*$/ ) {
$newline = <IN>;
$newline =~ s/^\s*//g;
$_ = $thisline . $newline;
$this_line = $_;
}
# first find all hrefs
while ( /<\s*a\s+href=\"?(.*?)[\s\"]/gi ) {
# then decide whether they are relevant for
# our purpose
$link = $1;
if ( $link =~ /^mailto|http(s)?:\/\//i ) {
# link is external. don't check it
print "external link: $link\n" if $debug;
next;
}
elsif ( $link =~ m/^#(.*)/ )
{
# this is a reference within this file. try to
# find its anchor
$internal_ref = $1;
print "internal reference: $link\n" if $debug;
open IN2, $filename;
$found = 0;
while ( <IN2> ) {
while ( /<a[^>]* (name=|class=\"anchor\" id=)\"?(.*?)[\s\"]/gi ) {
if ( $2 eq $internal_ref)
{
print " found.\n" if $debug;
$found = 1;
last;
}
}
}
die "---Internal reference `$internal_ref' not found in file $filename\n This line is: $this_line.\n"
unless $found
# work around a bug in doxygen 1.6.3:
# https://bugzilla.gnome.org/show_bug.cgi?id=620372
|| ($internal_ref =~ /^index_[:_~]/) ;
next;
}
elsif ( $link =~ /^(.*?)#(.*)/ )
{
# this is a reference within another file. try to
# find its anchor
$external_file = $1;
$external_ref = $2;
# if the file name was prepended with http: (but is a local file,
# so no double-slash), then split off http:
$external_file =~ s/^http(s)?://g;
print "external reference: $link\n" if $debug;
open IN2, $external_file;
$found = 0;
while ( <IN2> ) {
while ( /<a[^>]* (name=|class=\"anchor\" id=)\"?(.*?)[\s\"]/gi ) {
if ( $2 eq $external_ref)
{
print " found.\n" if $debug;
$found = 1;
last;
}
}
}
die "---External reference `$external_file#$external_ref' not found in file $filename\n This line is: $this_line.\n"
unless $found
# work around a bug in doxygen 1.6.3:
# https://bugzilla.gnome.org/show_bug.cgi?id=620372
|| ($external_ref =~ /^index_[:_~]/) ;
next;
}
else {
# this must now be a regular file which is
# referenced. the file must be local
# if the file name was prepended with http: (but is a local file,
# so no double-slash), then split off http:
$link =~ s/^http(s)?://g;
die "---Local file `$link' not found in file `$filename'\n This line is: $this_line.\n"
unless ((-r $link) && (-f $link));
}
}
# check whether references to images are valid
while ( /img\s+src=\"?(.*?)[\s\"]/gi ) {
# check whether the file for the image is present
$link = $1;
die "---Local image `$link' not found in file `$filename'\n This line is: $this_line.\n"
unless ((-r $link) && (-f $link));
}
}
}
|