patch-1.3.72 linux/scripts/lxdialog/menubox.c
Next file: linux/scripts/patch-kernel
Previous file: linux/scripts/lxdialog/Makefile
Back to the patch index
Back to the overall index
- Lines: 44
- Date:
Fri Mar 8 08:59:12 1996
- Orig file:
v1.3.71/linux/scripts/lxdialog/menubox.c
- Orig date:
Tue Mar 5 10:11:17 1996
diff -u --recursive --new-file v1.3.71/linux/scripts/lxdialog/menubox.c linux/scripts/lxdialog/menubox.c
@@ -30,8 +30,11 @@
print_item (WINDOW * win, const char *item, int choice, int selected, int hotkey)
{
int i, j;
+ char menu_item[menu_width+1];
- j = first_alpha(item);
+ strncpy(menu_item, item, menu_width);
+ menu_item[menu_width] = 0;
+ j = first_alpha(menu_item);
/* Clear 'residue' of last item */
wattrset (win, menubox_attr);
@@ -39,10 +42,10 @@
for (i = 0; i < menu_width; i++)
waddch (win, ' ');
wattrset (win, selected ? item_selected_attr : item_attr);
- mvwaddstr (win, choice, item_x, (char *)item);
+ mvwaddstr (win, choice, item_x, menu_item);
if (hotkey) {
wattrset (win, selected ? tag_key_selected_attr : tag_key_attr);
- mvwaddch(win, choice, item_x+j, item[j]);
+ mvwaddch(win, choice, item_x+j, menu_item[j]);
}
}
@@ -169,7 +172,7 @@
*/
item_x = 0;
for (i = 0; i < item_no; i++) {
- item_x = MAX (item_x, strlen (items[i * 2 + 1]) + 2);
+ item_x = MAX (item_x, MIN(menu_width, strlen (items[i * 2 + 1]) + 2));
if (strcmp(current, items[i*2]) == 0) choice = i;
}
@@ -301,7 +304,7 @@
case '\n':
delwin (dialog);
if (button == 2)
- fprintf(stderr, "\"%s\" \"%s\"",
+ fprintf(stderr, "%s \"%s\"",
items[(scroll + choice) * 2],
items[(scroll + choice) * 2 + 1] +
first_alpha(items[(scroll + choice) * 2 + 1]));
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov
with Sam's (original) version of this