From 9ac736c72ffcbdd48a08e2bc195b05953aa4c88c Mon Sep 17 00:00:00 2001 From: Lukas Nykryn Date: Tue, 16 Sep 2014 17:09:57 +0200 Subject: rename_devices: comments need to have a blank before them Cherry-picked from: 65901ce5f29f9ec45339c3474a360d9bbcee6bac Resolves: #1220924 --- src/rename_device.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/rename_device.c') diff --git a/src/rename_device.c b/src/rename_device.c index f8cfd391..2f0d8de9 100644 --- a/src/rename_device.c +++ b/src/rename_device.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -120,13 +121,19 @@ int isCfg(const struct dirent *dent) { } static inline char *dequote(char *start, char *end) { - char *c; - //remove comments and trailing whitespace - c = strchr(start, '#'); - if (c!=NULL) - *c='\0'; + char *c; + //remove comments and trailing whitespace + for (c = start; c && *c; c++) { + c = strchr(c, '#'); + if (!c) + break; + if (c > start && isblank(*(c-1))) { + *c = '\0'; + break; + } + } - g_strchomp(start); + g_strchomp(start); if (end==NULL) { end=start; -- cgit v1.2.1