Pad input with null characters if it is not a multiple of 3.

PR:		bin/31156
MFC after:	1 week
This commit is contained in:
ru 2001-10-09 11:05:27 +00:00
parent 9c40d2f8d9
commit 48d3dbff31
2 changed files with 7 additions and 1 deletions

View File

@ -117,6 +117,12 @@ encode()
if (putchar(ch) == EOF)
break;
for (p = buf; n > 0; n -= 3, p += 3) {
/* Pad with nulls if not a multiple of 3. */
if (n < 3) {
p[2] = '\0';
if (n < 2)
p[1] = '\0';
}
ch = *p >> 2;
ch = ENC(ch);
if (putchar(ch) == EOF)

View File

@ -83,7 +83,7 @@ Character
The last line may be shorter than the normal 45 bytes.
If the size is not a multiple of 3, this fact can be determined
by the value of the count on the last line.
Extra garbage will be included to make the character count a multiple
Extra null characters will be included to make the character count a multiple
of 4.
The body is terminated by a line with a count of zero.
This line consists of one