--- lbbs/src/menu.c 2025/05/08 08:05:58 1.31 +++ lbbs/src/menu.c 2025/05/13 07:28:51 1.38 @@ -17,7 +17,6 @@ #include "bbs.h" #include "bbs_cmd.h" #include "user_priv.h" -#include "reg_ex.h" #include "bbs_cmd.h" #include "menu.h" #include "log.h" @@ -42,6 +41,7 @@ int load_menu(MENU_SET *p_menu_set, cons int i = 0; int j = 0; char buffer[LINE_BUFFER_LEN]; + char temp[LINE_BUFFER_LEN]; char screen_filename[FILE_PATH_LEN]; char *p = NULL; char *q = NULL; @@ -83,7 +83,7 @@ int load_menu(MENU_SET *p_menu_set, cons { if (p_menu != NULL) { - log_error("Begin new menu without end the prior one, in menu config line %d\n", fin_line); + log_error("Incomplete menu definition in menu config line %d\n", fin_line); return -1; } p_menu = (MENU *)malloc(sizeof(MENU)); @@ -306,7 +306,7 @@ int load_menu(MENU_SET *p_menu_set, cons q = strtok_r(NULL, MENU_CONF_DELIM_WITHOUT_SPACE, &saveptr); if (q == NULL || (q = strchr(q, '\"')) == NULL) { - log_error("Error #1 menu item text in menu config line %d\n", fin_line); + log_error("Error menu item text in menu config line %d\n", fin_line); return -1; } q++; @@ -521,7 +521,8 @@ int load_menu(MENU_SET *p_menu_set, cons { fin_line++; - p = strtok_r(buffer, MENU_CONF_DELIM_WITH_SPACE, &saveptr); + strncpy(temp, buffer, sizeof(temp)); // Duplicate line for strtok_r + p = strtok_r(temp, MENU_CONF_DELIM_WITH_SPACE, &saveptr); if (p != NULL && *p == '%') // END of menu screen { break; @@ -586,6 +587,13 @@ int display_menu(MENU *p_menu) return -1; } + if (p_menu->item_cur_pos > 0 && + checkpriv(&BBS_priv, 0, p_menu->items[p_menu->item_cur_pos]->priv) != 0 && + checklevel(&BBS_priv, p_menu->items[p_menu->item_cur_pos]->level) != 0) + { + menu_selectable = 1; + } + if (p_menu->title.show) { show_top(p_menu->title.text); @@ -672,7 +680,6 @@ int menu_control(MENU_SET *p_menu_set, i switch (key) { case CR: - igetch(1); // Cleanup remaining '\n' in the buffer case KEY_RIGHT: if (p_menu->items[p_menu->item_cur_pos]->submenu) { @@ -688,13 +695,13 @@ int menu_control(MENU_SET *p_menu_set, i { return menu_control(p_menu_set, KEY_LEFT); } - break; } else { return (exec_cmd(p_menu->items[p_menu->item_cur_pos]->action, p_menu->items[p_menu->item_cur_pos]->name)); } + break; case KEY_LEFT: if (p_menu_set->menu_select_depth > 0) { @@ -703,21 +710,20 @@ int menu_control(MENU_SET *p_menu_set, i { return menu_control(p_menu_set, KEY_LEFT); } - break; } else { display_menu_cursor(p_menu, 0); p_menu->item_cur_pos = p_menu->item_count - 1; - while (!p_menu->items[p_menu->item_cur_pos]->display || - p_menu->items[p_menu->item_cur_pos]->priv != 0 || - p_menu->items[p_menu->item_cur_pos]->level != 0) + while (p_menu->item_cur_pos >= 0 && (!p_menu->items[p_menu->item_cur_pos]->display || + p_menu->items[p_menu->item_cur_pos]->priv != 0 || + p_menu->items[p_menu->item_cur_pos]->level != 0)) { p_menu->item_cur_pos--; } display_menu_cursor(p_menu, 1); - break; } + break; case KEY_UP: display_menu_cursor(p_menu, 0); do @@ -757,6 +763,7 @@ int menu_control(MENU_SET *p_menu_set, i } } } + break; } return 0;