diff options
author | Karl Berry <karl@freefriends.org> | 2010-11-07 18:44:02 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-11-07 18:44:02 +0000 |
commit | 06c82f3579a129beef83a8606658c58c649cae8c (patch) | |
tree | 95bc2ac952c11d7cf7aa699c1c89ac4a157005b9 /Build/source/texk/kpathsea/cnf.c | |
parent | d08417bc6582e8e4fa6fa2d6248259446b3b050e (diff) |
remove trailing comment and preceding whitespace, so they do not appear as part of a variable value (from Akira)
git-svn-id: svn://tug.org/texlive/trunk@20354 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/kpathsea/cnf.c')
-rw-r--r-- | Build/source/texk/kpathsea/cnf.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Build/source/texk/kpathsea/cnf.c b/Build/source/texk/kpathsea/cnf.c index 5c11ae30d00..cb18c66ab83 100644 --- a/Build/source/texk/kpathsea/cnf.c +++ b/Build/source/texk/kpathsea/cnf.c @@ -64,6 +64,21 @@ do_line (kpathsea kpse, string line) if (*line == 0 || *line == '%' || *line == '#') return; + /* Remove trailing comment: a % or # preceded by whitespace. Also + remove any whitespace before that. For example, the value for + foo = a#b %something + is a#b. */ + value = line + strlen (line) - 1; /* start at end of line */ + while (value > line) { + if (*value == '%' || *value == '#') { + value--; /* move before comment char */ + while (ISSPACE (*value)) + *value-- = 0; /* wipe out as much preceding whitespace + continue; (and comment) as we find */ + } + value--; /* move before the new null byte */ + } + /* The variable name is everything up to the next space or = or `.'. */ start = line; while (!ISSPACE (*line) && *line != '=' && *line != '.') |