From 35b912dd259ed1b1530a70217d2640ce76eba2e6 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Mon, 16 Jun 2014 20:15:29 +0200 Subject: [PATCH] util: rewrote path building in makeThemePack Use a better name for local variable and allocate the (almost) correct number of characters for the path instead of a fixed offset that could be a problem if the constant part of the path were to be updated. Signed-off-by: Christophe CURIS --- util/getstyle.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/util/getstyle.c b/util/getstyle.c index 7c8f00b4..08909a84 100644 --- a/util/getstyle.c +++ b/util/getstyle.c @@ -181,6 +181,9 @@ static void findCopyFile(const char *dir, const char *file) free(fullPath); } +#define THEME_SUBPATH "/Library/WindowMaker/Themes/" +#define THEME_EXTDIR ".themed/" + static void makeThemePack(WMPropList * style, const char *themeName) { WMPropList *keys; @@ -189,13 +192,16 @@ static void makeThemePack(WMPropList * style, const char *themeName) int i; size_t themeNameLen; char *themeDir; - const char *t; + const char *user_base; - if ((t = wusergnusteppath()) == NULL) + user_base = wusergnusteppath(); + if (user_base == NULL) return; - themeNameLen = strlen(t) + strlen(themeName) + 50; + themeNameLen = strlen(user_base) + sizeof(THEME_SUBPATH) + strlen(themeName) + sizeof(THEME_EXTDIR) + 1; themeDir = wmalloc(themeNameLen); - snprintf(themeDir, themeNameLen, "%s/Library/WindowMaker/Themes/%s.themed/", t, themeName); + snprintf(themeDir, themeNameLen, + "%s" THEME_SUBPATH "%s" THEME_EXTDIR, + user_base, themeName); ThemePath = themeDir; if (!wmkdirhier(themeDir)) { -- 2.11.4.GIT