]> diplodocus.org Git - nmh/blobdiff - sbr/base64.c
Document the changes made to mhshow.
[nmh] / sbr / base64.c
index 7ceb27b95759651d6bd36732d60904bb3150674d..2fbef4b002496960d38c697c93e248a13abb221b 100644 (file)
@@ -48,7 +48,15 @@ writeBase64aux (FILE *in, FILE *out, int crlf)
                     * everything down and push the last character back.
                     */
                    if (i == cc - 1) {
                     * everything down and push the last character back.
                     */
                    if (i == cc - 1) {
-                       ungetc('\n', in);
+                       /*
+                        * If we're at the end of the input, there might be
+                        * more room in inbuf; if so, add it there.  Otherwise
+                        * push it back to the input.
+                        */
+                       if (cc < sizeof(inbuf))
+                           inbuf[cc++] = '\n';
+                       else
+                           ungetc('\n', in);
                        skipnl = 1;
                    } else {
                        /* This only works as long as sizeof(inbuf) == 3 */
                        skipnl = 1;
                    } else {
                        /* This only works as long as sizeof(inbuf) == 3 */