diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2014-04-05 11:49:06 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2014-04-05 11:49:06 +0200 |
commit | a44a1eab199c6174a7bb6d935034ea6fb946f6c3 (patch) | |
tree | ee7160f7ae92706eea61c2a762956dd1c1d3e213 /src | |
parent | 698d6a3631b4f0d8dd65c05fe5361c55df1d469a (diff) | |
download | weechat-a44a1eab199c6174a7bb6d935034ea6fb946f6c3.zip |
core: fix "/buffer clear" with a name (don't clear all merged buffers with same number)
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-command.c | 33 |
1 files changed, 25 insertions, 8 deletions
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); + } } } } |