Kaydet (Commit) 95612cc8 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Rework Ascii85Encoder::ConvertToAscii85 code somewhat

...making sure not to generate characters into the output that are ultimately
discarded again.  In preparation of eventually changing the output from a char
array to something more flexible like OStringBuffer.

Change-Id: I2fde3d02752d4e81ee1ee34188266e72d1d8b01d
Reviewed-on: https://gerrit.libreoffice.org/66528
Tested-by: Jenkins
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst 5de78478
......@@ -190,18 +190,26 @@ Ascii85Encoder::ConvertToAscii85 ()
else
{
/* real ascii85 encoding */
mpFileBuffer [mnOffset + 4] = (nByteValue % 85) + 33;
// Of the up to 5 characters to be generated, do not generate the last (4 - mnByte) ones
// that correspond to the (4 - mnByte) zero padding bytes added to the input:
if (mnByte == 4) {
mpFileBuffer [mnOffset + 4] = (nByteValue % 85) + 33;
}
nByteValue /= 85;
mpFileBuffer [mnOffset + 3] = (nByteValue % 85) + 33;
if (mnByte >= 3) {
mpFileBuffer [mnOffset + 3] = (nByteValue % 85) + 33;
}
nByteValue /= 85;
mpFileBuffer [mnOffset + 2] = (nByteValue % 85) + 33;
if (mnByte >= 2) {
mpFileBuffer [mnOffset + 2] = (nByteValue % 85) + 33;
}
nByteValue /= 85;
mpFileBuffer [mnOffset + 1] = (nByteValue % 85) + 33;
nByteValue /= 85;
mpFileBuffer [mnOffset + 0] = (nByteValue % 85) + 33;
// Ignore the last (4 - mnByte) generated characters that correspond to the (4 - mnByte)
// zero padding bytes:
mnColumn += (mnByte + 1);
mnOffset += (mnByte + 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment