summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtests/colcrtbin0 -> 14720 bytes
-rw-r--r--tests/expected/colcrt/regressions-hang13
-rw-r--r--tests/ts/colcrt/hang11
-rwxr-xr-xtests/ts/colcrt/regressions3
-rw-r--r--text-utils/colcrt.c7
5 files changed, 13 insertions, 1 deletions
diff --git a/tests/colcrt b/tests/colcrt
new file mode 100755
index 000000000..d8c792bca
--- /dev/null
+++ b/tests/colcrt
Binary files differ
diff --git a/tests/expected/colcrt/regressions-hang1 b/tests/expected/colcrt/regressions-hang1
new file mode 100644
index 000000000..cb16e46a3
--- /dev/null
+++ b/tests/expected/colcrt/regressions-hang1
@@ -0,0 +1,3 @@
+789:;<=>=>?IABUVNXYZ[ `abcdefgg !"#$%&'()*+,-./01234)*:,-./0123456789:;[=>?1234)*:,-./0123456789:;[=>?4456789:;<=>?IABUVN`abcdefg !"
+ -
+return value: 0
diff --git a/tests/ts/colcrt/hang1 b/tests/ts/colcrt/hang1
new file mode 100644
index 000000000..d26259e99
--- /dev/null
+++ b/tests/ts/colcrt/hang1
@@ -0,0 +1 @@
+789:;<=>=>?IABUVNXYZ[_`abcdefgg !"#$%&'()*+,-./01234)*:,-./0123456789:;[=>?1234)*:,-./0123456789:;[=>?4456789:;<=>?IABUVN`abcdefg !" $%&'()*+,-./0123z{|ü~e \ No newline at end of file
diff --git a/tests/ts/colcrt/regressions b/tests/ts/colcrt/regressions
index 067523f08..2ab751c36 100755
--- a/tests/ts/colcrt/regressions
+++ b/tests/ts/colcrt/regressions
@@ -23,12 +23,13 @@ ts_check_test_command "$TS_CMD_COLCRT"
check_input_file() {
ts_init_subtest ${1##*/}
- $TS_CMD_COLCRT < $1 > $TS_OUTPUT 2>&1
+ timeout 2 $TS_CMD_COLCRT < $1 > $TS_OUTPUT 2>&1
echo "return value: $?" >> $TS_OUTPUT
ts_finalize_subtest
}
check_input_file "$TS_SELF/crash1"
check_input_file "$TS_SELF/crash2"
+check_input_file "$TS_SELF/hang1"
ts_finalize
diff --git a/text-utils/colcrt.c b/text-utils/colcrt.c
index abe3a0768..62f84251a 100644
--- a/text-utils/colcrt.c
+++ b/text-utils/colcrt.c
@@ -152,6 +152,7 @@ static void colcrt(struct colcrt_control *ctl)
{
int col;
wint_t c;
+ long old_pos;
ctl->print_nl = 1;
if (ctl->half_lines)
@@ -161,7 +162,13 @@ static void colcrt(struct colcrt_control *ctl)
if (OUTPUT_COLS - 1 < col) {
output_lines(ctl, col);
errno = 0;
+ old_pos = ftell(ctl->f);
while ((c = getwc(ctl->f)) != L'\n') {
+ long new_pos = ftell(ctl->f);
+ if (old_pos == new_pos)
+ fseek(ctl->f, 1, SEEK_CUR);
+ else
+ old_pos = new_pos;
if (errno == 0 && c == WEOF)
return;
else