Skip to content

Commit 7c7839d

Browse files
authored
Merge pull request #877 from drgrice1/probFileName-not-required
Don't require that probFileName be set.
2 parents c72bbc7 + 14907f0 commit 7c7839d

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

lib/PGalias.pm

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ sub initialize {
8282
my $self = shift;
8383
my $envir = $self->{envir};
8484

85-
$self->{pgFileName} = $envir->{probFileName};
85+
$self->{pgFileName} = $envir->{probFileName} // '';
8686
$self->{htmlDirectory} = $envir->{htmlDirectory};
8787
$self->{htmlURL} = $envir->{htmlURL};
8888
$self->{tempDirectory} = $envir->{tempDirectory};
@@ -111,8 +111,6 @@ sub check_parameters {
111111
my $self = shift;
112112

113113
# Problem specific data
114-
$self->warning_message('The path to the current problem file template probFileName is not defined.')
115-
unless $self->{pgFileName};
116114
$self->warning_message('The current problem set version number (psvn) is not defined')
117115
unless defined $self->{psvn};
118116
$self->warning_message('The displayMode is not defined') unless $self->{displayMode};
@@ -242,7 +240,7 @@ sub make_alias {
242240
################################################################################
243241

244242
warn "Error in the macro alias. Alias does not understand how to process files with extension $ext.
245-
(Path to problem file is " . $self->{envir}->{pgFileName} . ") ";
243+
(Path to problem file is " . $self->{pgFileName} . ") ";
246244
}
247245

248246
$self->warning_message(
@@ -296,11 +294,14 @@ sub alias_for_html {
296294
}
297295
my @aux_files_directories = @{ $self->{envir}->{$dirPath} };
298296

299-
# replace "." with the current pg question directory
300-
my $current_pg_directory = $self->directoryFromPath($pgFileName);
301-
$current_pg_directory = $self->{templateDirectory} . $current_pg_directory;
302-
@aux_files_directories = map { ($_ eq '.') ? $current_pg_directory : $_ } @aux_files_directories;
303-
#$self->debug_message("search directories", @aux_files_directories);
297+
if ($pgFileName) {
298+
# Replace "." with the current pg problem file directory.
299+
my $current_pg_directory = $self->directoryFromPath($pgFileName);
300+
$current_pg_directory = $self->{templateDirectory} . $current_pg_directory;
301+
@aux_files_directories = map { $_ eq '.' ? $current_pg_directory : $_ } @aux_files_directories;
302+
} else {
303+
@aux_files_directories = grep { $_ ne '.' } @aux_files_directories;
304+
}
304305

305306
# Find complete path to the original file
306307
my $file_path;
@@ -438,11 +439,14 @@ sub alias_for_tex {
438439
}
439440
my @aux_files_directories = @{ $self->{envir}->{$dirPath} };
440441

441-
# replace "." with the current pg question directory
442-
my $current_pg_directory = $self->directoryFromPath($pgFileName);
443-
$current_pg_directory = $self->{templateDirectory} . "/" . $current_pg_directory;
444-
@aux_files_directories = map { ($_ eq '.') ? $current_pg_directory : $_ } @aux_files_directories;
445-
#$self->debug_message("search directories", @aux_files_directories);
442+
if ($pgFileName) {
443+
# Replace "." with the current pg problem file directory.
444+
my $current_pg_directory = $self->directoryFromPath($pgFileName);
445+
$current_pg_directory = $self->{templateDirectory} . $current_pg_directory;
446+
@aux_files_directories = map { $_ eq '.' ? $current_pg_directory : $_ } @aux_files_directories;
447+
} else {
448+
@aux_files_directories = grep { $_ ne '.' } @aux_files_directories;
449+
}
446450

447451
# Find complete path to the original file
448452
my $file_path;

lib/PGresource.pm

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,8 @@ sub create_unique_id {
9595
$self->warning_message("unique id already exists for $fileName.");
9696
return $self->{unique_id};
9797
}
98-
$self->warning_message("auxiliary file $fileName missing resource path ") unless $self->path;
99-
$self->warning_message("auxiliary file $fileName missing parent pg file name") unless $self->{parent_file_id};
100-
$self->warning_message("auxiliary file $fileName missing problem psvn") unless $self->{parent_alias}->{psvn};
98+
$self->warning_message("auxiliary file $fileName missing resource path ") unless $self->path;
99+
$self->warning_message("auxiliary file $fileName missing problem psvn") unless $self->{parent_alias}->{psvn};
101100
$self->warning_message("auxiliary file $fileName missing unique_id_stub")
102101
unless $self->{parent_alias}->{unique_id_stub};
103102
my $unique_id_seed = $self->path() . $self->{parent_file_id} . $self->{id};

0 commit comments

Comments
 (0)