X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fparse.c;h=80a918cb89e8e76140acfcf6d952e967fbf675b8;hb=47cc179781aec47bf317c5c15879fa0dad95de86;hp=421dc48fa717f2cecdfce577276a1e446337eb78;hpb=5da148530ee8931c8ed7771c373146afaf2b14e1;p=chaz%2Fopenbox diff --git a/openbox/parse.c b/openbox/parse.c index 421dc48f..80a918cb 100644 --- a/openbox/parse.c +++ b/openbox/parse.c @@ -5,7 +5,7 @@ static GHashTable *reg = NULL; static ParseFunc func = NULL; /* parse tokens from the [openbox] section of the rc file */ -static void parse_rc_token(ParseTokenType type, union ParseToken token); +static void parse_rc_token(ParseToken *token); void destkey(gpointer key) { g_free(key); } @@ -31,20 +31,27 @@ void parse_reg_section(char *section, ParseFunc func) g_hash_table_insert(reg, g_ascii_strdown(section, -1), (void*)func); } -void parse_free_token(ParseTokenType type, union ParseToken token) +void parse_free_token(ParseToken *token) { - switch (type) { + GList *it; + + switch (token->type) { case TOKEN_STRING: - g_free(token.string); + g_free(token->data.string); break; case TOKEN_IDENTIFIER: - g_free(token.identifier); + g_free(token->data.identifier); + break; + case TOKEN_LIST: + for (it = token->data.list; it; it = it->next) { + parse_free_token(it->data); + g_free(it->data); + } + g_list_free(token->data.list); break; case TOKEN_REAL: case TOKEN_INTEGER: case TOKEN_BOOL: - case TOKEN_LBRACKET: - case TOKEN_RBRACKET: case TOKEN_LBRACE: case TOKEN_RBRACE: case TOKEN_EQUALS: @@ -59,10 +66,10 @@ void parse_set_section(char *section) func = (ParseFunc)g_hash_table_lookup(reg, section); } -void parse_token(ParseTokenType type, union ParseToken token) +void parse_token(ParseToken *token) { if (func != NULL) - func(type, token); + func(token); } static void parse_rc_token(ParseToken *token) @@ -75,7 +82,7 @@ static void parse_rc_token(ParseToken *token) if (id == NULL) { if (token->type == TOKEN_IDENTIFIER) { - id = token.identifier; + id = token->data.identifier; return; } else { yyerror("syntax error"); @@ -89,16 +96,16 @@ static void parse_rc_token(ParseToken *token) } } else if (!got_val) { if (token->type == TOKEN_STRING) { - s = token.string; - got_val = type; + s = token->data.string; + got_val = token->type; return; } else if (token->type == TOKEN_BOOL) { - b = token.bool; - got_val = type; + b = token->data.bool; + got_val = token->type; return; } else if (token->type == TOKEN_INTEGER) { - i = token.integer; - got_val = type; + i = token->data.integer; + got_val = token->type; return; } else yyerror("syntax error"); @@ -133,5 +140,5 @@ static void parse_rc_token(ParseToken *token) id = s = NULL; got_eq = FALSE; got_val = 0; - parse_free_token(token->type, token); + parse_free_token(token); }