Commit 53b86282 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Simplify

parent 490d3dd9
...@@ -337,22 +337,21 @@ config_parse(girara_session_t* session, const char* path) ...@@ -337,22 +337,21 @@ config_parse(girara_session_t* session, const char* path)
continue; continue;
} }
girara_list_t* argument_list = girara_list_new(); girara_list_t* argument_list = girara_list_new2(g_free);
if (argument_list == NULL) { if (argument_list == NULL) {
g_free(line); g_free(line);
fclose(file); fclose(file);
return false; return false;
} }
girara_list_set_free_function(argument_list, g_free);
gchar** argv = NULL; gchar** argv = NULL;
gint argc = 0; gint argc = 0;
/* parse current line */
if (g_shell_parse_argv(line, &argc, &argv, NULL) != FALSE) { if (g_shell_parse_argv(line, &argc, &argv, NULL) != FALSE) {
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
char* argument = g_strdup(argv[i]); char* argument = g_strdup(argv[i]);
girara_list_append(argument_list, (void*) argument); girara_list_append(argument_list, argument);
} }
} else { } else {
girara_list_free(argument_list); girara_list_free(argument_list);
...@@ -390,18 +389,16 @@ config_parse(girara_session_t* session, const char* path) ...@@ -390,18 +389,16 @@ config_parse(girara_session_t* session, const char* path)
} else { } else {
/* search for config handle */ /* search for config handle */
girara_session_private_t* session_private = session->private_data; girara_session_private_t* session_private = session->private_data;
girara_config_handle_t* handle = NULL; bool found = false;
GIRARA_LIST_FOREACH_BODY(session_private->config.handles, girara_config_handle_t*, tmp, GIRARA_LIST_FOREACH_BODY(session_private->config.handles, girara_config_handle_t*, handle,
handle = tmp;
if (g_strcmp0(handle->identifier, argv[0]) == 0) { if (g_strcmp0(handle->identifier, argv[0]) == 0) {
found = true;
handle->handle(session, argument_list); handle->handle(session, argument_list);
break; break;
} else {
handle = NULL;
} }
); );
if (handle == NULL) { if (found == false) {
girara_warning("Could not process line %d in '%s': Unknown handle '%s'", line_number, path, argv[0]); girara_warning("Could not process line %d in '%s': Unknown handle '%s'", line_number, path, argv[0]);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment