aboutsummaryrefslogtreecommitdiffstats
path: root/libfonts_get_output_rendering_settings.c
diff options
context:
space:
mode:
Diffstat (limited to 'libfonts_get_output_rendering_settings.c')
-rw-r--r--libfonts_get_output_rendering_settings.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/libfonts_get_output_rendering_settings.c b/libfonts_get_output_rendering_settings.c
index aa3af95..f634550 100644
--- a/libfonts_get_output_rendering_settings.c
+++ b/libfonts_get_output_rendering_settings.c
@@ -17,7 +17,7 @@ getn(const char *file_part1, size_t file_part1_len, const char *file_part2,
if (!path) {
enomem:
errno = ENOMEM;
- return 0; /* TODO abort function */
+ return -1;
}
memcpy(path, file_part1, file_part1_len);
@@ -60,23 +60,29 @@ libfonts_get_output_rendering_settings(struct libfonts_rendering_settings *setti
}
env = libfonts_getenv__("XDG_CONFIG_HOME", ctx);
- if (env && *env)
- if (get(env, "/libfonts/output-rendering.conf", settings, name, ctx))
+ if (env && *env) {
+ ret = get(env, "/libfonts/output-rendering.conf", settings, name, ctx);
+ if (ret)
goto out;
+ }
env = libfonts_getenv__("HOME", ctx);
if (env && *env) {
- if (get(env, "/.config/libfonts/output-rendering.conf", settings, name, ctx))
+ ret = get(env, "/.config/libfonts/output-rendering.conf", settings, name, ctx);
+ if (ret)
goto out;
- if (get(env, "/.libfonts/output-rendering.conf", settings, name, ctx))
+ ret = get(env, "/.libfonts/output-rendering.conf", settings, name, ctx);
+ if (ret)
goto out;
}
home = libfonts_gethome__(ctx);
if (home && *home) {
- if (get(home, "/.config/libfonts/output-rendering.conf", settings, name, ctx))
+ ret = get(home, "/.config/libfonts/output-rendering.conf", settings, name, ctx);
+ if (ret)
goto out;
- if (get(home, "/.libfonts/output-rendering.conf", settings, name, ctx))
+ ret = get(home, "/.libfonts/output-rendering.conf", settings, name, ctx);
+ if (ret)
goto out;
}
@@ -85,21 +91,21 @@ libfonts_get_output_rendering_settings(struct libfonts_rendering_settings *setti
do {
next = strchr(&env[1], ':');
len = next ? (size_t)(next - env) : strlen(env);
- if (len)
- if (getn(env, len, "/libfonts/output-rendering.conf", settings, name, ctx))
+ if (len) {
+ ret = getn(env, len, "/libfonts/output-rendering.conf", settings, name, ctx);
+ if (ret)
goto out;
+ }
env += len + 1;
} while (next);
}
- if (get("/etc", "/libfonts/output-rendering.conf", settings, name, ctx))
- goto out;
-
- ret = 0;
+ ret = get("/etc", "/libfonts/output-rendering.conf", settings, name, ctx);
out:
free(home);
- errno = saved_errno;
+ if (ret >= 0)
+ errno = saved_errno;
return ret;
}