From f46f9bff178cdb8a2ddffef691fafad46b8a1365 Mon Sep 17 00:00:00 2001 From: Sascha Kruse Date: Fri, 21 Dec 2012 16:04:48 +0100 Subject: [PATCH] replace string "\n" with char '\n' this way we don't need the extra check for the string "\n" in do_word_wrap and rstrip strips newlines away. fixes github issue #80 --- dunst.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dunst.c b/dunst.c index 82cfbef..308153a 100644 --- a/dunst.c +++ b/dunst.c @@ -533,11 +533,6 @@ int do_word_wrap(char *source, int max_width) *eol = '\0'; return 1 + do_word_wrap(eol + 1, max_width); } - if (*eol == '\\' && *(eol + 1) == 'n') { - *eol = ' '; - *(eol + 1) = '\0'; - return 1 + do_word_wrap(eol + 2, max_width); - } if (word_wrap && max_width > 0) { if (textnw(dc, source, (eol - source) + 1) >= max_width) { @@ -1070,6 +1065,10 @@ int init_notification(notification * n, int id) } n->msg = fix_markup(n->msg); + + while (strstr(n->msg, "\\n") != NULL) + n->msg = string_replace("\\n", "\n", n->msg); + n->msg = rstrip(n->msg);