parse lines that start with '#' as comments

This commit is contained in:
Dana Jansens 2003-03-22 22:26:25 +00:00
parent 2b1a11c69d
commit 93783c2a04

View file

@ -5,6 +5,7 @@
static char *yyfilename;
static int yylineno = 1;
static gboolean haserror = FALSE;
static gboolean comment = FALSE;
static ConfigEntry entry = { NULL, -1 };
static void stringvalue();
@ -26,6 +27,7 @@ assign {white}={white}
{number}/{white}\n numbervalue();
^{identifier}/{assign} identifier();
\n newline();
^# comment = TRUE;
=
[ \t]
. haserror = TRUE;
@ -34,6 +36,7 @@ assign {white}={white}
static void stringvalue()
{
if (!comment) {
if (!haserror && entry.name != NULL && (signed)entry.type < 0) {
entry.type = Config_String;
entry.value.string = g_strdup(yytext+1); /* drop the left quote */
@ -45,24 +48,30 @@ static void stringvalue()
} else
haserror = TRUE;
}
}
static void numbervalue()
{
if (!comment) {
if (!haserror && entry.name != NULL && (signed)entry.type < 0) {
entry.type = Config_Integer;
entry.value.integer = atoi(yytext);
} else
haserror = TRUE;
}
}
static void identifier()
{
if (!comment) {
entry.name = g_strdup(yytext);
entry.type = -1;
}
}
static void newline()
{
if (!comment) {
if (!haserror && entry.name != NULL && (signed)entry.type >= 0) {
if (!config_set(entry.name, entry.type, entry.value))
g_warning("Invalid option in '%s': '%s'\n",
@ -77,6 +86,7 @@ static void newline()
entry.type = -1;
haserror = FALSE;
}
++yylineno;
}