bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Failure of resizeterm() causes subsequent call with stdscr to crash


From: Thomas Dickey
Subject: Re: Failure of resizeterm() causes subsequent call with stdscr to crash
Date: Wed, 25 Sep 2024 17:02:56 -0400

On Wed, Sep 25, 2024 at 04:20:40PM -0400, Thomas Dickey wrote:
> On Wed, Sep 25, 2024 at 10:35:24AM -0400, Bill Gray wrote:
> > On 9/25/24 08:29, Peter Bierma wrote:> This was reported downstream as a bug
> > in Python's curses module. See the
> > > issue there: https://github.com/python/cpython/issues/120378
> > > <https://github.com/python/cpython/issues/120378>

noting a comment there:

        According to GNU, it seems the function is erroneously documented as
        taking integers, while in reality they are shorts. 

...which is an incorrect reading of the documentation.  curses functions
have "always" used int's for position because that's how it started with BSD.
Later, prototypes were introduced.

X/Open Curses uses the same prototype, but it does not imply anything about
how the parameters are used.

But curses generally used short's in the WINDOW struct, as in this chunk
from Solaris:

        struct _win_st
        {
                short           _cury, _curx;   /* current coordinates */
                short           _maxy, _maxx;   /* max coordinates */
                short           _begy, _begx;   /* (0,0) screen coordinates */
                char            _flags;
                short           _yoffset;       /* actual begy is 
_begy+_yoffset */
                bool            _clear,         /* clearok() info */

Interestingly, that changed in 4.4BSD's version (used by NetBSD in 1993)
to a size_t - the CSRG SCCS for curses.h has this chunk:

        ^As 00043/00028/00229
        ^Ad D 5.13 92/09/14 11:00:23 elan 32 31
        ^Ac Converted to new data structures.

Long afterwards (2000), NetBSD made WINDOW opaque, but that's not relevant
to the types for _maxx, etc.  NetBSD doesn't have the same issues with ABI
as ncurses, anyway, because NetBSD's scope is more limited :-)

PDCurses changed from short to int around the same time - it was short in
version 1.4 (January 1990) and int in 2.0 (November 1992).  Reportedly
PDCurses evolved from pccurses and in turn from ncurses - something
to keep in mind - but ncurses started from the original mid-1980s version.
PDCurses 1.4 did not use function prototypes in curses.h, so it assumed
the K&R code - all int's.

Anyway - the internals could be short, size_t or int, depending on the
implementation.

-- 
Thomas E. Dickey <dickey@invisible-island.net>
https://invisible-island.net

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]