conf: replace "mask" bit field with two "bool" variables
Due to padding, this takes the same amount of memory.
This commit is contained in:
parent
b1e95b1fa8
commit
34e9a0a960
18
src/conf.c
18
src/conf.c
@ -39,13 +39,12 @@
|
|||||||
#define CONF_BLOCK_BEGIN "{"
|
#define CONF_BLOCK_BEGIN "{"
|
||||||
#define CONF_BLOCK_END "}"
|
#define CONF_BLOCK_END "}"
|
||||||
|
|
||||||
#define CONF_REPEATABLE_MASK 0x01
|
|
||||||
#define CONF_BLOCK_MASK 0x02
|
|
||||||
#define CONF_LINE_TOKEN_MAX 3
|
#define CONF_LINE_TOKEN_MAX 3
|
||||||
|
|
||||||
struct config_entry {
|
struct config_entry {
|
||||||
const char *name;
|
const char *name;
|
||||||
unsigned char mask;
|
bool repeatable;
|
||||||
|
bool block;
|
||||||
|
|
||||||
GSList *params;
|
GSList *params;
|
||||||
};
|
};
|
||||||
@ -111,14 +110,10 @@ newConfigEntry(const char *name, int repeatable, int block)
|
|||||||
struct config_entry *ret = g_new(struct config_entry, 1);
|
struct config_entry *ret = g_new(struct config_entry, 1);
|
||||||
|
|
||||||
ret->name = name;
|
ret->name = name;
|
||||||
ret->mask = 0;
|
ret->repeatable = repeatable;
|
||||||
|
ret->block = block;
|
||||||
ret->params = NULL;
|
ret->params = NULL;
|
||||||
|
|
||||||
if (repeatable)
|
|
||||||
ret->mask |= CONF_REPEATABLE_MASK;
|
|
||||||
if (block)
|
|
||||||
ret->mask |= CONF_BLOCK_MASK;
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,15 +329,14 @@ void config_read_file(const char *file)
|
|||||||
g_error("unrecognized parameter in config file at "
|
g_error("unrecognized parameter in config file at "
|
||||||
"line %i: %s\n", count, string);
|
"line %i: %s\n", count, string);
|
||||||
|
|
||||||
if (!(entry->mask & CONF_REPEATABLE_MASK) &&
|
if (entry->params != NULL && !entry->repeatable) {
|
||||||
entry->params != NULL) {
|
|
||||||
param = entry->params->data;
|
param = entry->params->data;
|
||||||
g_error("config parameter \"%s\" is first defined on "
|
g_error("config parameter \"%s\" is first defined on "
|
||||||
"line %i and redefined on line %i\n",
|
"line %i and redefined on line %i\n",
|
||||||
array[0], param->line, count);
|
array[0], param->line, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry->mask & CONF_BLOCK_MASK) {
|
if (entry->block) {
|
||||||
if (0 != strcmp(array[1], CONF_BLOCK_BEGIN)) {
|
if (0 != strcmp(array[1], CONF_BLOCK_BEGIN)) {
|
||||||
g_error("improperly formatted config file at "
|
g_error("improperly formatted config file at "
|
||||||
"line %i: %s\n", count, string);
|
"line %i: %s\n", count, string);
|
||||||
|
Loading…
Reference in New Issue
Block a user