From 14da73d07fa5ef1c602c4a83a00a181ca02bf004 Mon Sep 17 00:00:00 2001 From: Charalampos Kardaris Date: Thu, 12 Dec 2019 19:54:51 +0200 Subject: Fix in escape logic --- mktrayicon.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mktrayicon.c b/mktrayicon.c index b414af3..634bc80 100644 --- a/mktrayicon.c +++ b/mktrayicon.c @@ -19,12 +19,18 @@ */ char* strncpy_esc(char *dest, const char *src, size_t n) { - size_t i; + size_t i = 0; size_t index = 0; - for (i = 0; i < n && src[i] != '\0'; i++){ - if (src[i] != '\\'){ + while (i < n && src[i] != '\0'){ + if (src[i] == '\\' && src[i+1] != '\0'){ + dest[index] = src[i+1]; + index++; + i+=2; + } + else{ dest[index] = src[i]; index++; + i++; } } for ( ; index < n; index++) -- cgit