summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2014-05-04 18:18:23 -0400
committerSimon Howard2014-05-04 18:18:23 -0400
commit869e52062b84ad65a8481f4a56bd83d2d31471a3 (patch)
treee4edafaaf0c2dc8d327b352d5bfd2471e42ecec5
parent9ec075b0249b8b63bb5725551d2cbf95f8b0bd9d (diff)
downloadchocolate-doom-869e52062b84ad65a8481f4a56bd83d2d31471a3.tar.gz
chocolate-doom-869e52062b84ad65a8481f4a56bd83d2d31471a3.tar.bz2
chocolate-doom-869e52062b84ad65a8481f4a56bd83d2d31471a3.zip
music: Tweak comment parsing for substitute configs.
Allow comments to be attached to the end of configuration lines, as well as being specified on a line on their own.
-rw-r--r--src/i_sdlmusic.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/i_sdlmusic.c b/src/i_sdlmusic.c
index 143f8eb2..a9b95562 100644
--- a/src/i_sdlmusic.c
+++ b/src/i_sdlmusic.c
@@ -520,11 +520,23 @@ static char *ParseSubstituteLine(char *filename, char *line)
char *p;
int hash_index;
+ // Strip out comments if present.
+ p = strchr(line, '#');
+ if (p != NULL)
+ {
+ while (p > line && isspace(*(p - 1)))
+ {
+ --p;
+ }
+ *p = '\0';
+ }
+
// Skip leading spaces.
for (p = line; *p != '\0' && isspace(*p); ++p);
- // Comment or empty line? This is valid syntax, so just return success.
- if (*p == '#' || *p == '\0')
+ // Empty line? This includes comment lines now that comments have
+ // been stripped.
+ if (*p == '\0')
{
return NULL;
}