src: more code fixes

current
Síle Ekaterin Liszka 2023-11-27 16:43:49 -08:00
parent f686af58a7
commit 91e3465541
3 changed files with 8 additions and 6 deletions

View File

@ -10,7 +10,7 @@ libtoml_dep = dependency(
exe = executable( exe = executable(
'smeargle', 'smeargle',
['src/main.c', 'src/font.c'], ['src/main.c', 'src/font.c', 'src/script.c'],
dependencies: libtoml_dep, dependencies: libtoml_dep,
install: true install: true
) )

View File

@ -51,7 +51,7 @@ font_t font_create(char *font_name, char *filename) {
void font_destroy(font_t font) { void font_destroy(font_t font) {
map_destroy(font.map); map_destroy(font.map);
free(font.name); free(font.name);
free(font.toml_filename); free(font.image_filename);
} }
unsigned int map_create(toml_table_t *table, map_t **map) { unsigned int map_create(toml_table_t *table, map_t **map) {

View File

@ -1,4 +1,6 @@
#include <toml.h>
#include "script.h" #include "script.h"
#include "util.h" #include "util.h"
@ -10,7 +12,7 @@ script_t script_create(toml_table_t *table) {
if (!(var).ok) {\ if (!(var).ok) {\
char str[200];\ char str[200];\
snprintf(str, 200, "key '%s' missing from", (key)); \ snprintf(str, 200, "key '%s' missing from", (key)); \
error(str, filename); \ error(str, filename.u.s); \
} }
TOML_GET_KEY(filename, "filename", toml_string_in) TOML_GET_KEY(filename, "filename", toml_string_in)
TOML_GET_KEY(font_name, "font", toml_string_in) TOML_GET_KEY(font_name, "font", toml_string_in)
@ -26,13 +28,13 @@ script_t script_create(toml_table_t *table) {
#undef TOML_GET_KEY #undef TOML_GET_KEY
toml_table_t *fonts = toml_table_in(table, "font"); toml_table_t *fonts = toml_table_in(table, "font");
toml_datum_t font_filename = toml_string_in(fonts, font_name); toml_datum_t font_filename = toml_string_in(fonts, font_name.u.s);
if (!font_filename.ok) { if (!font_filename.ok) {
char str[200] char str[200];
snprintf(str, 200, "failed to obtain data for font %s", font_name); snprintf(str, 200, "failed to obtain data for font %s", font_name);
error(str, ""); error(str, "");
} }
font = font_create(font_name, font_filename); font = font_create(font_name.u.s, font_filename.u.s);
script.filename = filename.u.s; script.filename = filename.u.s;
script.font = font; script.font = font;