Fix a build fail on MINGW

This commit is contained in:
Akira TAGOH 2012-06-13 20:01:30 +09:00
parent 2ec0440fb5
commit cd280f6532
6 changed files with 41 additions and 34 deletions

View File

@ -99,12 +99,13 @@ FcAtomicCreate (const FcChar8 *file)
FcBool FcBool
FcAtomicLock (FcAtomic *atomic) FcAtomicLock (FcAtomic *atomic)
{ {
int fd = -1;
FILE *f = 0;
int ret; int ret;
struct stat lck_stat; struct stat lck_stat;
#ifdef HAVE_LINK #ifdef HAVE_LINK
int fd = -1;
FILE *f = 0;
strcpy ((char *) atomic->tmp, (char *) atomic->file); strcpy ((char *) atomic->tmp, (char *) atomic->file);
strcat ((char *) atomic->tmp, TMP_NAME); strcat ((char *) atomic->tmp, TMP_NAME);
fd = mkstemp ((char *) atomic->tmp); fd = mkstemp ((char *) atomic->tmp);
@ -185,7 +186,7 @@ FcBool
FcAtomicReplaceOrig (FcAtomic *atomic) FcAtomicReplaceOrig (FcAtomic *atomic)
{ {
#ifdef _WIN32 #ifdef _WIN32
unlink (atomic->file); unlink ((const char *) atomic->file);
#endif #endif
if (rename ((char *) atomic->new, (char *) atomic->file) < 0) if (rename ((char *) atomic->new, (char *) atomic->file) < 0)
return FcFalse; return FcFalse;

View File

@ -1672,7 +1672,7 @@ DllMain (HINSTANCE hinstDLL,
switch (fdwReason) { switch (fdwReason) {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
if (!GetModuleFileName ((HMODULE) hinstDLL, fontconfig_path, if (!GetModuleFileName ((HMODULE) hinstDLL, (LPCH) fontconfig_path,
sizeof (fontconfig_path))) sizeof (fontconfig_path)))
break; break;
@ -1681,15 +1681,15 @@ DllMain (HINSTANCE hinstDLL,
* "etc/fonts" in there as FONTCONFIG_PATH. Otherwise use the * "etc/fonts" in there as FONTCONFIG_PATH. Otherwise use the
* folder where the DLL is as FONTCONFIG_PATH. * folder where the DLL is as FONTCONFIG_PATH.
*/ */
p = strrchr (fontconfig_path, '\\'); p = (FcChar8 *) strrchr ((const char *) fontconfig_path, '\\');
if (p) if (p)
{ {
*p = '\0'; *p = '\0';
p = strrchr (fontconfig_path, '\\'); p = (FcChar8 *) strrchr ((const char *) fontconfig_path, '\\');
if (p && (FcStrCmpIgnoreCase (p + 1, "bin") == 0 || if (p && (FcStrCmpIgnoreCase (p + 1, (const FcChar8 *) "bin") == 0 ||
FcStrCmpIgnoreCase (p + 1, "lib") == 0)) FcStrCmpIgnoreCase (p + 1, (const FcChar8 *) "lib") == 0))
*p = '\0'; *p = '\0';
strcat (fontconfig_path, "\\etc\\fonts"); strcat ((char *) fontconfig_path, "\\etc\\fonts");
} }
else else
fontconfig_path[0] = '\0'; fontconfig_path[0] = '\0';
@ -1804,11 +1804,11 @@ FcConfigGetPath (void)
if (fontconfig_path[0] == '\0') if (fontconfig_path[0] == '\0')
{ {
char *p; char *p;
if(!GetModuleFileName(NULL, fontconfig_path, sizeof(fontconfig_path))) if(!GetModuleFileName(NULL, (LPCH) fontconfig_path, sizeof(fontconfig_path)))
goto bail1; goto bail1;
p = strrchr (fontconfig_path, '\\'); p = strrchr ((const char *) fontconfig_path, '\\');
if (p) *p = '\0'; if (p) *p = '\0';
strcat (fontconfig_path, "\\fonts"); strcat ((char *) fontconfig_path, "\\fonts");
} }
#endif #endif
dir = (FcChar8 *) FONTCONFIG_PATH; dir = (FcChar8 *) FONTCONFIG_PATH;

View File

@ -55,7 +55,9 @@
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0500 # define _WIN32_WINNT 0x0500
# endif
# define WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN
# define STRICT # define STRICT
# include <windows.h> # include <windows.h>

View File

@ -82,7 +82,7 @@ FcStat (const FcChar8 *file, struct stat *statb)
char *basename; char *basename;
DWORD rc; DWORD rc;
if (!GetFileAttributesEx (file, GetFileExInfoStandard, &wfad)) if (!GetFileAttributesEx ((LPCSTR) file, GetFileExInfoStandard, &wfad))
return -1; return -1;
statb->st_dev = 0; statb->st_dev = 0;
@ -91,12 +91,12 @@ FcStat (const FcChar8 *file, struct stat *statb)
* Call GetLongPathName() to get the spelling of the path name as it * Call GetLongPathName() to get the spelling of the path name as it
* is on disk. * is on disk.
*/ */
rc = GetFullPathName (file, sizeof (full_path_name), full_path_name, &basename); rc = GetFullPathName ((LPCSTR) file, sizeof (full_path_name), full_path_name, &basename);
if (rc == 0 || rc > sizeof (full_path_name)) if (rc == 0 || rc > sizeof (full_path_name))
return -1; return -1;
rc = GetLongPathName (full_path_name, full_path_name, sizeof (full_path_name)); rc = GetLongPathName (full_path_name, full_path_name, sizeof (full_path_name));
statb->st_ino = FcStringHash (full_path_name); statb->st_ino = FcStringHash ((const FcChar8 *) full_path_name);
statb->st_mode = _S_IREAD | _S_IWRITE; statb->st_mode = _S_IREAD | _S_IWRITE;
statb->st_mode |= (statb->st_mode >> 3) | (statb->st_mode >> 6); statb->st_mode |= (statb->st_mode >> 3) | (statb->st_mode >> 6);
@ -129,8 +129,6 @@ FcStat (const FcChar8 *file, struct stat *statb)
return stat ((char *) file, statb); return stat ((char *) file, statb);
} }
#endif
/* Adler-32 checksum implementation */ /* Adler-32 checksum implementation */
struct Adler32 { struct Adler32 {
int a; int a;
@ -238,6 +236,7 @@ FcDirChecksum (const FcChar8 *dir, time_t *checksum)
return 0; return 0;
} }
#endif /* _WIN32 */
int int
FcStatChecksum (const FcChar8 *file, struct stat *statb) FcStatChecksum (const FcChar8 *file, struct stat *statb)
@ -245,11 +244,16 @@ FcStatChecksum (const FcChar8 *file, struct stat *statb)
if (FcStat (file, statb) == -1) if (FcStat (file, statb) == -1)
return -1; return -1;
#ifndef _WIN32
/* We have a workaround of the broken stat() in FcStat() for Win32.
* No need to do something further more.
*/
if (FcIsFsMtimeBroken (file)) if (FcIsFsMtimeBroken (file))
{ {
if (FcDirChecksum (file, &statb->st_mtime) == -1) if (FcDirChecksum (file, &statb->st_mtime) == -1)
return -1; return -1;
} }
#endif
return 0; return 0;
} }
@ -258,7 +262,7 @@ static int
FcFStatFs (int fd, FcStatFS *statb) FcFStatFs (int fd, FcStatFS *statb)
{ {
const char *p = NULL; const char *p = NULL;
int ret; int ret = -1;
FcBool flag = FcFalse; FcBool flag = FcFalse;
memset (statb, 0, sizeof (FcStatFS)); memset (statb, 0, sizeof (FcStatFS));

View File

@ -1052,13 +1052,13 @@ FcStrCanonFilename (const FcChar8 *s)
{ {
#ifdef _WIN32 #ifdef _WIN32
FcChar8 full[FC_MAX_FILE_LEN + 2]; FcChar8 full[FC_MAX_FILE_LEN + 2];
int size = GetFullPathName (s, sizeof (full) -1, int size = GetFullPathName ((LPCSTR) s, sizeof (full) -1,
full, NULL); (LPSTR) full, NULL);
if (size == 0) if (size == 0)
perror ("GetFullPathName"); perror ("GetFullPathName");
FcConvertDosPath (full); FcConvertDosPath ((char *) full);
return FcStrCanonAbsoluteFilename (full); return FcStrCanonAbsoluteFilename (full);
#else #else
if (s[0] == '/') if (s[0] == '/')

View File

@ -1882,11 +1882,11 @@ FcParseDir (FcConfigParse *parse)
data = prefix; data = prefix;
} }
#ifdef _WIN32 #ifdef _WIN32
if (strcmp (data, "CUSTOMFONTDIR") == 0) if (strcmp ((const char *) data, "CUSTOMFONTDIR") == 0)
{ {
char *p; char *p;
data = buffer; data = buffer;
if (!GetModuleFileName (NULL, buffer, sizeof (buffer) - 20)) if (!GetModuleFileName (NULL, (LPCH) buffer, sizeof (buffer) - 20))
{ {
FcConfigMessage (parse, FcSevereError, "GetModuleFileName failed"); FcConfigMessage (parse, FcSevereError, "GetModuleFileName failed");
goto bail; goto bail;
@ -1901,11 +1901,11 @@ FcParseDir (FcConfigParse *parse)
if (p) *p = '\0'; if (p) *p = '\0';
strcat (data, "\\fonts"); strcat (data, "\\fonts");
} }
else if (strcmp (data, "APPSHAREFONTDIR") == 0) else if (strcmp ((const char *) data, "APPSHAREFONTDIR") == 0)
{ {
char *p; char *p;
data = buffer; data = buffer;
if (!GetModuleFileName (NULL, buffer, sizeof (buffer) - 20)) if (!GetModuleFileName (NULL, (LPCH) buffer, sizeof (buffer) - 20))
{ {
FcConfigMessage (parse, FcSevereError, "GetModuleFileName failed"); FcConfigMessage (parse, FcSevereError, "GetModuleFileName failed");
goto bail; goto bail;
@ -1914,17 +1914,17 @@ FcParseDir (FcConfigParse *parse)
if (p) *p = '\0'; if (p) *p = '\0';
strcat (data, "\\..\\share\\fonts"); strcat (data, "\\..\\share\\fonts");
} }
else if (strcmp (data, "WINDOWSFONTDIR") == 0) else if (strcmp ((const char *) data, "WINDOWSFONTDIR") == 0)
{ {
int rc; int rc;
data = buffer; data = buffer;
rc = pGetSystemWindowsDirectory (buffer, sizeof (buffer) - 20); rc = pGetSystemWindowsDirectory ((LPSTR) buffer, sizeof (buffer) - 20);
if (rc == 0 || rc > sizeof (buffer) - 20) if (rc == 0 || rc > sizeof (buffer) - 20)
{ {
FcConfigMessage (parse, FcSevereError, "GetSystemWindowsDirectory failed"); FcConfigMessage (parse, FcSevereError, "GetSystemWindowsDirectory failed");
goto bail; goto bail;
} }
if (data [strlen (data) - 1] != '\\') if (data [strlen ((const char *) data) - 1] != '\\')
strcat (data, "\\"); strcat (data, "\\");
strcat (data, "fonts"); strcat (data, "fonts");
} }
@ -1978,7 +1978,7 @@ FcParseCacheDir (FcConfigParse *parse)
data = prefix; data = prefix;
} }
#ifdef _WIN32 #ifdef _WIN32
if (strcmp (data, "WINDOWSTEMPDIR_FONTCONFIG_CACHE") == 0) if (strcmp ((const char *) data, "WINDOWSTEMPDIR_FONTCONFIG_CACHE") == 0)
{ {
int rc; int rc;
FcStrFree (data); FcStrFree (data);
@ -1989,17 +1989,17 @@ FcParseCacheDir (FcConfigParse *parse)
goto bail; goto bail;
} }
FcMemAlloc (FC_MEM_STRING, 1000); FcMemAlloc (FC_MEM_STRING, 1000);
rc = GetTempPath (800, data); rc = GetTempPath (800, (LPSTR) data);
if (rc == 0 || rc > 800) if (rc == 0 || rc > 800)
{ {
FcConfigMessage (parse, FcSevereError, "GetTempPath failed"); FcConfigMessage (parse, FcSevereError, "GetTempPath failed");
goto bail; goto bail;
} }
if (data [strlen (data) - 1] != '\\') if (data [strlen ((const char *) data) - 1] != '\\')
strcat (data, "\\"); strcat (data, "\\");
strcat (data, "fontconfig\\cache"); strcat (data, "fontconfig\\cache");
} }
else if (strcmp (data, "LOCAL_APPDATA_FONTCONFIG_CACHE") == 0) else if (strcmp ((const char *) data, "LOCAL_APPDATA_FONTCONFIG_CACHE") == 0)
{ {
char szFPath[MAX_PATH + 1]; char szFPath[MAX_PATH + 1];
size_t len; size_t len;
@ -2019,7 +2019,7 @@ FcParseCacheDir (FcConfigParse *parse)
goto bail; goto bail;
} }
FcMemAlloc (FC_MEM_STRING, len); FcMemAlloc (FC_MEM_STRING, len);
strncpy(data, szFPath, len); strncpy((char *) data, szFPath, len);
} }
#endif #endif
if (strlen ((char *) data) == 0) if (strlen ((char *) data) == 0)