Author: tkreuzer
Date: Sat Mar 16 14:46:35 2013
New Revision: 58517
URL:
http://svn.reactos.org/svn/reactos?rev=58517&view=rev
Log:
[CRT]
Implement _splitpath_s and _wsplitpath_s
[MSVCRT]
Export _splitpath_s and _wsplitpath_s
Added:
trunk/reactos/lib/sdk/crt/string/_splitpath.c (with props)
trunk/reactos/lib/sdk/crt/string/_splitpath_s.c (with props)
trunk/reactos/lib/sdk/crt/string/_tsplitpath_x.h
- copied, changed from r58513, trunk/reactos/lib/sdk/crt/string/splitp.c
trunk/reactos/lib/sdk/crt/string/_wsplitpath.c (with props)
trunk/reactos/lib/sdk/crt/string/_wsplitpath_s.c (with props)
Removed:
trunk/reactos/lib/sdk/crt/string/splitp.c
trunk/reactos/lib/sdk/crt/string/wsplitp.c
Modified:
trunk/reactos/dll/win32/msvcrt/msvcrt.spec
trunk/reactos/lib/sdk/crt/crt.cmake
trunk/reactos/lib/sdk/crt/libcntpr.cmake
Modified: trunk/reactos/dll/win32/msvcrt/msvcrt.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msvcrt/msvcrt.sp…
==============================================================================
--- trunk/reactos/dll/win32/msvcrt/msvcrt.spec [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msvcrt/msvcrt.spec [iso-8859-1] Sat Mar 16 14:46:35 2013
@@ -857,7 +857,7 @@
@ cdecl _spawnvp(long str ptr)
@ cdecl _spawnvpe(long str ptr ptr)
@ cdecl _splitpath(str ptr ptr ptr ptr)
-# stub _splitpath_s
+@ cdecl _splitpath_s(str ptr long ptr long ptr long ptr long)
# stub _sprintf_l
# stub _sprintf_p_l
# stub _sprintf_s_l
@@ -1127,7 +1127,7 @@
@ cdecl _wspawnvp(long wstr ptr)
@ cdecl _wspawnvpe(long wstr ptr ptr)
@ cdecl _wsplitpath(wstr ptr ptr ptr ptr)
-# @ cdecl _wsplitpath_s(wstr ptr long ptr long ptr long ptr long)
+@ cdecl _wsplitpath_s(wstr ptr long ptr long ptr long ptr long)
@ cdecl _wstat(wstr ptr)
@ cdecl _wstati64(wstr ptr)
@ cdecl _wstat64(wstr ptr)
Modified: trunk/reactos/lib/sdk/crt/crt.cmake
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/crt.cmake?rev=…
==============================================================================
--- trunk/reactos/lib/sdk/crt/crt.cmake [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/crt.cmake [iso-8859-1] Sat Mar 16 14:46:35 2013
@@ -260,6 +260,10 @@
stdlib/wmakpath_s.c
string/_mbsnlen.c
string/_mbstrnlen.c
+ string/_splitpath.c
+ string/_splitpath_s.c
+ string/_wsplitpath.c
+ string/_wsplitpath_s.c
string/atof.c
string/atoi.c
string/atoi64.c
@@ -271,7 +275,6 @@
string/itow.c
string/mbstowcs_s.c
string/scanf.c
- string/splitp.c
string/strcoll.c
string/strcspn.c
string/strdup.c
@@ -299,7 +302,6 @@
string/wcstombs_s.c
string/wcstoul.c
string/wctype.c
- string/wsplitp.c
string/wtoi.c
string/wtoi64.c
string/wtol.c
Modified: trunk/reactos/lib/sdk/crt/libcntpr.cmake
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/libcntpr.cmake…
==============================================================================
--- trunk/reactos/lib/sdk/crt/libcntpr.cmake [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/libcntpr.cmake [iso-8859-1] Sat Mar 16 14:46:35 2013
@@ -26,6 +26,8 @@
search/bsearch.c
search/lfind.c
stdlib/qsort.c
+ string/_splitpath.c
+ string/_wsplitpath.c
string/ctype.c
string/iswctype.c
string/is_wctype.c
@@ -46,7 +48,6 @@
string/itoa.c
string/itow.c
string/mbstowcs_nt.c
- string/splitp.c
string/strtol.c
string/strtoul.c
string/strtoull.c
@@ -55,7 +56,6 @@
string/wcstombs_nt.c
string/wcstoul.c
string/wctype.c
- string/wsplitp.c
string/wtoi64.c
string/wtoi.c
string/wtol.c
Added: trunk/reactos/lib/sdk/crt/string/_splitpath.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/_splitp…
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/_splitpath.c (added)
+++ trunk/reactos/lib/sdk/crt/string/_splitpath.c [iso-8859-1] Sat Mar 16 14:46:35 2013
@@ -1,0 +1,11 @@
+/*
+ * COPYRIGHT: GNU GPL, see COPYING in the top level directory
+ * PROJECT: ReactOS crt library
+ * FILE: lib/sdk/crt/string/_splitpath.c
+ * PURPOSE: Implementation of _splitpath
+ * PROGRAMMER: Timo Kreuzer
+ */
+
+#define _tsplitpath_x _splitpath
+
+#include "_tsplitpath_x.h"
Propchange: trunk/reactos/lib/sdk/crt/string/_splitpath.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/lib/sdk/crt/string/_splitpath_s.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/_splitp…
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/_splitpath_s.c (added)
+++ trunk/reactos/lib/sdk/crt/string/_splitpath_s.c [iso-8859-1] Sat Mar 16 14:46:35 2013
@@ -1,0 +1,12 @@
+/*
+ * COPYRIGHT: GNU GPL, see COPYING in the top level directory
+ * PROJECT: ReactOS crt library
+ * FILE: lib/sdk/crt/string/_splitpath_s.c
+ * PURPOSE: Implementation of _splitpath_s
+ * PROGRAMMER: Timo Kreuzer
+ */
+
+#define _tsplitpath_x _splitpath_s
+#define IS_SECAPI 1
+
+#include "_tsplitpath_x.h"
Propchange: trunk/reactos/lib/sdk/crt/string/_splitpath_s.c
------------------------------------------------------------------------------
svn:eol-style = native
Copied: trunk/reactos/lib/sdk/crt/string/_tsplitpath_x.h (from r58513,
trunk/reactos/lib/sdk/crt/string/splitp.c)
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/_tsplit…
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/splitp.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/string/_tsplitpath_x.h [iso-8859-1] Sat Mar 16 14:46:35
2013
@@ -1,19 +1,66 @@
/*
* PROJECT: ReactOS Kernel
* LICENSE: BSD - See COPYING.ARM in the top level directory
- * PURPOSE: CRT: implementation of _splitpath / _wsplitpath
+ * PURPOSE: CRT: implementation of __[w]splitpath[_s]
* PROGRAMMERS: Timo Kreuzer
*/
#include <precomp.h>
#include <tchar.h>
-/*
- * @implemented
- */
-void _tsplitpath(const _TCHAR* path, _TCHAR* drive, _TCHAR* dir, _TCHAR* fname, _TCHAR*
ext)
+#if IS_SECAPI
+#define _FAILURE -1
+#define _SUCCESS 0
+
+_Check_return_wat_
+_CRTIMP_ALTERNATIVE
+errno_t
+__cdecl
+_tsplitpath_x(
+ _In_z_ const _TCHAR* path,
+ _Out_writes_opt_z_(drive_size) _TCHAR* drive,
+ _In_ size_t drive_size,
+ _Out_writes_opt_z_(dir_size) _TCHAR* dir,
+ _In_ size_t dir_size,
+ _Out_writes_opt_z_(fname_size) _TCHAR* fname,
+ _In_ size_t fname_size,
+ _Out_writes_opt_z_(ext_size) _TCHAR* ext,
+ _In_ size_t ext_size)
+#else
+#define _FAILURE
+#define _SUCCESS
+
+_CRT_INSECURE_DEPRECATE(_splitpath_s)
+_CRTIMP
+void
+__cdecl
+_tsplitpath_x(
+ _In_z_ const _TCHAR* path,
+ _Pre_maybenull_ _Post_z_ _TCHAR* drive,
+ _Pre_maybenull_ _Post_z_ _TCHAR* dir,
+ _Pre_maybenull_ _Post_z_ _TCHAR* fname,
+ _Pre_maybenull_ _Post_z_ _TCHAR* ext)
+#endif
{
const _TCHAR *src, *dir_start, *file_start = 0, *ext_start = 0;
+ size_t count;
+#if !IS_SECAPI
+ const size_t drive_size = INT_MAX, dir_size = INT_MAX,
+ fname_size = INT_MAX, ext_size = INT_MAX;
+#endif
+
+#if IS_SECAPI
+ /* Validate parameters */
+ if (MSVCRT_CHECK_PMT((path == NULL) ||
+ ((drive != NULL) && (drive_size == 0)) ||
+ ((dir != NULL) && (dir_size == 0)) ||
+ ((fname != NULL) && (fname_size == 0)) ||
+ ((ext != NULL) && (ext_size == 0))))
+ {
+ errno = EINVAL;
+ return -1;
+ }
+#endif
/* Truncate all output strings */
if (drive) drive[0] = '\0';
@@ -28,7 +75,7 @@
#ifndef _LIBCNT_
_set_errno(EINVAL);
#endif
- return;
+ return _FAILURE;
}
#endif
@@ -40,12 +87,12 @@
(path[2] == '?') && (path[3] == '\\')) path += 4;
#endif
- if (path[0] == '\0') return;
+ if (path[0] == '\0') return _FAILURE;
/* Check if we have a drive letter (only 1 char supported) */
if (path[1] == ':')
{
- if (drive)
+ if (drive && (drive_size >= 3))
{
drive[0] = path[0];
drive[1] = ':';
@@ -58,7 +105,7 @@
dir_start = path;
while (*path != '\0')
{
- /* Remember last path seperator and last dot */
+ /* Remember last path separator and last dot */
if ((*path == '\\') || (*path == '/')) file_start = path + 1;
if (*path == '.') ext_start = path;
path++;
@@ -73,22 +120,27 @@
if (dir)
{
src = dir_start;
- while (src < file_start) *dir++ = *src++;
+ count = dir_size - 1;
+ while (src < file_start && count--) *dir++ = *src++;
*dir = '\0';
}
if (fname)
{
src = file_start;
- while (src < ext_start) *fname++ = *src++;
+ count = fname_size - 1;
+ while (src < ext_start && count--) *fname++ = *src++;
*fname = '\0';
}
if (ext)
{
src = ext_start;
- while (*src != '\0') *ext++ = *src++;
+ count = ext_size - 1;
+ while (*src != '\0' && count--) *ext++ = *src++;
*ext = '\0';
}
+
+ return _SUCCESS;
}
Added: trunk/reactos/lib/sdk/crt/string/_wsplitpath.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/_wsplit…
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/_wsplitpath.c (added)
+++ trunk/reactos/lib/sdk/crt/string/_wsplitpath.c [iso-8859-1] Sat Mar 16 14:46:35 2013
@@ -1,0 +1,12 @@
+/*
+ * COPYRIGHT: GNU GPL, see COPYING in the top level directory
+ * PROJECT: ReactOS crt library
+ * FILE: lib/sdk/crt/string/_wsplitpath.c
+ * PURPOSE: Implementation of _wsplitpath
+ * PROGRAMMER: Timo Kreuzer
+ */
+
+#define _tsplitpath_x _wsplitpath
+#define _UNICODE
+
+#include "_tsplitpath_x.h"
Propchange: trunk/reactos/lib/sdk/crt/string/_wsplitpath.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/lib/sdk/crt/string/_wsplitpath_s.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/_wsplit…
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/_wsplitpath_s.c (added)
+++ trunk/reactos/lib/sdk/crt/string/_wsplitpath_s.c [iso-8859-1] Sat Mar 16 14:46:35
2013
@@ -1,0 +1,13 @@
+/*
+ * COPYRIGHT: GNU GPL, see COPYING in the top level directory
+ * PROJECT: ReactOS crt library
+ * FILE: lib/sdk/crt/string/_wsplitpath_s.c
+ * PURPOSE: Implementation of _wsplitpath_s
+ * PROGRAMMER: Timo Kreuzer
+ */
+
+#define _tsplitpath_x _wsplitpath_s
+#define _UNICODE
+#define IS_SECAPI 1
+
+#include "_tsplitpath_x.h"
Propchange: trunk/reactos/lib/sdk/crt/string/_wsplitpath_s.c
------------------------------------------------------------------------------
svn:eol-style = native
Removed: trunk/reactos/lib/sdk/crt/string/splitp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/splitp.…
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/splitp.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/string/splitp.c (removed)
@@ -1,94 +1,0 @@
-/*
- * PROJECT: ReactOS Kernel
- * LICENSE: BSD - See COPYING.ARM in the top level directory
- * PURPOSE: CRT: implementation of _splitpath / _wsplitpath
- * PROGRAMMERS: Timo Kreuzer
- */
-
-#include <precomp.h>
-#include <tchar.h>
-
-/*
- * @implemented
- */
-void _tsplitpath(const _TCHAR* path, _TCHAR* drive, _TCHAR* dir, _TCHAR* fname, _TCHAR*
ext)
-{
- const _TCHAR *src, *dir_start, *file_start = 0, *ext_start = 0;
-
- /* Truncate all output strings */
- if (drive) drive[0] = '\0';
- if (dir) dir[0] = '\0';
- if (fname) fname[0] = '\0';
- if (ext) ext[0] = '\0';
-
-#if WINVER >= 0x600
- /* Check parameter */
- if (!path)
- {
-#ifndef _LIBCNT_
- _set_errno(EINVAL);
-#endif
- return;
- }
-#endif
-
- _Analysis_assume_(path != 0);
-
-#if WINVER == 0x600
- /* Skip '\\?\' prefix */
- if ((path[0] == '\\') && (path[1] == '\\') &&
- (path[2] == '?') && (path[3] == '\\')) path += 4;
-#endif
-
- if (path[0] == '\0') return;
-
- /* Check if we have a drive letter (only 1 char supported) */
- if (path[1] == ':')
- {
- if (drive)
- {
- drive[0] = path[0];
- drive[1] = ':';
- drive[2] = '\0';
- }
- path += 2;
- }
-
- /* Scan the rest of the string */
- dir_start = path;
- while (*path != '\0')
- {
- /* Remember last path seperator and last dot */
- if ((*path == '\\') || (*path == '/')) file_start = path + 1;
- if (*path == '.') ext_start = path;
- path++;
- }
-
- /* Check if we got a file name / extension */
- if (!file_start)
- file_start = dir_start;
- if (!ext_start || ext_start < file_start)
- ext_start = path;
-
- if (dir)
- {
- src = dir_start;
- while (src < file_start) *dir++ = *src++;
- *dir = '\0';
- }
-
- if (fname)
- {
- src = file_start;
- while (src < ext_start) *fname++ = *src++;
- *fname = '\0';
- }
-
- if (ext)
- {
- src = ext_start;
- while (*src != '\0') *ext++ = *src++;
- *ext = '\0';
- }
-}
-
Removed: trunk/reactos/lib/sdk/crt/string/wsplitp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/string/wsplitp…
==============================================================================
--- trunk/reactos/lib/sdk/crt/string/wsplitp.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/string/wsplitp.c (removed)
@@ -1,7 +1,0 @@
-
-#define _UNICODE
-#define UNICODE
-
-#include <tchar.h>
-
-#include "splitp.c"