mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 13:37:22 +00:00
[common] add comment support to the ini parser
This commit is contained in:
parent
1aadf91901
commit
6aeafc6651
@ -367,6 +367,7 @@ bool option_load(const char * filename)
|
|||||||
int lineno = 1;
|
int lineno = 1;
|
||||||
char * module = NULL;
|
char * module = NULL;
|
||||||
bool line = true;
|
bool line = true;
|
||||||
|
bool comment = false;
|
||||||
bool expectLine = false;
|
bool expectLine = false;
|
||||||
bool expectValue = false;
|
bool expectValue = false;
|
||||||
char * name = NULL;
|
char * name = NULL;
|
||||||
@ -379,6 +380,9 @@ bool option_load(const char * filename)
|
|||||||
|
|
||||||
for(int c = fgetc(fp); !feof(fp); c = fgetc(fp))
|
for(int c = fgetc(fp); !feof(fp); c = fgetc(fp))
|
||||||
{
|
{
|
||||||
|
if (comment && c != '\n')
|
||||||
|
continue;
|
||||||
|
|
||||||
switch(c)
|
switch(c)
|
||||||
{
|
{
|
||||||
case '[':
|
case '[':
|
||||||
@ -477,6 +481,14 @@ bool option_load(const char * filename)
|
|||||||
(*p)[(*len)++] = c;
|
(*p)[(*len)++] = c;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ';':
|
||||||
|
if (line)
|
||||||
|
{
|
||||||
|
comment = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// fallthrough
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (expectLine)
|
if (expectLine)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user