diff --git a/runtime/ov_probe.c b/runtime/ov_probe.c index c0ffa181..8a1eb20a 100644 --- a/runtime/ov_probe.c +++ b/runtime/ov_probe.c @@ -821,6 +821,10 @@ static void probe_menu_text(void) { for (int id = UI_MENU_FIRST; id <= UI_MENU_LAST_ID; id++) { CHECK(ui_text_defined("en", (UiTextId)id) && ui_text_defined("ru", (UiTextId)id), "menu text id %d lacks en or ru", id); CHECK(*ui_text_in("en", (UiTextId)id) && *ui_text_in("ru", (UiTextId)id), "menu text id %d is empty", id); + // the description pane keeps the whole text and a note after it (option_rows.cpp desc_set) + CHECK(strlen(ui_text_in("en", (UiTextId)id)) + 256 < UI_DESC_BYTES && + strlen(ui_text_in("ru", (UiTextId)id)) + 256 < UI_DESC_BYTES, "menu text id %d is too long for the " + "description pane", id); } CHECK(!ui_text_defined("en", UI_TEXT_COUNT) && !*ui_text_in("ru", UI_TEXT_COUNT), "an id past the catalog gives text"); // other languages fall back to English for the menu, and keep their own keyboard texts diff --git a/runtime/ui/option_rows.cpp b/runtime/ui/option_rows.cpp index f0f82b36..04199d01 100644 --- a/runtime/ui/option_rows.cpp +++ b/runtime/ui/option_rows.cpp @@ -36,7 +36,7 @@ static bool g_disable_next; // opt_disable_next: the next row is gr static UiTextId g_disable_note; // The description pane: this frame's hovered and selected rows, the page's first row, and the last one shown. -struct Desc { char text[512]; }; +struct Desc { char text[UI_DESC_BYTES]; }; static Desc g_hover, g_focus, g_first, g_shown; // disabled: the note of a row opt_disable_next greyed out, else NULL. diff --git a/runtime/ui_text.h b/runtime/ui_text.h index 13a328b6..1043f7d5 100644 --- a/runtime/ui_text.h +++ b/runtime/ui_text.h @@ -163,6 +163,11 @@ typedef enum { UI_TEXT_COUNT } UiTextId; +// Bytes of the menu's description pane (ui/option_rows.cpp, struct Desc): a description plus the note appended to it +// ("after restart", "set by environment variable", a disabled row's note). UTF-8 Cyrillic takes two bytes a letter, so +// the longest Russian description is about 850 bytes; the probe checks every menu text leaves room for a note. +enum { UI_DESC_BYTES = 2048 }; + // UTF-8 text for id in the language of ov_language(); English when the catalog has no row for that language. const char *ui_text(UiTextId id); // The same for an explicit catalog language ("en", "ja", "fr", "de", "it", "es", "nl", "pt", "ru", "zh-Hans",