diff options
author | George Hazan <george.hazan@gmail.com> | 2013-01-05 13:38:59 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-01-05 13:38:59 +0000 |
commit | 3cd763c7a9c62bfb1c1dc43246b2199ee9427e92 (patch) | |
tree | cc8edc9da30eeda76be402bd940f35acbd0e1c97 /plugins/SMS/src/AdditionalFunctions/MemoryCompare.h | |
parent | 8860a0297c57d8c5fe3e6ddaef64ee6780ea116b (diff) |
64-bit compatibility fixes for the SMS plugin
git-svn-id: http://svn.miranda-ng.org/main/trunk@2979 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SMS/src/AdditionalFunctions/MemoryCompare.h')
-rw-r--r-- | plugins/SMS/src/AdditionalFunctions/MemoryCompare.h | 175 |
1 files changed, 17 insertions, 158 deletions
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<lpString2 >> 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, lpcSource1<lpcSource2
- jz short less_than //; CSTR_LESS_THAN
-
- test edi,edi //; lpcSource2=NULL, lpcSource1>lpcSource2
- 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<dwSource1Size) && (((const BYTE*)lpcSource1)[dwDiffPosition]==((const BYTE*)lpcSource2)[dwDiffPosition]); dwDiffPosition++);
- if (dwDiffPosition==dwSource1Size)
- {
- dwRet=CSTR_EQUAL;
- }else{
- if ((*((BYTE*)(((SIZE_T)lpcSource1)+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<dwSource2Size)
- {
- dwRet=CSTR_LESS_THAN;
- }else{
- dwRet=CSTR_GREATER_THAN;
- }
- }
-return(dwRet);
-}//*/
+ SIZE_T dwDiffPosition;
+ //dwDiffPosition=RtlCompareMemory(lpcSource1,lpcSource2,dwSource1Size);
+ for(dwDiffPosition=0; (dwDiffPosition<dwSource1Size) && (((const BYTE*)lpcSource1)[dwDiffPosition]==((const BYTE*)lpcSource2)[dwDiffPosition]); dwDiffPosition++);
+ if (dwDiffPosition==dwSource1Size)
+ return CSTR_EQUAL;
-/*
-__inline DWORD MemoryCompareEx(LPCVOID lpcSource1,SIZE_T dwSource1Size,LPCVOID lpcSource2,SIZE_T dwSource2Size,SIZE_T *pdwDiffPosition)
-{
- DWORD dwRet;
-
- if (dwSource1Size==dwSource2Size)
- {
- if (lpcSource1==lpcSource2)
- {
- dwRet=CSTR_EQUAL;
- }else{
- if (lpcSource1 && lpcSource2)
- {
- SIZE_T dwDiffPosition;
-
- dwDiffPosition=RtlCompareMemory(lpcSource1,lpcSource2,dwSource1Size);
- if (dwDiffPosition==dwSource1Size)
- {
- dwRet=CSTR_EQUAL;
- }else{
- if ((*((BYTE*)(((SIZE_T)lpcSource1)+dwDiffPosition)))>(*((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<dwSource2Size)
- {
- dwRet=CSTR_LESS_THAN;
- }else{
- dwRet=CSTR_GREATER_THAN;
+ if ((*((BYTE*)(((SIZE_T)lpcSource1)+dwDiffPosition)))>(*((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_)
|