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:
tokyo4j 2025-10-15 16:36:01 +09:00 committed by Hiroaki Yamamoto
parent eebf5b3e4e
commit 7f67b9c866
8 changed files with 50 additions and 101 deletions

View file

@ -12,7 +12,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common/grab-file.h"
#include "common/buf.h"
#include "common/mem.h"
#include "common/string-helpers.h"
#include "buffer.h"
@ -273,7 +273,7 @@ img_xbm_load(const char *filename, float *rgba)
uint32_t color = argb32(rgba);
/* Read file into memory as it's easier to tokenize that way */
struct buf token_buf = grab_file(filename);
struct buf token_buf = buf_from_file(filename);
if (token_buf.len) {
struct token *tokens = tokenize_xbm(token_buf.data);
pixmap = parse_xbm_tokens(tokens, color);