diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-06-10 09:49:11 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-06-10 09:51:04 +0200 |
commit | 5d06ab76df64c3cecc7ac30a2914c03f27c1e1b0 (patch) | |
tree | 3240148138c418c4ba15481a113e02635fc06e1f /src | |
parent | 2eacbe61530ed277d2763b8015afa2e63da02b70 (diff) | |
download | weechat-5d06ab76df64c3cecc7ac30a2914c03f27c1e1b0.zip |
exec: remove trailing "M" (carriage return) in output of commands
Regression was indirectly caused by commit
d18f68e497c4244404ff8f4f50de82717b178e09 in core that allows to display all
control chars in buffers.
But the fix is in exec plugin: end of line in command output can now be "\r\n"
in addition to a single "\n".
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/exec/exec.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/plugins/exec/exec.c b/src/plugins/exec/exec.c index be28473c8..77cf90bea 100644 --- a/src/plugins/exec/exec.c +++ b/src/plugins/exec/exec.c @@ -379,12 +379,15 @@ exec_concat_output (struct t_exec_cmd *exec_cmd, struct t_gui_buffer *buffer, int out, const char *text) { int length, new_size; - const char *ptr_text; - char *new_output, *pos, *line; + const char *ptr_text, *pos, *pos_next; + char *new_output, *line; ptr_text = text; - /* if output is not sent as hsignal, display lines (ending with '\n') */ + /* + * if output is not sent as hsignal, display lines + * (ending with "\r\n" or "\n") + */ if (!exec_cmd->hsignal) { ptr_text = text; @@ -393,6 +396,9 @@ exec_concat_output (struct t_exec_cmd *exec_cmd, struct t_gui_buffer *buffer, pos = strchr (ptr_text, '\n'); if (!pos) break; + pos_next = pos + 1; + if ((pos > ptr_text) && (ptr_text[pos - ptr_text - 1] == '\r')) + pos--; if (exec_cmd->output_size[out] > 0) { length = exec_cmd->output_size[out] + (pos - ptr_text) + 1; @@ -418,7 +424,7 @@ exec_concat_output (struct t_exec_cmd *exec_cmd, struct t_gui_buffer *buffer, exec_cmd->output_size[out] = 0; exec_display_line (exec_cmd, buffer, out, line); free (line); - ptr_text = pos + 1; + ptr_text = pos_next; } } |