Discussion:
[Dvipng] Bug#346181: dvipng distorts filenames with periods
t***@kky.ttu.ee
2006-01-06 08:22:06 UTC
Permalink
Package: dvipng
Version: 1.5-2

The dvipng tool makes strange changes into filenames which contain
periods.

Lets say, I have these two files to convert:
sample.dvi
sample3.22.dvi

The first filename causes no problems:
$ dvipng sample
or
$ dvipng sample.dvi

both produce sample1.png

The second filename, however, leads to different results depending on
whether the .dvi extension is included on the command line or not:

$ dvipng sample3.22

produces sample31.png
while

$ dvipng sample3.22.dvi

produces sample3.221.png

I think that both should produce sample3.221.png.

Actually I recommend that another separator, such as a dash, be placed
in front of the "1", producing sample3.22-1.png . This would allow for
more readable filenames for cases where the basename ends with a
digit.
--
Toomas Tamm e-mail: tt-deb (at) kky.ttu.ee
Chair of Inorganic Chemistry voice: INT+372-620-2810
Tallinn University of Technology fax: INT+372-620-2828
Ehitajate tee 5, EE-19086 Tallinn, Estonia http://www.kk.ttu.ee/toomas/
Jan-Åke Larsson
2006-01-09 08:49:03 UTC
Permalink
Post by t***@kky.ttu.ee
Package: dvipng
Version: 1.5-2
The dvipng tool makes strange changes into filenames which contain
periods.
sample.dvi
sample3.22.dvi
$ dvipng sample
or
$ dvipng sample.dvi
both produce sample1.png
The second filename, however, leads to different results depending on
$ dvipng sample3.22
produces sample31.png
while
$ dvipng sample3.22.dvi
produces sample3.221.png
I think that both should produce sample3.221.png.
Actually I recommend that another separator, such as a dash, be placed
in front of the "1", producing sample3.22-1.png . This would allow for
more readable filenames for cases where the basename ends with a
digit.
This bug is fixed as follows:
--- dvi.c~ Fri Feb 4 15:42:03 2005
+++ dvi.c Mon Jan 9 09:25:02 2006
@@ -124,7 +124,7 @@
}
strcpy(dvi->outname,basename(dviname));
tmpstring = strrchr(dvi->outname, '.');
- if (tmpstring != NULL)
+ if (tmpstring != NULL && strcmp(tmpstring,".dvi") == 0)
*tmpstring = '\0';
strcat(dvi->outname, "%d.png");
} else {

Regarding the separator between a numeric filename and page number,
tastes tend to differ as to what the separator should be. I'd recommend
using the -o switch in this case, as in

dvipng sample3.22 -o sample3.22-%d.png

which, incidentally, bypasses the bug you reported too.

I won't rerelease on account of this bug, but no doubt something else
will turn up.

Kind regards,
Jan-Åke
--
Some people, when confronted with a problem, think "I know, I'll use
regular expressions." Now they have two problems.
Loading...