[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: reasoning behind default of 5 for CCHARW_MAX
From: |
Thomas Dickey |
Subject: |
Re: reasoning behind default of 5 for CCHARW_MAX |
Date: |
Sat, 23 Nov 2019 20:33:40 -0500 |
User-agent: |
NeoMutt/20170113 (1.7.2) |
On Sat, Nov 23, 2019 at 05:24:14AM -0500, Nick Black wrote:
> Hello, friends in character cell UIs!
>
> Does anyone know the reasoning behind the default value of 5 for
> CCHARW_MAX? I'm aware that it can be changed (at the cost of
> breaking ABI compatibility) via --with-ccharw-max since NCURSES
> 5.7, but I can't figure out why 5 was originally chosen.
>
> I've checked X/Open Curses 4.2 (1996) and X/Open Curses 7
> (2009), but both simply say that cchar_t ought be able to hold
> an "implementation-defined" number of wchar_ts, without any
> further guidance that I can find. include/curses.head in a
> ncurses-6.1-20191019 checkout just restates material seen on
> the man page. Is there something I'm missing?
yes - see
https://pubs.opengroup.org/onlinepubs/7908799/xcurses/intov.html#tag_001_003_005
Implementations may limit the number of non-spacing characters that can
be associated with a spacing character, provided any limit is at least
5.
so actually it "should be" 6 in ncurses, not 5.
If this were 1999 rather than 2019, I'd change it.
At the moment, no (binary compatibility gets in the way,
and apparently the array size is big enough anyway).
AIX curses (since release 4...) has an array of 5 wchar_t's,
following a separate wchar_t, so they followed that.
HPUX (since release 10...) has an opaque structure of 28 bytes.
That seems to be consistent (4 bytes for attributes+color).
Solaris xpg4 (X/Open Curses) has single array of 6 wchar_t's
Here's the code from AIX's curses.h:
--------------------------------------------------------------------------------
#define ZLC_MOD_MAX 5
#define SETMCC(__wc) ((__wc).c = 0)
#define CLRMCC(win, __wc) ((__wc) = (win)->_bkgd)
#define ISMCC(__wc) ((__wc).c == 0)
#ifndef __cchar_t_
#define __cchar_t_
typedef struct {
attr_t a;
wchar_t c;
wchar_t z[ZLC_MOD_MAX];
} cchar_t;
#endif
--------------------------------------------------------------------------------
while ncurses had
--------------------------------------------------------------------------------
#define CCHARW_MAX 5
typedef
{
attr_t attr;
wchar_t chars[CCHARW_MAX];
}
cchar_t;
--------------------------------------------------------------------------------
My copy of the AIX header dates from 1996, but AIX 4 was initially
released in 1994. The X/Open Curses stuff would have been added to AIX
4 right around the time that (probably) Zeyd added the cchar_t
definition, and this would also have been a while (6 months or more)
before there was an X/Open Curses document to study free-of-charge
(i.e., by participating in a review).
In the AIX header, "c" is the spacing/base character, and "z" are the
possible non-spacing/zero-width characters. With the typical online
documentation at the time, the meaning of the two would have been too
obscure to do more than confuse. So we have "5" in ncurses.
Interesting enough, OSF1r4 had the same identical definition as AIX;
neither header mentions anything other than DEC and IBM, respectively.
--
Thomas E. Dickey <address@hidden>
https://invisible-island.net
ftp://ftp.invisible-island.net
signature.asc
Description: PGP signature