diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2005-03-05 19:19:12 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2005-03-05 19:19:12 +0000 |
commit | 951ec2e7befae3f6f163e39d51c3c297a2816f94 (patch) | |
tree | 356f6a7148a4a33a8128661784cbba3dbec34e4a /src/gui/curses/gui-display.c | |
parent | bce7a0e961dfbcbed06f2099e07d47222c2962e9 (diff) | |
download | weechat-951ec2e7befae3f6f163e39d51c3c297a2816f94.zip |
Fixed crash when a line is ending by lot of spaces
Diffstat (limited to 'src/gui/curses/gui-display.c')
-rw-r--r-- | src/gui/curses/gui-display.c | 66 |
1 files changed, 38 insertions, 28 deletions
diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c index c027c8c89..8eafbac6a 100644 --- a/src/gui/curses/gui-display.c +++ b/src/gui/curses/gui-display.c @@ -432,7 +432,8 @@ gui_display_word (t_gui_window *window, t_gui_line *line, char saved_char_end, saved_char; int end_of_word, chars_to_display, num_displayed; - if (window->win_chat_cursor_y > window->win_chat_height - 1) + if (!message || !end_msg || + (window->win_chat_cursor_y > window->win_chat_height - 1)) return; snprintf (format_align, 32, "%%-%ds", line->length_align); @@ -617,36 +618,45 @@ gui_display_line (t_gui_window *window, t_gui_line *line, int count, int simulat &word_end_msg, &word_end_offset, &word_length_with_spaces, &word_length); - /* spaces + word too long for current line */ - if ((window->win_chat_cursor_x + word_length_with_spaces > window->win_chat_width - 1) - && (word_length < window->win_chat_width - line->length_align)) + if (word_length > 0) { - gui_display_new_line (window, num_lines, count, - &lines_displayed, simulate); - ptr_message = word_start_msg; - offset = word_start_offset; + /* spaces + word too long for current line */ + if ((window->win_chat_cursor_x + word_length_with_spaces > window->win_chat_width - 1) + && (word_length < window->win_chat_width - line->length_align)) + { + gui_display_new_line (window, num_lines, count, + &lines_displayed, simulate); + ptr_message = word_start_msg; + offset = word_start_offset; + } + + /* word is exactly width => we'll skip next leading spaces for next line */ + if (word_length == window->win_chat_width - line->length_align) + skip_spaces = 1; + + /* display word */ + gui_display_word (window, line, + ptr_message, offset, + word_end_msg, word_end_offset, + num_lines, count, &lines_displayed, simulate); + + /* move pointer after end of word */ + ptr_message = word_end_msg; + offset = word_end_offset; + gui_message_get_next_char (&ptr_message, &offset); + + /* skip leading spaces? */ + if (skip_spaces) + { + while (ptr_message && (ptr_message->message[offset] == ' ')) + gui_message_get_next_char (&ptr_message, &offset); + } } - - /* word is exactly width => we'll skip next leading spaces for next line */ - if (word_length == window->win_chat_width - line->length_align) - skip_spaces = 1; - - /* display word */ - gui_display_word (window, line, - ptr_message, offset, - word_end_msg, word_end_offset, - num_lines, count, &lines_displayed, simulate); - - /* move pointer after end of word */ - ptr_message = word_end_msg; - offset = word_end_offset; - gui_message_get_next_char (&ptr_message, &offset); - - /* skip leading spaces? */ - if (skip_spaces) + else { - while (ptr_message && (ptr_message->message[offset] == ' ')) - gui_message_get_next_char (&ptr_message, &offset); + gui_display_new_line (window, num_lines, count, + &lines_displayed, simulate); + ptr_message = NULL; } } |