--- test-migration.c 2013-10-11 05:10:18 +0200 +++ fontconfig-2.11.0/test/test-migration.c 2014-02-05 16:32:48 +0200 @@ -4,8 +4,16 @@ #include #include #include +#include #include + +#ifdef _WIN32 +#include +#define mkdir(path,mode) _mkdir(path) +#endif + + FcBool mkdir_p(const char *dir) { @@ -53,7 +61,10 @@ strcpy (n, dir); n[len] = '/'; strcpy (&n[len + 1], e->d_name); - if (e->d_type == DT_DIR) + + struct stat aFileD; + stat(n, &aFileD); + if ((aFileD.st_mode & S_IFMT) == S_IFDIR) { if (!unlink_dirs (n)) { @@ -88,18 +99,27 @@ int main(void) { - char template[32] = "fontconfig-XXXXXXXX"; - char *tmp = mkdtemp (template); + char template[128] = ""; + strcpy (template, P_tmpdir); + strcat (template, "/fontconfig-XXXXXXXX"); + char *tmp = mktemp (template); + mkdir_p (tmp); size_t len = strlen (tmp), xlen, dlen; char xdg[256], confd[256], fn[256], nfn[256], ud[256], nud[256]; int ret = -1; FILE *fp; char *content = ""; - - strcpy (xdg, tmp); - strcpy (&xdg[len], "/.config"); - setenv ("HOME", tmp, 1); - setenv ("XDG_CONFIG_HOME", xdg, 1); + + memset (xdg, '\0', sizeof(xdg)); + strcpy (xdg, "HOME="); + strcat (xdg, tmp); + strcat (xdg, "/.config"); + putenv (xdg); + memset (xdg, '\0', sizeof(xdg)); + strcpy (xdg, "XDG_CONFIG_HOME="); + strcat (xdg, tmp); + strcat (xdg, "/.config"); + putenv (xdg); xlen = strlen (xdg); strcpy (confd, xdg); strcpy (&confd[xlen], "/fontconfig");