Two related things about PDC_wcwidth().
1. It isn't declared in a public header. The function is exported (PDCEX; nm shows T PDC_wcwidth), but declared only in curspriv.h, so a program linking against PDCursesMod has to declare the prototype itself.
This matters most on Windows, where the C runtime has no wcwidth() at all, so PDC_wcwidth() is the only implementation available in the process. A binding that needs to tell a spacing character from a zero-width combining mark — to validate setcchar() input, say — has to carry its own copy. Python's curses module is gaining PDCursesMod support and currently vendors ~120 lines of Markus Kuhn's wcwidth() for the Windows build, duplicating what the library already has and exports. Declaring the existing symbol in curses.h would let consumers drop that.
2. With PDC_FORCE_UTF8, deferring to the system wcwidth() looks wrong. HAVE_WCWIDTH is chosen from __linux + _XOPEN_SOURCE alone, independently of PDC_FORCE_UTF8. HISTORY.md gives the reasoning:
On Linux, we use the system-provided wcwidth() instead of our own. Aside from avoiding redundant code, this may help in non-Unicode locales (our wcwidth() is for Unicode only).
That reasoning holds for a locale-driven build, but PDC_FORCE_UTF8 means the library encodes cells as UTF-8 whatever the locale says — so classification should be Unicode-based too. Built WIDE=Y UTF8=Y with -D_XOPEN_SOURCE=700, under uk_UA.koi8u:
U+0301 (combining acute): wcwidth() = -1, PDC_wcwidth() = -1
The same library in a UTF-8 locale returns 0. Would it make sense for PDC_FORCE_UTF8 to select the built-in Unicode table regardless of platform?
(PDCursesMod 4.5.4, vt port, Linux.)
Two related things about
PDC_wcwidth().1. It isn't declared in a public header. The function is exported (
PDCEX;nmshowsT PDC_wcwidth), but declared only incurspriv.h, so a program linking against PDCursesMod has to declare the prototype itself.This matters most on Windows, where the C runtime has no
wcwidth()at all, soPDC_wcwidth()is the only implementation available in the process. A binding that needs to tell a spacing character from a zero-width combining mark — to validatesetcchar()input, say — has to carry its own copy. Python'scursesmodule is gaining PDCursesMod support and currently vendors ~120 lines of Markus Kuhn'swcwidth()for the Windows build, duplicating what the library already has and exports. Declaring the existing symbol incurses.hwould let consumers drop that.2. With
PDC_FORCE_UTF8, deferring to the systemwcwidth()looks wrong.HAVE_WCWIDTHis chosen from__linux+_XOPEN_SOURCEalone, independently ofPDC_FORCE_UTF8.HISTORY.mdgives the reasoning:That reasoning holds for a locale-driven build, but
PDC_FORCE_UTF8means the library encodes cells as UTF-8 whatever the locale says — so classification should be Unicode-based too. BuiltWIDE=Y UTF8=Ywith-D_XOPEN_SOURCE=700, underuk_UA.koi8u:The same library in a UTF-8 locale returns
0. Would it make sense forPDC_FORCE_UTF8to select the built-in Unicode table regardless of platform?(PDCursesMod 4.5.4,
vtport, Linux.)