From a44a1eab199c6174a7bb6d935034ea6fb946f6c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 5 Apr 2014 11:49:06 +0200 Subject: core: fix "/buffer clear" with a name (don't clear all merged buffers with same number) --- src/core/wee-command.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/core/wee-command.c b/src/core/wee-command.c index cde611957..20edfbc3b 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -546,7 +546,7 @@ COMMAND_CALLBACK(buffer) struct t_gui_buffer *weechat_buffer; long number, number1, number2, numbers[3]; char *error, *value, *pos, *str_number1, *pos_number2; - int i, error_main_buffer, num_buffers, count, prev_number; + int i, error_main_buffer, num_buffers, count, prev_number, clear_number; /* make C compiler happy */ (void) data; @@ -590,19 +590,36 @@ COMMAND_CALLBACK(buffer) { for (i = 2; i < argc; i++) { - ptr_buffer = (string_strcasecmp (argv[i], "-merged") == 0) ? - buffer : gui_buffer_search_by_number_or_name (argv[i]); + if (string_strcasecmp (argv[i], "-merged") == 0) + { + ptr_buffer = buffer; + clear_number = 1; + } + else + { + ptr_buffer = gui_buffer_search_by_number_or_name (argv[i]); + number = strtol (argv[2], &error, 10); + clear_number = (error && !error[0]); + } if (ptr_buffer) { - for (ptr_buffer2 = gui_buffers; ptr_buffer2; - ptr_buffer2 = ptr_buffer2->next_buffer) + if (clear_number) { - if ((ptr_buffer2->number == ptr_buffer->number) - && ptr_buffer2->clear) + for (ptr_buffer2 = gui_buffers; ptr_buffer2; + ptr_buffer2 = ptr_buffer2->next_buffer) { - gui_buffer_clear (ptr_buffer2); + if ((ptr_buffer2->number == ptr_buffer->number) + && ptr_buffer2->clear) + { + gui_buffer_clear (ptr_buffer2); + } } } + else + { + if (ptr_buffer->clear) + gui_buffer_clear (ptr_buffer); + } } } } -- cgit v1.2.3