Moved most kernel string functions to dlls/kernel.

This commit is contained in:
Alexandre Julliard 2003-09-16 20:35:42 +00:00
parent 0f170015f1
commit 65e7196fed
4 changed files with 213 additions and 211 deletions

View File

@ -1,6 +1,8 @@
/*
* Kernel string functions
*
* Copyright 1993 Yngvi Sigurjonsson
* Copyright 1996 Alexandre Julliard
* Copyright 2001 Dmitry Timoshkov for CodeWeavers
*
* This library is free software; you can redistribute it and/or
@ -24,12 +26,24 @@
#include "windef.h"
#include "winbase.h"
#include "excpt.h"
#include "wine/winbase16.h"
#include "wine/unicode.h"
#include "wine/exception.h"
static INT (WINAPI *pLoadStringA)(HINSTANCE, UINT, LPSTR, INT);
static INT (WINAPI *pwvsprintfA)(LPSTR, LPCSTR, va_list);
/* filter for page-fault exceptions */
static WINE_EXCEPTION_FILTER(page_fault)
{
if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION)
return EXCEPTION_EXECUTE_HANDLER;
return EXCEPTION_CONTINUE_SEARCH;
}
/***********************************************************************
* Helper for k32 family functions
*/
@ -131,6 +145,200 @@ INT WINAPIV k32wsprintfA(LPSTR buffer, LPCSTR spec, ...)
}
/***********************************************************************
* hmemcpy (KERNEL.348)
*/
void WINAPI hmemcpy16( LPVOID dst, LPCVOID src, LONG count )
{
memcpy( dst, src, count );
}
/***********************************************************************
* lstrcat (KERNEL.89)
*/
SEGPTR WINAPI lstrcat16( SEGPTR dst, LPCSTR src )
{
/* Windows does not check for NULL pointers here, so we don't either */
strcat( MapSL(dst), src );
return dst;
}
/***********************************************************************
* lstrcat (KERNEL32.@)
* lstrcatA (KERNEL32.@)
*/
LPSTR WINAPI lstrcatA( LPSTR dst, LPCSTR src )
{
__TRY
{
strcat( dst, src );
}
__EXCEPT(page_fault)
{
SetLastError( ERROR_INVALID_PARAMETER );
return NULL;
}
__ENDTRY
return dst;
}
/***********************************************************************
* lstrcatW (KERNEL32.@)
*/
LPWSTR WINAPI lstrcatW( LPWSTR dst, LPCWSTR src )
{
__TRY
{
strcatW( dst, src );
}
__EXCEPT(page_fault)
{
SetLastError( ERROR_INVALID_PARAMETER );
return NULL;
}
__ENDTRY
return dst;
}
/***********************************************************************
* lstrcatn (KERNEL.352)
*/
SEGPTR WINAPI lstrcatn16( SEGPTR dst, LPCSTR src, INT16 n )
{
LPSTR p = MapSL(dst);
LPSTR start = p;
while (*p) p++;
if ((n -= (p - start)) <= 0) return dst;
lstrcpynA( p, src, n );
return dst;
}
/***********************************************************************
* lstrcpy (KERNEL.88)
*/
SEGPTR WINAPI lstrcpy16( SEGPTR dst, LPCSTR src )
{
if (!lstrcpyA( MapSL(dst), src )) dst = 0;
return dst;
}
/***********************************************************************
* lstrcpy (KERNEL32.@)
* lstrcpyA (KERNEL32.@)
*/
LPSTR WINAPI lstrcpyA( LPSTR dst, LPCSTR src )
{
__TRY
{
/* this is how Windows does it */
memmove( dst, src, strlen(src)+1 );
}
__EXCEPT(page_fault)
{
SetLastError( ERROR_INVALID_PARAMETER );
return NULL;
}
__ENDTRY
return dst;
}
/***********************************************************************
* lstrcpyW (KERNEL32.@)
*/
LPWSTR WINAPI lstrcpyW( LPWSTR dst, LPCWSTR src )
{
__TRY
{
strcpyW( dst, src );
}
__EXCEPT(page_fault)
{
SetLastError( ERROR_INVALID_PARAMETER );
return NULL;
}
__ENDTRY
return dst;
}
/***********************************************************************
* lstrcpyn (KERNEL.353)
*/
SEGPTR WINAPI lstrcpyn16( SEGPTR dst, LPCSTR src, INT16 n )
{
lstrcpynA( MapSL(dst), src, n );
return dst;
}
/***********************************************************************
* lstrlen (KERNEL.90)
*/
INT16 WINAPI lstrlen16( LPCSTR str )
{
return (INT16)lstrlenA( str );
}
/***********************************************************************
* lstrlen (KERNEL32.@)
* lstrlenA (KERNEL32.@)
*/
INT WINAPI lstrlenA( LPCSTR str )
{
INT ret;
__TRY
{
ret = strlen(str);
}
__EXCEPT(page_fault)
{
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
__ENDTRY
return ret;
}
/***********************************************************************
* lstrlenW (KERNEL32.@)
*/
INT WINAPI lstrlenW( LPCWSTR str )
{
INT ret;
__TRY
{
ret = strlenW(str);
}
__EXCEPT(page_fault)
{
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
__ENDTRY
return ret;
}
/***********************************************************************
* UnicodeToAnsi (KERNEL.434)
*/
INT16 WINAPI UnicodeToAnsi16( LPCWSTR src, LPSTR dst, INT16 codepage )
{
if ( codepage == -1 ) codepage = CP_ACP;
return WideCharToMultiByte( codepage, 0, src, -1, dst, 0x7fffffff, NULL, NULL );
}
/***************************************************************************
*
* Win 2.x string functions now moved to USER

View File

@ -231,7 +231,7 @@ BOOLEAN WINAPI RtlDosPathNameToNtPathName_U(PWSTR dos_path,
ntpath->Length = strlenW(ntpath->Buffer) * sizeof(WCHAR);
if (file_part && *file_part)
*file_part = ntpath->Buffer + ntpath->Length / sizeof(WCHAR) - lstrlenW(*file_part);
*file_part = ntpath->Buffer + ntpath->Length / sizeof(WCHAR) - strlenW(*file_part);
/* FIXME: cd filling */

View File

@ -2415,7 +2415,7 @@ DWORD WINAPI QueryDosDeviceW(LPCWSTR devname,LPWSTR target,DWORD bufsize)
for(i=0; (i< (sizeof(devices)/sizeof(devices[0]))); i++) {
DWORD len = strlenW(devices[i]);
if(target && (bufsize >= ret + len + 2)) {
lstrcpyW(target+ret, devices[i]);
strcpyW(target+ret, devices[i]);
ret += len + 1;
} else {
/* in this case WinXP returns 0 */
@ -2474,9 +2474,9 @@ DWORD WINAPI QueryDosDeviceW(LPCWSTR devname,LPWSTR target,DWORD bufsize)
ret = strlenW(pDev) + strlenW(pName) + numsiz + 2;
if (ret > bufsize) ret = 0;
if (target && ret) {
lstrcpyW(target,pDev);
lstrcatW(target,pName);
if (pNum) lstrcatW(target,pNum);
strcpyW(target,pDev);
strcatW(target,pName);
if (pNum) strcatW(target,pNum);
target[ret-1] = 0;
}
return ret;

View File

@ -36,150 +36,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(string);
/* filter for page-fault exceptions */
static WINE_EXCEPTION_FILTER(page_fault)
{
if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION)
return EXCEPTION_EXECUTE_HANDLER;
return EXCEPTION_CONTINUE_SEARCH;
}
/***********************************************************************
* hmemcpy (KERNEL.348)
*/
void WINAPI hmemcpy16( LPVOID dst, LPCVOID src, LONG count )
{
memcpy( dst, src, count );
}
/***********************************************************************
* lstrcat (KERNEL.89)
*/
SEGPTR WINAPI lstrcat16( SEGPTR dst, LPCSTR src )
{
/* Windows does not check for NULL pointers here, so we don't either */
strcat( MapSL(dst), src );
return dst;
}
/***********************************************************************
* lstrcat (KERNEL32.@)
* lstrcatA (KERNEL32.@)
*/
LPSTR WINAPI lstrcatA( LPSTR dst, LPCSTR src )
{
__TRY
{
strcat( dst, src );
}
__EXCEPT(page_fault)
{
SetLastError( ERROR_INVALID_PARAMETER );
return NULL;
}
__ENDTRY
return dst;
}
/***********************************************************************
* lstrcatW (KERNEL32.@)
*/
LPWSTR WINAPI lstrcatW( LPWSTR dst, LPCWSTR src )
{
__TRY
{
strcatW( dst, src );
}
__EXCEPT(page_fault)
{
SetLastError( ERROR_INVALID_PARAMETER );
return NULL;
}
__ENDTRY
return dst;
}
/***********************************************************************
* lstrcatn (KERNEL.352)
*/
SEGPTR WINAPI lstrcatn16( SEGPTR dst, LPCSTR src, INT16 n )
{
LPSTR p = MapSL(dst);
LPSTR start = p;
while (*p) p++;
if ((n -= (p - start)) <= 0) return dst;
lstrcpynA( p, src, n );
return dst;
}
/***********************************************************************
* lstrcpy (KERNEL.88)
*/
SEGPTR WINAPI lstrcpy16( SEGPTR dst, LPCSTR src )
{
if (!lstrcpyA( MapSL(dst), src )) dst = 0;
return dst;
}
/***********************************************************************
* lstrcpy (KERNEL32.@)
* lstrcpyA (KERNEL32.@)
*/
LPSTR WINAPI lstrcpyA( LPSTR dst, LPCSTR src )
{
__TRY
{
/* this is how Windows does it */
memmove( dst, src, strlen(src)+1 );
}
__EXCEPT(page_fault)
{
ERR("(%p, %p): page fault occurred ! Caused by bug ?\n", dst, src);
SetLastError( ERROR_INVALID_PARAMETER );
return NULL;
}
__ENDTRY
return dst;
}
/***********************************************************************
* lstrcpyW (KERNEL32.@)
*/
LPWSTR WINAPI lstrcpyW( LPWSTR dst, LPCWSTR src )
{
__TRY
{
strcpyW( dst, src );
}
__EXCEPT(page_fault)
{
SetLastError( ERROR_INVALID_PARAMETER );
return NULL;
}
__ENDTRY
return dst;
}
/***********************************************************************
* lstrcpyn (KERNEL.353)
*/
SEGPTR WINAPI lstrcpyn16( SEGPTR dst, LPCSTR src, INT16 n )
{
lstrcpynA( MapSL(dst), src, n );
return dst;
}
/***********************************************************************
* lstrcpyn (KERNEL32.@)
* lstrcpynA (KERNEL32.@)
@ -247,65 +103,3 @@ LPWSTR WINAPI lstrcpynW( LPWSTR dst, LPCWSTR src, INT n )
if (count) *p = 0;
return dst;
}
/***********************************************************************
* lstrlen (KERNEL.90)
*/
INT16 WINAPI lstrlen16( LPCSTR str )
{
return (INT16)lstrlenA( str );
}
/***********************************************************************
* lstrlen (KERNEL32.@)
* lstrlenA (KERNEL32.@)
*/
INT WINAPI lstrlenA( LPCSTR str )
{
INT ret;
__TRY
{
ret = strlen(str);
}
__EXCEPT(page_fault)
{
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
__ENDTRY
return ret;
}
/***********************************************************************
* lstrlenW (KERNEL32.@)
*/
INT WINAPI lstrlenW( LPCWSTR str )
{
INT ret;
__TRY
{
ret = strlenW(str);
}
__EXCEPT(page_fault)
{
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
__ENDTRY
return ret;
}
/***********************************************************************
* UnicodeToAnsi (KERNEL.434)
*/
INT16 WINAPI UnicodeToAnsi16( LPCWSTR src, LPSTR dst, INT16 codepage )
{
if ( codepage == -1 )
codepage = CP_ACP;
return WideCharToMultiByte( codepage, 0, src, -1, dst, 0x7fffffff, NULL, NULL );
}