[PATCH 2/5] msvcr80: Fix ioinfo structure definition.

Paul Gofman pgofman at codeweavers.com
Mon Apr 4 10:52:18 CDT 2022


Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
---
 configure.ac                        |   1 +
 dlls/msvcr80/tests/Makefile.in      |   7 ++
 dlls/msvcr80/tests/msvcr80.c        | 148 ++++++++++++++++++++++++++++
 dlls/msvcr80/tests/msvcr80.manifest |  22 +++++
 dlls/msvcr80/tests/msvcr80.rc       |  22 +++++
 dlls/msvcrt/file.c                  |   6 +-
 6 files changed, 202 insertions(+), 4 deletions(-)
 create mode 100644 dlls/msvcr80/tests/Makefile.in
 create mode 100644 dlls/msvcr80/tests/msvcr80.c
 create mode 100644 dlls/msvcr80/tests/msvcr80.manifest
 create mode 100644 dlls/msvcr80/tests/msvcr80.rc

diff --git a/configure.ac b/configure.ac
index e509b232d11..6cbc0a61be1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2798,6 +2798,7 @@ WINE_CONFIG_MAKEFILE(dlls/msvcr120_app)
 WINE_CONFIG_MAKEFILE(dlls/msvcr70)
 WINE_CONFIG_MAKEFILE(dlls/msvcr71)
 WINE_CONFIG_MAKEFILE(dlls/msvcr80)
+WINE_CONFIG_MAKEFILE(dlls/msvcr80/tests)
 WINE_CONFIG_MAKEFILE(dlls/msvcr90)
 WINE_CONFIG_MAKEFILE(dlls/msvcr90/tests)
 WINE_CONFIG_MAKEFILE(dlls/msvcrt)
