diff options
author | Charalampos Kardaris <ckardaris@outlook.com> | 2019-12-12 19:54:51 +0200 |
---|---|---|
committer | Charalampos Kardaris <ckardaris@outlook.com> | 2019-12-12 19:54:51 +0200 |
commit | 14da73d07fa5ef1c602c4a83a00a181ca02bf004 (patch) | |
tree | e0d7ced0721900ed2ea1053bb63f2d9a897a5753 /mktrayicon.c | |
parent | Accept empty entries everywhere (diff) | |
download | mktrayicon-14da73d07fa5ef1c602c4a83a00a181ca02bf004.tar.gz mktrayicon-14da73d07fa5ef1c602c4a83a00a181ca02bf004.tar.bz2 mktrayicon-14da73d07fa5ef1c602c4a83a00a181ca02bf004.zip |
Fix in escape logic
Diffstat (limited to 'mktrayicon.c')
-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++) |