groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 11/15: font/devpdf/util/BuildFoundries.pl: Fix fresh bug.


From: G. Branden Robinson
Subject: [groff] 11/15: font/devpdf/util/BuildFoundries.pl: Fix fresh bug.
Date: Fri, 3 Jun 2022 05:04:52 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 19f7a3562615f96a3ad8722d8083c73fa6988b75
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Thu Jun 2 21:23:13 2022 -0500

    font/devpdf/util/BuildFoundries.pl: Fix fresh bug.
    
    * font/devpdf/util/BuildFoundries.pl: Alter script to write to the
      standard output stream instead of (re)writing a file named "download"
      in the current working directory.  This recovers from a problem I
      introduced in commit 6e62be835d, 2 May, as an unforeseen side effect
      of improving build parallelism so that the "download" file wouldn't be
      read until it was fully populated.  As a side benefit, this approach
      is more Unixy, and less dependent on $PWD.
    
      (top level): Stop calling `WriteDownload` with an argument.
    
      (LoadFoundry): Close only the file handle of interest when done, not
      all of them (including `STDOUT`, which we now need).
    
      (CheckFoundry): Same--just for cleanliness, since at present running
      the script in 'check' mode doesn't write to any streams.
    
      (WriteDownload): Stop taking an argument and manipulating file
      handles.  Write download file to standard output.
    
      (LoadDownload, WriteDownload): Drop `top` scalar, used as a mutex to
      serialize read and write access to "download" file; it is no longer
      needed since the "download" file is now only read.
---
 ChangeLog                          | 21 +++++++++++++++++++++
 font/devpdf/util/BuildFoundries.pl | 25 ++++++++-----------------
 2 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ebbde841..08753363 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2022-06-02  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * font/devpdf/util/BuildFoundries.pl: Alter script to write to
+       the standard output stream instead of (re)writing a file named
+       "download" in the current working directory.  This recovers from
+       a problem I introduced in commit 6e62be835d, 2 May, as an
+       unforeseen side effect of improving build parallelism so that
+       the "download" file wouldn't be read until it was fully
+       populated.  As a side benefit, this approach is more Unixy, and
+       less dependent on $PWD.
+       (top level): Stop calling `WriteDownload` with an argument.
+       (LoadFoundry): Close only the file handle of interest when done,
+       not all of them (including `STDOUT`, which we now need).
+       (CheckFoundry): Same--just for cleanliness, since at present
+       running the script in 'check' mode doesn't write to any streams.
+       (WriteDownload): Stop taking an argument and manipulating file
+       handles.  Write download file to standard output.
+       (LoadDownload, WriteDownload): Drop `top` scalar, used as a
+       mutex to serialize read and write access to "download" file; it
+       is no longer needed since the "download" file is now only read.
+
 2022-06-01  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        [build]: Rename shell variables and Autoconf/Automake macros of
diff --git a/font/devpdf/util/BuildFoundries.pl 
b/font/devpdf/util/BuildFoundries.pl
index 7ddec1d2..9c9080e9 100644
--- a/font/devpdf/util/BuildFoundries.pl
+++ b/font/devpdf/util/BuildFoundries.pl
@@ -13,8 +13,8 @@
 # Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
 #
-# groff is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# groff is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 # for more details.
 #
@@ -49,7 +49,7 @@ else
 {
     LoadDownload("download"); # not required
     LoadFoundry("Foundry");
-    WriteDownload("download");
+    WriteDownload();
 }
 exit 0;
 
@@ -157,7 +157,7 @@ sub LoadFoundry
        }
     }
 
-    close();
+    close(F);
     Warn("\nThe path(s) used for searching:\n$foundrypath\n") if $notFoundFont;
 }
 
@@ -406,7 +406,6 @@ sub PutDownload
 sub LoadDownload
 {
     my $fn=shift;
-    my $top=1;
 
     return if !open(F,"<$fn");
 
@@ -415,7 +414,7 @@ sub LoadDownload
        chomp;
        s/\r$//;        # in case edited in windows
 
-       if ($top and substr($_,0,1) eq '#' or $_ eq '')
+       if (substr($_,0,1) eq '#' or $_ eq '')
        {
            # Preserve comments at top of download file
 
@@ -423,7 +422,6 @@ sub LoadDownload
            next;
        }
 
-       $top=0;
        s/\s*#.*?$//;   # remove comments
 
        next if $_ eq '';
@@ -439,20 +437,13 @@ sub LoadDownload
 
 sub WriteDownload
 {
-    my $fn=shift;
-    my $top=1;
-
-    open(F,">$fn") or Die("can't create new file '$fn'");
-
-    print F join("\n",@downloadpreamble),"\n";
+    print join("\n",@downloadpreamble),"\n";
 
     foreach my $k (sort keys %download)
     {
        my ($f,$ps)=split(/ /,$k);
-       print F "$f\t$ps\t$download{$k}\n";
+       print "$f\t$ps\t$download{$k}\n";
     }
-
-    close(F);
 }
 
 sub Notice {
@@ -545,5 +536,5 @@ sub CheckFoundry
        }
     }
 
-    close();
+    close(F);
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]