[l2h] re: 99.1 htmladdimg problem

Ross MOORE Ross MOORE <ross@ics.mq.edu.au>
Thu, 29 Jul 1999 10:42:52 +1000 (EST)


> On Fri March 8, Graham Gough reported:
> 
> > Since installing 99.1 beta (March 8, 1999) from the Bayreuth archive,
> > htmladdimg has stopped working. The following complete document worked
> > fine with 98.2b8 but produces no trace of the link when using 99.1
> >
> > \documentclass{article}
> > \usepackage{html}
> > \begin{document}
> > \htmladdimg{http://www.cs.man.ac.uk/logo.gif}
> > \end{document}
> 
> I've come across the same problem with 99.2alpha. A comparison with earlier
> known-to-work versions reveals a return where none had been previously in
> sub find_unique in latex2html(.pin)
> 
> sub find_unique {
>     local($image1) = @_;
>     local($imagedata,$image2,$result,$key);
>     local($/) = undef;
> 
>     if(open(IMG1,"<$image1")) {
>         $imagedata = <IMG1>;
>         close(IMG1);
>     } else {
>         print "\nError: Cannot read '$image1': $!\n";
>         return; 
> #       ^^^^^^

Shouldn't that line be:   return $image1;

>     }
>  
>     foreach $image2 (keys(%image_size)) {
> <etc, etc>
 
By returning early the 'foreach' loop is avoided; since
$imagedata was not set, then it can never match other images,
so nothing useful is done within the loop.
The result of the subroutine should be the same, we just get
there more quickly by exiting early. Yes ?


> Commenting this return out causes images to appear as they should, when
> referred to by a URL. There may be other effects and indeed this part of
> the sub could bear re-writing to prevent opening of such a file in the
> first place - or perhaps there should be an earlier test to prevent this
> sub from being called when dealing with an image that is referred to be
> URL?
 
It looks to me like someone (perhaps me) recognised the advantage 
in pulling out early, but forgot to set the return value.

The only other edit that I see as being desirable is to suppress
the  Error: message, when the filename starts with  http: .
Any other suggestions ?


Hope this helps,

	Ross Moore