summaryrefslogtreecommitdiff
path: root/src/fe-common
diff options
context:
space:
mode:
authorailin-nemui <ailin-nemui@users.noreply.github.com>2017-06-19 14:09:02 +0200
committerailin-nemui <ailin-nemui@users.noreply.github.com>2017-06-19 14:09:02 +0200
commit02a5d1a00b4f484b4b2422785944e022810bbbb0 (patch)
tree629001d1cb7640331a962dcee76ee857c7f8e5ad /src/fe-common
parent9d3cfe1069b5cfaf0efb972e36695b781ecf93de (diff)
downloadirssi-02a5d1a00b4f484b4b2422785944e022810bbbb0.zip
fix weird n-fold unescaping
Diffstat (limited to 'src/fe-common')
-rw-r--r--src/fe-common/core/chat-completion.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/fe-common/core/chat-completion.c b/src/fe-common/core/chat-completion.c
index 1f00feaf..1c9db28e 100644
--- a/src/fe-common/core/chat-completion.c
+++ b/src/fe-common/core/chat-completion.c
@@ -1011,13 +1011,17 @@ static void sig_complete_target(GList **list, WINDOW_REC *window,
}
}
+static void event_text(const char *data, SERVER_REC *server, WI_ITEM_REC *item);
+
/* expand \n, \t and \\ */
static char *expand_escapes(const char *line, SERVER_REC *server,
WI_ITEM_REC *item)
{
char *ptr, *ret;
- int chr;
+ const char *prev;
+ int chr;
+ prev = line;
ret = ptr = g_malloc(strlen(line)+1);
for (; *line != '\0'; line++) {
if (*line != '\\') {
@@ -1036,9 +1040,11 @@ static char *expand_escapes(const char *line, SERVER_REC *server,
/* newline .. we need to send another "send text"
event to handle it (or actually the text before
the newline..) */
- if (ret != ptr) {
- *ptr = '\0';
- signal_emit("send text", 3, ret, server, item);
+ if (prev != line) {
+ const char *prev_line = g_strndup(prev, (line - prev) - 1);
+ event_text(prev_line, server, item);
+ g_free((char *)prev_line);
+ prev = line + 1;
ptr = ret;
}
} else if (chr != -1) {