mirror of
https://github.com/labwc/labwc.git
synced 2026-02-16 22:05:27 -05:00
Don't remove newlines when parsing config, menu and XBM
Removing newlines in rc.xml and menu.xml caused parser error with following content: <!-- - - Some comments - --> ...though it is a valid XML. Let's not do that. I moved `grab_file()` to `buf.c` and renamed it to `buf_from_file()`, because it now directly touches `struct buf` and I don't like having a source file only for one function.
This commit is contained in:
parent
eebf5b3e4e
commit
7f67b9c866
8 changed files with 50 additions and 101 deletions
|
|
@ -1872,25 +1872,13 @@ rcxml_read(const char *filename)
|
|||
*/
|
||||
for (struct wl_list *elm = iter(&paths); elm != &paths; elm = iter(elm)) {
|
||||
struct path *path = wl_container_of(elm, path, link);
|
||||
FILE *stream = fopen(path->string, "r");
|
||||
if (!stream) {
|
||||
struct buf b = buf_from_file(path->string);
|
||||
if (!b.len) {
|
||||
continue;
|
||||
}
|
||||
|
||||
wlr_log(WLR_INFO, "read config file %s", path->string);
|
||||
|
||||
struct buf b = BUF_INIT;
|
||||
char *line = NULL;
|
||||
size_t len = 0;
|
||||
while (getline(&line, &len, stream) != -1) {
|
||||
char *p = strrchr(line, '\n');
|
||||
if (p) {
|
||||
*p = '\0';
|
||||
}
|
||||
buf_add(&b, line);
|
||||
}
|
||||
zfree(line);
|
||||
fclose(stream);
|
||||
rcxml_parse_xml(&b);
|
||||
buf_reset(&b);
|
||||
if (!should_merge_config) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue