gbranden pushed a commit to branch master
in repository groff.
commit 4b5984b9bc5eded79add69d4ba50017f4d0ef559
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Jul 4 10:57:08 2025 -0500
[gropdf]: Refactor/rename `OpenInc` subroutine.
* src/devices/gropdf/gropdf.pl (OpenInc): Rename this subroutine...
(OpenIncludedFile): ...to this. Also rename local scalars for
clarity, and give them clearer semantics. `fn` becomes `arg`, and is
the untransformed actual parameter passed in. Rename `fnm` to
`fileName`, which is used only when the subroutine performs a
transformation on `arg` (when it is not an absolute filespec, the code
tries to locate it by prefixing with elements of the `idirs` list).
(do_x): Update call site.
---
ChangeLog | 13 +++++++++++++
src/devices/gropdf/gropdf.pl | 26 +++++++++++++++-----------
2 files changed, 28 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index de39db4e4..56d482699 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2025-07-04 G. Branden Robinson <[email protected]>
+
+ * src/devices/gropdf/gropdf.pl: Refactor.
+ (OpenInc): Rename this subroutine...
+ (OpenIncludedFile): ...to this. Also rename local scalars for
+ clarity, and give them clearer semantics. `fn` becomes `arg`,
+ and is the untransformed actual parameter passed in. Rename
+ `fnm` to `fileName`, which is used only when the subroutine
+ performs a transformation on `arg` (when it is not an absolute
+ filespec, the code tries to locate it by prefixing with elements
+ of the `idirs` list).
+ (do_x): Update call site.
+
2025-07-04 G. Branden Robinson <[email protected]>
* src/devices/gropdf/gropdf.pl (do_x): Trivially refactor.
diff --git a/src/devices/gropdf/gropdf.pl b/src/devices/gropdf/gropdf.pl
index eff27bfff..74c49c085 100644
--- a/src/devices/gropdf/gropdf.pl
+++ b/src/devices/gropdf/gropdf.pl
@@ -1712,7 +1712,7 @@ sub do_x
my $info;
my $image;
- my ($FD,$fileName)=OpenInc($fil);
+ my ($FD,$fileName)=OpenIncludedFile($fil);
if (!defined($FD))
{
@@ -2453,33 +2453,37 @@ sub LoadSWF
return $xonm;
}
-sub OpenInc
+# Open file named in argument; if the file specification is not
+# absolute, resolve it by searching the include path constructed with
+# the `-I` option. Return a 2-list.
+# (file handle or undef, "resolved" file name)
+sub OpenIncludedFile
{
- my $fn=shift;
- my $fnm=$fn;
+ my $arg=shift;
+ my $fileName=undef;
my $F;
- if (substr($fnm,0,1) eq '/' or substr($fnm,1,1) eq ':') # dos
+ if (substr($arg,0,1) eq '/' or substr($arg,1,1) eq ':') # dos
{
- if (-r $fnm and open($F,"<$fnm"))
+ if (-r $arg and open($F,"<$arg"))
{
- return($F,$fnm);
+ return($F,$arg);
}
}
else
{
foreach my $dir (@idirs)
{
- $fnm="$dir/$fn";
+ $fileName="$dir/$arg";
- if (-r "$fnm" and open($F,"<$fnm"))
+ if (-r "$fileName" and open($F,"<$fileName"))
{
- return($F,$fnm);
+ return($F,$fileName);
}
}
}
- return(undef,$fn);
+ return(undef,$arg);
}
sub LoadPDF
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit