[vorbis-tools] 01/01: Truncate long status lines on small terminals

Martin Steghöfer martin.steghoefer-guest at moszumanska.debian.org
Mon Dec 8 18:21:42 UTC 2014


This is an automated email from the git hooks/post-receive script.

martin.steghoefer-guest pushed a commit to branch master
in repository vorbis-tools.

commit c9620b1474b4db0e5bc42f7309e4ebb34f1fd0d6
Author: Martin Steghöfer <martin at steghoefer.eu>
Date:   Mon Dec 8 19:21:08 2014 +0100

    Truncate long status lines on small terminals
    
    Closes: #239073
---
 ...cate-long-status-lines-on-small-terminals.patch | 58 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 2 files changed, 59 insertions(+)

diff --git a/debian/patches/0010-Truncate-long-status-lines-on-small-terminals.patch b/debian/patches/0010-Truncate-long-status-lines-on-small-terminals.patch
new file mode 100644
index 0000000..c64f02f
--- /dev/null
+++ b/debian/patches/0010-Truncate-long-status-lines-on-small-terminals.patch
@@ -0,0 +1,58 @@
+From: =?utf-8?q?Martin_Stegh=C3=B6fer?= <martin at steghoefer.eu>
+Date: Mon, 8 Dec 2014 19:18:37 +0100
+Subject: Truncate long status lines on small terminals
+
+If the status line is longer than the number of columns of the terminal
+that stderr prints to, line-wrapping occurs and the mechanisms to
+overwrite the current line don't work any longer, thus filling the
+terminal with status lines. This can be avoided by checking the
+available size and truncating the line, if necessary. The truncation
+is indicated to the user via suspension points.
+
+Bug-Debian: https://bugs.debian.org/239073
+Forwarded: https://trac.xiph.org/ticket/1677#comment:1
+---
+ ogg123/status.c | 23 +++++++++++++++++++++++
+ 1 file changed, 23 insertions(+)
+
+diff --git a/ogg123/status.c b/ogg123/status.c
+index ccec389..8eb073a 100644
+--- a/ogg123/status.c
++++ b/ogg123/status.c
+@@ -24,6 +24,7 @@
+ #include <pthread.h>
+ 
+ #ifdef HAVE_UNISTD_H
++#include <sys/ioctl.h>
+ #include <unistd.h>
+ #endif
+ 
+@@ -166,6 +167,28 @@ int print_statistics_line (stat_format_t stats[])
+ 
+     stats++;
+   }
++  
++#ifdef HAVE_UNISTD_H
++  /* If the line would break in the console, truncate it to avoid the break,
++     and indicate the truncation by adding points of ellipsis */
++  struct winsize max;
++  int ioctlError = ioctl(STDERR_FILENO, TIOCGWINSZ, &max);
++  if (!ioctlError) {
++    const int limit = max.ws_col - 1;
++    if (len > limit) {
++      int pointsStart = limit - 3;
++      if (pointsStart < 0) {
++        pointsStart = 0;
++      }
++      int position;
++      for (position = pointsStart; position < limit; position++) {
++        str[position] = '.';
++      }
++      str[position] = 0;
++      len = position;
++    }
++  }
++#endif
+ 
+   len += sprintf(str+len, "\r");
+ 
diff --git a/debian/patches/series b/debian/patches/series
index 67d3016..8ab4e55 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -7,3 +7,4 @@
 0007-Fix-ogg123-freeze-when-interrupting-at-End-Of-Stream.patch
 0008-Make-it-clear-in-documentation-that-f-needs-a-previo.patch
 0009-Fix-oggenc-crash-on-closing-raw-input-files.patch
+0010-Truncate-long-status-lines-on-small-terminals.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-xiph/vorbis-tools.git



More information about the pkg-xiph-commits mailing list