summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharalampos Kardaris <ckardaris@outlook.com>2019-12-12 19:54:51 +0200
committerCharalampos Kardaris <ckardaris@outlook.com>2019-12-12 19:54:51 +0200
commit14da73d07fa5ef1c602c4a83a00a181ca02bf004 (patch)
treee0d7ced0721900ed2ea1053bb63f2d9a897a5753
parentAccept empty entries everywhere (diff)
downloadmktrayicon-14da73d07fa5ef1c602c4a83a00a181ca02bf004.tar.gz
mktrayicon-14da73d07fa5ef1c602c4a83a00a181ca02bf004.tar.bz2
mktrayicon-14da73d07fa5ef1c602c4a83a00a181ca02bf004.zip
Fix in escape logic
-rw-r--r--mktrayicon.c12
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++)
bgstack15