From 3cd763c7a9c62bfb1c1dc43246b2199ee9427e92 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 5 Jan 2013 13:38:59 +0000 Subject: 64-bit compatibility fixes for the SMS plugin git-svn-id: http://svn.miranda-ng.org/main/trunk@2979 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- .../SMS/src/AdditionalFunctions/MemoryCompare.h | 175 ++------------------- 1 file changed, 17 insertions(+), 158 deletions(-) (limited to 'plugins/SMS/src/AdditionalFunctions/MemoryCompare.h') diff --git a/plugins/SMS/src/AdditionalFunctions/MemoryCompare.h b/plugins/SMS/src/AdditionalFunctions/MemoryCompare.h index de663c6d8a..3fdb5e08b3 100644 --- a/plugins/SMS/src/AdditionalFunctions/MemoryCompare.h +++ b/plugins/SMS/src/AdditionalFunctions/MemoryCompare.h @@ -5,173 +5,32 @@ #pragma once #endif // _MSC_VER > 1000 - -// If the string pointed to by lpString1 is less than the string pointed -// to by lpString2, the return value is negative. -// If the string pointed to by lpString1 is greater than the string pointed -// to by lpString2, the return value is positive. -// If the strings are equal, the return value is zero. -// -// lpString1> ret=1=CSTR_LESS_THAN -// lpString1=lpString2 >> ret=2=CSTR_EQUAL -// lpString1>lpString2 >> ret=3=CSTR_GREATER_THAN - - -/*__inline DWORD MemoryCompare(LPCVOID lpcSource1,SIZE_T dwSource1Size,LPCVOID lpcSource2,SIZE_T dwSource2Size) -{ - DWORD dwRet; - - __asm - { - mov ecx,dwSource1Size //; ecx = Source string 1 Size - cmp ecx,dwSource2Size //; сверяем длинны участков памяти - jg short greater_than - jl short less_than - test ecx,ecx - jz short equal //; NULL=NULL - - mov esi,lpcSource1 //; edi = Source string 1 - mov edi,lpcSource2 //; esi = Source string 2 - cmp edi,esi //; сверяем указатели на участки памяти - je short equal //; это один и тотже участок, они естественно равны - - test esi,esi //; lpcSource1=NULL, lpcSource1lpcSource2 - jz short greater_than //; CSTR_GREATER_THAN - - //cld //; сканируя в прямом направлении - - repe cmpsb //; цикл сравнения. - cmp_loop: - //sub ecx,4 - //jz short equal - - //inc esi - //inc edi - //mov al,byte ptr [esi] - //cmpsd - //cmp al,byte ptr [edi] - //je short cmp_loop - jg short greater_than - jl short less_than - - equal: //; если мы попали сюда, значит, они - mov dwRet,CSTR_EQUAL //; совпадают (match) - jmp end_func - less_than: //; не совпадают - mov dwRet,CSTR_LESS_THAN - jmp end_func - greater_than: - mov dwRet,CSTR_GREATER_THAN - - end_func: - } -return(dwRet); -}//*/ - __inline DWORD MemoryCompare(LPCVOID lpcSource1,SIZE_T dwSource1Size,LPCVOID lpcSource2,SIZE_T dwSource2Size) { - DWORD dwRet; + if (dwSource1Size == dwSource2Size) { + if (lpcSource1 == lpcSource2) + return CSTR_EQUAL; - if (dwSource1Size==dwSource2Size) - { - if (lpcSource1==lpcSource2) - { - dwRet=CSTR_EQUAL; - }else{ - if (lpcSource1 && lpcSource2) - { + if (lpcSource1 && lpcSource2) { #ifdef _INC_MEMORY - dwRet=(2+memcmp(lpcSource1,lpcSource2,dwSource1Size)); + return 2 + memcmp(lpcSource1,lpcSource2,dwSource1Size)); #else - SIZE_T dwDiffPosition; - - //dwDiffPosition=RtlCompareMemory(lpcSource1,lpcSource2,dwSource1Size); - for(dwDiffPosition=0; (dwDiffPosition(*((BYTE*)(((SIZE_T)lpcSource2)+dwDiffPosition)))) - { - dwRet=CSTR_GREATER_THAN; - }else{ - dwRet=CSTR_LESS_THAN; - } - } -#endif - }else{ - if (lpcSource1) - {//lpcSource2==NULL - dwRet=CSTR_GREATER_THAN; - }else{//lpcSource1==NULL - dwRet=CSTR_LESS_THAN; - } - } - } - }else{ - if (dwSource1Size(*((BYTE*)(((SIZE_T)lpcSource2)+dwDiffPosition)))) - { - dwRet=CSTR_GREATER_THAN; - }else{ - dwRet=CSTR_LESS_THAN; - } - } - - if (pdwDiffPosition) (*pdwDiffPosition)=dwDiffPosition; - }else{ - if (lpcSource1) - {//lpcSource2==NULL - dwRet=CSTR_GREATER_THAN; - }else{//lpcSource1==NULL - dwRet=CSTR_LESS_THAN; - } - } - } - }else{ - if (dwSource1Size(*((BYTE*)(((SIZE_T)lpcSource2)+dwDiffPosition)))) + return CSTR_GREATER_THAN; + + return CSTR_LESS_THAN; +#endif } + return (lpcSource1) ? CSTR_GREATER_THAN : CSTR_LESS_THAN; } -return(dwRet); + return (dwSource1Size < dwSource2Size) ? CSTR_LESS_THAN : CSTR_GREATER_THAN; } -*/ - #endif // !defined(AFX_MEMORYCOMPARE__H__INCLUDED_) -- cgit v1.2.3