]> ToastFreeware Gitweb - gregoa/bti.git/blobdiff - config.c
Only treat # as a comment marker if it's at the beginning of line or is preceded...
[gregoa/bti.git] / config.c
index 346fed8ceaacc83d4b86d2c7f68424a9d4df9f35..9326c7132ab6ada3ebf40a56cebdbedc6bfa62dc 100644 (file)
--- a/config.c
+++ b/config.c
@@ -344,8 +344,14 @@ void bti_parse_configfile(struct session *session)
                if (line[n - 1] == '\n')
                        line[n - 1] = '\0';
 
-               /* '#' is comment markers, like bash style */
-               *strchrnul(line, '#') = '\0';
+               /* '#' is comment markers, like bash style
+                  but it is a valid character in some fields, so
+                  only treat it as a comment marker if it occurs
+                  at the beginning of the line, or after whitespace */
+               char *hashmarker = strchrnul(line, '#');
+               if (line == hashmarker) line[0] = '\0';
+               if (*(--hashmarker) == ' ' || *hashmarker == '\t')
+                       *hashmarker = '\0';
                c = line;
                while (isspace(*c))
                        c++;