[PING][PATCH v2] Fix multi-line strings in TuiWindow.write

Simon Marchi simark@simark.ca
Fri Dec 4 17:22:00 GMT 2020


On 2020-12-04 9:18 a.m., Hannes Domani via Gdb-patches wrote:
> Ping.
>
> Am Freitag, 20. November 2020, 01:01:43 MEZ hat Hannes Domani via Gdb-patches <gdb-patches@sourceware.org> Folgendes geschrieben:
>
>> Currently multi-line strings are all written to the first line.
>>
>> Since tui_copy_source_line sets the text variable to the start of the
>> next line, the check for newline has to be done with the previous character.
>>
>> gdb/ChangeLog:
>>
>> 2020-11-19  Hannes Domani  <ssbssa@yahoo.de>
>>
>>      * python/py-tui.c (tui_py_window::output): Fix multi-line strings.
>> ---
>> v2:
>> - Don't break multiple TuiWindow.write calls without newline characters.
>> ---
>> gdb/python/py-tui.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/gdb/python/py-tui.c b/gdb/python/py-tui.c
>> index 95c71f1d2d..306bd7b801 100644
>> --- a/gdb/python/py-tui.c
>> +++ b/gdb/python/py-tui.c
>> @@ -203,13 +203,13 @@ tui_py_window::output (const char *text)
>>      {
>>        wmove (handle.get (), cursor_y + 1, cursor_x + 1);
>>
>> +      const char *prev_text = text;
>>        std::string line = tui_copy_source_line (&text, 0, 0,
>>                            vwidth - cursor_x, 0);
>>        tui_puts (line.c_str (), handle.get ());
>>
>> -      if (*text == '\n')
>> +      if (text > prev_text && (text[-1] == '\n' || text[-1] == '\r'))
>>      {
>> -      ++text;
>>        ++cursor_y;
>>        cursor_x = 0;
>>      }
>> --
>> 2.29.2

I tried to apply this and give it a try (although I know nothing about
this code), and it looks like the patch is based on an old commit.  This
code was changed in September, quite a bit before your original patch:

https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=149830c137f351cb41888f87493cc42a72dbeac7;hp=5f278258ccae6a666c72de709a3171975fbaeb05

Can you see if the issue still exists in current master?  And if so, the
fix will have to be adapted to the new code.

Simon


More information about the Gdb-patches mailing list