[ros-diffs] [spetreolle] 47999: Implement _osplatform Import _makepath_s and _wmakepath_s from Wine. Passes msvcrt data and dir tests.

spetreolle at svn.reactos.org spetreolle at svn.reactos.org
Sun Jul 11 16:25:32 UTC 2010


Author: spetreolle
Date: Sun Jul 11 16:25:30 2010
New Revision: 47999

URL: http://svn.reactos.org/svn/reactos?rev=47999&view=rev
Log:
Implement _osplatform
Import _makepath_s and _wmakepath_s from Wine.
Passes msvcrt data and dir tests.

Added:
    trunk/reactos/lib/sdk/crt/stdlib/makepath_s.c   (with props)
    trunk/reactos/lib/sdk/crt/stdlib/wmakpath_s.c   (with props)
Modified:
    trunk/reactos/dll/win32/msvcrt/dllmain.c
    trunk/reactos/dll/win32/msvcrt/msvcrt.spec
    trunk/reactos/lib/sdk/crt/crt.rbuild
    trunk/reactos/lib/sdk/crt/misc/environ.c

Modified: trunk/reactos/dll/win32/msvcrt/dllmain.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msvcrt/dllmain.c?rev=47999&r1=47998&r2=47999&view=diff
==============================================================================
--- trunk/reactos/dll/win32/msvcrt/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msvcrt/dllmain.c [iso-8859-1] Sun Jul 11 16:25:30 2010
@@ -35,6 +35,7 @@
 extern void FreeEnvironment(char **environment);
 extern void _atexit_cleanup(void);
 
+extern unsigned int _osplatform;
 extern unsigned int _osver;
 extern unsigned int _winminor;
 extern unsigned int _winmajor;
@@ -72,6 +73,7 @@
         _winver     = (osvi.dwMajorVersion << 8) | osvi.dwMinorVersion;
         _winmajor   = osvi.dwMajorVersion;
         _winminor   = osvi.dwMinorVersion;
+        _osplatform = osvi.dwPlatformId;
         _osver      = osvi.dwBuildNumber;
         hHeap = HeapCreate(0, 100000, 0);
         if (hHeap == NULL)

