From 6887af4f2bf8a863889f7110e9be78bbfc4fa3f3 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 5 Jul 2019 09:24:14 +0200 Subject: [PATCH] wineps.drv: Build with msvcrt. Signed-off-by: Alexandre Julliard --- dlls/wineps.drv/Makefile.in | 2 + dlls/wineps.drv/afm.c | 2 - dlls/wineps.drv/builtin.c | 2 +- dlls/wineps.drv/driver.c | 8 ++-- dlls/wineps.drv/escape.c | 6 --- dlls/wineps.drv/graphics.c | 13 ++---- dlls/wineps.drv/init.c | 12 ++---- dlls/wineps.drv/ppd.c | 3 -- dlls/wineps.drv/ps.c | 1 + dlls/wineps.drv/psdrv.h | 3 +- dlls/wineps.drv/type1.c | 3 -- dlls/wineps.drv/type1afm.c | 81 +++++++++++++++++-------------------- dlls/wineps.drv/type42.c | 3 -- 13 files changed, 52 insertions(+), 87 deletions(-) diff --git a/dlls/wineps.drv/Makefile.in b/dlls/wineps.drv/Makefile.in index c7282d8a06e..e5f4af4543c 100644 --- a/dlls/wineps.drv/Makefile.in +++ b/dlls/wineps.drv/Makefile.in @@ -1,6 +1,8 @@ MODULE = wineps.drv IMPORTS = user32 gdi32 winspool advapi32 +EXTRADLLFLAGS = -mno-cygwin + C_SRCS = \ afm.c \ bitblt.c \ diff --git a/dlls/wineps.drv/afm.c b/dlls/wineps.drv/afm.c index e07187e3901..c5e0cd3f36d 100644 --- a/dlls/wineps.drv/afm.c +++ b/dlls/wineps.drv/afm.c @@ -21,8 +21,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" - #include #include "psdrv.h" diff --git a/dlls/wineps.drv/builtin.c b/dlls/wineps.drv/builtin.c index 75485cd6031..67f452d937d 100644 --- a/dlls/wineps.drv/builtin.c +++ b/dlls/wineps.drv/builtin.c @@ -282,7 +282,7 @@ BOOL PSDRV_GetTextMetrics(PHYSDEV dev, TEXTMETRICW *metrics) * Find the AFMMETRICS for a given UV. Returns first glyph in the font * (space?) if the font does not have a glyph for the given UV. */ -static int MetricsByUV(const void *a, const void *b) +static int __cdecl MetricsByUV(const void *a, const void *b) { return (int)(((const AFMMETRICS *)a)->UV - ((const AFMMETRICS *)b)->UV); } diff --git a/dlls/wineps.drv/driver.c b/dlls/wineps.drv/driver.c index 64d813a44ce..f8e9cecb280 100644 --- a/dlls/wineps.drv/driver.c +++ b/dlls/wineps.drv/driver.c @@ -25,8 +25,6 @@ #define NONAMELESSUNION #define NONAMELESSSTRUCT -#include "config.h" - #include #include "wine/debug.h" @@ -283,7 +281,7 @@ static INT_PTR CALLBACK PSDRV_PaperDlgProc(HWND hwnd, UINT msg, WCHAR buf[256]; res = di->pi->ppd->DefaultResolution; - len = sprintfW(buf, resW, res); + len = swprintf(buf, ARRAY_SIZE(buf), resW, res); buf[len++] = ' '; LoadStringW(PSDRV_hInstance, IDS_DPI, buf + len, ARRAY_SIZE(buf) - len); SendDlgItemMessageW(hwnd, IDD_QUALITY, CB_ADDSTRING, 0, (LPARAM)buf); @@ -313,9 +311,9 @@ static INT_PTR CALLBACK PSDRV_PaperDlgProc(HWND hwnd, UINT msg, DWORD idx; if (res->resx == res->resy) - len = sprintfW(buf, resW, res->resx); + len = swprintf(buf, ARRAY_SIZE(buf), resW, res->resx); else - len = sprintfW(buf, resxyW, res->resx, res->resy); + len = swprintf(buf, ARRAY_SIZE(buf), resxyW, res->resx, res->resy); buf[len++] = ' '; LoadStringW(PSDRV_hInstance, IDS_DPI, buf + len, ARRAY_SIZE(buf) - len); idx = SendDlgItemMessageW(hwnd, IDD_QUALITY, CB_ADDSTRING, 0, (LPARAM)buf); diff --git a/dlls/wineps.drv/escape.c b/dlls/wineps.drv/escape.c index b3eff6813c0..d8be542609e 100644 --- a/dlls/wineps.drv/escape.c +++ b/dlls/wineps.drv/escape.c @@ -18,9 +18,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" -#include "wine/port.h" - #include #include #include @@ -28,9 +25,6 @@ #include #include #include -#ifdef HAVE_UNISTD_H -# include -#endif #include "windef.h" #include "winbase.h" diff --git a/dlls/wineps.drv/graphics.c b/dlls/wineps.drv/graphics.c index 66108d13388..8af1024ef86 100644 --- a/dlls/wineps.drv/graphics.c +++ b/dlls/wineps.drv/graphics.c @@ -18,18 +18,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" - #include #include #include #include -#if defined(HAVE_FLOAT_H) -# include -#endif -#if !defined(PI) -# define PI M_PI -#endif +#include #include "windef.h" #include "winbase.h" #include "winuser.h" @@ -221,8 +214,8 @@ static BOOL PSDRV_DrawArc( PHYSDEV dev, INT left, INT top, start_angle = atan2((double)(y - start.y) * ratio, (double)(start.x - x)); end_angle = atan2((double)(y - end.y) * ratio, (double)(end.x - x)); - start_angle *= 180.0 / PI; - end_angle *= 180.0 / PI; + start_angle *= 180.0 / M_PI; + end_angle *= 180.0 / M_PI; PSDRV_WriteSpool(dev,"%DrawArc\n", 9); PSDRV_SetPen(dev); diff --git a/dlls/wineps.drv/init.c b/dlls/wineps.drv/init.c index 0dff6cc8682..ae65d6919b3 100644 --- a/dlls/wineps.drv/init.c +++ b/dlls/wineps.drv/init.c @@ -19,9 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" -#include "wine/port.h" - #include #include @@ -36,7 +33,6 @@ #include "winuser.h" #include "psdrv.h" #include "winspool.h" -#include "wine/library.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(psdrv); @@ -650,7 +646,7 @@ static WCHAR *get_ppd_filename( HANDLE printer ) if (!info) return NULL; GetPrinterDriverW( printer, NULL, 2, (BYTE*)info, needed, &needed ); name = (WCHAR *)info; - memmove( name, info->pDataFile, (strlenW( info->pDataFile ) + 1) * sizeof(WCHAR) ); + memmove( name, info->pDataFile, (lstrlenW( info->pDataFile ) + 1) * sizeof(WCHAR) ); return name; } @@ -674,15 +670,15 @@ PRINTERINFO *PSDRV_FindPrinterInfo(LPCWSTR name) LIST_FOR_EACH_ENTRY( pi, &printer_list, PRINTERINFO, entry ) { - if (!strcmpW( pi->friendly_name, name )) + if (!wcscmp( pi->friendly_name, name )) return pi; } pi = HeapAlloc( PSDRV_Heap, HEAP_ZERO_MEMORY, sizeof(*pi) ); if (pi == NULL) return NULL; - if (!(pi->friendly_name = HeapAlloc( PSDRV_Heap, 0, (strlenW(name)+1)*sizeof(WCHAR) ))) goto fail; - strcpyW( pi->friendly_name, name ); + if (!(pi->friendly_name = HeapAlloc( PSDRV_Heap, 0, (lstrlenW(name)+1)*sizeof(WCHAR) ))) goto fail; + lstrcpyW( pi->friendly_name, name ); if (OpenPrinterW( pi->friendly_name, &hPrinter, NULL ) == 0) { ERR ("OpenPrinter failed with code %i\n", GetLastError ()); diff --git a/dlls/wineps.drv/ppd.c b/dlls/wineps.drv/ppd.c index 08d07b89644..aa013940fe7 100644 --- a/dlls/wineps.drv/ppd.c +++ b/dlls/wineps.drv/ppd.c @@ -19,9 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" -#include "wine/port.h" - #include #include #include diff --git a/dlls/wineps.drv/ps.c b/dlls/wineps.drv/ps.c index 4fd3c767b91..60737d67bda 100644 --- a/dlls/wineps.drv/ps.c +++ b/dlls/wineps.drv/ps.c @@ -29,6 +29,7 @@ #define NONAMELESSSTRUCT #include "windef.h" #include "winbase.h" +#include "winnls.h" #include "wingdi.h" #include "psdrv.h" #include "wine/debug.h" diff --git a/dlls/wineps.drv/psdrv.h b/dlls/wineps.drv/psdrv.h index 9cbee65ed8c..af77d90abff 100644 --- a/dlls/wineps.drv/psdrv.h +++ b/dlls/wineps.drv/psdrv.h @@ -28,7 +28,6 @@ #include "wingdi.h" #include "winspool.h" -#include "wine/unicode.h" #include "wine/gdi_driver.h" #include "wine/list.h" @@ -595,7 +594,7 @@ static inline WCHAR *strdupW( const WCHAR *str ) WCHAR *ret; if (!str) return NULL; - size = (strlenW( str ) + 1) * sizeof(WCHAR); + size = (lstrlenW( str ) + 1) * sizeof(WCHAR); ret = HeapAlloc( GetProcessHeap(), 0, size ); if (ret) memcpy( ret, str, size ); return ret; diff --git a/dlls/wineps.drv/type1.c b/dlls/wineps.drv/type1.c index 58fe11f2694..67b31f4cc98 100644 --- a/dlls/wineps.drv/type1.c +++ b/dlls/wineps.drv/type1.c @@ -18,9 +18,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" -#include "wine/port.h" - #include #include #include diff --git a/dlls/wineps.drv/type1afm.c b/dlls/wineps.drv/type1afm.c index 19bb2d36eb2..f29369b433a 100644 --- a/dlls/wineps.drv/type1afm.c +++ b/dlls/wineps.drv/type1afm.c @@ -25,23 +25,15 @@ * */ -#include "config.h" -#include "wine/port.h" - #include #include #include #include -#ifdef HAVE_DIRENT_H -# include -#endif #include +#include #include #include /* INT_MIN */ - -#ifdef HAVE_FLOAT_H #include /* FLT_MAX */ -#endif #include "windef.h" #include "winbase.h" @@ -818,7 +810,7 @@ static const LONG ansiChars[21] = 0x20ac, 0x2122, 0x2219 }; -static int cmpUV(const void *a, const void *b) +static int __cdecl cmpUV(const void *a, const void *b) { return (int)(*((const LONG *)a) - *((const LONG *)b)); } @@ -849,7 +841,7 @@ static inline BOOL IsWinANSI(LONG uv) * Also does some font metric calculations that require UVs to be known. * */ -static int UnicodeGlyphByNameIndex(const void *a, const void *b) +static int __cdecl UnicodeGlyphByNameIndex(const void *a, const void *b) { return ((const UNICODEGLYPH *)a)->name->index - ((const UNICODEGLYPH *)b)->name->index; @@ -935,7 +927,7 @@ static VOID Unicodify(AFM *afm, OLD_AFMMETRICS *metrics) * Reads metrics for all glyphs. *p_metrics will be NULL on non-fatal error. * */ -static int OldAFMMetricsByUV(const void *a, const void *b) +static int __cdecl OldAFMMetricsByUV(const void *a, const void *b) { return ((const OLD_AFMMETRICS *)a)->UV - ((const OLD_AFMMETRICS *)b)->UV; } @@ -1099,17 +1091,18 @@ static BOOL BuildAFM(FILE *file) * unexpected errors (memory allocation or I/O). * */ -static BOOL ReadAFMFile(LPCSTR filename) +static BOOL ReadAFMFile(LPCWSTR filename) { + static const WCHAR rW[] = {'r',0}; FILE *f; BOOL retval; - TRACE("%s\n", filename); + TRACE("%s\n", debugstr_w(filename)); - f = fopen(filename, "r"); + f = _wfopen(filename, rW); if (f == NULL) { - WARN("%s: %s\n", filename, strerror(errno)); + WARN("%s: %s\n", debugstr_w(filename), strerror(errno)); return TRUE; } @@ -1127,41 +1120,41 @@ static BOOL ReadAFMFile(LPCSTR filename) */ static BOOL ReadAFMDir(LPCSTR dirname) { - struct dirent *dent; - DIR *dir; - CHAR filename[256]; + static const WCHAR starW[] = {'*',0}; + static const WCHAR afmW[] = {'.','a','f','m',0}; + WCHAR *path = wine_get_dos_file_name( dirname ); + struct _wfinddata_t data; + intptr_t handle; + WCHAR *p, *filename; + BOOL ret = TRUE; - dir = opendir(dirname); - if (dir == NULL) + if (!path) return TRUE; + if (!(filename = HeapAlloc( GetProcessHeap(), 0, lstrlenW(path) + 256 ))) { - WARN("%s: %s\n", dirname, strerror(errno)); - return TRUE; + HeapFree( GetProcessHeap(), 0, path ); + return FALSE; } + lstrcpyW( filename, path ); + HeapFree( GetProcessHeap(), 0, path ); + p = filename + lstrlenW(filename); + *p++ = '\\'; + lstrcpyW( p, starW ); - while ((dent = readdir(dir)) != NULL) + handle = _wfindfirst( filename, &data ); + if (handle != -1) { - CHAR *file_extension = strchr(dent->d_name, '.'); - int fn_len; - - if (file_extension == NULL || _strnicmp(file_extension, ".afm", -1) != 0) - continue; - - fn_len = snprintf(filename, 256, "%s/%s", dirname, dent->d_name); - if (fn_len < 0 || fn_len > sizeof(filename) - 1) - { - WARN("Path '%s/%s' is too long\n", dirname, dent->d_name); - continue; - } - - if (ReadAFMFile(filename) == FALSE) - { - closedir(dir); - return FALSE; - } + do + { + WCHAR *ext = wcschr( data.name, '.' ); + if (!ext || wcsicmp(ext, afmW)) continue; + lstrcpyW( p, data.name ); + if (!(ret = ReadAFMFile( filename ))) break; + } while (!_wfindnext( handle, &data )); } + _findclose( handle ); - closedir(dir); - return TRUE; + HeapFree( GetProcessHeap(), 0, filename ); + return ret; } /******************************************************************************* diff --git a/dlls/wineps.drv/type42.c b/dlls/wineps.drv/type42.c index 451cceb7560..4ef7929c8fb 100644 --- a/dlls/wineps.drv/type42.c +++ b/dlls/wineps.drv/type42.c @@ -18,9 +18,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" -#include "wine/port.h" - #include #include #include