Bug 274472 - bsddialog and PuTTY shows garbled graphics
Summary: bsddialog and PuTTY shows garbled graphics
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 14.0-STABLE
Hardware: Any Any
: --- Affects Only Me
Assignee: Alfonso S. Siciliano
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-14 22:08 UTC by Daniel Engberg
Modified: 2023-12-16 15:44 UTC (History)
3 users (show)

See Also:


Attachments
Screenshot (6.91 KB, image/png)
2023-10-14 22:08 UTC, Daniel Engberg
no flags Details
ncurses borders with wide chars in putty (12.55 KB, image/png)
2023-11-04 14:52 UTC, Alfonso S. Siciliano
no flags Details
screenshot (10.35 KB, image/png)
2023-11-22 06:39 UTC, jakub_lach
no flags Details
test 1 (6.22 KB, image/png)
2023-11-23 20:12 UTC, jakub_lach
no flags Details
test 2 (6.20 KB, image/png)
2023-11-23 20:12 UTC, jakub_lach
no flags Details
test 3 (9.65 KB, image/png)
2023-11-23 20:13 UTC, jakub_lach
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Engberg freebsd_committer freebsd_triage 2023-10-14 22:08:14 UTC
Created attachment 245623 [details]
Screenshot

FreeBSD 14.0-RC1

ENV:
LANG=C.UTF-8
MM_CHARSET=UTF-8
TERM=xterm

PuTTY:
Window --> Translation --> Remove character set: UTF-8

How to reproduce:
bsddialog --msgbox plop 0 0

Workaround:
Enable Window --> Translation --> "Enable VT100 line drawing even in UTF-8 mode"
Comment 1 Alfonso S. Siciliano freebsd_committer freebsd_triage 2023-10-16 10:35:06 UTC
Thank you for the report and the screenshot.

The problem is quite obvious looking at the image. The environment does not print unicode chars to draw borders.

Probably `--ascii-lines` could avoid the garbled graphics:
% bsddialog --ascii-lines --msgbox plop 0 0

In reality bsddialog does not handle the graphics, it is handled by ncurses. Precisely bsddialog uses ncurses API to print characters, strings, change colors and move the cursor. The "garbled graphics" are unicode charachters to print lines (used to implement the borders of a dialog).

I' ll search a computer with Windows/putty to try to reproduce the problem. Anyway we can start the investigation.

Scenario 1.
I suspect some problem with ncurses <-> putty. It is a well known problem, many discussions exist online:
 - with an easy solution https://www.suse.com/support/kb/doc/?id=000018370
 - with a comment by the ncurses maintainer https://stackoverflow.com/questions/37845244/acs-characters-not-working-in-putty-even-with-export-ncurses-no-utf8-acs-1
 - another with the ncurses maintainer https://stackoverflow.com/questions/29955575/how-to-support-extended-curses-characters-with-putty
 - and so on...

Could you try some solution online?

Scenario 2.
bsddialog has some problem. Please could you show the output:
% bsddialog --version
% /usr/bin/bsddialog --version
% /usr/local/bin/bsddialog --version

and the output of an easy test:
% fetch https://gitlab.com/alfix/freebsd-lab/-/raw/main/ncurses_unicode_test.c
% cc -D_XOPEN_SOURCE_EXTENDED ncurses_unicode_test.c -o ncurses_unicode_test -lncursesw
% ./ncurses_unicode_test

(Actually the last test does not use bsddialog, only ncurses, so we can understand the origin of the problem).

Alfonso
Comment 2 Daniel Engberg freebsd_committer freebsd_triage 2023-10-16 20:47:31 UTC
Hi,

