Subject: Bad macros, locales (Was: Re: libedit 8bit clean)
To: None <current-users@NetBSD.ORG>
From: Jarda Dolecek <dolecek@ics.muni.cz>
List: current-users
Date: 02/27/1997 17:08:30
> > 
> > How much work would have to be done to enable %subj% ? I didn't looked
> > at sources yet, I don't want to try to do something impossible ;-)
> 
> You could always write new libedit from scratch :-)
> Just change every ED_UNASSIGNED to ED_INSERT in el_map_vi_insert[] in
> src/lib/libedit/map.c and compile with localized ctype.h (isprint and iscntrl
> will do).
> 

I have had to change it only for index >160 <255. This enables all
ISO-8859-X chars in vi mode (i.e. default one). Maybe it should be
done in original (-current) libedit too ?

The other thing I've encountered during trying to get it work:
the macros in <ctype.h> do evil things for 8bit (i.e. >127) chars. I
know the char tables in libc don't specify values for >127 chars
anyway, but ...

Consider isprint('\355') ( \355 is legal ISO 8859-{1|2} char - lowercase
i acute) Defines in <ctype.h> expand it to:

 ((_ctype_ + 1)['\355'] & (_P|_U|_L|_N|_B))

BUT - for compiler '\355' equals to -19, so the macro looks truly
like this:

((_ctype_ + 1)[-19] & (_P|_U|_L|_N|_B))
             ^^^^^^^^
I wouldn't expect this is what we want.

Every subject to any <ctype.h> macro have to be casted to unsigned
char to make it work correctly.

Should I send-pr it or am I just missing something ?

The second - is there any work underway to make locales work (or
better, be usable) ? I have looked at FreeBSD locales; it seems to
me a bit mixed, but code would be usable as a reasonable base.  I
would volunteer to try to get it work (as I would like to have
NetBSD even better than is now ;-), if anyone is interested and if
the work would have any chance to be accepted by core. For me,
I have hacked my libc's table and am satisfied ;-)

I have noticed one unclosed send-pr relative to this problem
(lib/2702, 1.2_BETA system). Oh, and lib/2309 too, it complains
about missing manpage to setlocale(3), it's from April 6, 1996.

Thanks in advance

-- 
Jaromir Dolecek             	ICS MU, Botanicka 68A, Brno, 60200, Czech Rep.
dolecek@ics.muni.cz			Tel.: +42-5-4151 2266
http://www.ics.muni.cz/~dolecek/
-------------------------------------------------------------------------------
It is better never to have been born.  But who among us has such luck?
One in a million, perhaps.