X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=openbox%2Fcparse.l;h=fcc72f06091cbb0ab939ecbe7528f6be791a6b28;hb=08a70966ee8fdec4204ab1ca9aed1371b1c828d0;hp=5a077493f8de04c080c763cfef1d2330450caf3d;hpb=93783c2a048574ffc99d329aae3f6ff50e31d8d7;p=chaz%2Fopenbox diff --git a/openbox/cparse.l b/openbox/cparse.l index 5a077493..fcc72f06 100644 --- a/openbox/cparse.l +++ b/openbox/cparse.l @@ -10,6 +10,7 @@ static ConfigEntry entry = { NULL, -1 }; static void stringvalue(); static void numbervalue(); +static void boolvalue(); static void identifier(); static void newline(); static int yywrap(); @@ -20,17 +21,19 @@ string \"[^"\n]*\" identifier [a-zA-Z][a-zA-Z0-9_.]* white [ \t]* assign {white}={white} +bool ([tT][rR][uU][eE]|[fF][aA][lL][sS][eE]|[yY][eE][sS]|[nN][oO]|[oO][nN]|[oO][fF][fF]) %% +^# comment = TRUE; +{bool}/{white}\n boolvalue(); {string}/{white}\n stringvalue(); {number}/{white}\n numbervalue(); ^{identifier}/{assign} identifier(); \n newline(); -^# comment = TRUE; = [ \t] -. haserror = TRUE; +. if (!comment) haserror = TRUE; %% @@ -61,6 +64,19 @@ static void numbervalue() } } +static void boolvalue() +{ + if (!comment) { + if (!haserror && entry.name != NULL && (signed)entry.type < 0) { + entry.type = Config_Bool; + entry.value.bool = (!g_ascii_strcasecmp("true", yytext) || + !g_ascii_strcasecmp("yes", yytext) || + !g_ascii_strcasecmp("on", yytext)); + } else + haserror = TRUE; + } +} + static void identifier() { if (!comment) { @@ -74,10 +90,10 @@ 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", - yyfilename, entry.name); + g_warning("Parser error in '%s' on line %d\n", yyfilename, + yylineno); } else { - printf("Parser error in '%s' on line %d\n", yyfilename, yylineno); + g_warning("Parser error in '%s' on line %d", yyfilename, yylineno); } g_free(entry.name); entry.name = NULL; @@ -87,6 +103,7 @@ static void newline() haserror = FALSE; } + comment = FALSE; ++yylineno; }