From 4032addbf93d6c5a66ed030579f6be89ead281ac Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 10 Jan 2002 04:03:34 +0000 Subject: [PATCH] When /SET expand_escapes was ON, \012 and \015 should be treated as newlines so that text after them is sent as privmsgs, not as direct commands to server. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2301 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/fe-common/core/chat-completion.c | 30 +++++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/fe-common/core/chat-completion.c b/src/fe-common/core/chat-completion.c index 0c401cfb..6294e452 100644 --- a/src/fe-common/core/chat-completion.c +++ b/src/fe-common/core/chat-completion.c @@ -738,23 +738,29 @@ static char *expand_escapes(const char *line, SERVER_REC *server, break; } - switch (*line) { - case 'n': + chr = expand_escape(&line); + if (chr == '\r' || chr == '\n') { /* newline .. we need to send another "send text" event to handle it (or actually the text before the newline..) */ - *ptr = '\0'; - signal_emit("send text", 3, ret, server, item); - ptr = ret; + if (ret != ptr) { + *ptr = '\0'; + signal_emit("send text", 3, ret, server, item); + ptr = ret; + } + } else if (chr != -1) { + /* escaping went ok */ + *ptr++ = chr; + } else { + /* unknown escape, add it as-is */ + *ptr++ = '\\'; + *ptr++ = *line; + } + + switch (*line) { + case 'n': break; default: - chr = expand_escape(&line); - if (chr != -1) - *ptr++ = chr; - else { - *ptr++ = '\\'; - *ptr++ = *line; - } } }