Skip to content

Commit

Permalink
Fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
hason committed May 16, 2024
1 parent 53240a4 commit d8ea630
Show file tree
Hide file tree
Showing 62 changed files with 9,226 additions and 7,955 deletions.
32 changes: 16 additions & 16 deletions Build.pl
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@
use Module::Build;

my $build = Module::Build->new(
module_name => 'DivinumOfficium',
dist_version => 0,
dist_author => 'Divinum Officium',
module_name => 'DivinumOfficium',
dist_version => 0,
dist_author => 'Divinum Officium',
dist_abstract => 'Generates texts for the traditional Roman liturgy.',
requires => {
'perl' => '5.10.1',
'CGI' => 0,
'CGI::Carp' => 0,
'CGI::Cookie' => 0,
'Encode' => 0,
'File::Basename' => 0,
'FindBin' => 0,
'Time::Local' => 0,
'Test::Cmd' => 0,
'Test::Carp' => 0,
'DateTime' => 0,
'List::MoreUtils' => 0,
requires => {
'perl' => '5.10.1',
'CGI' => 0,
'CGI::Carp' => 0,
'CGI::Cookie' => 0,
'Encode' => 0,
'File::Basename' => 0,
'FindBin' => 0,
'Time::Local' => 0,
'Test::Cmd' => 0,
'Test::Carp' => 0,
'DateTime' => 0,
'List::MoreUtils' => 0,
},
);

Expand Down
50 changes: 21 additions & 29 deletions admin/bad1252.pl
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,28 @@

# Find files with narrowly undesired windows-1252 data

for my $file ( @ARGV )
{
local $/;
if ( open IN, "<$file" )
{
my $data = <IN>;
close IN;
for my $file (@ARGV) {
local $/;

if ( $data )
{
my @bads = $data =~ /([^\x{01}-\x{7e}\x{86}\x{87}\x{8A}\x{8C}\x{8E}\x{91}-\x{94}\x{96}\x{97}\x{9A}\x{9C}\x{9E}\x{9F}\x{AB}\x{AE}\x{BB}\x{BF}-\x{D6}\x{D8}-\x{F6}\x{F8}-\x{FF}])/g;
if (open IN, "<$file") {
my $data = <IN>;
close IN;

if ( @bads )
{
my %bads;
$bads{sprintf('0x%x',ord $_)} = 1 for @bads;
print "$file : ". join(',',keys %bads)
}
else
{
print "$file : clean";
}
}
else
{
print "$file : empty";
}
}
else
{
print "$file : can't read";
if ($data) {
my @bads = $data =~
/([^\x{01}-\x{7e}\x{86}\x{87}\x{8A}\x{8C}\x{8E}\x{91}-\x{94}\x{96}\x{97}\x{9A}\x{9C}\x{9E}\x{9F}\x{AB}\x{AE}\x{BB}\x{BF}-\x{D6}\x{D8}-\x{F6}\x{F8}-\x{FF}])/g;

if (@bads) {
my %bads;
$bads{sprintf('0x%x', ord $_)} = 1 for @bads;
print "$file : " . join(',', keys %bads);
} else {
print "$file : clean";
}
} else {
print "$file : empty";
}
} else {
print "$file : can't read";
}
}
84 changes: 44 additions & 40 deletions admin/corrects_french_typo.pl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use File::Copy;

sub Usage() {
print <<EOF;
print <<EOF;
$0 -h
$0 (read from STDIN)
$0 FILES
Expand All @@ -24,58 +24,62 @@ ()
exit 0;

sub Main {
return ConvertStream() unless @_;
return Usage() if ($_[0] =~ m/-h/);
ConvertFile($_) for (@_);
return ConvertStream() unless @_;
return Usage() if ($_[0] =~ m/-h/);
ConvertFile($_) for (@_);
}

sub ConvertFile($) {
my $filename = shift;
my $modified = 0;
say "Reading \"", $filename, "\"";
my ($tmpfh, $tmpfilename) = tempfile; binmode $tmpfh, ':utf8';
open my $fh, '<', $filename;
while (<$fh>) {
chomp;
$modified |= ConvertLine(1);
say $tmpfh $_;
}
close $fh;
close $tmpfh;
if ($modified) {
move $filename, $filename.".old";
move $tmpfilename, $filename;
say "corrected! Original file is \"", $filename.".old", "\"";
} else {
say "no error found!";
}
say ""; # newline
return $modified;
my $filename = shift;
my $modified = 0;
say "Reading \"", $filename, "\"";
my ($tmpfh, $tmpfilename) = tempfile;
binmode $tmpfh, ':utf8';
open my $fh, '<', $filename;

while (<$fh>) {
chomp;
$modified |= ConvertLine(1);
say $tmpfh $_;
}
close $fh;
close $tmpfh;

if ($modified) {
move $filename, $filename . ".old";
move $tmpfilename, $filename;
say "corrected! Original file is \"", $filename . ".old", "\"";
} else {
say "no error found!";
}
say ""; # newline
return $modified;
}

sub ConvertStream {
foreach (<STDIN>) {
ConvertLine(0);
print $_;
}
foreach (<STDIN>) {
ConvertLine(0);
print $_;
}
}

sub ConvertLine($) {
my $verbose = shift or 0;
my $modified = 0;
my $old = $_;
$modified |= s/'//g;
$modified |= s/O /Ô /g;
$modified |= s/(E|É)pitre/Épître/g;
$modified |= s/E(vangile|glise|pître)/É$1/g;
$modified |= s/ (:|;|!|\?)/ $1/g; # replace the usual space with a unbreakable space
print <<EOF
my $verbose = shift or 0;
my $modified = 0;
my $old = $_;
$modified |= s/'//g;
$modified |= s/O /Ô /g;
$modified |= s/(E|É)pitre/Épître/g;
$modified |= s/E(vangile|glise|pître)/É$1/g;
$modified |= s/ (:|;|!|\?)/ $1/g; # replace the usual space with a unbreakable space
print <<EOF
l. $.:
< $old
> $_
EOF
if $modified and $verbose;
return $modified;

if $modified and $verbose;
return $modified;
}

__END__
Loading

0 comments on commit d8ea630

Please sign in to comment.