From 92cb89490bbb23a0931fbf6cc6e21a5b9acebe82 Mon Sep 17 00:00:00 2001 From: Kim Woelders Date: Sun, 21 Jan 2018 16:02:36 +0100 Subject: [PATCH] Avoid confusing dual use of Mode.theme.path --- src/E.h | 2 +- src/main.c | 8 +++++--- src/theme.c | 20 +++++++++++--------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/E.h b/src/E.h index 96f73442..28bf4365 100644 --- a/src/E.h +++ b/src/E.h @@ -551,7 +551,7 @@ void StartupBackgroundsDestroy(void); /* theme.c */ char *ThemePathFind(const char *theme); char *ThemePathName(const char *path); -void ThemeFind(void); +void ThemeFind(const char *theme); char **ThemesList(int *num); /* diff --git a/src/main.c b/src/main.c index 5921ee61..93249d24 100644 --- a/src/main.c +++ b/src/main.c @@ -96,6 +96,7 @@ main(int argc, char **argv) int ch, i, loop; struct utsname ubuf; const char *str, *dstr; + char *theme; /* This function runs all the setup for startup, and then * proceeds into the primary event loop at the end. @@ -146,7 +147,7 @@ main(int argc, char **argv) * understand. */ - Mode.theme.path = NULL; + theme = NULL; dstr = NULL; for (loop = 1; loop;) @@ -194,7 +195,7 @@ main(int argc, char **argv) SetSMID(eoptarg); break; case 't': - Mode.theme.path = Estrdup(eoptarg); + theme = Estrdup(eoptarg); break; case 'V': printf("%s %s\n", e_wm_name, e_wm_version); @@ -240,7 +241,8 @@ main(int argc, char **argv) LangInit(); /* The theme path must now be available for config file loading. */ - ThemeFind(); + ThemeFind(theme); + Efree(theme); /* Set the Environment variables */ Esetenv("EVERSION", e_wm_version); diff --git a/src/theme.c b/src/theme.c index 110314fc..9186c139 100644 --- a/src/theme.c +++ b/src/theme.c @@ -337,16 +337,18 @@ ThemePathFind(const char *theme) } void -ThemeFind(void) +ThemeFind(const char *theme) { - char *name, *path, *s; + char name[FILEPATH_LEN_MAX]; + const char *p; + char *path, *s; - /* - * Conf.theme.name is read from the configuration. - * Mode.theme.path may be assigned on the command line. - */ - name = (Mode.theme.path) ? Mode.theme.path : Conf.theme.name; - s = (name) ? strchr(name, '=') : NULL; + name[0] = '\0'; + p = (theme) ? theme : Conf.theme.name; + if (p) + snprintf(name, sizeof(name), "%s", p); + + s = strchr(name, '='); if (s) { *s++ = '\0'; @@ -356,7 +358,7 @@ ThemeFind(void) path = ThemePathFind(name); - if (!path && (!name || strcmp(name, "-"))) + if (!path && strcmp(name, "-")) { Alert(_("No themes were found in the default directories:\n" " %s\n"