-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
panel_hidden conflicts with NetBSD and ncurses #325
Comments
fixing #325 while being a breaking change
A very odd bug! Whence came the
...which flips the meaning of the return value (for non-NULL pointers). That matches what I'd intuitively expect; if( panel_hidden( pan) == TRUE)
/* panel is not actually hidden */ SVR4 documentation for the function is here, but is ambiguous on the point. I've modified the test_pan.c demo (click here for the modified version) to show the return value of As to the However, I added them four years ago; if they've actually signalled an error falsely, nobody mentioned it to me. (Admittedly, it does happen that people don't report even blatant bugs, either because they're busy or assume I already must know about them. And the very bug that is the subject of this issue is an example of one that's gone unreported for a couple of decades. As you suggest, this is a rarely-used function.) |
fixing #325 while being a bit of a breaking change (returning FALSE 1 instead of ERR -1)
I was confused - the difference is only between OK = 1 and ERR = -1, not switched around |
True confession time : I must have noticed this bug four years ago and simply coded around it. I've no memory of doing that... I probably saw it, thought "that's weird, I'll have to look into that further later", and then didn't. It'd be good if any fix could be coordinated with @wmcbrine. Going by the SVR4 documentation for |
fixing #325 while being a breaking change returning TRUE (1) and FALSE (0) instead of OK (0) and ERR (-1)
Thanks for the note - I've pushed a new version of the commit that drops this check in the panel demo (and adds to the changelog [also including the missing Unicode update, that started last January]) |
fixing #325 while being a breaking change returning TRUE (1) and FALSE (0) instead of OK (0) and ERR (-1)
The possible reason is that ncurses had a long standing bug in its documentation which was fixed 20230819. Older versions say
While the current one says:
|
... rechecked: The official doc https://invisible-island.net/ncurses/man/panel.3x.html#h3-panel_hidden has it correctly - because that is ncurses 6.5 (2024) the release notes for 6.5 say that the doc was wrong. Checking a mirror of older versions shows that since ncurses 5.7 the code wasn't changed and this change as previous versions was not changing the return values; ncurses 5.0 from 26 years ago already returned TRUE if the panel is hidden... but: ncurses 4 (27 years ago) indeed had the same bug we currently inspect here |
There was a brief thread on the bug-ncurses in which the bug in documentation was pointed out; the docs were fixed immediately afterward. As both you and that thread note, the code behaved correctly. (Unless you go back 27 years.) For this change, we would bump PDCursesMod's #if (defined( PDCURSES) && (PDC_BUILD < 3908)) || (defined( __PDCURSESMOD__) && (PDC_BUILD < 4500))
/* code assuming our 'old' mis-implementation */
#else
/* code that assumes the standard SVR4 version of panel_hidden() */
#endif If William doesn't do anything, then that first line becomes #if (defined( PDCURSES) && (!defined( __PDCURSESMOD__) || PDC_BUILD < 4500))
[0] This originally said 'from 4400 to 4401'. Corrected following @GitMensch`s reply below. |
I'm confused, if we change PDC_VER_MINOR that way then PDC_BUILD will be 4500, no? |
fixing #325 while being a breaking change returning TRUE (1) and FALSE (0) instead of OK (0) and ERR (-1) version constants increased, now at 4.5.0
I've wrapped this up in a separate branch for now, please do a review (even if it may stay as-is for a bunch of days), allowing me to further adjust as needed. |
Looks pretty good to me. Minor changes :
#if (defined( PDCURSES) && (!defined( __PDCURSESMOD__) || PDC_BUILD < 4500))
if( panel_hidden( curr_top) == OK) /* old, non-standard behavior */
#else
if( panel_hidden( curr_top) == TRUE) /* correct behavior according to SVR4 */
#endif (same test as in my previous message, but with the correct
|
while the portability list says "portable", it actually isn't.
This is PDC+PDCMs definition:
https://github.com/Bill-Gray/PDCursesMod/blob/a5f13c248c5cca3fd3ccc29d91385b0ee1161567/pdcurses/panel.c#L431C1-L438C2
with this doc:
while ncurses says:
Note: while not documented, PDCM+PDC return ERR as expected - but specially for PDCM only if asserts are not enabled, which breaks further compatibility (this line should be dropped).
I'll create a PR for a fix, but I'm not sure if this should be applied as-is, because this will break programs written explicit for PDC/PDCM, using this function and checking for ERR explicit (but on the other hand, it may not be that often used and instead checked for non-zero directly - and even if it is checked for OK or non-zero that would be good).
It would be interesting to get input from @wmcbrine as well as this is a really old portability issue.
The text was updated successfully, but these errors were encountered: