diff options
Diffstat (limited to 'src/plugins/perl/weechat-perl.c')
-rw-r--r-- | src/plugins/perl/weechat-perl.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/plugins/perl/weechat-perl.c b/src/plugins/perl/weechat-perl.c index 846a0ae6f..e06603165 100644 --- a/src/plugins/perl/weechat-perl.c +++ b/src/plugins/perl/weechat-perl.c @@ -226,36 +226,42 @@ void weechat_perl_output_flush () { const char *ptr_command; - char *command; + char *temp_buffer, *command; int length; if (!*perl_buffer_output[0]) return; + /* if there's no buffer, we catch the output, so there's no flush */ + if (perl_eval_mode && !perl_eval_buffer) + return; + + temp_buffer = strdup (*perl_buffer_output); + if (!temp_buffer) + return; + + weechat_string_dyn_copy (perl_buffer_output, NULL); + if (perl_eval_mode) { - /* if there's no buffer, we catch the output, so there's no flush */ - if (!perl_eval_buffer) - return; - if (perl_eval_send_input) { if (perl_eval_exec_commands) - ptr_command = *perl_buffer_output; + ptr_command = temp_buffer; else - ptr_command = weechat_string_input_for_buffer (*perl_buffer_output); + ptr_command = weechat_string_input_for_buffer (temp_buffer); if (ptr_command) { - weechat_command (perl_eval_buffer, *perl_buffer_output); + weechat_command (perl_eval_buffer, temp_buffer); } else { - length = 1 + strlen (*perl_buffer_output) + 1; + length = 1 + strlen (temp_buffer) + 1; command = malloc (length); if (command) { snprintf (command, length, "%c%s", - *perl_buffer_output[0], *perl_buffer_output); + temp_buffer[0], temp_buffer); weechat_command (perl_eval_buffer, (command[0]) ? command : " "); free (command); @@ -264,7 +270,7 @@ weechat_perl_output_flush () } else { - weechat_printf (perl_eval_buffer, "%s", *perl_buffer_output); + weechat_printf (perl_eval_buffer, "%s", temp_buffer); } } else @@ -275,10 +281,10 @@ weechat_perl_output_flush () weechat_gettext ("%s: stdout/stderr (%s): %s"), PERL_PLUGIN_NAME, (perl_current_script) ? perl_current_script->name : "?", - *perl_buffer_output); + temp_buffer); } - weechat_string_dyn_copy (perl_buffer_output, NULL); + free (temp_buffer); } /* |