[Bug-gs] ASCII85-Decoding: Wrong Odds??
Esther Bergter
Esther.Bergter@vipcomag.de
Mon, 14 Jan 2002 16:42:39 +0100
------------------------------------------------------------------------
Symptoms:
End of ASCII85 Strings is wrong.
Running the testfile attached, the result ist
"1. Bodyparu" (it should read "1. Bodypart")
and the line above is inhomogenous (' instead of -);
on hp-laserjet printer the file looks as expected, it reads "1.Bodypart"
------------------------------------------------------------------------
My fix is (sources from 5.5.5, file sfilter2.c)
private int
a85d_finish(int ccount, ulong word, stream_cursor_write * pw)
{
/* Assume there is enough room in the output buffer! */
byte *q = pw->ptr;
int status = EOFC;
switch (ccount) {
case 0:
break;
case 1: /* syntax error */
status = ERRC;
break;
case 2: /* 1 odd byte */
//word = word * (85L * 85 * 85) + 0xffffffL;
word = word * (85L * 85 * 85) + 0x0L;
goto o1;
case 3: /* 2 odd bytes */
//word = word * (85L * 85) + 0xffffL;
word = word * (85L * 85) + 0x0L;
goto o2;
case 4: /* 3 odd bytes */
//word = word * 85 + 0xffL;
word = word * 85 + 0x0L;
q[3] = (byte) (word >> 8);
o2: q[2] = (byte) (word >> 16);
o1: q[1] = (byte) (word >> 24);
q += ccount - 1;
pw->ptr = q;
}
return status;
}
------------------------------------------------------------------------
Remark: Postscript Language Reference Manual reads in 3.13 (cited)
If the ASCII85Encode filter is closed when the number of characters written
to it is not a multiple of 4 (...) Given n (1,2, or 3) bytes of binary data,
it first appends 4-n zero bytes ....
(end of citation)
So, when decoding, why are there added n 0xff ?
On the other hand, I don't believe, my customer is the first on earth
testing ascii85.
I'm afraid, I missed the clue. Is there an encoding error in the teststring
(which I can't help) or some other switches?
------------------------------------------------------------------------
Ghostscript version (or include output from "gs -h"):
versions 4.0.3, 5.5.5, 6.5.0 as sources, 6.5.2 as compiled exe
------------------------------------------------------------------------
Where you got Ghostscript:
downloads from artifex server ; gs652w32.exe downloaded (today) from
wisc.edu mirror
------------------------------------------------------------------------
Hardware system you are using (including printer model if the problem
involves printing):
same error on NT and SunOS sparc
------------------------------------------------------------------------
Operating system you are using:
Windows 2000 / Sun 5.7
------------------------------------------------------------------------
If you are using X Windows, and your problem involved output to the screen,
the output from running xdpyinfo and xwininfo:
------------------------------------------------------------------------
C compiler you are using, including its version, if you compiled Ghostscript
yourself:
cl on NT ; gcc 2.95.1 on Sun
------------------------------------------------------------------------
If you compiled Ghostscript yourself, changes you made to the makefiles:
lots, to include in our software.
(as the native executable reproduces same error, I don't think this helps
further)
------------------------------------------------------------------------
Environment variables: GS_DEVICE GS_FONTPATH GS_LIB GS_OPTIONS
installed gswin32 using self-extractor
------------------------------------------------------------------------
Command line:
gs demo1.PS (or alike on NT)
(especially, the error does not depend on some special device, it occurs
also on the built-in default device using gswin32).
------------------------------------------------------------------------
URL or FTP location of test files (include the data at the end of this form
if 500K or less):
%!PS-
%%DocumentFonts: atend
%%Creator: SAPscript, SAP R/3 rel.5.0A
%%Minimized to demonstrate error
%%EndComments
/Courier findfont 10 scalefont setfont
save
100 500 moveto
%% this should read 1.Bodypart
<~0eOS8De+-4@<-H~> show
100 600 moveto
%% the line is inhomogenous
<~?XI/I?XI/I?XI/I?XI/I?XI/I?XI/I?XI/I?XI/I?XI/I?XI/I?XI/I?XI/I?O~> show
<~?XI/I?XI/I?XI/I?XI/I?XI/I?XI/~> show
showpage
restore
%%Trailer
%%DocumentFonts:
%%+Courier
%%Pages: 1
----------------------------------------------
Regards,
Esther Bergter
VIPcom GmbH
Rüdesheimer Str.7
80686 München
Esther.Bergter@vipcomag.de
Fax: +49 89 54750 226
Tel. +49 89 54750 126