diff options
author | Ulrich Sibiller <uli42@gmx.de> | 2019-04-23 19:19:04 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2019-05-10 16:24:03 +0200 |
commit | 8029141e772568872e668cfb1df9b5a7968d2236 (patch) | |
tree | d53547d5eaedc2fa5758c3e4eb09d2315fe22ba8 /nx-X11/programs/Xserver/hw | |
parent | bcb5c7962ae18d36205e4fa0b578ca9e95559859 (diff) | |
download | nx-libs-8029141e772568872e668cfb1df9b5a7968d2236.tar.gz nx-libs-8029141e772568872e668cfb1df9b5a7968d2236.tar.bz2 nx-libs-8029141e772568872e668cfb1df9b5a7968d2236.zip |
Font.c: build the font paths at runtime
Drop the font path defines and build the path strings at runtime instead.
Diffstat (limited to 'nx-X11/programs/Xserver/hw')
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Font.c | 67 |
1 files changed, 34 insertions, 33 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Font.c b/nx-X11/programs/Xserver/hw/nxagent/Font.c index 23fcfe8d5..8c1cb7269 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Font.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Font.c @@ -76,21 +76,13 @@ is" without express or implied warranty. #define NXAGENT_ALTERNATE_FONT_DIR_2 "/usr/share/fonts/X11" #define NXAGENT_ALTERNATE_FONT_DIR_3 "/usr/X11R6/lib/X11/fonts" -#define NXAGENT_DEFAULT_FONT_PATH \ -"/usr/share/nx/fonts/Type1/,/usr/share/nx/fonts/75dpi/,\ -/usr/share/nx/fonts/100dpi/,/usr/share/nx/fonts/TTF/" - -#define NXAGENT_ALTERNATE_FONT_PATH \ -"/usr/share/X11/fonts/Type1/,/usr/share/X11/fonts/75dpi/,\ -/usr/share/X11/fonts/100dpi/,/usr/share/X11/fonts/TTF/" - -#define NXAGENT_ALTERNATE_FONT_PATH_2 \ -"/usr/share/fonts/X11/Type1/,/usr/share/fonts/X11/75dpi/,\ -/usr/share/fonts/X11/100dpi/,/usr/share/fonts/X11/TTF/" - -#define NXAGENT_ALTERNATE_FONT_PATH_3 \ -"/usr/X11R6/lib/X11/fonts/Type1/,/usr/X11R6/lib/X11/fonts/75dpi/,\ -/usr/X11R6/lib/X11/fonts/100dpi/,/usr/X11R6/lib/X11/fonts/TTF/" +const char * nxagentFontSubdirs[] = { + "Type1", + "75dpi", + "100dpi", + "TTF", + NULL +}; #undef NXAGENT_FONTCACHE_DEBUG #undef NXAGENT_RECONNECT_FONT_DEBUG @@ -1439,10 +1431,9 @@ static Bool nxagentGetFontServerPath(char * fontServerPath, int size) return True; } -void nxagentVerifySingleFontPath(char **dest, const char *fontDir, const char *fontPath) +void nxagentVerifySingleFontPath(char **dest, const char *fontDir) { struct stat dirStat; - char * newdest = NULL; if (!dest || !*dest) return; @@ -1455,22 +1446,32 @@ void nxagentVerifySingleFontPath(char **dest, const char *fontDir, const char *f validateString(fontDir)); #endif - if (**dest != '\0') + for (int i = 0; ; i++) { - newdest = realloc(*dest, strlen(*dest) + strlen(fontPath) + 2); - if (newdest == NULL) + char *tmppath = NULL; + int rc; + + const char *subdir = nxagentFontSubdirs[i]; + + if (subdir == NULL) return; - strcat(newdest, ","); - } - else - { - newdest = realloc(*dest, strlen(*dest) + strlen(fontPath) + 1); - if (newdest == NULL) + + if (**dest != '\0') + { + rc = asprintf(&tmppath, "%s,%s/%s", *dest, fontDir, subdir); + } + else + { + rc = asprintf(&tmppath, "%s/%s", fontDir, subdir); + } + + if (rc == -1) return; - } - strcat(newdest, fontPath); - *dest = newdest; + free(*dest); + *dest = tmppath; + tmppath = NULL; + } } } @@ -1496,10 +1497,10 @@ void nxagentVerifyDefaultFontPath(void) return; } - nxagentVerifySingleFontPath(&fontPath, NXAGENT_DEFAULT_FONT_DIR, NXAGENT_DEFAULT_FONT_PATH); - nxagentVerifySingleFontPath(&fontPath, NXAGENT_ALTERNATE_FONT_DIR, NXAGENT_ALTERNATE_FONT_PATH); - nxagentVerifySingleFontPath(&fontPath, NXAGENT_ALTERNATE_FONT_DIR_2, NXAGENT_ALTERNATE_FONT_PATH_2); - nxagentVerifySingleFontPath(&fontPath, NXAGENT_ALTERNATE_FONT_DIR_3, NXAGENT_ALTERNATE_FONT_PATH_3); + nxagentVerifySingleFontPath(&fontPath, NXAGENT_DEFAULT_FONT_DIR); + nxagentVerifySingleFontPath(&fontPath, NXAGENT_ALTERNATE_FONT_DIR); + nxagentVerifySingleFontPath(&fontPath, NXAGENT_ALTERNATE_FONT_DIR_2); + nxagentVerifySingleFontPath(&fontPath, NXAGENT_ALTERNATE_FONT_DIR_3); if (*fontPath == '\0') { |