Module Name: src Committed By: christos Date: Mon Dec 16 19:40:50 UTC 2024
Modified Files: src/external/gpl3/gdb/dist/gdb/tui: tui-winsource.c Log Message: Add macros so that the getmax{x,y} functions work like ncurses (don't core dump on NULL window, but return -1) To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/external/gpl3/gdb/dist/gdb/tui/tui-winsource.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/gpl3/gdb/dist/gdb/tui/tui-winsource.c diff -u src/external/gpl3/gdb/dist/gdb/tui/tui-winsource.c:1.7 src/external/gpl3/gdb/dist/gdb/tui/tui-winsource.c:1.8 --- src/external/gpl3/gdb/dist/gdb/tui/tui-winsource.c:1.7 Sun Dec 15 11:21:57 2024 +++ src/external/gpl3/gdb/dist/gdb/tui/tui-winsource.c Mon Dec 16 14:40:50 2024 @@ -41,6 +41,10 @@ #include "tui/tui-location.h" #include "gdb_curses.h" +/* ncurses returns -1, but BSD segfaults; the code assumes ncurses */ +#define tui_getmaxx(w) ((w) ? getmaxx (w) : -1) +#define tui_getmaxy(w) ((w) ? getmaxy (w) : -1) + /* Function to display the "main" routine. */ void tui_display_main () @@ -316,7 +320,7 @@ tui_source_window_base::refresh_window ( the screen, potentially creating a flicker. */ wnoutrefresh (handle.get ()); - int pad_width = m_pad.get () ? getmaxx (m_pad.get ()) : 0; + int pad_width = tui_getmaxx (m_pad.get ()); int left_margin = this->left_margin (); int view_width = this->view_width (); int content_width = m_max_length; @@ -365,10 +369,10 @@ tui_source_window_base::show_source_cont /* If the required pad width is wider than the previously requested pad width, then we might want to grow the pad. */ if (required_pad_width > m_pad_requested_width - || required_pad_height > getmaxy (m_pad.get ())) + || required_pad_height > tui_getmaxy (m_pad.get ())) { /* The current pad width. */ - int pad_width = m_pad == nullptr ? 0 : getmaxx (m_pad.get ()); + int pad_width = m_pad == nullptr ? 0 : tui_getmaxx (m_pad.get ()); gdb_assert (pad_width <= m_pad_requested_width); @@ -377,7 +381,7 @@ tui_source_window_base::show_source_cont bigger pad. There's no point asking again, so we'll just make so with the pad we currently have. */ if (pad_width == m_pad_requested_width - || required_pad_height > getmaxy (m_pad.get ())) + || required_pad_height > tui_getmaxy (m_pad.get ())) { pad_width = required_pad_width; @@ -399,7 +403,7 @@ tui_source_window_base::show_source_cont m_pad_requested_width = required_pad_width; tui_debug_printf ("requested width %d, allocated width %d", - required_pad_width, getmaxx (m_pad.get ())); + required_pad_width, tui_getmaxx (m_pad.get ())); } gdb_assert (m_pad != nullptr); @@ -534,7 +538,7 @@ tui_source_window_base::validate_scroll_ m_horizontal_offset = 0; int content_width = m_max_length; - int pad_width = getmaxx (m_pad.get ()); + int pad_width = tui_getmaxx (m_pad.get ()); int view_width = this->view_width (); tui_debug_printf ("pad_width = %d, view_width = %d, content_width = %d",