mirror of
https://github.com/javalsai/lidm.git
synced 2025-07-03 22:38:41 +02:00
Merge pull request #43 from javalsai/improvements
fix: broken cfg parser (blame 8403bfc2)
This commit is contained in:
commit
11e9257c4a
15
src/config.c
15
src/config.c
@ -126,7 +126,7 @@ struct parser_error parse_key(enum introspection_type typ, union typ_ptr at,
|
|||||||
aux_str = strdup(key);
|
aux_str = strdup(key);
|
||||||
if (!aux_str) FAIL("allocation failure");
|
if (!aux_str) FAIL("allocation failure");
|
||||||
aux_err = parse_str_inplace(aux_str);
|
aux_err = parse_str_inplace(aux_str);
|
||||||
if (!aux_err.msg) {
|
if (aux_err.msg) {
|
||||||
free(aux_str);
|
free(aux_str);
|
||||||
return aux_err;
|
return aux_err;
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ struct parser_error parse_key(enum introspection_type typ, union typ_ptr at,
|
|||||||
aux_str = strdup(key);
|
aux_str = strdup(key);
|
||||||
if (!aux_str) FAIL("allocation failure");
|
if (!aux_str) FAIL("allocation failure");
|
||||||
aux_err = parse_str_inplace(aux_str);
|
aux_err = parse_str_inplace(aux_str);
|
||||||
if (!aux_err.msg) {
|
if (aux_err.msg) {
|
||||||
free(aux_str);
|
free(aux_str);
|
||||||
return aux_err;
|
return aux_err;
|
||||||
}
|
}
|
||||||
@ -170,7 +170,7 @@ struct parser_error parse_key(enum introspection_type typ, union typ_ptr at,
|
|||||||
#undef FAIL
|
#undef FAIL
|
||||||
#undef NOFAIL
|
#undef NOFAIL
|
||||||
|
|
||||||
// NOLINTBEGIN(readability-identifier-length,readability-function-cognitive-complexity,readability-identifier-length)
|
// NOLINTBEGIN(readability-identifier-length,readability-function-cognitive-complexity)
|
||||||
struct status config_line_handler(void* _config, char* table, char* k,
|
struct status config_line_handler(void* _config, char* table, char* k,
|
||||||
char* v) {
|
char* v) {
|
||||||
struct config* config = (struct config*)_config;
|
struct config* config = (struct config*)_config;
|
||||||
@ -213,11 +213,14 @@ struct status config_line_handler(void* _config, char* table, char* k,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this_intros_key->typ == STRING)
|
||||||
|
log_printf("[I] cfg parsed [%s.%s] (%s)\n", table, k, *k_addr.string);
|
||||||
|
else
|
||||||
log_printf("[I] cfg parsed [%s.%s]\n", table, k);
|
log_printf("[I] cfg parsed [%s.%s]\n", table, k);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
// NOLINTEND(readability-identifier-length,readability-function-cognitive-complexity,readability-identifier-length)
|
// NOLINTEND(readability-identifier-length,readability-function-cognitive-complexity)
|
||||||
|
|
||||||
int parse_config(struct config* NNULLABLE config, char* NNULLABLE path) {
|
int parse_config(struct config* NNULLABLE config, char* NNULLABLE path) {
|
||||||
FILE* fd = fopen(path, "r");
|
FILE* fd = fopen(path, "r");
|
||||||
@ -232,9 +235,7 @@ int parse_config(struct config* NNULLABLE config, char* NNULLABLE path) {
|
|||||||
|
|
||||||
bool ret = read_desktop(fd, config, config_line_handler);
|
bool ret = read_desktop(fd, config, config_line_handler);
|
||||||
(void)fclose(fd);
|
(void)fclose(fd);
|
||||||
if (!ret) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!ret) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user