NetBSD-Bugs archive

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

Re: lib/45791



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

From: Nat Sloss <nathanialsloss%yahoo.com.au@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: lib/45791
Date: Fri, 27 Jan 2012 15:19:45 +1100

 Hi,
 
 Thanks Christos for the quick commit.  I tried it out and it works well.
 
 Although it introduces a new problem as it differs from my patch when it comes 
 to cursor placement when no more characters remaining.  Consider this:
 
 getnstr( somebuff, 5);  -  As in the previous example.
 
 Now at the prompt enter in 4 characters. You'll notice the cursor is in the 5 
 character position.  Enter in another character.  This character is not 
 echoed and the cursor moves back to the fourth position.  Enter in yet 
 another character and this character is echoed as the fourth character and 
 the cursor moves back to the fourth character position. Every character after 
 the initial four characters is not considered as input although echoed.
 
 I think this was a simple mistake as the changes display a space at xpos when 
 remaining == 0, but then moves the cursor xpos - 1 instead of xpos.  
 
 As I think the cursor should stay at the fifth character position for any 
 characters received after the initial four characters.
 
 I suggest one of the following fixes:
 
 Patch 1: move xpos when remaining - 0;
 
 --- getstr.c.orig      2012-01-07 17:53:19.000000000 +1100
 +++ getstr.c   2012-01-26 13:58:13.000000000 +1100
 @@ -250,7 +250,7 @@
                                remain--;
                        } else {
                                mvwaddch(win, win->cury, xpos, ' ');
 -                              wmove(win, win->cury, xpos - 1);
 +                              wmove(win, win->cury, xpos);
                        }
                }
        }
 
 
 
 or patch 2:  It saves a line and moves xpos for all characters.
 
 --- getstr.c.orig      2012-01-07 17:53:19.000000000 +1100
 +++ getstr.c   2012-01-26 14:00:50.000000000 +1100
 @@ -243,15 +243,14 @@
                        if (remain) {
                                if (iscntrl((unsigned char)c)) {
                                        mvwaddch(win, win->cury, xpos, ' ');
 -                                      wmove(win, win->cury, xpos + 1);
                                }
                                str++;
                                xpos++;
                                remain--;
                        } else {
                                mvwaddch(win, win->cury, xpos, ' ');
 -                              wmove(win, win->cury, xpos - 1);
                        }
 +                      wmove(win, win->cury, xpos);
                }
        }
  
 I don't know which is better and I don't think these routines are UTF-8/16 
 ready so probably patch two in my opinion as it is a little more succinct.
 
 
 Anyhow once again thanks for the quick commit, sorry for the slow reply I'm 
 still in holiday mode.
 
 Regards,
 
 Nat
 


Home | Main Index | Thread Index | Old Index