Modified: trunk/reactos/dll/win32/msvcrt/msvcrt.spec
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msvcrt/msvcrt.spec?rev=47999&r1=47998&r2=47999&view=diff
==============================================================================
--- trunk/reactos/dll/win32/msvcrt/msvcrt.spec [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msvcrt/msvcrt.spec [iso-8859-1] Sun Jul 11 16:25:30 2010
@@ -597,7 +597,7 @@
 @ cdecl _ltow(long ptr long)
 # stub _ltow_s
 @ cdecl _makepath(ptr str str str str)
-# stub _makepath_s
+@ cdecl _makepath_s(ptr long str str str str)
 # stub _malloc_dbg
 @ cdecl _matherr(ptr)
 @ cdecl _mbbtombc(long)
@@ -756,7 +756,7 @@
 @ cdecl _onexit(ptr)
 @ varargs _open(str long)
 @ cdecl _open_osfhandle(long long)
-# stub _osplatform
+@ extern _osplatform _osplatform
 @ extern _osver _osver
 @ stub _outp #(long long)
 @ stub _outpd #(long long)
@@ -1086,7 +1086,7 @@
 # stub _winput_s
 @ extern _winver
 @ cdecl _wmakepath(wstr wstr wstr wstr wstr)
-# stub _wmakepath_s
+@ cdecl _wmakepath_s(ptr long wstr wstr wstr wstr)
 @ cdecl _wmkdir(wstr)
 @ cdecl _wmktemp(wstr)
 # stub _wmktemp_s

Modified: trunk/reactos/lib/sdk/crt/crt.rbuild
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/crt.rbuild?rev=47999&r1=47998&r2=47999&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/crt.rbuild [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/crt.rbuild [iso-8859-1] Sun Jul 11 16:25:30 2010
@@ -329,6 +329,7 @@
 		<file>gcvt.c</file>
 		<file>getenv.c</file>
 		<file>makepath.c</file>
+		<file>makepath_s.c</file>
 		<file>mbtowc.c</file>
 		<file>mbstowcs.c</file>
 		<file>obsol.c</file>
@@ -341,6 +342,7 @@
 		<file>wputenv.c</file>
 		<file>wsenv.c</file>
 		<file>wmakpath.c</file>
+		<file>wmakpath_s.c</file>
 	</directory>
 	<directory name="string">
 		<if property="ARCH" value="i386">

Modified: trunk/reactos/lib/sdk/crt/misc/environ.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/misc/environ.c?rev=47999&r1=47998&r2=47999&view=diff
==============================================================================
--- trunk/reactos/lib/sdk/crt/misc/environ.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/misc/environ.c [iso-8859-1] Sun Jul 11 16:25:30 2010
@@ -11,6 +11,7 @@
 #include <string.h>
 
 
+unsigned int _osplatform = 0;
 unsigned int _osver = 0;
 unsigned int _winminor = 0;
 unsigned int _winmajor = 0;

Added: trunk/reactos/lib/sdk/crt/stdlib/makepath_s.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/stdlib/makepath_s.c?rev=47999&view=auto
==============================================================================
--- trunk/reactos/lib/sdk/crt/stdlib/makepath_s.c (added)
+++ trunk/reactos/lib/sdk/crt/stdlib/makepath_s.c [iso-8859-1] Sun Jul 11 16:25:30 2010
@@ -1,0 +1,120 @@
+/*
+ * PROJECT:     ReactOS CRT library
+ * LICENSE:     See COPYING in the top level directory
+ * FILE:        lib/sdk/crt/stdlib/makepath_s.c
+ * PURPOSE:     Creates a path
+ * PROGRAMMERS: Wine team
+ *              Copyright 1996,1998 Marcus Meissner
+ *              Copyright 1996 Jukka Iivonen
+ *              Copyright 1997,2000 Uwe Bonnes
+ *              Copyright 2000 Jon Griffiths
+ *
+ */
+
+#include <precomp.h>
+#include <stdlib.h>
+#include <string.h>
+
+/*********************************************************************
+ *		_makepath_s (MSVCRT.@)
+ *
+ * Safe version of _makepath.
+ */
+int CDECL _makepath_s(char *path, size_t size, const char *drive,
+                      const char *directory, const char *filename,
+                      const char *extension)
+{
+    char *p = path;
+
+    if (!path || !size)
+    {
+        *_errno() = EINVAL;
+        return EINVAL;
+    }
+
+    if (drive && drive[0])
+    {
+        if (size <= 2)
+            goto range;
+
+        *p++ = drive[0];
+        *p++ = ':';
+        size -= 2;
+    }
+
+    if (directory && directory[0])
+    {
+        unsigned int len = strlen(directory);
+        unsigned int needs_separator = directory[len - 1] != '/' && directory[len - 1] != '\\';
+        unsigned int copylen = min(size - 1, len);
+
+        if (size < 2)
+            goto range;
+
+        memmove(p, directory, copylen);
+
+        if (size <= len)
+            goto range;
+
+        p += copylen;
+        size -= copylen;
+
+        if (needs_separator)
+        {
+            if (size < 2)
+                goto range;
+
+            *p++ = '\\';
+            size -= 1;
+        }
+    }
+
+    if (filename && filename[0])
+    {
+        unsigned int len = strlen(filename);
+        unsigned int copylen = min(size - 1, len);
+
+        if (size < 2)
+            goto range;
+
+        memmove(p, filename, copylen);
+
+        if (size <= len)
+            goto range;
+
+        p += len;
+        size -= len;
+    }
+
+    if (extension && extension[0])
+    {
+        unsigned int len = strlen(extension);
+        unsigned int needs_period = extension[0] != '.';
+        unsigned int copylen;
+
+        if (size < 2)
+            goto range;
+
+        if (needs_period)
+        {
+            *p++ = '.';
+            size -= 1;
+        }
+
+        copylen = min(size - 1, len);
+        memcpy(p, extension, copylen);
+
+        if (size <= len)
+            goto range;
+
+        p += copylen;
+    }
+
+    *p = '\0';
+    return 0;
+
+range:
+    path[0] = '\0';
+    *_errno() = ERANGE;
+    return ERANGE;
+}

Propchange: trunk/reactos/lib/sdk/crt/stdlib/makepath_s.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: trunk/reactos/lib/sdk/crt/stdlib/wmakpath_s.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/stdlib/wmakpath_s.c?rev=47999&view=auto
==============================================================================
--- trunk/reactos/lib/sdk/crt/stdlib/wmakpath_s.c (added)
+++ trunk/reactos/lib/sdk/crt/stdlib/wmakpath_s.c [iso-8859-1] Sun Jul 11 16:25:30 2010
@@ -1,0 +1,121 @@
+/*
+ * PROJECT:     ReactOS CRT library
+ * LICENSE:     See COPYING in the top level directory
+ * FILE:        lib/sdk/crt/stdlib/wmakpath_s.c
+ * PURPOSE:     Creates a path
+ * PROGRAMMERS: Wine team
+ *              Copyright 1996,1998 Marcus Meissner
+ *              Copyright 1996 Jukka Iivonen
+ *              Copyright 1997,2000 Uwe Bonnes
+ *              Copyright 2000 Jon Griffiths
+ *
+ */
+
+#include <precomp.h>
+#include <stdlib.h>
+#include <string.h>
+
+/*********************************************************************
+ *		_wmakepath_s (MSVCRT.@)
+ *
+ * Safe version of _wmakepath.
+ */
+int CDECL _wmakepath_s(wchar_t *path, size_t size, const wchar_t *drive,
+                       const wchar_t *directory, const wchar_t *filename,
+                       const wchar_t *extension)
+{
+    wchar_t *p = path;
+
+    if (!path || !size)
+    {
+        *_errno() = EINVAL;
+        return EINVAL;
+    }
+
+    if (drive && drive[0])
+    {
+        if (size <= 2)
+            goto range;
+
+        *p++ = drive[0];
+        *p++ = ':';
+        size -= 2;
+    }
+
+    if (directory && directory[0])
+    {
+        unsigned int len = strlenW(directory);
+        unsigned int needs_separator = directory[len - 1] != '/' && directory[len - 1] != '\\';
+        unsigned int copylen = min(size - 1, len);
+
+        if (size < 2)
+            goto range;
+
+        memmove(p, directory, copylen * sizeof(wchar_t));
+
+        if (size <= len)
+            goto range;
+
+        p += copylen;
+        size -= copylen;
+
+        if (needs_separator)
+        {
+            if (size < 2)
+                goto range;
+
+            *p++ = '\\';
+            size -= 1;
+        }
+    }
+
+    if (filename && filename[0])
+    {
+        unsigned int len = strlenW(filename);
+        unsigned int copylen = min(size - 1, len);
+
+        if (size < 2)
+            goto range;
+
+        memmove(p, filename, copylen * sizeof(wchar_t));
+
+        if (size <= len)
+            goto range;
+
+        p += len;
+        size -= len;
+    }
+
+    if (extension && extension[0])
+    {
+        unsigned int len = strlenW(extension);
+        unsigned int needs_period = extension[0] != '.';
+        unsigned int copylen;
+
+        if (size < 2)
+            goto range;
+
+        if (needs_period)
+        {
+            *p++ = '.';
+            size -= 1;
+        }
+
+        copylen = min(size - 1, len);
+        memcpy(p, extension, copylen * sizeof(wchar_t));
+
+        if (size <= len)
+            goto range;
+
+        p += copylen;
+    }
+
+    *p = '\0';
+    return 0;
+
+range:
+    path[0] = '\0';
+    *_errno() = ERANGE;
+    return ERANGE;
+}
+

Propchange: trunk/reactos/lib/sdk/crt/stdlib/wmakpath_s.c
------------------------------------------------------------------------------
    svn:eol-style = native




More information about the Ros-diffs mailing list