diff options
-rw-r--r-- | mktrayicon.c | 12 |
1 files 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++) |