Add 'line' as a configuration parsing primitive and use it for ignoring comment lines, so that punctuation in them doesn't cause problems anymore.
Patch status: merged
Patch by Eelis van der Weegen
To apply this patch, use:
curl http://cr.i3wm.org/patch/121/raw.patch | git am
b/parser-specs/config.spec
16 |
@@ -49,7 +49,7 @@ state INITIAL: |
17 |
|
18 |
# We ignore comments and 'set' lines (variables). |
19 |
state IGNORE_LINE: |
20 |
- end, string |
21 |
+ line |
22 |
-> INITIAL |
23 |
|
24 |
# floating_minimum_size <width> x <height> |
25 |
@@ -311,7 +311,7 @@ state MODE: |
26 |
|
27 |
# We ignore comments and 'set' lines (variables). |
28 |
state MODE_IGNORE_LINE: |
29 |
- end, string |
30 |
+ line |
31 |
-> MODE |
32 |
|
33 |
state MODE_BINDING: |
34 |
@@ -362,7 +362,7 @@ state BAR: |
35 |
|
36 |
# We ignore comments and 'set' lines (variables). |
37 |
state BAR_IGNORE_LINE: |
38 |
- end, string |
39 |
+ line |
40 |
-> BAR |
41 |
|
42 |
state BAR_BAR_COMMAND: |
43 |
@@ -428,7 +428,7 @@ state BAR_COLORS: |
44 |
|
45 |
# We ignore comments and 'set' lines (variables). |
46 |
state BAR_COLORS_IGNORE_LINE: |
47 |
- end, string |
48 |
+ line |
49 |
-> BAR_COLORS |
50 |
|
51 |
state BAR_COLORS_SINGLE: |
b/src/config_parser.c
56 |
@@ -446,6 +446,16 @@ struct ConfigResult *parse_config(const char *input, struct context *context) { |
57 |
} |
58 |
} |
59 |
|
60 |
+ if (strcmp(token->name, "line") == 0) { |
61 |
+ while (*walk != '\0' && *walk != '\n' && *walk != '\r') |
62 |
+ walk++; |
63 |
+ next_state(token); |
64 |
+ token_handled = true; |
65 |
+ linecnt++; |
66 |
+ walk++; |
67 |
+ break; |
68 |
+ } |
69 |
+ |
70 |
if (strcmp(token->name, "end") == 0) { |
71 |
//printf("checking for end: *%s*\n", walk); |
72 |
if (*walk == '\0' || *walk == '\n' || *walk == '\r') { |