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

View File

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

View File

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

View File

@ -82,7 +82,7 @@ FcStat (const FcChar8 *file, struct stat *statb)
char *basename;
DWORD rc;
if (!GetFileAttributesEx (file, GetFileExInfoStandard, &wfad))
if (!GetFileAttributesEx ((LPCSTR) file, GetFileExInfoStandard, &wfad))
return -1;
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
* 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))
return -1;
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 |= (statb->st_mode >> 3) | (statb->st_mode >> 6);
@ -129,8 +129,6 @@ FcStat (const FcChar8 *file, struct stat *statb)
return stat ((char *) file, statb);
}
#endif
/* Adler-32 checksum implementation */
struct Adler32 {
int a;
@ -238,6 +236,7 @@ FcDirChecksum (const FcChar8 *dir, time_t *checksum)
return 0;
}
#endif /* _WIN32 */
int
FcStatChecksum (const FcChar8 *file, struct stat *statb)
@ -245,11 +244,16 @@ FcStatChecksum (const FcChar8 *file, struct stat *statb)
if (FcStat (file, statb) == -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 (FcDirChecksum (file, &statb->st_mtime) == -1)
return -1;
}
#endif
return 0;
}
@ -258,7 +262,7 @@ static int
FcFStatFs (int fd, FcStatFS *statb)
{
const char *p = NULL;
int ret;
int ret = -1;
FcBool flag = FcFalse;
memset (statb, 0, sizeof (FcStatFS));

View File

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

View File

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