Bug 104585

Summary: ncurses compatibility broken
Product: [openSUSE] SUSE LINUX 10.0 Reporter: Jan Engelhardt <jengelh>
Component: ConsoleAppsAssignee: Petr Ostadal <postadal>
Status: VERIFIED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: dickey
Version: Beta 1   
Target Milestone: ---   
Hardware: x86   
OS: Linux   
Whiteboard:
Found By: Beta-Customer Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Testcase

Description Jan Engelhardt 2005-08-14 09:54:18 UTC
Take a SUSE 9.3 system and install the ncurses from 10.0 Beta 1.
Have UTF-8 enabled for vc (/dev/ttyX) and xterms.

vc will show ascii-style line drawings graphics for e.g. iptraf - this is
normal because ncurses is not that advanced yet. Under xterm, true line drawing
chars are printed. Ok, everything fine until here.

Install the ncurses.rpm from 10.0 Beta 1 and iptraf breaks under vc. All my
"locale" stuff is set to en_US.UTF-8. There is something strange going on, as
even gcc prints:

othptab.c:151: warning: pointer targets in passing argument 1 of ■convmacaddr■
differ in signedness

e.g. some blocks rather than ` and ' around convmacaddr. (When trying to
compile some broken app.)
Comment 1 Jan Engelhardt 2005-08-14 09:56:23 UTC
Installing the older ncurses-5.4-68 rpm from SUSE 9.3 again fixes all issues,
including the gcc one. Gcc then prints no quotes whatsoever around said
convmvaddr.
Comment 2 Dr. Werner Fink 2005-08-16 09:13:11 UTC
Do _not_ mix two different versions.  I'm not willingly to
switch back to the old ncurses version due to the fact that
the new one fixes several problems with UTF-8.  Please
recompile iptraf with the new ncurses version.
Comment 3 Jan Engelhardt 2005-08-18 14:36:16 UTC
I already did recompile it, that's why I posted this bug in the first place.

Software involved:
iptraf-2.7.0-192
ncurses-5.4-71
ncurses-devel-5.4-71
Comment 4 Dr. Werner Fink 2005-08-18 15:32:33 UTC
Hmm ... tell me, why I should switch back to the old
ncruses version.  It seems that iptraf is the only
one which shows this problem.  Even yast does not
have any problem.
Comment 5 Dr. Werner Fink 2005-08-18 15:38:10 UTC
Reasign it to the iptraf maintainer.  Btw: does iptraf uses
the wide character version of ncurses or the normal version?
Comment 6 Jan Engelhardt 2005-08-18 15:43:49 UTC
Reminder: I am using iptraf-2.7.0-192 (fresh from STABLE), and ncurses 5.4-71
(10.0 Beta 1), so no 9.3 issue.


Normal version. But at best, ncurses should automatically handle it if the
terminal is UTF-8 or not. It did that in the 9.3 rpm. This does not only affect
iptraf, but external stuff like http://hte.sf.net/ to name one more example.

What it does not affect is e.g. mc, but that uses slang on the other hand,
rather than ncurses.

The problem persists even if I make iptraf use -lncursesw.
Comment 7 Thomas Dickey 2005-08-28 00:20:33 UTC
The unpatched iptraf 2.7.0 doesn't initialize its locale.
Does SuSE's package fix that?  (I don't see how it would
work properly otherwise).
Comment 8 Jan Engelhardt 2005-08-28 11:30:39 UTC
I have never tried vanilla iptraf, only ever used the srpm from suse.
Comment 9 Thomas Dickey 2005-08-29 20:13:19 UTC
I took a look at iptraf-2.7.0-188.src.rpm, and it doesn't call
setlocale either in the original source or any of the patches.
Unless there's some common library that calls setlocale, it
won't work properly in a UTF-8 locale.
Comment 10 Jan Engelhardt 2005-09-03 17:27:27 UTC
Created attachment 48706 [details]
Testcase

If linked against ncurses-5.4-68, it prints a bar character at line 10. With
-71, it does not.

Linked against -lncurses; not -lncursesw. Though, BTW linking it against
ncursesw in -68 does not work either but I guess that's something different.
Comment 11 Thomas Dickey 2005-09-03 18:31:06 UTC
But if you add
   #include <locale.h>
and
    setlocale(LC_ALL, "");
it does work.  That is a consequence of this change in ncurses:
20040228
        + check for nl_langinfo(CODESET), use it if available (report by
          Stanislav Ievlev).
Before that change, ncurses would attempt to guess what locale one
should have initialized an application to.  I don't think there's a
way to have both old/new behavior supported.
Comment 12 Jan Engelhardt 2005-09-05 16:28:48 UTC
And how does it find out if the term is UTF8, if LC_ALL (implies
LC_MESSAGES/LC_CTYPE) is erased? Looking at the stty settings?
Anyway, some lot of ncurses apps need fixing. Close when done.
Comment 13 Thomas Dickey 2005-09-05 17:35:26 UTC
The call
    setlocale(LC_ALL, "");
tells the runtime libraries to look at the environment variables
to see what should be set.  It's not an ncurses problem: for several
years, the only recommendation for dealing with locale issues has been
for the application to set its locale properly.  There is _limited_
support for 8-bit character sets; UTF-8 does not fall into that class.
(If SuSE prefers to step backward 3-4 years and turn off the nl_langinfo
change, that's their choice ;-)
Comment 14 Jan Engelhardt 2005-09-11 08:01:06 UTC
Yes, it works again if I put setlocale(LC_ALL,"") in HTE.
Comment 15 Thomas Dickey 2005-09-12 20:50:13 UTC
thanks (report bugs).