Bug#824142: mtr 0.86 uses suboptimal colours in curses (patch attached)

2016-05-13 Thread Adam Conrad
On Fri, May 13, 2016 at 07:35:55AM +0200, Rogier Wolff wrote:
> 
> I'm really busy right now. But if there is a patch out there that I
> need to apply "upstream", let me know.

Nah, upstream looks sane, this was just a request for the Debian
maintainer to pull two upstream commits into his package.

... Adam



Bug#824142: mtr 0.86 uses suboptimal colours in curses (patch attached)

2016-05-12 Thread Rogier Wolff

Hi Adam, 

I'm really busy right now. But if there is a patch out there that I
need to apply "upstream", let me know.

Roger. 

On Thu, May 12, 2016 at 01:40:04PM -0600, Adam Conrad wrote:
> Package: mtr
> Version: 0.86-1
> Severity: normal
> Tags: patch
> User: ubuntu-de...@lists.ubuntu.com
> Usertags: origin-ubuntu yakkety ubuntu-patch
> 
> 
> 
> In Ubuntu, the attached patch was applied to achieve the following:
> 
>   * Pull commits from upstream to fix terminal colours (LP: #1581186)
> 
> As I note in the LP bug[1], this is hardly a critical issue, but it's
> been driving me nuts since 0.86 landed.  Stupidly, I went and learned
> curses and fixed it locally, which only then gave me the right search
> terms (mtr + use_default_colors) to get Google to point out that it
> was already fixed in upstream git.  So, I threw away my work, grabbed
> the upstream commits, and here we are.
> 
> Would be lovely for you to pick this up in the Debian package, so I
> can delete my recently-added delta from Ubuntu (and so Debian users
> can enjoy slightly less broken colours in mtr in unstable).
> 
> ... Adam
> 
> [1] https://bugs.launchpad.net/ubuntu/+source/mtr/+bug/1581186
> 
> -- System Information:
> Debian Release: stretch/sid
>   APT prefers yakkety
>   APT policy: (500, 'yakkety')
> Architecture: amd64 (x86_64)
> Foreign Architectures: i386
> 
> Kernel: Linux 4.4.0-21-lowlatency (SMP w/4 CPU cores; PREEMPT)
> Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
> Shell: /bin/sh linked to /bin/dash
> Init: systemd (via /run/systemd/system)

> diff -Nru mtr-0.86/debian/patches/color1.patch 
> mtr-0.86/debian/patches/color1.patch
> --- mtr-0.86/debian/patches/color1.patch  1969-12-31 17:00:00.0 
> -0700
> +++ mtr-0.86/debian/patches/color1.patch  2016-05-12 12:58:21.0 
> -0600
> @@ -0,0 +1,34 @@
> +commit 63a1f1493bfbaf7e55eb7e20b3791fc8b14cf92d
> +Author: Rogier Wolff 
> +Date:   Mon Dec 29 09:22:46 2014 +0100
> +
> +added use-default-colors...
> +
> +diff --git a/configure.ac b/configure.ac
> +index d5d1b0e..7199781 100644
> +--- a/configure.ac
>  b/configure.ac
> +@@ -34,6 +34,9 @@ AC_CHECK_FUNC(initscr, ,
> + AC_DEFINE(NO_CURSES, 1, Define if you don't have the curses libraries 
> available.)
> + CURSES_OBJ=
> + 
> ++AC_CHECK_LIB(ncurses, use_default_colors, 
> ++  AC_DEFINE(HAVE_USE_DEFAULT_COLORS, 1, [Define this if your curses library 
> has the use_default_colors() command.]))
> ++
> + AC_CHECK_FUNCS(attron fcntl)
> + 
> + AC_CHECK_LIB(m, floor, , AC_MSG_ERROR(No math library found))
> +diff --git a/curses.c b/curses.c
> +index 3904cb1..02b7937 100644
> +--- a/curses.c
>  b/curses.c
> +@@ -701,6 +701,9 @@ void mtr_curses_open(void)
> +   raw();
> +   noecho(); 
> +   start_color();
> ++#ifdef HAVE_USE_DEFAULT_COLORS
> ++  use_default_colors();
> ++#endif
> +   int i;
> +   for (i = 0; i < 8; i++)
> +   init_pair(i+1, i, 0);
> diff -Nru mtr-0.86/debian/patches/color2.patch 
> mtr-0.86/debian/patches/color2.patch
> --- mtr-0.86/debian/patches/color2.patch  1969-12-31 17:00:00.0 
> -0700
> +++ mtr-0.86/debian/patches/color2.patch  2016-05-12 12:58:21.0 
> -0600
> @@ -0,0 +1,30 @@
> +commit 7571201cf7a3394e0dcd2b037aba1836089cc084
> +Author: Narthorn 
> +Date:   Mon Oct 12 13:24:57 2015 +0200
> +
> +curses: Fix background transparency in terminal
> +
> +Patch comes from, and closes traviscross/mtr#72.
> +
> +diff --git a/curses.c b/curses.c
> +index 02b7937..f95f5d1 100644
> +--- a/curses.c
>  b/curses.c
> +@@ -700,13 +700,15 @@ void mtr_curses_open(void)
> +   initscr();
> +   raw();
> +   noecho(); 
> ++  int bg_col = 0;
> +   start_color();
> + #ifdef HAVE_USE_DEFAULT_COLORS
> +-  use_default_colors();
> ++  if (use_default_colors() == OK)
> ++bg_col = -1;
> + #endif
> +   int i;
> +   for (i = 0; i < 8; i++)
> +-  init_pair(i+1, i, 0);
> ++  init_pair(i+1, i, bg_col);
> + 
> +   mtr_curses_init();
> +   mtr_curses_redraw();
> diff -Nru mtr-0.86/debian/patches/series mtr-0.86/debian/patches/series
> --- mtr-0.86/debian/patches/series2015-12-07 12:49:27.0 -0700
> +++ mtr-0.86/debian/patches/series2016-05-12 12:58:41.0 -0600
> @@ -0,0 +1,2 @@
> +color1.patch
> +color2.patch


-- 
** r.e.wo...@bitwizard.nl ** http://www.BitWizard.nl/ ** +31-15-2600998 **
**Delftechpark 26 2628 XH  Delft, The Netherlands. KVK: 27239233**
*-- BitWizard writes Linux device drivers for any device you may have! --*
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.



Bug#824142: mtr 0.86 uses suboptimal colours in curses (patch attached)

2016-05-12 Thread Adam Conrad
Package: mtr
Version: 0.86-1
Severity: normal
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu yakkety ubuntu-patch



In Ubuntu, the attached patch was applied to achieve the following:

  * Pull commits from upstream to fix terminal colours (LP: #1581186)

As I note in the LP bug[1], this is hardly a critical issue, but it's
been driving me nuts since 0.86 landed.  Stupidly, I went and learned
curses and fixed it locally, which only then gave me the right search
terms (mtr + use_default_colors) to get Google to point out that it
was already fixed in upstream git.  So, I threw away my work, grabbed
the upstream commits, and here we are.

Would be lovely for you to pick this up in the Debian package, so I
can delete my recently-added delta from Ubuntu (and so Debian users
can enjoy slightly less broken colours in mtr in unstable).

... Adam

[1] https://bugs.launchpad.net/ubuntu/+source/mtr/+bug/1581186

-- System Information:
Debian Release: stretch/sid
  APT prefers yakkety
  APT policy: (500, 'yakkety')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.4.0-21-lowlatency (SMP w/4 CPU cores; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
diff -Nru mtr-0.86/debian/patches/color1.patch mtr-0.86/debian/patches/color1.patch
--- mtr-0.86/debian/patches/color1.patch	1969-12-31 17:00:00.0 -0700
+++ mtr-0.86/debian/patches/color1.patch	2016-05-12 12:58:21.0 -0600
@@ -0,0 +1,34 @@
+commit 63a1f1493bfbaf7e55eb7e20b3791fc8b14cf92d
+Author: Rogier Wolff 
+Date:   Mon Dec 29 09:22:46 2014 +0100
+
+added use-default-colors...
+
+diff --git a/configure.ac b/configure.ac
+index d5d1b0e..7199781 100644
+--- a/configure.ac
 b/configure.ac
+@@ -34,6 +34,9 @@ AC_CHECK_FUNC(initscr, ,
+ 	AC_DEFINE(NO_CURSES, 1, Define if you don't have the curses libraries available.)
+ 	CURSES_OBJ=
+ 
++AC_CHECK_LIB(ncurses, use_default_colors, 
++  AC_DEFINE(HAVE_USE_DEFAULT_COLORS, 1, [Define this if your curses library has the use_default_colors() command.]))
++
+ AC_CHECK_FUNCS(attron fcntl)
+ 
+ AC_CHECK_LIB(m, floor, , AC_MSG_ERROR(No math library found))
+diff --git a/curses.c b/curses.c
+index 3904cb1..02b7937 100644
+--- a/curses.c
 b/curses.c
+@@ -701,6 +701,9 @@ void mtr_curses_open(void)
+   raw();
+   noecho(); 
+   start_color();
++#ifdef HAVE_USE_DEFAULT_COLORS
++  use_default_colors();
++#endif
+   int i;
+   for (i = 0; i < 8; i++)
+   init_pair(i+1, i, 0);
diff -Nru mtr-0.86/debian/patches/color2.patch mtr-0.86/debian/patches/color2.patch
--- mtr-0.86/debian/patches/color2.patch	1969-12-31 17:00:00.0 -0700
+++ mtr-0.86/debian/patches/color2.patch	2016-05-12 12:58:21.0 -0600
@@ -0,0 +1,30 @@
+commit 7571201cf7a3394e0dcd2b037aba1836089cc084
+Author: Narthorn 
+Date:   Mon Oct 12 13:24:57 2015 +0200
+
+curses: Fix background transparency in terminal
+
+Patch comes from, and closes traviscross/mtr#72.
+
+diff --git a/curses.c b/curses.c
+index 02b7937..f95f5d1 100644
+--- a/curses.c
 b/curses.c
+@@ -700,13 +700,15 @@ void mtr_curses_open(void)
+   initscr();
+   raw();
+   noecho(); 
++  int bg_col = 0;
+   start_color();
+ #ifdef HAVE_USE_DEFAULT_COLORS
+-  use_default_colors();
++  if (use_default_colors() == OK)
++bg_col = -1;
+ #endif
+   int i;
+   for (i = 0; i < 8; i++)
+-  init_pair(i+1, i, 0);
++  init_pair(i+1, i, bg_col);
+ 
+   mtr_curses_init();
+   mtr_curses_redraw();
diff -Nru mtr-0.86/debian/patches/series mtr-0.86/debian/patches/series
--- mtr-0.86/debian/patches/series	2015-12-07 12:49:27.0 -0700
+++ mtr-0.86/debian/patches/series	2016-05-12 12:58:41.0 -0600
@@ -0,0 +1,2 @@
+color1.patch
+color2.patch