diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2019-08-13 21:30:05 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2019-08-13 21:30:05 +0300 |
commit | 1309ae35b1ff7ed26a3ccc2fcdc6bd13bb494cee (patch) | |
tree | 6ea8a548ea90abff02d892ed9ff216c13211a89f | |
parent | 191c06630813efdda69a58eed2f65e0e07cd9727 (diff) | |
download | runcap-1309ae35b1ff7ed26a3ccc2fcdc6bd13bb494cee.tar.gz runcap-1309ae35b1ff7ed26a3ccc2fcdc6bd13bb494cee.tar.bz2 |
Pass the last line to the monitor even if it is not terminated with a newline
* runcap.c (stream_capture_get): Consume the last line even if it
is not terminated with a newline.
* t/linemon02.at: New test case.
* t/Makefile.am: Add new test.
* t/testsuite.at: Include new test.
-rw-r--r-- | runcap.c | 7 | ||||
-rw-r--r-- | t/Makefile.am | 1 | ||||
-rw-r--r-- | t/linemon02.at | 23 | ||||
-rw-r--r-- | t/testsuite.at | 1 |
4 files changed, 32 insertions, 0 deletions
@@ -145,2 +145,9 @@ stream_capture_get(struct stream_capture *cap, int *feof) if (rc == 0) { + if (cap->sc_linemon && cap->sc_level > cap->sc_cur) { + cap->sc_linemon(cap->sc_base + cap->sc_cur, + cap->sc_level - cap->sc_cur, + cap->sc_monarg); + cap->sc_cur = cap->sc_level; + cap->sc_nlines++; + } *feof = 1; diff --git a/t/Makefile.am b/t/Makefile.am index b41aa20..22786c0 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -51,2 +51,3 @@ TESTSUITE_AT = \ linemon01.at\ + linemon02.at\ seek00.at\ diff --git a/t/linemon02.at b/t/linemon02.at new file mode 100644 index 0000000..87ff0ea --- /dev/null +++ b/t/linemon02.at @@ -0,0 +1,23 @@ +AT_SETUP([line monitor, no trailing newline]) +AT_KEYWORDS([linemon linemon02.at]) +AT_CHECK([rt -m -- genout -l 31 $INPUT +], +[0], +[stdout: CHAPTER I. Down the Rabbit-Holeres=0 +exit code: 0 +stdout: 1 lines, 31 bytes +stderr: 0 lines, 0 bytes +]) + +AT_CHECK([rt -m -- genout -l 102 $INPUT +], +[0], +[stdout: CHAPTER I. Down the Rabbit-Hole +stdout: +stdout: Alice was beginning to get very tired of sitting by her sister on theres=0 +exit code: 0 +stdout: 3 lines, 102 bytes +stderr: 0 lines, 0 bytes +]) +AT_CLEANUP + diff --git a/t/testsuite.at b/t/testsuite.at index cdcec12..0c93340 100644 --- a/t/testsuite.at +++ b/t/testsuite.at @@ -27,2 +27,3 @@ m4_include([linemon00.at]) m4_include([linemon01.at]) +m4_include([linemon02.at]) m4_include([seek00.at]) |