mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-21 17:51:03 +00:00
Compare commits
3 Commits
4d89b2903b
...
3f48486a5c
Author | SHA1 | Date | |
---|---|---|---|
|
3f48486a5c | ||
|
a16e4b206a | ||
|
f048b2eeed |
@ -1,5 +1,6 @@
|
|||||||
# -*- mode: perl; -*-
|
# -*- mode: perl; -*-
|
||||||
package CheckURL;
|
package CheckURL;
|
||||||
|
|
||||||
# file CheckURL.pm
|
# file CheckURL.pm
|
||||||
#
|
#
|
||||||
# This file is part of LyX, the document processor.
|
# This file is part of LyX, the document processor.
|
||||||
@ -13,9 +14,10 @@ package CheckURL;
|
|||||||
#
|
#
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
our(@EXPORT, @ISA);
|
our (@EXPORT, @ISA);
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
use Exporter ();
|
use Exporter ();
|
||||||
@ISA = qw(Exporter);
|
@ISA = qw(Exporter);
|
||||||
@EXPORT = qw(check_url);
|
@EXPORT = qw(check_url);
|
||||||
}
|
}
|
||||||
@ -25,16 +27,18 @@ sub check_http_url($$$$);
|
|||||||
sub check_ftp_dir_entry($$);
|
sub check_ftp_dir_entry($$);
|
||||||
sub check_ftp_url($$$$);
|
sub check_ftp_url($$$$);
|
||||||
sub check_unknown_url($$$$);
|
sub check_unknown_url($$$$);
|
||||||
sub check_url($$);
|
sub check_url($$$$);
|
||||||
################
|
################
|
||||||
|
|
||||||
sub check_http_url($$$$)
|
my $fe;
|
||||||
{
|
my $fs;
|
||||||
|
|
||||||
|
sub check_http_url($$$$) {
|
||||||
require LWP::UserAgent;
|
require LWP::UserAgent;
|
||||||
|
|
||||||
my ($protocol, $host, $path, $file) = @_;
|
my ($protocol, $host, $path, $file) = @_;
|
||||||
|
|
||||||
my $ua = LWP::UserAgent->new;
|
my $ua = LWP::UserAgent->new(timeout => 20);
|
||||||
my $getp = "/";
|
my $getp = "/";
|
||||||
if ($path ne "") {
|
if ($path ne "") {
|
||||||
$getp .= $path;
|
$getp .= $path;
|
||||||
@ -54,11 +58,11 @@ sub check_http_url($$$$)
|
|||||||
$buf = $response->decoded_content;
|
$buf = $response->decoded_content;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print " " . $response->status_line . ": ";
|
print $fe " " . $response->status_line . ": ";
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
my @title = ();
|
my @title = ();
|
||||||
my $res = 0;
|
my $res = 0;
|
||||||
while ($buf =~ s/\<title\>([^\<]*)\<\/title\>//i) {
|
while ($buf =~ s/\<title\>([^\<]*)\<\/title\>//i) {
|
||||||
my $title = $1;
|
my $title = $1;
|
||||||
$title =~ s/[\r\n]/ /g;
|
$title =~ s/[\r\n]/ /g;
|
||||||
@ -66,9 +70,9 @@ sub check_http_url($$$$)
|
|||||||
$title =~ s/^ //;
|
$title =~ s/^ //;
|
||||||
$title =~ s/ $//;
|
$title =~ s/ $//;
|
||||||
push(@title, $title);
|
push(@title, $title);
|
||||||
print "title = \"$title\": ";
|
print $fe "title = \"$title\": ";
|
||||||
if ($title =~ /Error 404|Not Found/) {
|
if ($title =~ /Error 404|Not Found/) {
|
||||||
print " Page reports 'Not Found' from \"$protocol://$host$getp\": ";
|
print $fe " Page reports 'Not Found' from \"$protocol://$host$getp\": ";
|
||||||
$res = 3;
|
$res = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,39 +83,39 @@ sub check_http_url($$$$)
|
|||||||
# returns 0, x if file does not match entry
|
# returns 0, x if file does not match entry
|
||||||
# 1, x everything OK
|
# 1, x everything OK
|
||||||
# 2, x if not accesible (permission)
|
# 2, x if not accesible (permission)
|
||||||
sub check_ftp_dir_entry($$)
|
sub check_ftp_dir_entry($$) {
|
||||||
{
|
|
||||||
my ($file, $e) = @_;
|
my ($file, $e) = @_;
|
||||||
my $other = '---';
|
my $other = '---';
|
||||||
my $isdir = 0;
|
my $isdir = 0;
|
||||||
|
|
||||||
#print "Checking '$file' against '$e'\n";
|
#print $fe "Checking '$file' against '$e'\n";
|
||||||
$file =~ s/^\///;
|
$file =~ s/^\///;
|
||||||
$isdir = 1 if ($e =~ /^d/);
|
$isdir = 1 if ($e =~ /^d/);
|
||||||
return(0,$isdir) if ($e !~ /\s$file$/);
|
return (0, $isdir) if ($e !~ /\s$file$/);
|
||||||
if ($e =~ /^.[-rwx]{6}([-rwx]{3})\s/) {
|
if ($e =~ /^.[-rwx]{6}([-rwx]{3})\s/) {
|
||||||
$other = $1;
|
$other = $1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#print "Invalid entry\n";
|
#print $fe "Invalid entry\n";
|
||||||
# Invalid entry
|
# Invalid entry
|
||||||
return(0,$isdir);
|
return (0, $isdir);
|
||||||
}
|
}
|
||||||
return(2,$isdir) if ($other !~ /^r/); # not readable
|
return (2, $isdir) if ($other !~ /^r/); # not readable
|
||||||
if ($isdir) {
|
if ($isdir) {
|
||||||
|
|
||||||
#return(2,$isdir) if ($other !~ /x$/); # directory, but not executable
|
#return(2,$isdir) if ($other !~ /x$/); # directory, but not executable
|
||||||
}
|
}
|
||||||
return(1,$isdir);
|
return (1, $isdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_ftp2_url($$$$)
|
sub check_ftp2_url($$$$) {
|
||||||
{
|
|
||||||
my ($protocol, $host, $path, $file) = @_;
|
my ($protocol, $host, $path, $file) = @_;
|
||||||
|
|
||||||
my $checkentry = 1;
|
my $checkentry = 1;
|
||||||
print "\nhost $host\n";
|
|
||||||
print "path $path\n";
|
#print $fe "\nhost $host\n";
|
||||||
print "file $file\n";
|
#print $fe "path $path\n";
|
||||||
|
#print $fe "file $file\n";
|
||||||
my $url = "$protocol://$host";
|
my $url = "$protocol://$host";
|
||||||
$path =~ s/\/$//;
|
$path =~ s/\/$//;
|
||||||
if (defined($file)) {
|
if (defined($file)) {
|
||||||
@ -120,7 +124,8 @@ sub check_ftp2_url($$$$)
|
|||||||
else {
|
else {
|
||||||
$url = "$url/$path/.";
|
$url = "$url/$path/.";
|
||||||
}
|
}
|
||||||
print "curl $url, file = $file\n";
|
|
||||||
|
#print $fe "curl $url, file = $file\n";
|
||||||
my %listfiles = ();
|
my %listfiles = ();
|
||||||
if (open(FFTP, "curl --anyauth -l $url|")) {
|
if (open(FFTP, "curl --anyauth -l $url|")) {
|
||||||
while (my $l = <FFTP>) {
|
while (my $l = <FFTP>) {
|
||||||
@ -130,44 +135,44 @@ sub check_ftp2_url($$$$)
|
|||||||
close(FFTP);
|
close(FFTP);
|
||||||
}
|
}
|
||||||
if (%listfiles) {
|
if (%listfiles) {
|
||||||
if (! defined($file)) {
|
if (!defined($file)) {
|
||||||
return(0, "OK");
|
return (0, "OK");
|
||||||
}
|
}
|
||||||
elsif (defined($listfiles{$file})) {
|
elsif (defined($listfiles{$file})) {
|
||||||
return(0, "OK");
|
return (0, "OK");
|
||||||
}
|
}
|
||||||
elsif (defined($listfiles{"ftpinfo.txt"})) {
|
elsif (defined($listfiles{"ftpinfo.txt"})) {
|
||||||
return(0, "Probably a directory");
|
return (0, "Probably a directory");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return(1, "Not found");
|
return (1, "Not found");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return(1, "Error");
|
return (1, "Error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_ftp_url($$$$)
|
sub check_ftp_url($$$$) {
|
||||||
{
|
|
||||||
use Net::FTP;
|
use Net::FTP;
|
||||||
|
|
||||||
my ($protocol, $host, $path, $file) = @_;
|
my ($protocol, $host, $path, $file) = @_;
|
||||||
my $res = 0;
|
my $res = 0;
|
||||||
my $message = "";
|
my $message = "";
|
||||||
|
|
||||||
my $ftp = Net::FTP->new($host, Debug => 0, Timeout => 120);
|
my $ftp = Net::FTP->new($host, Debug => 0, Timeout => 20);
|
||||||
if(!$ftp) {
|
if (!$ftp) {
|
||||||
return(3,"Cannot connect to $host");
|
return (3, "Cannot connect to $host");
|
||||||
}
|
}
|
||||||
if (! $ftp->login("anonymous",'-anonymous@')) {
|
if (!$ftp->login("anonymous", '-anonymous@')) {
|
||||||
$message = $ftp->message;
|
$message = $ftp->message;
|
||||||
$res = 3;
|
$res = 3;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
my $rEntries;
|
my $rEntries;
|
||||||
if ($path ne "") {
|
if ($path ne "") {
|
||||||
#print "Path = $path\n";
|
|
||||||
|
#print $fe "Path = $path\n";
|
||||||
#if (!$ftp->cwd($path)) {
|
#if (!$ftp->cwd($path)) {
|
||||||
# $message = $ftp->message;
|
# $message = $ftp->message;
|
||||||
# $res = 3;
|
# $res = 3;
|
||||||
@ -177,41 +182,43 @@ sub check_ftp_url($$$$)
|
|||||||
else {
|
else {
|
||||||
$rEntries = $ftp->dir();
|
$rEntries = $ftp->dir();
|
||||||
}
|
}
|
||||||
if (! $rEntries) {
|
if (!$rEntries) {
|
||||||
$res = 3;
|
$res = 3;
|
||||||
$message = "Could not read directory \"$path\"";
|
$message = "Could not read directory \"$path\"";
|
||||||
}
|
}
|
||||||
elsif (defined($file)) {
|
elsif (defined($file)) {
|
||||||
my $found = 0;
|
my $found = 0;
|
||||||
my $found2 = 0;
|
my $found2 = 0;
|
||||||
for my $f ( @{$rEntries}) {
|
for my $f (@{$rEntries}) {
|
||||||
#print "Entry: $path $f\n";
|
|
||||||
my ($res1,$isdir) = check_ftp_dir_entry($file,$f);
|
#print $fe "Entry: $path $f\n";
|
||||||
if ($res1 == 1) {
|
my ($res1, $isdir) = check_ftp_dir_entry($file, $f);
|
||||||
$found = 1;
|
if ($res1 == 1) {
|
||||||
last;
|
$found = 1;
|
||||||
}
|
last;
|
||||||
elsif ($res1 == 2) {
|
}
|
||||||
# found, but not accessible
|
elsif ($res1 == 2) {
|
||||||
$found2 = 1;
|
|
||||||
$message = "Permission denied for '$file'";
|
# found, but not accessible
|
||||||
}
|
$found2 = 1;
|
||||||
|
$message = "Permission denied for '$file'";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (! $found) {
|
if (!$found) {
|
||||||
$res = 4;
|
$res = 4;
|
||||||
if (! $found2) {
|
if (!$found2) {
|
||||||
$message = "File or directory '$file' not found";
|
$message = "File or directory '$file' not found";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$ftp->quit;
|
$ftp->quit;
|
||||||
#print "returning ($res,$message)\n";
|
|
||||||
return($res, $message);
|
#print $fe "returning ($res,$message)\n";
|
||||||
|
return ($res, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_unknown_url($$$$)
|
sub check_unknown_url($$$$) {
|
||||||
{
|
|
||||||
use LWP::Simple;
|
use LWP::Simple;
|
||||||
|
|
||||||
my ($protocol, $host, $path, $file) = @_;
|
my ($protocol, $host, $path, $file) = @_;
|
||||||
@ -226,49 +233,53 @@ sub check_unknown_url($$$$)
|
|||||||
$url .= "/$path";
|
$url .= "/$path";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(defined($file)) {
|
if (defined($file)) {
|
||||||
#print "Trying $url$file\n";
|
|
||||||
|
#print $fe "Trying $url$file\n";
|
||||||
$res = head("$url/$file");
|
$res = head("$url/$file");
|
||||||
if(! $res) {
|
if (!$res) {
|
||||||
|
|
||||||
# try to check for directory '/';
|
# try to check for directory '/';
|
||||||
#print "Trying $url$file/\n";
|
#print $fe "Trying $url$file/\n";
|
||||||
$res = head("$url/$file/");
|
$res = head("$url/$file/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#print "Trying $url\n";
|
#print $fe "Trying $url\n";
|
||||||
$res = head($url);
|
$res = head($url);
|
||||||
}
|
}
|
||||||
return(! $res);
|
return (!$res);
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Main entry
|
# Main entry
|
||||||
sub check_url($$)
|
sub check_url($$$$) {
|
||||||
{
|
my ($url, $use_curl, $fex, $fsx) = @_;
|
||||||
my($url,$use_curl) = @_;
|
$fe = $fex;
|
||||||
|
$fs = $fsx;
|
||||||
my $file = undef;
|
my $file = undef;
|
||||||
my ($protocol,$host,$path);
|
my ($protocol, $host, $path);
|
||||||
|
|
||||||
my $res = 0;
|
my $res = 0;
|
||||||
|
|
||||||
# Split the url to protocol,host,path
|
# Split the url to protocol,host,path
|
||||||
if ($url =~ /^([a-z]+):\/\/([^\/]+)(.*)$/) {
|
if ($url =~ /^([a-z]+):\/\/([^\/]+)(.*)$/) {
|
||||||
$protocol = $1;
|
$protocol = $1;
|
||||||
$host = $2;
|
$host = $2;
|
||||||
$path = $3;
|
$path = $3;
|
||||||
$path =~ s/^\///;
|
$path =~ s/^\///;
|
||||||
if($path =~ s/\/([^\/]+)$//) {
|
if ($path =~ s/\/([^\/]+)$//) {
|
||||||
$file = $1;
|
$file = $1;
|
||||||
if($file =~ / /) {
|
if ($file =~ / /) {
|
||||||
# Filename contains ' ', maybe invalid. Don't check
|
|
||||||
$file = undef;
|
# Filename contains ' ', maybe invalid. Don't check
|
||||||
|
$file = undef;
|
||||||
}
|
}
|
||||||
$path .= "/";
|
$path .= "/";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print " Invalid url '$url'";
|
print $fe " Invalid url '$url'";
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
if ($protocol =~ /^https?$/) {
|
if ($protocol =~ /^https?$/) {
|
||||||
@ -286,7 +297,7 @@ sub check_url($$)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# it never should reach this point
|
# it never should reach this point
|
||||||
print " What protocol is '$protocol'?";
|
print $fe " What protocol is '$protocol'?";
|
||||||
$res = check_unknown_url($protocol, $host, $path, $file);
|
$res = check_unknown_url($protocol, $host, $path, $file);
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
@ -2,3 +2,4 @@ http://www.uon.edu/doe
|
|||||||
ftp://www.test.test
|
ftp://www.test.test
|
||||||
http://www.test.test
|
http://www.test.test
|
||||||
#proto://host.xx.ab/abcd
|
#proto://host.xx.ab/abcd
|
||||||
|
http://example.com/%20foo
|
||||||
|
@ -10,6 +10,7 @@ http://jasa.peerx-press.org/html/jasa/Using_LaTeX
|
|||||||
http://spie.org/app/Publications/index.cfm?fuseaction=authinfo&type=proceedings
|
http://spie.org/app/Publications/index.cfm?fuseaction=authinfo&type=proceedings
|
||||||
http://www.jstatsoft.org/downloads/JSSstyle.zip
|
http://www.jstatsoft.org/downloads/JSSstyle.zip
|
||||||
http://www.photogrammetry.ethz.ch/tarasp_workshop/isprs.cls
|
http://www.photogrammetry.ethz.ch/tarasp_workshop/isprs.cls
|
||||||
|
https://journals.aps.org/revtex
|
||||||
|
|
||||||
# The following ftp url is correct, but
|
# The following ftp url is correct, but
|
||||||
# ftp commands like 'dir', 'get' do not work.
|
# ftp commands like 'dir', 'get' do not work.
|
||||||
|
@ -31,47 +31,55 @@
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
use File::Spec;
|
use File::Spec;
|
||||||
my $p = File::Spec->rel2abs(__FILE__);
|
my $p = File::Spec->rel2abs(__FILE__);
|
||||||
$p =~ s/[\/\\]?[^\/\\]+$//;
|
$p =~ s/[\/\\]?[^\/\\]+$//;
|
||||||
unshift(@INC, "$p");
|
unshift(@INC, "$p");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use warnings;
|
||||||
|
use Cwd qw(abs_path);
|
||||||
use CheckURL;
|
use CheckURL;
|
||||||
use Try::Tiny;
|
use Try::Tiny;
|
||||||
use locale;
|
use locale;
|
||||||
use POSIX qw(locale_h);
|
use POSIX qw(locale_h);
|
||||||
|
|
||||||
setlocale(LC_CTYPE, "");
|
setlocale(LC_CTYPE, "");
|
||||||
setlocale(LC_MESSAGES, "en_US.UTF-8");
|
setlocale(LC_MESSAGES, "en_US.UTF-8");
|
||||||
|
|
||||||
|
use File::Temp qw/ tempfile tempdir /;
|
||||||
|
use File::Spec;
|
||||||
|
use Fcntl qw(:flock SEEK_END);
|
||||||
|
|
||||||
# Prototypes
|
# Prototypes
|
||||||
sub printNotUsedURLS($\%);
|
sub printNotUsedURLS($\%);
|
||||||
sub replaceSpecialChar($);
|
sub replaceSpecialChar($);
|
||||||
sub readUrls($\%);
|
sub readUrls($\%);
|
||||||
sub parse_file($ );
|
sub parse_file($ );
|
||||||
sub handle_url($$$ );
|
sub handle_url($$$ );
|
||||||
|
sub printx($$$$);
|
||||||
##########
|
##########
|
||||||
|
|
||||||
my %URLS = ();
|
my %URLS = ();
|
||||||
my %ignoredURLS = ();
|
my %ignoredURLS = ();
|
||||||
my %revertedURLS = ();
|
my %revertedURLS = ();
|
||||||
my %extraURLS = ();
|
my %extraURLS = ();
|
||||||
my %selectedURLS = ();
|
my %selectedURLS = ();
|
||||||
my %knownToRegisterURLS = ();
|
my %knownToRegisterURLS = ();
|
||||||
my $summaryFile = undef;
|
my $summaryFile = undef;
|
||||||
|
|
||||||
my $checkSelectedOnly = 0;
|
my $checkSelectedOnly = 0;
|
||||||
for my $arg (@ARGV) {
|
for my $arg (@ARGV) {
|
||||||
die("Bad argument \"$arg\"") if ($arg !~ /=/);
|
die("Bad argument \"$arg\"") if ($arg !~ /=/);
|
||||||
my ($type,$val) = split("=", $arg);
|
my ($type, $val) = split("=", $arg);
|
||||||
if ($type eq "filesToScan") {
|
if ($type eq "filesToScan") {
|
||||||
|
|
||||||
#The file should be a list of files to search in
|
#The file should be a list of files to search in
|
||||||
if (open(FLIST, $val)) {
|
if (open(FLIST, $val)) {
|
||||||
while (my $l = <FLIST>) {
|
while (my $l = <FLIST>) {
|
||||||
chomp($l);
|
chomp($l);
|
||||||
parse_file($l);
|
parse_file($l);
|
||||||
}
|
}
|
||||||
close(FLIST);
|
close(FLIST);
|
||||||
}
|
}
|
||||||
@ -102,7 +110,9 @@ for my $arg (@ARGV) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my @urls = sort keys %URLS, keys %extraURLS;
|
my @urls = sort keys %URLS, keys %extraURLS;
|
||||||
|
my @testvals = ();
|
||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
#my @urls = ("ftp://ftp.edpsciences.org/pub/aa/readme.html", "ftp://ftp.springer.de/pub/tex/latex/compsc/proc/author");
|
#my @urls = ("ftp://ftp.edpsciences.org/pub/aa/readme.html", "ftp://ftp.springer.de/pub/tex/latex/compsc/proc/author");
|
||||||
my $errorcount = 0;
|
my $errorcount = 0;
|
||||||
@ -126,57 +136,146 @@ for my $u (@urls) {
|
|||||||
if (defined($selectedURLS{$u})) {
|
if (defined($selectedURLS{$u})) {
|
||||||
${selectedURLS}{$u}->{count} += 1;
|
${selectedURLS}{$u}->{count} += 1;
|
||||||
}
|
}
|
||||||
next if ($checkSelectedOnly && ! defined($selectedURLS{$u}));
|
next if ($checkSelectedOnly && !defined($selectedURLS{$u}));
|
||||||
$URLScount++;
|
$URLScount++;
|
||||||
print "Checking '$u': ";
|
push(@testvals, {u => $u, use_curl => $use_curl,});
|
||||||
my ($res, $prnt, $outSum);
|
|
||||||
try {
|
|
||||||
$res = check_url($u, $use_curl);
|
|
||||||
if ($res) {
|
|
||||||
print "Failed\n";
|
|
||||||
$prnt = "";
|
|
||||||
$outSum = 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$prnt = "OK\n";
|
|
||||||
$outSum = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
$prnt = "Failed, caught error: $_\n";
|
|
||||||
$outSum = 1;
|
|
||||||
$res = 700;
|
|
||||||
};
|
|
||||||
printx("$prnt", $outSum);
|
|
||||||
my $printSourceFiles = 0;
|
|
||||||
my $err_txt = "Error url:";
|
|
||||||
|
|
||||||
if ($res || $checkSelectedOnly) {
|
|
||||||
$printSourceFiles = 1;
|
|
||||||
}
|
|
||||||
if ($res && defined($revertedURLS{$u})) {
|
|
||||||
$err_txt = "Failed url:";
|
|
||||||
}
|
|
||||||
$res = ! $res if (defined($revertedURLS{$u}));
|
|
||||||
if ($res || $checkSelectedOnly) {
|
|
||||||
printx("$err_txt \"$u\"\n", $outSum);
|
|
||||||
}
|
|
||||||
if ($printSourceFiles) {
|
|
||||||
if (defined($URLS{$u})) {
|
|
||||||
for my $f(sort keys %{$URLS{$u}}) {
|
|
||||||
my $lines = ":" . join(',', @{$URLS{$u}->{$f}});
|
|
||||||
printx(" $f$lines\n", $outSum);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($res ) {
|
|
||||||
$errorcount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Ready to go multitasking
|
||||||
|
my ($vol, $dir, $file) = File::Spec->splitpath($summaryFile);
|
||||||
|
my $tempdir = tempdir("$dir/CounterXXXXXXX", CLEANUP => 1);
|
||||||
|
my $countfile = "$tempdir/counter";
|
||||||
|
my $counter = 0;
|
||||||
|
if (open(my $FO, '>', $countfile)) {
|
||||||
|
print {$FO} $counter;
|
||||||
|
close($FO);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
unlink($countfile);
|
||||||
|
die("Could not write to $countfile");
|
||||||
|
}
|
||||||
|
|
||||||
|
print "Using tempdir \"" . abs_path($tempdir) . "\"\n";
|
||||||
|
|
||||||
|
my @wait = ();
|
||||||
|
for (my $i = 0; $i < 10; $i++) { # Number of subprocesses
|
||||||
|
my $pid = fork();
|
||||||
|
if ($pid == 0) {
|
||||||
|
|
||||||
|
# I am child
|
||||||
|
open(my $fe, '>:encoding(UTF-8)', "$tempdir/xxxError$i");
|
||||||
|
open(my $fs, '>:encoding(UTF-8)', "$tempdir/xxxSum$i");
|
||||||
|
while (1) {
|
||||||
|
open(my $fh, '+<', $countfile) or die("cannot open $countfile");
|
||||||
|
flock($fh, LOCK_EX) or die "$i: Cannot lock $countfile - $!\n";
|
||||||
|
my $l = <$fh>; # get actual count number
|
||||||
|
my $diff = undef;
|
||||||
|
if (defined($testvals[$l + 150])) {
|
||||||
|
$diff = 5;
|
||||||
|
}
|
||||||
|
elsif (defined($testvals[$l + 50])) {
|
||||||
|
$diff = 3;
|
||||||
|
}
|
||||||
|
elsif (defined($testvals[$l + 20])) {
|
||||||
|
$diff = 2;
|
||||||
|
}
|
||||||
|
elsif (defined($testvals[$l])) {
|
||||||
|
$diff = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
close($fs);
|
||||||
|
print $fe "NumberOfErrors $errorcount\n";
|
||||||
|
close($fe);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
my $next = $l + $diff;
|
||||||
|
seek($fh, 0, 0);
|
||||||
|
truncate($fh, 0);
|
||||||
|
print $fh $next;
|
||||||
|
close($fh);
|
||||||
|
for (my $i = 0; $i < $diff; $i++) {
|
||||||
|
my $entryidx = $l + $i;
|
||||||
|
my $rentry = $testvals[$entryidx];
|
||||||
|
next if (!defined($rentry));
|
||||||
|
my $u = $rentry->{u};
|
||||||
|
my $use_curl = $rentry->{use_curl};
|
||||||
|
|
||||||
|
print $fe "Checking($entryidx) '$u': ";
|
||||||
|
my ($res, $prnt, $outSum);
|
||||||
|
try {
|
||||||
|
$res = check_url($u, $use_curl, $fe, $fs);
|
||||||
|
if ($res) {
|
||||||
|
print $fe "Failed\n";
|
||||||
|
$prnt = "";
|
||||||
|
$outSum = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$prnt = "OK\n";
|
||||||
|
$outSum = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
$prnt = "Failed, caught error: $_\n";
|
||||||
|
$outSum = 1;
|
||||||
|
$res = 700;
|
||||||
|
};
|
||||||
|
printx("$prnt", $outSum, $fe, $fs);
|
||||||
|
my $printSourceFiles = 0;
|
||||||
|
my $err_txt = "Error url:";
|
||||||
|
|
||||||
|
if ($res || $checkSelectedOnly) {
|
||||||
|
$printSourceFiles = 1;
|
||||||
|
}
|
||||||
|
if ($res && defined($revertedURLS{$u})) {
|
||||||
|
$err_txt = "Failed url:";
|
||||||
|
}
|
||||||
|
$res = !$res if (defined($revertedURLS{$u}));
|
||||||
|
if ($res || $checkSelectedOnly) {
|
||||||
|
printx("$err_txt \"$u\"\n", $outSum, $fe, $fs);
|
||||||
|
}
|
||||||
|
if ($printSourceFiles) {
|
||||||
|
if (defined($URLS{$u})) {
|
||||||
|
for my $f (sort keys %{$URLS{$u}}) {
|
||||||
|
my $lines = ":" . join(',', @{$URLS{$u}->{$f}});
|
||||||
|
printx(" $f$lines\n", $outSum, $fe, $fs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($res) {
|
||||||
|
$errorcount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$wait[$i] = $pid;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (my $i = 0; $i < 10; $i++) {
|
||||||
|
my $p = $wait[$i];
|
||||||
|
if ($p > 0) {
|
||||||
|
waitpid($p, 0);
|
||||||
|
open(my $fe, '<', "$tempdir/xxxError$i");
|
||||||
|
while (my $l = <$fe>) {
|
||||||
|
if ($l =~ /^NumberOfErrors\s(\d+)/) {
|
||||||
|
$errorcount += $1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print $l;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close($fe);
|
||||||
|
open(my $fs, '<', "$tempdir/xxxSum$i");
|
||||||
|
while (my $l = <$fs>) {
|
||||||
|
print SFO $l;
|
||||||
|
}
|
||||||
|
close($fs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unlink($countfile);
|
||||||
|
|
||||||
if (%URLS) {
|
if (%URLS) {
|
||||||
printNotUsedURLS("Ignored", %ignoredURLS);
|
printNotUsedURLS("Ignored", %ignoredURLS);
|
||||||
printNotUsedURLS("Selected", %selectedURLS);
|
printNotUsedURLS("Selected", %selectedURLS);
|
||||||
printNotUsedURLS("KnownInvalid", %extraURLS);
|
printNotUsedURLS("KnownInvalid", %extraURLS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,124 +286,119 @@ if (defined($summaryFile)) {
|
|||||||
exit($errorcount);
|
exit($errorcount);
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
sub printx($$)
|
sub printx($$$$) {
|
||||||
{
|
my ($txt, $outSum, $fe, $fs) = @_;
|
||||||
my ($txt, $outSum) = @_;
|
print $fe "$txt";
|
||||||
print "$txt";
|
|
||||||
if ($outSum && defined($summaryFile)) {
|
if ($outSum && defined($summaryFile)) {
|
||||||
print SFO "$txt";
|
print $fs "$txt";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub printNotUsedURLS($\%)
|
sub printNotUsedURLS($\%) {
|
||||||
{
|
|
||||||
my ($txt, $rURLS) = @_;
|
my ($txt, $rURLS) = @_;
|
||||||
my @msg = ();
|
my @msg = ();
|
||||||
for my $u ( sort keys %{$rURLS}) {
|
for my $u (sort keys %{$rURLS}) {
|
||||||
if ($rURLS->{$u}->{count} < 2) {
|
if ($rURLS->{$u}->{count} < 2) {
|
||||||
my @submsg = ();
|
my @submsg = ();
|
||||||
for my $f (sort keys %{$rURLS->{$u}}) {
|
for my $f (sort keys %{$rURLS->{$u}}) {
|
||||||
next if ($f eq "count");
|
next if ($f eq "count");
|
||||||
push(@submsg, "$f:" . $rURLS->{$u}->{$f});
|
push(@submsg, "$f:" . $rURLS->{$u}->{$f});
|
||||||
}
|
}
|
||||||
push(@msg, "\n $u\n " . join("\n ", @submsg) . "\n");
|
push(@msg, "\n $u\n " . join("\n ", @submsg) . "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (@msg) {
|
if (@msg) {
|
||||||
print "\n$txt URLs not found in sources: " . join(' ',@msg) . "\n";
|
print "\n$txt URLs not found in sources: " . join(' ', @msg) . "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub replaceSpecialChar($)
|
sub replaceSpecialChar($) {
|
||||||
{
|
|
||||||
my ($l) = @_;
|
my ($l) = @_;
|
||||||
$l =~ s/\\SpecialChar(NoPassThru)?\s*(TeX|LaTeX|LyX)[\s]?/\2/;
|
$l =~ s/\\SpecialChar(NoPassThru)?\s*(TeX|LaTeX|LyX)[\s]?/\2/;
|
||||||
return($l);
|
return ($l);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub readUrls($\%)
|
sub readUrls($\%) {
|
||||||
{
|
|
||||||
my ($file, $rUrls) = @_;
|
my ($file, $rUrls) = @_;
|
||||||
|
|
||||||
die("Could not read file $file") if (! open(ULIST, $file));
|
die("Could not read file $file") if (!open(ULIST, $file));
|
||||||
my $line = 0;
|
my $line = 0;
|
||||||
while (my $l = <ULIST>) {
|
while (my $l = <ULIST>) {
|
||||||
$line++;
|
$line++;
|
||||||
$l =~ s/[\r\n]+$//; # remove eol
|
$l =~ s/[\r\n]+$//; # remove eol
|
||||||
$l =~ s/\s*\#.*$//; # remove comment
|
$l =~ s/\s*\#.*$//; # remove comment
|
||||||
$l = &replaceSpecialChar($l);
|
$l = &replaceSpecialChar($l);
|
||||||
next if ($l eq "");
|
next if ($l eq "");
|
||||||
my $use_curl = 0;
|
my $use_curl = 0;
|
||||||
if ($l =~ s/^\s*UseCurl\s*//) {
|
if ($l =~ s/^\s*UseCurl\s*//) {
|
||||||
$use_curl = 1;
|
$use_curl = 1;
|
||||||
}
|
}
|
||||||
if (! defined($rUrls->{$l} )) {
|
if (!defined($rUrls->{$l})) {
|
||||||
$rUrls->{$l} = {$file => $line, count => 1, use_curl => $use_curl};
|
$rUrls->{$l} = {$file => $line, count => 1, use_curl => $use_curl};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(ULIST);
|
close(ULIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub parse_file($)
|
sub parse_file($) {
|
||||||
{
|
my ($f) = @_;
|
||||||
my($f) = @_;
|
my $status = "out"; # outside of URL/href
|
||||||
my $status = "out"; # outside of URL/href
|
|
||||||
|
|
||||||
return if ($f =~ /\/attic\//);
|
return if ($f =~ /\/attic\//);
|
||||||
if(open(FI, $f)) {
|
if (open(FI, $f)) {
|
||||||
my $line = 0;
|
my $line = 0;
|
||||||
while(my $l = <FI>) {
|
while (my $l = <FI>) {
|
||||||
$line++;
|
$line++;
|
||||||
$l =~ s/[\r\n]+$//; # Simulate chomp
|
$l =~ s/[\r\n]+$//; # Simulate chomp
|
||||||
if ($status eq "out") {
|
if ($status eq "out") {
|
||||||
# searching for "\begin_inset Flex URL"
|
|
||||||
if($l =~ /^\s*\\begin_inset\s+Flex\s+URL\s*$/) {
|
# searching for "\begin_inset Flex URL"
|
||||||
$status = "inUrlInset";
|
if ($l =~ /^\s*\\begin_inset\s+Flex\s+URL\s*$/) {
|
||||||
}
|
$status = "inUrlInset";
|
||||||
elsif ($l =~ /^\s*\\begin_inset\s+CommandInset\s+href\s*$/) {
|
}
|
||||||
$status = "inHrefInset";
|
elsif ($l =~ /^\s*\\begin_inset\s+CommandInset\s+href\s*$/) {
|
||||||
}
|
$status = "inHrefInset";
|
||||||
else {
|
}
|
||||||
# Outside of url, check also
|
else {
|
||||||
if ($l =~ /"((ftp|http|https):\/\/[^ ]+)"/) {
|
# Outside of url, check also
|
||||||
my $url = $1;
|
if ($l =~ /"((ftp|http|https):\/\/[^ ]+)"/) {
|
||||||
handle_url($url, $f, "x$line");
|
my $url = $1;
|
||||||
}
|
handle_url($url, $f, "x$line");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if($l =~ /^\s*\\end_(layout|inset)\s*$/) {
|
if ($l =~ /^\s*\\end_(layout|inset)\s*$/) {
|
||||||
$status = "out";
|
$status = "out";
|
||||||
}
|
}
|
||||||
elsif ($status eq "inUrlInset") {
|
elsif ($status eq "inUrlInset") {
|
||||||
if ($l =~ /\s*([a-z]+:\/\/.+)\s*$/) {
|
if ($l =~ /\s*([a-z]+:\/\/.+)\s*$/) {
|
||||||
my $url = $1;
|
my $url = $1;
|
||||||
$status = "out";
|
$status = "out";
|
||||||
handle_url($url, $f, "u$line");
|
handle_url($url, $f, "u$line");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif ($status eq "inHrefInset") {
|
elsif ($status eq "inHrefInset") {
|
||||||
if ($l =~ /^target\s+"([a-z]+:\/\/[^ ]+)"$/) {
|
if ($l =~ /^target\s+"([a-z]+:\/\/[^ ]+)"$/) {
|
||||||
my $url = $1;
|
my $url = $1;
|
||||||
$status = "out";
|
$status = "out";
|
||||||
handle_url($url, $f, "h$line");
|
handle_url($url, $f, "h$line");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(FI);
|
close(FI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub handle_url($$$)
|
sub handle_url($$$) {
|
||||||
{
|
my ($url, $f, $line) = @_;
|
||||||
my($url, $f, $line) = @_;
|
|
||||||
|
|
||||||
$url = &replaceSpecialChar($url);
|
$url = &replaceSpecialChar($url);
|
||||||
if(!defined($URLS{$url})) {
|
if (!defined($URLS{$url})) {
|
||||||
$URLS{$url} = {};
|
$URLS{$url} = {};
|
||||||
}
|
}
|
||||||
if(!defined($URLS{$url}->{$f})) {
|
if (!defined($URLS{$url}->{$f})) {
|
||||||
$URLS{$url}->{$f} = [];
|
$URLS{$url}->{$f} = [];
|
||||||
}
|
}
|
||||||
push(@{$URLS{$url}->{$f}}, $line);
|
push(@{$URLS{$url}->{$f}}, $line);
|
||||||
|
@ -2040,7 +2040,9 @@ docstring const i18npreamble(docstring const & templ, Language const * lang,
|
|||||||
else if (ascii_fallback)
|
else if (ascii_fallback)
|
||||||
translated = to_ascii(testenc->latexString(name).first);
|
translated = to_ascii(testenc->latexString(name).first);
|
||||||
else
|
else
|
||||||
translated = "\\inputencoding{" + texenc + "}"
|
// We need to \protect this as it can end up in a moving argument
|
||||||
|
// (\lstlistlistingname in book classes goes to \@mkboth via \contentsname)
|
||||||
|
translated = "\\protect\\inputencoding{" + texenc + "}"
|
||||||
+ s1 + langenc + s2 + to_utf8(name)
|
+ s1 + langenc + s2 + to_utf8(name)
|
||||||
+ s1 + bufenc + s2;
|
+ s1 + bufenc + s2;
|
||||||
preamble = subst(preamble, sub.str(), translated);
|
preamble = subst(preamble, sub.str(), translated);
|
||||||
|
@ -346,7 +346,7 @@ bool FloatPlacement::checkWidgets(bool readonly) const
|
|||||||
if (readonly) {
|
if (readonly) {
|
||||||
floatTypeCO->setEnabled(false);
|
floatTypeCO->setEnabled(false);
|
||||||
placementCO->setEnabled(false);
|
placementCO->setEnabled(false);
|
||||||
aligmentGB->setEnabled(false);
|
alignmentGB->setEnabled(false);
|
||||||
spanCB->setEnabled(false);
|
spanCB->setEnabled(false);
|
||||||
sidewaysCB->setEnabled(false);
|
sidewaysCB->setEnabled(false);
|
||||||
} else
|
} else
|
||||||
|
@ -65,7 +65,7 @@
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="3">
|
<item row="1" column="3">
|
||||||
<widget class="QGroupBox" name="aligmentGB">
|
<widget class="QGroupBox" name="alignmentGB">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Alignment of Contents</string>
|
<string>Alignment of Contents</string>
|
||||||
</property>
|
</property>
|
||||||
@ -88,6 +88,16 @@
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QRadioButton" name="alignRightRB">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Right-align float contents</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&Right</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QRadioButton" name="alignDocDefaultRB">
|
<widget class="QRadioButton" name="alignDocDefaultRB">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
@ -98,13 +108,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QRadioButton" name="alignLeftRB">
|
<widget class="QRadioButton" name="alignClassDefaultRB">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Left-align float contents</string>
|
<string>Use the class' default alignment for floats, whatever it is.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Left</string>
|
<string>Class &Default</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -118,25 +128,28 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QRadioButton" name="alignRightRB">
|
<widget class="QRadioButton" name="alignLeftRB">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Right-align float contents</string>
|
<string>Left-align float contents</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Right</string>
|
<string>&Left</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="2" column="1">
|
||||||
<widget class="QRadioButton" name="alignClassDefaultRB">
|
<spacer name="horizontalSpacer_3">
|
||||||
<property name="toolTip">
|
<property name="orientation">
|
||||||
<string>Use the class' default alignment for floats, whatever it is.</string>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="sizeHint" stdset="0">
|
||||||
<string>Class &Default</string>
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
Loading…
Reference in New Issue
Block a user