~aperezdc/dmon

f2df4ba1ff3ae8fef2d562aa8da2c349e5e7b68c — Matt Schulte 3 years ago d0ce7a0
Prevent logging from exiting on empty lines

Before this commit, `freadline` did not distinguish between an empty
line and EOF. This would case a printf such as

```
printf("\nHello, World\n");
```

to cause dlog, dslog, or drlog to exit.

In order to fix this, this commit includes the delimiter in the result
of `freaduntil`, which means `\n` will be included in all calls to
`freadline`.

Fixes #10
Fixes #12
3 files changed, 0 insertions(+), 3 deletions(-)

M dlog.c
M drlog.c
M util.c
M dlog.c => dlog.c +0 -1
@@ 139,7 139,6 @@ dlog_main (int argc, char **argv)
            }

            iov[n_iov++] = iov_from_buffer (&linebuf);
            iov[n_iov++] = iov_from_literal ("\n");

            assert ((unsigned) n_iov <= (sizeof (iov) / sizeof (iov[0])));


M drlog.c => drlog.c +0 -1
@@ 280,7 280,6 @@ recreate_ts:
    }

    iov[n_iov++] = iov_from_buffer (&line);
    iov[n_iov++] = iov_from_literal ("\n");
    assert ((unsigned) n_iov <= (sizeof (iov) / sizeof (iov[0])));

    for (;;) {

M util.c => util.c +0 -1
@@ 603,7 603,6 @@ freaduntil(int          fd,
            memmove (dbuf_data(overflow),
                     dbuf_data(overflow) + len,
                     dbuf_size(overflow));
            dbuf_resize(buffer, dbuf_size(buffer) - 1);
            return dbuf_size(buffer);
        }