summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2019-08-13 18:30:05 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2019-08-13 18:30:05 (GMT)
commit1309ae35b1ff7ed26a3ccc2fcdc6bd13bb494cee (patch) (side-by-side diff)
tree6ea8a548ea90abff02d892ed9ff216c13211a89f
parent191c06630813efdda69a58eed2f65e0e07cd9727 (diff)
downloadruncap-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.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--runcap.c7
-rw-r--r--t/Makefile.am1
-rw-r--r--t/linemon02.at23
-rw-r--r--t/testsuite.at1
4 files changed, 32 insertions, 0 deletions
diff --git a/runcap.c b/runcap.c
index 6790dc4..5a09e55 100644
--- a/runcap.c
+++ b/runcap.c
@@ -143,6 +143,13 @@ stream_capture_get(struct stream_capture *cap, int *feof)
return -1;
}
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;
return 0;
} else
diff --git a/t/Makefile.am b/t/Makefile.am
index b41aa20..22786c0 100644
--- a/t/Makefile.am
+++ b/t/Makefile.am
@@ -49,6 +49,7 @@ TESTSUITE_AT = \
pipe.at\
linemon00.at\
linemon01.at\
+ linemon02.at\
seek00.at\
seek01.at
# Add more files here
diff --git a/t/linemon02.at b/t/linemon02.at
new file mode 100644
index 0000000..87ff0ea
--- a/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
@@ -25,6 +25,7 @@ m4_include([stdin.at])
m4_include([pipe.at])
m4_include([linemon00.at])
m4_include([linemon01.at])
+m4_include([linemon02.at])
m4_include([seek00.at])
m4_include([seek01.at])

Return to:

Send suggestions and report system problems to the System administrator.