Running "bsddialog --ascii-lines --msgbox plop 0 0" works, bapt replicated this by running putty (https://www.freshports.org/security/putty/) on FreeBSD too.

This occurs on both 13.2 and 14.0 using a fresh checkout of the ports tree

I just want to point out that this worked before switching and is probably something we want to fix before 14 gets released.

Best regards,
Daniel
Comment 3 Alfonso S. Siciliano freebsd_committer freebsd_triage 2023-10-27 13:40:21 UTC
I created a review to upload some screenshot and to find the better solution, review D42380.
Comment 4 Alfonso S. Siciliano freebsd_committer freebsd_triage 2023-11-04 14:52:54 UTC
Created attachment 246112 [details]
ncurses borders with wide chars in putty

I can use wide chars instead of utf8 to draw borders. This avoids runtime settings like "env NCURSES_NO_UTF8_ACS=1" and putty: "Window -> Translation -> [X] Enable VT100 line drawing even in UTF-8 mode".

Tested witn ncurses in Current 15.0 (below) and putty (screenshoot).

#include <curses.h>
#include <locale.h>
#include <err.h>
#include <stdlib.h>

/*
 * % cc -D_XOPEN_SOURCE_EXTENDED ncurses-acs-test.c -o ncurses-acs-test -lncursesw
 * % ./ncurses-acs-test
*/

int main()
{
	int u8;
	char *locale;

	if ((locale = setlocale(LC_ALL, "")) == NULL)
		err(1, "Cannot set locale");
	/* init ncurses */
	if (initscr() == NULL)
		errx(1, "Cannot init curses (initscr)\n");

	/* testing */
	box_set(stdscr, 0,0); /* uses WACS_  (wide chars) */
	//box(stdscr, 0, 0);  /* uses ACS_  (UTF8 chars) */
	mvaddstr(1, 2, "Testing Line-drawing");

	mvaddstr(3, 3, "locale and ncurses.");
	mvprintw(4, 4, "1) locale: %s.", locale);
	mvprintw(5, 4, "2) ncurses version: %s, %d.", NCURSES_VERSION, NCURSES_VERSION_PATCH);
	u8 = tigetnum("U8");
	mvprintw(6, 4, "3) U8 cap: %d, TERM: %s", u8, getenv("TERM"));

	mvaddstr(9, 3, "Unicode chars.");
	mvaddstr(10, 4, "1) locale encode: あいうえお");
	mvaddstr(11, 4, "2) Unicode chars border (ACS_*): ");
	addch(ACS_VLINE); addch(' ');
	addch(ACS_HLINE); addch(' ');
	addch(ACS_ULCORNER); addch(' ');
	addch(ACS_URCORNER); addch(' ');
	addch(ACS_LRCORNER); addch(' ');
	addch(ACS_LLCORNER); addch(' ');
	addch(ACS_RTEE); addch(' ');
	addch(ACS_LTEE); addch(' ');

	mvaddstr(13, 3, "Wide chars.");
	mvaddwstr(14, 4, L"1) wchar: あいうえお");
	mvaddstr(15, 4, "2) Wide chars border (WACS_*): ");
	add_wch(WACS_VLINE); addch(' ');
	add_wch(WACS_HLINE); addch(' ');
	add_wch(WACS_ULCORNER); addch(' ');
	add_wch(WACS_URCORNER); addch(' ');
	add_wch(WACS_LRCORNER); addch(' ');
	add_wch(WACS_LLCORNER); addch(' ');
	add_wch(WACS_RTEE); addch(' ');
	add_wch(WACS_LTEE); addch(' ');

	/* refresh and exit */
	mvaddstr(20, 2, "Thank you to test <Press a Key to close> ");
	refresh();
	getch();
	endwin();

	return (0);
}
Comment 5 Daniel Engberg freebsd_committer freebsd_triage 2023-11-04 15:23:43 UTC
Oh, that looks nice!
Comment 6 commit-hook freebsd_committer freebsd_triage 2023-11-17 18:56:56 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=fb4e7422ac7a5e21b497763b301353a066dcd135

commit fb4e7422ac7a5e21b497763b301353a066dcd135
Author:     Alfonso S. Siciliano <asiciliano@FreeBSD.org>
AuthorDate: 2023-11-17 18:45:21 +0000
Commit:     Alfonso S. Siciliano <asiciliano@FreeBSD.org>
CommitDate: 2023-11-17 18:55:58 +0000

    devel/bsddialog: Update to 1.0.1

    Changes:        https://gitlab.com/alfix/bsddialog/-/blob/main/CHANGELOG

    PR:             275134 274472
    Approved by:    fernape

 devel/bsddialog/Makefile  | 3 ++-
 devel/bsddialog/distinfo  | 6 +++---
 devel/bsddialog/pkg-plist | 2 +-
 3 files changed, 6 insertions(+), 5 deletions(-)
Comment 7 jakub_lach 2023-11-21 20:27:00 UTC
(In reply to commit-hook from comment #6)

I had problems with some of the dialogs since Nov (?), now I get "â"s in place of borders in make config in (xterm/terminus).
Comment 8 jakub_lach 2023-11-21 20:29:46 UTC
(In reply to jakub_lach from comment #7)

| Testing unicode ncurses.                                                            |
|                                                                                     |
|  locale and ncurses.                                                                |
|   1) locale: pl_PL.ISO8859-2.                                                       |
|   2) ncurses version: 6.2, 20210220.                                                |
|   3) U8 cap: -2, TERM: xterm                                                        |
|                                                                                     |
|                                                                                     |
|  Unicode chars.                                                                     |
|   1) locale encode: ă~A~Bă~A~Dă~A~Fă~A~Hă~A~J                                       |
|   2) wchar:                                                                         |
|   3) Unicode border chars (ACS_*): | - + + + + + +                                  |
|                                                                                     |
| Thank you to test <Press a Key to close>
Comment 9 jakub_lach 2023-11-21 20:38:16 UTC
FreeBSD 14.0-STABLE #0 stable/14-ae8387cc8 amd64
Comment 10 jakub_lach 2023-11-22 06:39:21 UTC
Created attachment 246479 [details]
screenshot
Comment 11 jakub_lach 2023-11-22 06:40:01 UTC
(In reply to jakub_lach from comment #10)

To be precise, bsddialog --msgbox plop 0 0 works. Garbling is in portsconfig.
Comment 12 jakub_lach 2023-11-22 06:47:42 UTC
(In reply to jakub_lach from comment #11)

Without X, config dialogs work (though borders are different than earlier), but the colours are off (that is, different shades than used in X). 

Pre changes/problems, both in xterm in X and in pure console dialogs looked more or less the same.
Comment 13 Alfonso S. Siciliano freebsd_committer freebsd_triage 2023-11-23 10:38:15 UTC
Hello jakub_lach@mailplus.pl,

Thank you for the report.

So to recap:

> To be precise, bsddialog --msgbox plop 0 0 works. Garbling is in portsconfig.

Please could you show the output of:

% portconfig -v
Comment 14 jakub_lach 2023-11-23 12:53:34 UTC
(In reply to Alfonso S. Siciliano from comment #13)

$ portconfig -v
portconfig version: 0.6.1 (libbsddialog: 1.0.1).
Comment 15 Alfonso S. Siciliano freebsd_committer freebsd_triage 2023-11-23 19:50:17 UTC
(In reply to jakub_lach from comment #14)

I cannot reproduce the problem with fresh 14 RELEASE iso and 15 CURRENT iso installation in VM.
Are you using putty from ports? Did you deinstall devel/bsddialog and ports-mgmt/portconfig and reinstall them from ports?

The output of:
% bsddialog --version
% /usr/local/bin/bsddialog --version

And screenshots of:
test in the Comment 4
% /usr/bin/bsddialog --msgbox base r 0
% /usr/local/bin/bsddialog --msgbox PORT 0 0
Comment 16 jakub_lach 2023-11-23 20:12:35 UTC
Created attachment 246522 [details]
test 1
Comment 17 jakub_lach 2023-11-23 20:12:59 UTC
Created attachment 246523 [details]
test 2
Comment 18 jakub_lach 2023-11-23 20:13:29 UTC
Created attachment 246524 [details]
test 3
Comment 19 jakub_lach 2023-11-23 20:16:46 UTC
(In reply to Alfonso S. Siciliano from comment #15)

$ bsddialog --version
Version: 0.4

$ /usr/local/bin/bsddialog --version
Version: 1.0.1

I do not use putty, I did reinstall bsddialog from ports (was not installed) and portconfig before tests.

I use xterm and x11-fonts/terminus-font.
Comment 20 Alfonso S. Siciliano freebsd_committer freebsd_triage 2023-11-23 20:43:48 UTC
Ok bsddialog tests are right.

> I do not use putty, I did reinstall bsddialog from ports (was not installed) 

You should reinstall portconfig now (after bsddialog) and retest. Then I am sure it is using the right lib version and the problem is only for portconfig.

Anyway this PR is for putty and (lib)bsddialog, if portconfig continues with the error you could open a new PR.
Comment 21 Daniel Engberg freebsd_committer freebsd_triage 2023-12-16 15:44:53 UTC
Close this due to second submitter timeout. Please open a new PR if your issue persists.