Skip to content

Commit

Permalink
base64 wip
Browse files Browse the repository at this point in the history
  • Loading branch information
aklomp committed Jan 28, 2024
1 parent 0456025 commit 6f52aaa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 3 additions & 2 deletions bin/base64.c
Expand Up @@ -247,11 +247,12 @@ static bool
write_wrapped (const struct config *config, char *buf, size_t len)
{
static size_t col = 0;
static char nl = '\x00';

// Special case: if buf is NULL, print final trailing newline.
if (buf == NULL) {
if (config->wrap > 0 && col > 0) {
return write_stdout(config, "\n", 1);
return write_stdout(config, &nl, 1);
}
return true;
}
Expand Down Expand Up @@ -287,7 +288,7 @@ write_wrapped (const struct config *config, char *buf, size_t len)

// If the line is full, append a newline.
if (col == config->wrap) {
if (iov_append(config, iov, &nvec, "\n", 1) == false) {
if (iov_append(config, iov, &nvec, &nl, 1) == false) {
return false;
}
col = 0;
Expand Down
3 changes: 1 addition & 2 deletions test/ci/issue137.sh
@@ -1,8 +1,7 @@
#!/bin/bash
set -xev

echo -ne "hello\nworld\n" > out.bin
xxd out.bin
echo -ne "hello\nworld\n" | xxd

wget https://github.com/aklomp/base64/files/14074869/in.bin.zip
unzip in.bin.zip
Expand Down

0 comments on commit 6f52aaa

Please sign in to comment.