From 2c8af19e350348f4e1d4eff86ca2a12b00ede08f Mon Sep 17 00:00:00 2001 From: eschnett Date: Sat, 2 Jul 2011 23:11:52 +0000 Subject: Accept comments in multi-line strings in parameter files Modify the parameter file parser to accept comments in multi-line strings. These comments extend from a "#" character to the end of the line. This makes it much easier to comment out variables in output strings. git-svn-id: http://svn.cactuscode.org/flesh/trunk@4710 17b73243-c579-4c4c-a9d2-2d5706c11dac --- src/util/ParseFile.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'src/util') diff --git a/src/util/ParseFile.c b/src/util/ParseFile.c index 7ccb9b20..646bed15 100644 --- a/src/util/ParseFile.c +++ b/src/util/ParseFile.c @@ -729,18 +729,42 @@ int ParseBuffer(char *buffer, #ifdef DEBUG printf("%c",c); #endif - value[p++] = (char)c; - CheckBuf(p,lineno); - if (c == '\n') + if (c == '#' && lineno != startline) { + /* found a comment inside a multi-line string */ + while ((c = buffer[pos++]) != '\n') + { + if (c == '\0') + { + break; + } + } + if (c == '\0') + { + value[p++] = (char)c; + CheckBuf(p,lineno); + break; + } #ifdef DEBUG printf ("LINE %d\n",lineno); #endif lineno++; } - else if (c == '\0') + else { - break; + value[p++] = (char)c; + CheckBuf(p,lineno); + if (c == '\n') + { +#ifdef DEBUG + printf ("LINE %d\n",lineno); +#endif + lineno++; + } + else if (c == '\0') + { + break; + } } } /* ignore all extra spaces or a trailing comment in this line */ -- cgit v1.2.3