NetBSD-Bugs archive

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

Re: lib/41257: curses: getyx + wmove violates least astonishment past end-of-line



The following reply was made to PR lib/41257; it has been noted by GNATS.

From: Jed Davis <jld%panix.com@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: lib/41257: curses: getyx + wmove violates least astonishment
        past end-of-line
Date: Thu, 7 May 2009 21:14:21 -0400

 On Tue, Apr 21, 2009 at 02:00:06PM +0000, Brett Lymn wrote:
 >  No, it is not the correct thing to do - the x & y coordinates should
 >  always be correct after adding bytes trying to paper over the cracks
 >  by diddling the reporting routines will result in pain, lossage and
 >  confusion because the internal cursor state is still wrong.
 
 But assuming that the one-past-the-end internal state is a reasonable
 state to be in -- which the presence of the __ISPASTEOL machinery seems
 to suggest -- then the alternative to hiding that state from the user is
 to allow it to be retrieved and restored, thusly:
 
 Index: move.c
 ===================================================================
 RCS file: /bag/nb/repo/src/lib/libcurses/move.c,v
 retrieving revision 1.15
 diff -u -p -r1.15 move.c
 --- move.c     21 Jan 2007 13:25:36 -0000      1.15
 +++ move.c     8 May 2009 01:07:31 -0000
 @@ -67,11 +67,14 @@ wmove(WINDOW *win, int y, int x)
  #endif
        if (x < 0 || y < 0)
                return (ERR);
 -      if (x >= win->maxx || y >= win->maxy)
 +      if (x > win->maxx || y >= win->maxy)
                return (ERR);
        win->curx = x;
        win->lines[win->cury]->flags &= ~__ISPASTEOL;
        win->cury = y;
 -      win->lines[y]->flags &= ~__ISPASTEOL;
 +      if (x == win->maxx)
 +              win->lines[y]->flags |= __ISPASTEOL;
 +      else
 +              win->lines[y]->flags &= ~__ISPASTEOL;
        return (OK);
  }
 
 I do agree that the == in addbytes.c should be a >=, regardless.
 
 --Jed
 


Home | Main Index | Thread Index | Old Index