Source-Changes-HG archive

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

[src/trunk]: src/lib/libmenu Fix an off by one bug in the scale_menu() function.



details:   https://anonhg.NetBSD.org/src/rev/aa76be63da9e
branches:  trunk
changeset: 539839:aa76be63da9e
user:      blymn <blymn%NetBSD.org@localhost>
date:      Wed Nov 27 11:53:11 2002 +0000

description:
Fix an off by one bug in the scale_menu() function.

diffstat:

 lib/libmenu/internals.c |  17 +++++++++--------
 lib/libmenu/menu.c      |   6 +++---
 2 files changed, 12 insertions(+), 11 deletions(-)

diffs (82 lines):

diff -r 56da14ab1595 -r aa76be63da9e lib/libmenu/internals.c
--- a/lib/libmenu/internals.c   Wed Nov 27 11:36:40 2002 +0000
+++ b/lib/libmenu/internals.c   Wed Nov 27 11:53:11 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: internals.c,v 1.10 2002/07/29 13:03:51 blymn Exp $     */
+/*     $NetBSD: internals.c,v 1.11 2002/11/27 11:53:11 blymn Exp $     */
 
 /*-
  * Copyright (c) 1998-1999 Brett Lymn (blymn%baea.com.au@localhost, brett_lymn%yahoo.com.au@localhost)
@@ -386,7 +386,7 @@
        
        wmove(menu->scrwin,
              menu->items[item]->row - menu->top_row,
-             menu->items[item]->col * menu->col_width);
+             menu->items[item]->col * (menu->col_width + 1));
 
        if (menu->cur_item == item)
                wattrset(menu->scrwin, menu->fore);
@@ -441,21 +441,22 @@
        }
        menu->items[item]->visible = 1;
        
+         /* kill any special attributes... */
+       wattrset(menu->scrwin, menu->back);
+
          /*
           * Fill in the spacing between items, annoying but it looks
           * odd if the menu items are inverse because the spacings do not
           * have the same attributes as the items.
           */
-       if (menu->items[item]->col > 0) {
+       if ((menu->items[item]->col > 0) &&
+           (menu->items[item]->col < (menu->item_cols - 1))) {
                wmove(menu->scrwin,
                      menu->items[item]->row - menu->top_row,
-                     menu->items[item]->col * menu->col_width - 1);
+                     menu->items[item]->col * (menu->col_width + 1) - 1);
                waddch(menu->scrwin, ' ');
        }
        
-         /* kill any special attributes... */
-       wattrset(menu->scrwin, menu->back);
-
          /* and position the cursor nicely */
        pos_menu_cursor(menu);
 }
@@ -507,7 +508,7 @@
                                }
                        }
                        wmove(menu->scrwin, row,
-                             col * menu->col_width);
+                             col * (menu->col_width + 1));
                        for (j = 0; j < menu->col_width; j++)
                                waddch(menu->scrwin, ' ');
                } else {
diff -r 56da14ab1595 -r aa76be63da9e lib/libmenu/menu.c
--- a/lib/libmenu/menu.c        Wed Nov 27 11:36:40 2002 +0000
+++ b/lib/libmenu/menu.c        Wed Nov 27 11:53:11 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: menu.c,v 1.14 2002/08/22 11:30:18 blymn Exp $  */
+/*     $NetBSD: menu.c,v 1.15 2002/11/27 11:53:11 blymn Exp $  */
 
 /*-
  * Copyright (c) 1998-1999 Brett Lymn (blymn%baea.com.au@localhost, brett_lymn%yahoo.com.au@localhost)
@@ -549,7 +549,7 @@
          /*
           * allow for spacing between columns...
           */
-       *cols += menu->cols;
+       *cols += (menu->cols - 1);
        
        return E_OK;
 }
@@ -731,7 +731,7 @@
 
        maxmark = max(menu->mark.length, menu->unmark.length);
        movx = maxmark + (menu->items[menu->cur_item]->col
-               * menu->col_width);
+               * (menu->col_width + 1));
        
        if (menu->match_len > 0)
                movx += menu->match_len - 1;



Home | Main Index | Thread Index | Old Index