Skip to content

Commit

Permalink
code: incorporate do_io.pl in FileIO.pm
Browse files Browse the repository at this point in the history
  • Loading branch information
mbab committed Oct 24, 2024
1 parent cf08ec2 commit 5fe356e
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 54 deletions.
1 change: 0 additions & 1 deletion epub/Eofficium.pl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ package horas;
# 4= duplex majus, 5 = duplex II classis 6=duplex I classes 7=above 0=none

#*** collect standard items
require "$Bin/do_io.pl";
require "$Bin/../DivinumOfficium/SetupString.pl";
require "$Bin/horascommon.pl";
require "$Bin/dialogcommon.pl";
Expand Down
3 changes: 1 addition & 2 deletions standalone/tools/epubgen2/EofficiumXhtml.pl
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,10 @@ package main;
#*** collect standard items

#allow the script to be started directly from the "standalone/tools/epubgen2" subdirectory
if (!-e "$Bin/do_io.pl") {
if (!-e "$Bin/../DivinumOfficium/SetupString.pl") {
$Bin = "$Bin/../../../web/cgi-bin/horas";
}

require "$Bin/../DivinumOfficium/do_io.pl";
require "$Bin/../DivinumOfficium/SetupString.pl";
require "$Bin/horascommon.pl";
require "$Bin/../DivinumOfficium/dialogcommon.pl";
Expand Down
42 changes: 34 additions & 8 deletions web/cgi-bin/DivinumOfficium/FileIO.pm
Original file line number Diff line number Diff line change
@@ -1,19 +1,45 @@
package DivinumOfficium::FileIO;
use strict;
use warnings;
use utf8;

# Temporary measure: if we got here, the parent directory is on the library
# search path, so this will work.
BEGIN {

package DivinumOfficium::FileIO;
require "DivinumOfficium/do_io.pl";
}

# Text-based IO for Divinum Officium Project.
#
BEGIN {
require Exporter;
our $VERSION = 1.00;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(do_read do_write);
}

# do_read(filename)
#
# Read a data file, assumed to be text, and return array of its lines.
# Returns () if nothing can be read.
sub do_read($) {
my $file = shift;

if (open(INP, '<:encoding(UTF-8)', $file)) {
local $/; # Slurp
local ($_) = <INP>;
close INP;
s/^\x{FEFF}//;
split(/\r?\n/);
} else {
();
}
}

# do_write
# Now we're in charge. Write in utf-8, never mind.
sub do_write($@) {
my $file = shift;

if (open(OUT, ">:encoding(utf-8)", $file)) {
print OUT for @_;
close OUT;
return 1;
}
}
1;
1;
35 changes: 0 additions & 35 deletions web/cgi-bin/DivinumOfficium/do_io.pl

This file was deleted.

1 change: 0 additions & 1 deletion web/cgi-bin/horas/kalendar.pl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ package main;
our $smallblack;
our $smallfont;

require "$Bin/../DivinumOfficium/do_io.pl";
require "$Bin/../DivinumOfficium/SetupString.pl";
require "$Bin/horascommon.pl";
require "$Bin/../DivinumOfficium/dialogcommon.pl";
Expand Down
1 change: 0 additions & 1 deletion web/cgi-bin/horas/officium.pl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ package main;
binmode(STDOUT, ':encoding(utf-8)');

#*** collect standard items
require "$Bin/../DivinumOfficium/do_io.pl";
require "$Bin/../DivinumOfficium/SetupString.pl";
require "$Bin/horascommon.pl";
require "$Bin/../DivinumOfficium/dialogcommon.pl";
Expand Down
1 change: 0 additions & 1 deletion web/cgi-bin/horas/popup.pl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ package main;
our ($lang1, $lang2);

#*** collect standard items
require "$Bin/../DivinumOfficium/do_io.pl";
require "$Bin/../DivinumOfficium/SetupString.pl";
require "$Bin/horascommon.pl";
require "$Bin/../DivinumOfficium/dialogcommon.pl";
Expand Down
1 change: 0 additions & 1 deletion web/cgi-bin/missa/Cmissa.pl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ package main;

#*** collect standard items
#require "ordocommon.pl";
require "$Bin/../DivinumOfficium/do_io.pl";
require "$Bin/../DivinumOfficium/SetupString.pl";
require "$Bin/../horas/horascommon.pl";
require "$Bin/../DivinumOfficium/dialogcommon.pl";
Expand Down
3 changes: 1 addition & 2 deletions web/cgi-bin/missa/Emissa.pl
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,10 @@ package main;

#*** collect standard items
#allow the script to be started directly from the "standalone/tools/epubgen2" subdirectory
if (!-e "$Bin/../DivinumOfficium/do_io.pl") {
if (!-e "$Bin/../DivinumOfficium/SetupString.pl") {
$Bin = "$Bin/../../../web/cgi-bin/missa";
}

require "$Bin/../DivinumOfficium/do_io.pl";
require "$Bin/../DivinumOfficium/SetupString.pl";
require "$Bin/../horas/horascommon.pl";
require "$Bin/../DivinumOfficium/dialogcommon.pl";
Expand Down
1 change: 0 additions & 1 deletion web/cgi-bin/missa/missa.pl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ package main;

#*** collect standard items
#require "$Bin/ordocommon.pl";
require "$Bin/../DivinumOfficium/do_io.pl";
require "$Bin/../DivinumOfficium/SetupString.pl";
require "$Bin/../horas/horascommon.pl";
require "$Bin/../DivinumOfficium/dialogcommon.pl";
Expand Down
1 change: 0 additions & 1 deletion web/cgi-bin/missa/mpopup.pl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ package main;
require "$Bin/propers.pl";

#require "$Bin/ordocommon.pl";
require "$Bin/../DivinumOfficium/do_io.pl";
binmode(STDOUT, ':encoding(utf-8)');

#*** get parameters
Expand Down

0 comments on commit 5fe356e

Please sign in to comment.