--- lbbs/src/menu.c 2025/05/08 08:05:58 1.31 +++ lbbs/src/menu.c 2025/05/10 02:52:17 1.35 @@ -42,6 +42,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 +84,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 +307,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 +522,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 +588,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); @@ -709,9 +718,7 @@ int menu_control(MENU_SET *p_menu_set, i { 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->item_cur_pos--; }