Sweden-Number/memory/string.c

373 lines
8.7 KiB
C
Raw Normal View History

Release 960611 Tue Jun 11 15:20:43 1996 Alexandre Julliard <julliard@lrc.epfl.ch> * [debugger/break.c] [loader/signal.c] Fixed breakpoints in 32-bit code. * [include/windows.h] Added many more Win32 versions of standard structures. * [include/winreg.h] [misc/registry.c] Moved private types into registry.c. * [memory/string.c] (New file) Moved most string functions from misc/lstr.c; added Win32 version of all functions. * [misc/wsprintf.c] Implemented Win32 wsprintf functions. * [objects/bitmap.c] Implemented Win32 bitmap functions. * [windows/dialog.c] Don't set dialog procedure before the controls are created. This avoids a crash in Winhelp. Tue Jun 11 14:10:06 1996 Martin von Loewis <loewis@informatik.hu-berlin.de> * [controls/menu.c] [if1632/user.spec] [windows/message.c] Replace PeekMessage with PeekMessage16. * [if1632/kernel32.spec][misc/main.c] GetVersion32,GetVersionEx32A,GetVersionEx32W: new functions. MAIN_ParseVersion: new function, new command line option -winver. GetVersion: modified to take command line argument into account. * [if1632/kernel32.spec] [win32/process.c] FreeLibrary32: new function. TlsAlloc: initialize Tls to zero. InterlockedIncrement,InterlockedDecrement,InterlockedExchange: new functions. * [if1632/kernel32.spec] SetErrorMode,GetActiveWindow: new relays to existing functions. * [if1632/kernel32.spec][win32/user32.c] PeekMessage32A,PeekMessage32W: new functions. * [include/struct32.h][include/windows.h] Moved MSG32 to windows.h. Renamed MSG to MSG16. Modified prototypes to use MSG16 * [include/winbase.h] OSVERSIONINFO32A,OSVERSIONINFO32W: new structures. Sun Jun 9 20:53:30 1996 Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de> * [if1632/Makefile.in] [loader/builtin.c] version.dll,lz32.dll added. * [include/lzexpand.h] [if1632/lz32.spec] [if1632/lzexpand.spec] [misc/lzexpand.c] lz32.dll added. Modified to new function naming standard. * [include/ver.h] [if1632/ver.spec] [if1632/version.spec] [misc/ver.c] version.dll added (win32 version of ver.dll). Modified to new function naming standard. Use registry to look up a LOCALE langids too. (VerInstallFile,VerFindFile still stubs) Fri Jun 7 20:40:20 1996 Albrecht Kleine <kleine@ak.sax.de> * [files/file.c] Added a warning if GetTempFileName() gets a bad drive parameter. * [misc/commdlg.c] Changed file listbox color to gray in SaveFile dialog (just like Windows does this).
1996-06-11 18:02:08 +02:00
/*
* String functions
*
* Copyright 1993 Yngvi Sigurjonsson
* Copyright 1996 Alexandre Julliard
*/
Release 960705 Fri Jul 5 16:27:43 1996 Alexandre Julliard <julliard@lrc.epfl.ch> * [controls/desktop.c] Use Windows file I/O routines to load the desktop bitmap. * [files/file.c] Implemented RemoveDirectory* and DeleteFile*. * [include/wine.h] Added SIGCONTEXT typedef to replace #define sigcontext_struct. * [loader/task.c] Fixed initial breakpoint setting for Win32 tasks. * [misc/wsprintf.c] Ignore Unicode formats for wsprintf16(). * [objects/font.c] Implemented Win32 version of GetTextMetrics. * [windows/winproc.c] [windows/win.c] [windows/class.c] [windows/dialog.c] Modified windows procedures to use thunks, to ensure that the procedure can be called directly from the Windows program. * [windows/win.c] Added function WIN_BuildWinArray() to make it easier to enumerate windows. Implemented Win32 version of EnumWindows() and friends. Fri Jul 5 11:56:22 1996 Andreas Kirschbaum <ank@rbg.informatik.th-darmstadt.de> * [controls/button.c] [windows/win.c] Operator precedence fixes. * [controls/edit.c] Implemented ES_PASSWORD, ES_LOWERCASE and ES_UPPERCASE styles. Fixed word wrap with long words. * [debugger/debug.l] New alias "where" for command "backtrace". * [if1632/gdi.spec] Corrected parameter of ExtTextOut. * [loader/module.c] Corrected printing of table of modules. * [misc/spy.c] Removed superfluous \n in message name. * [windows/message.c] Declared MSG_SendMessage as static. Changed parameter of DirectedYield() from queue handle to task handle. Removed warning mesages for argument of printf. * [windows/nonclient.c] Added the flag DT_NOPREFIX when drawing window titles. * [windows/win.c] WIN_WalkWindows now prints the invalid window handle. Added a warning if Get-/SetWindowWord/-Long gets an invalid offset. * [windows/winproc.c] Allows creating dialog windows with NULL as dialog function. Wed Jul 3 09:26:41 1996 Andrew Lewycky <plewycky@oise.utoronto.ca> * [windows/event.c] EVENT_key: Fixes to VK_ code generation for space bar and punctuation. * [files/file.c] GetTempFileName: first character in temporary name is "~". * [memory/heap.c] HEAP_MakeInUseBlockFree now frees the whole subheap if possible. * [objects/text.c] ExtTextOut16(): handle NULL lpRect and ETO_OPAQUE. * [misc/driver.c] Removed some bugs and reformatted. Actually loads drivers now. * [include/callback.h] Added CallDriverProc() and CallWindowsExitProc(). * [loader/module.c] MODULE_CallWEP(): new function. * [misc/lzexpand.c] LZSeek(): return new pointer, not old one. * [misc/ver.c] find_ne_resource(): fixed dependence on LZSeek() bug. GetFileResource(): initialize reslen before using it. * [windows/class.c] SetClassWord(): add missing else. * [objects/font.c] lpFontList is now MAX_FONTS+1. It used to overwrite the array. InitFontList: allocate one huge array of structures. FONT_MatchFont: uppercase the face name. Thu Jun 27 12:41:40 1996 Bruce Milner <bruce@genetics.utah.edu> * [memory/heap.c] Fixed a typo in HeapReAlloc(). Tue Jun 25 22:22:03 1996 Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de> * [files/directory.c] [files/drive.c] [if1632/kernel.spec] [if1632/kernel32.spec] [if1632/shell.spec] [include/windows.h] GetTempPath* added GetDriveType* fixed, updated to NewNameStandard. GetCurrentDirectory* fixed (needs to prepend X:\). * [controls/listbox.c] Missing NULL check added. * [if1632/winmm.spec] [loader/builtin.c] winmm.dll (32bit mmsystem equivalent) specs added. * [memory/string.c] [if1632/kernel32.spec] [include/windows.h] Rtl{Move,Zero,Fill}Memory added. * [misc/registry.c] Some NULL ptr dereference bugs fixed. * [multimedia/mcicda.c][multimedia/mcistring.c][multimedia/mmsystem.c] Check for NULL ptr. Fill mciOpenDrv when mixing mciOpen and mciSendString("open .."). Aliasing should work for all MCI devices. * [windows/win.c] Allow passing invalid window handles to CloseWindow(). Tue Jun 25 20:02:15 1996 Jukka Iivonen <iivonen@cc.helsinki.fi> * [files/directory.c] [if1632/kernel32.spec] GetSystemDirectory32A and GetSystemDirectory32W added. * [misc/main.c] [if1632/kernel32.spec] Beep and SetEnvironmentVariable32W added.
1996-07-05 19:14:13 +02:00
#define NO_TRANSITION_TYPES /* This file is Win32-clean */
Release 960611 Tue Jun 11 15:20:43 1996 Alexandre Julliard <julliard@lrc.epfl.ch> * [debugger/break.c] [loader/signal.c] Fixed breakpoints in 32-bit code. * [include/windows.h] Added many more Win32 versions of standard structures. * [include/winreg.h] [misc/registry.c] Moved private types into registry.c. * [memory/string.c] (New file) Moved most string functions from misc/lstr.c; added Win32 version of all functions. * [misc/wsprintf.c] Implemented Win32 wsprintf functions. * [objects/bitmap.c] Implemented Win32 bitmap functions. * [windows/dialog.c] Don't set dialog procedure before the controls are created. This avoids a crash in Winhelp. Tue Jun 11 14:10:06 1996 Martin von Loewis <loewis@informatik.hu-berlin.de> * [controls/menu.c] [if1632/user.spec] [windows/message.c] Replace PeekMessage with PeekMessage16. * [if1632/kernel32.spec][misc/main.c] GetVersion32,GetVersionEx32A,GetVersionEx32W: new functions. MAIN_ParseVersion: new function, new command line option -winver. GetVersion: modified to take command line argument into account. * [if1632/kernel32.spec] [win32/process.c] FreeLibrary32: new function. TlsAlloc: initialize Tls to zero. InterlockedIncrement,InterlockedDecrement,InterlockedExchange: new functions. * [if1632/kernel32.spec] SetErrorMode,GetActiveWindow: new relays to existing functions. * [if1632/kernel32.spec][win32/user32.c] PeekMessage32A,PeekMessage32W: new functions. * [include/struct32.h][include/windows.h] Moved MSG32 to windows.h. Renamed MSG to MSG16. Modified prototypes to use MSG16 * [include/winbase.h] OSVERSIONINFO32A,OSVERSIONINFO32W: new structures. Sun Jun 9 20:53:30 1996 Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de> * [if1632/Makefile.in] [loader/builtin.c] version.dll,lz32.dll added. * [include/lzexpand.h] [if1632/lz32.spec] [if1632/lzexpand.spec] [misc/lzexpand.c] lz32.dll added. Modified to new function naming standard. * [include/ver.h] [if1632/ver.spec] [if1632/version.spec] [misc/ver.c] version.dll added (win32 version of ver.dll). Modified to new function naming standard. Use registry to look up a LOCALE langids too. (VerInstallFile,VerFindFile still stubs) Fri Jun 7 20:40:20 1996 Albrecht Kleine <kleine@ak.sax.de> * [files/file.c] Added a warning if GetTempFileName() gets a bad drive parameter. * [misc/commdlg.c] Changed file listbox color to gray in SaveFile dialog (just like Windows does this).
1996-06-11 18:02:08 +02:00
#include <ctype.h>
#include <string.h>
#include "windows.h"
#include "ldt.h"
/***********************************************************************
* hmemcpy (KERNEL.348)
*/
void hmemcpy( LPVOID dst, LPCVOID src, LONG count )
{
memcpy( dst, src, count );
}
/***********************************************************************
* lstrcat16 (KERNEL.89)
*/
SEGPTR lstrcat16( SEGPTR dst, SEGPTR src )
{
lstrcat32A( (LPSTR)PTR_SEG_TO_LIN(dst), (LPCSTR)PTR_SEG_TO_LIN(src) );
return dst;
}
/***********************************************************************
* lstrcat32A (KERNEL32.599)
*/
LPSTR lstrcat32A( LPSTR dst, LPCSTR src )
{
strcat( dst, src );
return dst;
}
/***********************************************************************
* lstrcat32W (KERNEL32.600)
*/
LPWSTR lstrcat32W( LPWSTR dst, LPCWSTR src )
{
register LPWSTR p = dst;
while (*p) p++;
while ((*p++ = *src++));
return dst;
}
/***********************************************************************
* lstrcatn16 (KERNEL.352)
*/
SEGPTR lstrcatn16( SEGPTR dst, SEGPTR src, INT16 n )
{
lstrcatn32A( (LPSTR)PTR_SEG_TO_LIN(dst), (LPCSTR)PTR_SEG_TO_LIN(src), n );
return dst;
}
/***********************************************************************
* lstrcatn32A (Not a Windows API)
*/
LPSTR lstrcatn32A( LPSTR dst, LPCSTR src, INT32 n )
{
register LPSTR p = dst;
while (*p) p++;
if ((n -= (INT32)(p - dst)) <= 0) return dst;
lstrcpyn32A( p, src, n );
return dst;
}
/***********************************************************************
* lstrcatn32W (Not a Windows API)
*/
LPWSTR lstrcatn32W( LPWSTR dst, LPCWSTR src, INT32 n )
{
register LPWSTR p = dst;
while (*p) p++;
if ((n -= (INT32)(p - dst)) <= 0) return dst;
lstrcpyn32W( p, src, n );
return dst;
}
/***********************************************************************
* lstrcmp16 (USER.430)
*/
INT16 lstrcmp16( LPCSTR str1, LPCSTR str2 )
{
return (INT16)lstrcmp32A( str1, str2 );
}
/***********************************************************************
* lstrcmp32A (KERNEL.602)
*/
INT32 lstrcmp32A( LPCSTR str1, LPCSTR str2 )
{
return (INT32)strcmp( str1, str2 );
}
/***********************************************************************
* lstrcmp32W (KERNEL.603)
*/
INT32 lstrcmp32W( LPCWSTR str1, LPCWSTR str2 )
{
while (*str1 && (*str1 == *str2)) { str1++; str2++; }
return (INT32)(*str1 - *str2);
}
/***********************************************************************
* lstrcmpi16 (USER.471)
*/
INT16 lstrcmpi16( LPCSTR str1, LPCSTR str2 )
{
return (INT16)lstrcmpi32A( str1, str2 );
}
/***********************************************************************
* lstrcmpi32A (KERNEL32.605)
*/
INT32 lstrcmpi32A( LPCSTR str1, LPCSTR str2 )
{
INT32 res;
while (*str1)
{
if ((res = toupper(*str1) - toupper(*str2)) != 0) return res;
str1++;
str2++;
}
return toupper(*str1) - toupper(*str2);
}
/***********************************************************************
* lstrcmpi32W (KERNEL32.606)
*/
INT32 lstrcmpi32W( LPCWSTR str1, LPCWSTR str2 )
{
INT32 res;
while (*str1)
{
/* FIXME: Unicode */
if ((res = toupper(*str1) - toupper(*str2)) != 0) return res;
str1++;
str2++;
}
return toupper(*str1) - toupper(*str2);
}
/***********************************************************************
* lstrcpy16 (KERNEL.88)
*/
SEGPTR lstrcpy16( SEGPTR dst, SEGPTR src )
{
lstrcpy32A( (LPSTR)PTR_SEG_TO_LIN(dst), (LPCSTR)PTR_SEG_TO_LIN(src) );
return dst;
}
/***********************************************************************
* lstrcpy32A (KERNEL32.608)
*/
LPSTR lstrcpy32A( LPSTR dst, LPCSTR src )
{
strcpy( dst, src );
return dst;
}
/***********************************************************************
* lstrcpy32W (KERNEL32.609)
*/
LPWSTR lstrcpy32W( LPWSTR dst, LPCWSTR src )
{
register LPWSTR p = dst;
while ((*p++ = *src++));
return dst;
}
/***********************************************************************
* lstrcpyn16 (KERNEL.353)
*/
SEGPTR lstrcpyn16( SEGPTR dst, SEGPTR src, INT16 n )
{
lstrcpyn32A( (LPSTR)PTR_SEG_TO_LIN(dst), (LPCSTR)PTR_SEG_TO_LIN(src), n );
return dst;
}
/***********************************************************************
* lstrcpyn32A (KERNEL32.611)
*/
LPSTR lstrcpyn32A( LPSTR dst, LPCSTR src, INT32 n )
{
LPSTR p = dst;
while ((n-- > 1) && *src) *p++ = *src++;
*p = 0;
return dst;
}
/***********************************************************************
* lstrcpyn32W (KERNEL32.612)
*/
LPWSTR lstrcpyn32W( LPWSTR dst, LPCWSTR src, INT32 n )
{
LPWSTR p = dst;
while ((n-- > 1) && *src) *p++ = *src++;
*p = 0;
return dst;
}
/***********************************************************************
* lstrlen16 (KERNEL.90)
*/
INT16 lstrlen16( LPCSTR str )
{
return (INT16)lstrlen32A( str );
}
/***********************************************************************
* lstrlen32A (KERNEL32.614)
*/
INT32 lstrlen32A( LPCSTR str )
{
/* looks weird, but win3.1 KERNEL got a GeneralProtection handler
* in lstrlen() ... we check only for NULL pointer reference.
* - Marcus Meissner
*/
if (!str) return 0;
return (INT32)strlen(str);
}
/***********************************************************************
* lstrlen32W (KERNEL32.615)
*/
INT32 lstrlen32W( LPCWSTR str )
{
INT32 len = 0;
if (!str) return 0;
while (*str++) len++;
return len;
}
/***********************************************************************
* lstrncmp16 (Not a Windows API)
*/
INT16 lstrncmp16( LPCSTR str1, LPCSTR str2, INT16 n )
{
return (INT16)lstrncmp32A( str1, str2, n );
}
/***********************************************************************
* lstrncmp32A (Not a Windows API)
*/
INT32 lstrncmp32A( LPCSTR str1, LPCSTR str2, INT32 n )
{
return (INT32)strncmp( str1, str2, n );
}
/***********************************************************************
* lstrncmp32W (Not a Windows API)
*/
INT32 lstrncmp32W( LPCWSTR str1, LPCWSTR str2, INT32 n )
{
if (!n) return 0;
while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; }
return (INT32)(*str1 - *str2);
}
/***********************************************************************
* lstrncmpi16 (Not a Windows API)
*/
INT16 lstrncmpi16( LPCSTR str1, LPCSTR str2, INT16 n )
{
return (INT16)lstrncmpi32A( str1, str2, n );
}
/***********************************************************************
* lstrncmpi32A (Not a Windows API)
*/
INT32 lstrncmpi32A( LPCSTR str1, LPCSTR str2, INT32 n )
{
INT32 res;
if (!n) return 0;
while ((--n > 0) && *str1)
{
if ((res = toupper(*str1) - toupper(*str2)) != 0) return res;
str1++;
str2++;
}
return toupper(*str1) - toupper(*str2);
}
/***********************************************************************
* lstrncmpi32W (Not a Windows API)
*/
INT32 lstrncmpi32W( LPCWSTR str1, LPCWSTR str2, INT32 n )
{
INT32 res;
if (!n) return 0;
while ((--n > 0) && *str1)
{
/* FIXME: Unicode */
if ((res = toupper(*str1) - toupper(*str2)) != 0) return res;
str1++;
str2++;
}
return toupper(*str1) - toupper(*str2);
}
Release 960705 Fri Jul 5 16:27:43 1996 Alexandre Julliard <julliard@lrc.epfl.ch> * [controls/desktop.c] Use Windows file I/O routines to load the desktop bitmap. * [files/file.c] Implemented RemoveDirectory* and DeleteFile*. * [include/wine.h] Added SIGCONTEXT typedef to replace #define sigcontext_struct. * [loader/task.c] Fixed initial breakpoint setting for Win32 tasks. * [misc/wsprintf.c] Ignore Unicode formats for wsprintf16(). * [objects/font.c] Implemented Win32 version of GetTextMetrics. * [windows/winproc.c] [windows/win.c] [windows/class.c] [windows/dialog.c] Modified windows procedures to use thunks, to ensure that the procedure can be called directly from the Windows program. * [windows/win.c] Added function WIN_BuildWinArray() to make it easier to enumerate windows. Implemented Win32 version of EnumWindows() and friends. Fri Jul 5 11:56:22 1996 Andreas Kirschbaum <ank@rbg.informatik.th-darmstadt.de> * [controls/button.c] [windows/win.c] Operator precedence fixes. * [controls/edit.c] Implemented ES_PASSWORD, ES_LOWERCASE and ES_UPPERCASE styles. Fixed word wrap with long words. * [debugger/debug.l] New alias "where" for command "backtrace". * [if1632/gdi.spec] Corrected parameter of ExtTextOut. * [loader/module.c] Corrected printing of table of modules. * [misc/spy.c] Removed superfluous \n in message name. * [windows/message.c] Declared MSG_SendMessage as static. Changed parameter of DirectedYield() from queue handle to task handle. Removed warning mesages for argument of printf. * [windows/nonclient.c] Added the flag DT_NOPREFIX when drawing window titles. * [windows/win.c] WIN_WalkWindows now prints the invalid window handle. Added a warning if Get-/SetWindowWord/-Long gets an invalid offset. * [windows/winproc.c] Allows creating dialog windows with NULL as dialog function. Wed Jul 3 09:26:41 1996 Andrew Lewycky <plewycky@oise.utoronto.ca> * [windows/event.c] EVENT_key: Fixes to VK_ code generation for space bar and punctuation. * [files/file.c] GetTempFileName: first character in temporary name is "~". * [memory/heap.c] HEAP_MakeInUseBlockFree now frees the whole subheap if possible. * [objects/text.c] ExtTextOut16(): handle NULL lpRect and ETO_OPAQUE. * [misc/driver.c] Removed some bugs and reformatted. Actually loads drivers now. * [include/callback.h] Added CallDriverProc() and CallWindowsExitProc(). * [loader/module.c] MODULE_CallWEP(): new function. * [misc/lzexpand.c] LZSeek(): return new pointer, not old one. * [misc/ver.c] find_ne_resource(): fixed dependence on LZSeek() bug. GetFileResource(): initialize reslen before using it. * [windows/class.c] SetClassWord(): add missing else. * [objects/font.c] lpFontList is now MAX_FONTS+1. It used to overwrite the array. InitFontList: allocate one huge array of structures. FONT_MatchFont: uppercase the face name. Thu Jun 27 12:41:40 1996 Bruce Milner <bruce@genetics.utah.edu> * [memory/heap.c] Fixed a typo in HeapReAlloc(). Tue Jun 25 22:22:03 1996 Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de> * [files/directory.c] [files/drive.c] [if1632/kernel.spec] [if1632/kernel32.spec] [if1632/shell.spec] [include/windows.h] GetTempPath* added GetDriveType* fixed, updated to NewNameStandard. GetCurrentDirectory* fixed (needs to prepend X:\). * [controls/listbox.c] Missing NULL check added. * [if1632/winmm.spec] [loader/builtin.c] winmm.dll (32bit mmsystem equivalent) specs added. * [memory/string.c] [if1632/kernel32.spec] [include/windows.h] Rtl{Move,Zero,Fill}Memory added. * [misc/registry.c] Some NULL ptr dereference bugs fixed. * [multimedia/mcicda.c][multimedia/mcistring.c][multimedia/mmsystem.c] Check for NULL ptr. Fill mciOpenDrv when mixing mciOpen and mciSendString("open .."). Aliasing should work for all MCI devices. * [windows/win.c] Allow passing invalid window handles to CloseWindow(). Tue Jun 25 20:02:15 1996 Jukka Iivonen <iivonen@cc.helsinki.fi> * [files/directory.c] [if1632/kernel32.spec] GetSystemDirectory32A and GetSystemDirectory32W added. * [misc/main.c] [if1632/kernel32.spec] Beep and SetEnvironmentVariable32W added.
1996-07-05 19:14:13 +02:00
/***********************************************************************
* RtlFillMemory (KERNEL32.441)
*/
VOID RtlFillMemory( LPVOID ptr, UINT32 len, UINT32 fill )
{
memset( ptr, fill, len );
}
/***********************************************************************
* RtlMoveMemory (KERNEL32.442)
*/
VOID RtlMoveMemory( LPVOID dst, LPCVOID src, UINT32 len )
{
/* memcpy does not support overlapped copies, */
/* and memmove is not portable. */
if (((BYTE *)dst + len <= (BYTE *)src) ||
((BYTE *)src + len <= (BYTE *)dst))
{
memcpy( dst, src, len );
return;
}
/* do it the hard way (FIXME: could do better than this) */
while (len--) *((BYTE *)dst)++ = *((BYTE *)src)++;
}
/***********************************************************************
* RtlZeroMemory (KERNEL32.444)
*/
VOID RtlZeroMemory( LPVOID ptr, UINT32 len )
{
memset( ptr, 0, len );
}