diff options
-rw-r--r-- | common/stringop.c | 20 | ||||
-rw-r--r-- | sway/config.c | 8 |
2 files changed, 5 insertions, 23 deletions
diff --git a/common/stringop.c b/common/stringop.c index efa3a207..81d9b963 100644 --- a/common/stringop.c +++ b/common/stringop.c | |||
@@ -10,7 +10,6 @@ | |||
10 | 10 | ||
11 | const char whitespace[] = " \f\n\r\t\v"; | 11 | const char whitespace[] = " \f\n\r\t\v"; |
12 | 12 | ||
13 | /* Note: This returns 8 characters for trimmed_start per tab character. */ | ||
14 | char *strip_whitespace(char *_str) { | 13 | char *strip_whitespace(char *_str) { |
15 | if (*_str == '\0') | 14 | if (*_str == '\0') |
16 | return _str; | 15 | return _str; |
@@ -29,25 +28,6 @@ char *strip_whitespace(char *_str) { | |||
29 | return str; | 28 | return str; |
30 | } | 29 | } |
31 | 30 | ||
32 | char *strip_comments(char *str) { | ||
33 | int in_string = 0, in_character = 0; | ||
34 | int i = 0; | ||
35 | while (str[i] != '\0') { | ||
36 | if (str[i] == '"' && !in_character) { | ||
37 | in_string = !in_string; | ||
38 | } else if (str[i] == '\'' && !in_string) { | ||
39 | in_character = !in_character; | ||
40 | } else if (!in_character && !in_string) { | ||
41 | if (str[i] == '#') { | ||
42 | str[i] = '\0'; | ||
43 | break; | ||
44 | } | ||
45 | } | ||
46 | ++i; | ||
47 | } | ||
48 | return str; | ||
49 | } | ||
50 | |||
51 | void strip_quotes(char *str) { | 31 | void strip_quotes(char *str) { |
52 | bool in_str = false; | 32 | bool in_str = false; |
53 | bool in_chr = false; | 33 | bool in_chr = false; |
diff --git a/sway/config.c b/sway/config.c index dd466e5b..67b442ad 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -207,7 +207,10 @@ bool read_config(FILE *file, bool is_active) { | |||
207 | while (!feof(file)) { | 207 | while (!feof(file)) { |
208 | line = read_line(file); | 208 | line = read_line(file); |
209 | line_number++; | 209 | line_number++; |
210 | line = strip_comments(line); | 210 | line = strip_whitespace(line); |
211 | if (line[0] == '#') { | ||
212 | continue; | ||
213 | } | ||
211 | struct cmd_results *res = config_command(line); | 214 | struct cmd_results *res = config_command(line); |
212 | switch(res->status) { | 215 | switch(res->status) { |
213 | case CMD_FAILURE: | 216 | case CMD_FAILURE: |
@@ -261,8 +264,7 @@ bool read_config(FILE *file, bool is_active) { | |||
261 | return success; | 264 | return success; |
262 | } | 265 | } |
263 | 266 | ||
264 | int output_name_cmp(const void *item, const void *data) | 267 | int output_name_cmp(const void *item, const void *data) { |
265 | { | ||
266 | const struct output_config *output = item; | 268 | const struct output_config *output = item; |
267 | const char *name = data; | 269 | const char *name = data; |
268 | 270 | ||