summaryrefslogtreecommitdiffstats
path: root/sway/commands/set.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/set.c')
-rw-r--r--sway/commands/set.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/sway/commands/set.c b/sway/commands/set.c
index 46fc6d38..84e9b792 100644
--- a/sway/commands/set.c
+++ b/sway/commands/set.c
@@ -5,6 +5,7 @@
5#include "sway/commands.h" 5#include "sway/commands.h"
6#include "sway/config.h" 6#include "sway/config.h"
7#include "list.h" 7#include "list.h"
8#include "log.h"
8#include "stringop.h" 9#include "stringop.h"
9 10
10// sort in order of longest->shortest 11// sort in order of longest->shortest
@@ -14,16 +15,24 @@ static int compare_set_qsort(const void *_l, const void *_r) {
14 return strlen(r->name) - strlen(l->name); 15 return strlen(r->name) - strlen(l->name);
15} 16}
16 17
18void free_sway_variable(struct sway_variable *var) {
19 if (!var) {
20 return;
21 }
22 free(var->name);
23 free(var->value);
24 free(var);
25}
26
17struct cmd_results *cmd_set(int argc, char **argv) { 27struct cmd_results *cmd_set(int argc, char **argv) {
18 char *tmp; 28 char *tmp;
19 struct cmd_results *error = NULL; 29 struct cmd_results *error = NULL;
20 if (!config->reading) return cmd_results_new(CMD_FAILURE, "set", "Can only be used in config file.");
21 if ((error = checkarg(argc, "set", EXPECTED_AT_LEAST, 2))) { 30 if ((error = checkarg(argc, "set", EXPECTED_AT_LEAST, 2))) {
22 return error; 31 return error;
23 } 32 }
24 33
25 if (argv[0][0] != '$') { 34 if (argv[0][0] != '$') {
26 sway_log(L_INFO, "Warning: variable '%s' doesn't start with $", argv[0]); 35 wlr_log(L_INFO, "Warning: variable '%s' doesn't start with $", argv[0]);
27 36
28 size_t size = snprintf(NULL, 0, "$%s", argv[0]); 37 size_t size = snprintf(NULL, 0, "$%s", argv[0]);
29 tmp = malloc(size + 1); 38 tmp = malloc(size + 1);