[l2h] propose fix to missing ps file problem

De-Wei Yin De-Wei Yin <yin@asc.on.ca>
Mon, 22 Mar 1999 18:30:49 -0500

Hello All!

There have been a number of instances where users have reported problems
in which some (but not all) of the graphics (equations and figures) are
lost during the PS to GIF conversion step.  In one recent case reported by
Olaf Bachmann (1999 March 01), he noted the following: 

<begin quote>

- when TMP is set, then I frequently get errors like:
pstoimg: Cannot find file /home/obachman/tmp/l2h1445/image033.ps: No such
file or directory
Error while converting image: No such file or directory
while dvips is running. Whereas everything works fine, if TMP is not set.

<end quote>

I think I have found the source of this problem (in 98.1p1i;  I haven't
looked at other versions):  the problem seems to be the scalar context of
the readdir function that is used to obtain the names of the PS files
without the .ps extension in the file name.  The original latex2html
script has, starting at line 3293,

        opendir(DIR, $TMPDIR || '.');
        while ($_ = readdir(DIR)) {
          next unless (/^$IMAGE_PREFIX\d+$/o);
          rename("$TMPDIR$_", "$TMPDIR$_.ps");

which caused me to experience the same problem that Olaf Bachman reported
on my computer.  I guess Perl and the file system fell out of sync with
each other when the files were renamed!  When I changed these lines so
that readdir is used in a list context: 

        opendir(DIR, $TMPDIR || '.');
        @ALL_IMAGE_FILES = grep /^$IMAGE_PREFIX\d+$/o, readdir(DIR);
        foreach (@ALL_IMAGE_FILES) {
          rename("$TMPDIR$_", "$TMPDIR$_.ps");

the problem ceased to appear.  Of course, there are two other places in
the script with possibly the same problem (line 3205, line 7503).  Also,
the name of the @ALL_IMAGE_FILES array above is an arbitrary choice of
mine.  I suppose it should be a locally allocated array--I'll defer the
final correction and implementation to Ross Moore and the other

De-Wei (Dewey) Yin, MASc
Computational Fluid Dynamics Software Development
AEA Technology Engineering Software Limited
554 Parkside Drive Unit 4, Waterloo, Ontario, Canada  N2L 5Z4
Tel: +1-519-886-8435 x 223    Fax: +1-519-886-7580
E-Mail: yin@asc.on.ca