diff options
author | eschnett <eschnett@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2011-07-02 23:11:52 +0000 |
---|---|---|
committer | eschnett <eschnett@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2011-07-02 23:11:52 +0000 |
commit | 2c8af19e350348f4e1d4eff86ca2a12b00ede08f (patch) | |
tree | 1d12a1d1a534ebe2946a20fc59cc1ec10d5380db /src/util | |
parent | 067fb40ec3ecc89821f559b60eecd451c49fb6a2 (diff) |
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
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/ParseFile.c | 34 |
1 files changed, 29 insertions, 5 deletions
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 */ |