From: Michel Alexandre Salim Date: Fri, 18 Mar 2011 19:44:00 +0000 (+0100) Subject: Only treat # as a comment marker if it's at the beginning of line or is preceded... X-Git-Url: https://git.toastfreeware.priv.at/gregoa/bti.git/commitdiff_plain/cb0d563370248c29cdc857c409d47387d068d7f6?hp=37a84bdcca02fc32e9e44c60ce297da2479ffc0a Only treat # as a comment marker if it's at the beginning of line or is preceded by a whitespace character --- diff --git a/config.c b/config.c index 346fed8..9326c71 100644 --- 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++;