Skip to content

Commit

Permalink
Merge branch 'yshui:next' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
pijulius authored Jun 13, 2024
2 parents a312328 + 68cb383 commit a0e8188
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "common.h"
#include "log.h"
#include "utils/dynarr.h"
#include "utils/kernel.h"
#include "utils/str.h"

Expand Down Expand Up @@ -722,5 +723,6 @@ bool parse_config(options_t *opt, const char *config_file) {
// clang-format on

list_init_head(&opt->included_config_files);
opt->all_scripts = dynarr_new(struct script *, 4);
return parse_config_libconfig(opt, config_file);
}
14 changes: 5 additions & 9 deletions src/config_libconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,18 +387,17 @@ parse_animation_one(struct win_script *animations, config_setting_t *setting) {
return script;
}

static struct script **
parse_animations(struct win_script *animations, config_setting_t *setting) {
/// `out_scripts`: all the script objects created, this is a dynarr.
static void parse_animations(struct win_script *animations, config_setting_t *setting,
struct script ***out_scripts) {
auto number_of_animations = (unsigned)config_setting_length(setting);
auto all_scripts = dynarr_new(struct script *, number_of_animations + 1);
for (unsigned i = 0; i < number_of_animations; i++) {
auto sub = config_setting_get_elem(setting, (unsigned)i);
auto script = parse_animation_one(animations, sub);
if (script != NULL) {
dynarr_push(all_scripts, script);
dynarr_push(*out_scripts, script);
}
}
return all_scripts;
}

#define FADING_TEMPLATE_1 \
Expand Down Expand Up @@ -984,10 +983,7 @@ bool parse_config_libconfig(options_t *opt, const char *config_file) {

config_setting_t *animations = config_lookup(&cfg, "animations");
if (animations) {
opt->all_scripts = parse_animations(opt->animations, animations);
} else {
// Reserve some space for generated fading scripts.
opt->all_scripts = dynarr_new(struct script *, 4);
parse_animations(opt->animations, animations, &opt->all_scripts);
}

opt->config_file_path = path;
Expand Down

0 comments on commit a0e8188

Please sign in to comment.