diff --git a/dlls/msvcr80/tests/Makefile.in b/dlls/msvcr80/tests/Makefile.in
new file mode 100644
index 00000000000..1a17aea05ce
--- /dev/null
+++ b/dlls/msvcr80/tests/Makefile.in
@@ -0,0 +1,7 @@
+TESTDLL   = msvcr80.dll
+
+C_SRCS = \
+	msvcr80.c
+
+RC_SRCS = \
+	msvcr80.rc
diff --git a/dlls/msvcr80/tests/msvcr80.c b/dlls/msvcr80/tests/msvcr80.c
new file mode 100644
index 00000000000..a9c51654e5e
--- /dev/null
+++ b/dlls/msvcr80/tests/msvcr80.c
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2022 Paul Gofman for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <share.h>
+#include <sys/stat.h>
+
+#include <windef.h>
+#include <winbase.h>
+#include <errno.h>
+#include "wine/test.h"
+
+#define WX_OPEN           0x01
+#define WX_ATEOF          0x02
+#define WX_READNL         0x04
+#define WX_PIPE           0x08
+#define WX_DONTINHERIT    0x10
+#define WX_APPEND         0x20
+#define WX_TTY            0x40
+#define WX_TEXT           0x80
+
+#define MSVCRT_FD_BLOCK_SIZE 32
+
+typedef struct
+{
+    HANDLE              handle;
+    unsigned char       wxflag;
+    char                lookahead[3];
+    int                 exflag;
+    CRITICAL_SECTION    crit;
+    char textmode : 7;
+    char unicode : 1;
+    char pipech2[2];
+    __int64 startpos;
+    BOOL utf8translations;
+    char dbcsBuffer;
+    BOOL dbcsBufferUsed;
+} ioinfo;
+
+static ioinfo **__pioinfo;
+
+static int (__cdecl *p__open)(const char *, int, ...);
+static int (__cdecl *p__close)(int);
+static intptr_t (__cdecl *p__get_osfhandle)(int);
+
+#define SETNOFAIL(x,y) x = (void*)GetProcAddress(hcrt,y)
+#define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0)
+static BOOL init(void)
+{
+    HMODULE hcrt;
+
+    SetLastError(0xdeadbeef);
+    hcrt = LoadLibraryA("msvcr80.dll");
+    if (!hcrt) {
+        win_skip("msvcr80.dll not installed (got %ld)\n", GetLastError());
+        return FALSE;
+    }
+
+    SET(__pioinfo, "__pioinfo");
+    SET(p__open,"_open");
+    SET(p__close,"_close");
+    SET(p__get_osfhandle, "_get_osfhandle");
+
+    return TRUE;
+}
+
+static void test_ioinfo_flags(void)
+{
+    HANDLE handle;
+    ioinfo *info;
+    char *tempf;
+    int tempfd;
+
+    tempf = _tempnam(".","wne");
+
+    tempfd = p__open(tempf, _O_CREAT|_O_TRUNC|_O_WRONLY|_O_WTEXT, _S_IWRITE);
+    ok(tempfd != -1, "_open failed with error: %d\n", errno);
+    handle = (HANDLE)p__get_osfhandle(tempfd);
+    info = &__pioinfo[tempfd / MSVCRT_FD_BLOCK_SIZE][tempfd % MSVCRT_FD_BLOCK_SIZE];
+    ok(!!info, "NULL info.\n");
+    ok(info->handle == handle, "Unexpected handle %p, expected %p.\n", info->handle, handle);
+    todo_wine ok(info->exflag == 1, "Unexpected exflag %#x.\n", info->exflag);
+    ok(info->wxflag == (WX_TEXT | WX_OPEN), "Unexpected wxflag %#x.\n", info->wxflag);
+    todo_wine ok(info->unicode, "Unicode is not set.\n");
+    todo_wine ok(info->textmode == 2, "Unexpected textmode %d.\n", info->textmode);
+    p__close(tempfd);
+
+    ok(info->handle == INVALID_HANDLE_VALUE, "Unexpected handle %p.\n", info->handle);
+    todo_wine ok(info->exflag == 1, "Unexpected exflag %#x.\n", info->exflag);
+    todo_wine ok(info->unicode, "Unicode is not set.\n");
+    ok(!info->wxflag, "Unexpected wxflag %#x.\n", info->wxflag);
+    todo_wine ok(info->textmode == 2, "Unexpected textmode %d.\n", info->textmode);
+
+    info = &__pioinfo[(tempfd + 4) / MSVCRT_FD_BLOCK_SIZE][(tempfd + 4) % MSVCRT_FD_BLOCK_SIZE];
+    ok(!!info, "NULL info.\n");
+    ok(info->handle == INVALID_HANDLE_VALUE, "Unexpected handle %p.\n", info->handle);
+    ok(!info->exflag, "Unexpected exflag %#x.\n", info->exflag);
+    ok(!info->textmode, "Unexpected textmode %d.\n", info->textmode);
+
+    tempfd = p__open(tempf, _O_CREAT|_O_TRUNC|_O_WRONLY|_O_TEXT, _S_IWRITE);
+    ok(tempfd != -1, "_open failed with error: %d\n", errno);
+    info = &__pioinfo[tempfd / MSVCRT_FD_BLOCK_SIZE][tempfd % MSVCRT_FD_BLOCK_SIZE];
+    ok(!!info, "NULL info.\n");
+    todo_wine ok(info->exflag == 1, "Unexpected exflag %#x.\n", info->exflag);
+    ok(info->wxflag == (WX_TEXT | WX_OPEN), "Unexpected wxflag %#x.\n", info->wxflag);
+    ok(!info->unicode, "Unicode is not set.\n");
+    ok(!info->textmode, "Unexpected textmode %d.\n", info->textmode);
+    p__close(tempfd);
+
+    tempfd = p__open(tempf, _O_CREAT|_O_TRUNC|_O_WRONLY|_O_U8TEXT, _S_IWRITE);
+    ok(tempfd != -1, "_open failed with error: %d\n", errno);
+    info = &__pioinfo[tempfd / MSVCRT_FD_BLOCK_SIZE][tempfd % MSVCRT_FD_BLOCK_SIZE];
+    ok(!!info, "NULL info.\n");
+    todo_wine ok(info->exflag == 1, "Unexpected exflag %#x.\n", info->exflag);
+    ok(info->wxflag == (WX_TEXT | WX_OPEN), "Unexpected wxflag %#x.\n", info->wxflag);
+    ok(!info->unicode, "Unicode is not set.\n");
+    todo_wine ok(info->textmode == 1, "Unexpected textmode %d.\n", info->textmode);
+    p__close(tempfd);
+
+    unlink(tempf);
+    free(tempf);
+}
+
+START_TEST(msvcr80)
+{
+    if(!init())
+        return;
+
+    test_ioinfo_flags();
+}
diff --git a/dlls/msvcr80/tests/msvcr80.manifest b/dlls/msvcr80/tests/msvcr80.manifest
new file mode 100644
index 00000000000..038788d4c4f
--- /dev/null
+++ b/dlls/msvcr80/tests/msvcr80.manifest
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+  <assemblyIdentity
+      type="win32"
+      name="Wine.msvcr80.Test"
+      version="1.0.0.0"
+      processorArchitecture="*"
+  />
+<description>Wine msvcr90 test suite</description>
+<dependency>
+  <dependentAssembly>
+    <assemblyIdentity
+        type="win32"
+        name="microsoft.vc80.crt"
+        version="8.0.50727.762"
+        processorArchitecture="*"
+        publicKeyToken="1fc8b3b9a1e18e3b"
+        language="*"
+    />
+</dependentAssembly>
+</dependency>
+</assembly>
diff --git a/dlls/msvcr80/tests/msvcr80.rc b/dlls/msvcr80/tests/msvcr80.rc
new file mode 100644
index 00000000000..69d3b1239b4
--- /dev/null
+++ b/dlls/msvcr80/tests/msvcr80.rc
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2022 Paul Gofman for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "winuser.h"
+
+/* @makedep: msvcr80.manifest */
+1 RT_MANIFEST msvcr80.manifest
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index a84e61d8993..3497205e12c 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -114,8 +114,6 @@ typedef struct {
     char pipech2[2];
     __int64 startpos;
     BOOL utf8translations;
-#endif
-#if _MSVCR_VER >= 90
     char dbcsBuffer;
     BOOL dbcsBufferUsed;
 #endif
@@ -3492,7 +3490,7 @@ int CDECL _write(int fd, const void* buf, unsigned int count)
             char conv[sizeof(lfbuf)];
             size_t len = 0;
 
-#if _MSVCR_VER >= 90
+#if _MSVCR_VER >= 80
             if (info->dbcsBufferUsed)
             {
                 conv[j++] = info->dbcsBuffer;
@@ -3511,7 +3509,7 @@ int CDECL _write(int fd, const void* buf, unsigned int count)
 
                     if (i == count)
                     {
-#if _MSVCR_VER >= 90
+#if _MSVCR_VER >= 80
                         info->dbcsBuffer = conv[j-1];
                         info->dbcsBufferUsed = TRUE;
                         break;
-- 
2.35.1




More information about the wine-devel mailing list