summaryrefslogtreecommitdiff
path: root/openbox/cparse.l
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2003-03-22 22:26:25 +0000
committerDana Jansens <danakj@orodu.net>2003-03-22 22:26:25 +0000
commit93783c2a048574ffc99d329aae3f6ff50e31d8d7 (patch)
tree5ce38d67417fbd5edf2b599496f02513d56429a2 /openbox/cparse.l
parent2b1a11c69dd6dd1fce86279bb12f6206d09bc5e5 (diff)
parse lines that start with '#' as comments
Diffstat (limited to 'openbox/cparse.l')
-rw-r--r--openbox/cparse.l70
1 files changed, 40 insertions, 30 deletions
diff --git a/openbox/cparse.l b/openbox/cparse.l
index c2bd008c..5a077493 100644
--- a/openbox/cparse.l
+++ b/openbox/cparse.l
@@ -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,49 +36,57 @@ assign {white}={white}
static void stringvalue()
{
- if (!haserror && entry.name != NULL && (signed)entry.type < 0) {
- entry.type = Config_String;
- entry.value.string = g_strdup(yytext+1); /* drop the left quote */
- if (entry.value.string[yyleng-2] != '"')
- printf("warning: improperly terminated string on line %d\n",
- yylineno);
- else
- entry.value.string[yyleng-2] = '\0';
- } else
- haserror = TRUE;
+ 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 */
+ if (entry.value.string[yyleng-2] != '"')
+ printf("warning: improperly terminated string on line %d\n",
+ yylineno);
+ else
+ entry.value.string[yyleng-2] = '\0';
+ } else
+ haserror = TRUE;
+ }
}
static void numbervalue()
{
- if (!haserror && entry.name != NULL && (signed)entry.type < 0) {
- entry.type = Config_Integer;
- entry.value.integer = atoi(yytext);
- } else
- haserror = TRUE;
+ 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()
{
- entry.name = g_strdup(yytext);
- entry.type = -1;
+ if (!comment) {
+ entry.name = g_strdup(yytext);
+ entry.type = -1;
+ }
}
static void newline()
{
- 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);
- } else {
- printf("Parser error in '%s' on line %d\n", yyfilename, yylineno);
- }
- g_free(entry.name);
- entry.name = NULL;
- if (entry.type == Config_String)
- g_free(entry.value.string);
- entry.type = -1;
+ 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);
+ } else {
+ printf("Parser error in '%s' on line %d\n", yyfilename, yylineno);
+ }
+ g_free(entry.name);
+ entry.name = NULL;
+ if (entry.type == Config_String)
+ g_free(entry.value.string);
+ entry.type = -1;
- haserror = FALSE;
+ haserror = FALSE;
+ }
++yylineno;
}