Update of /cvsroot/win32forth/win32forth/src/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13414/src/lib
Modified Files:
w_search.f
Log Message:
Jos: Restored compareia.
Index: w_search.f
===================================================================
RCS file: /cvsroot/win32forth/win32forth/src/lib/w_search.f,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** w_search.f 22 Aug 2005 10:47:56 -0000 1.3
--- w_search.f 23 Aug 2005 18:29:28 -0000 1.4
***************
*** 53,56 ****
--- 53,110 ----
+ \ Initial Made by Ron Aharon.
+ \ COMPAREI is the same as COMPARE , but case-insensitive
+ \ Modifications to get a better shell-sort:
+ \ 1. The version leaves the chars from 0 to 2F unchanged.
+ \ The effect is that in a sort the non-alphanumeric characters will not be
+ \ between the alphanumeric characters.
+ \ 2. It uses jnb instead of jns which makes sure that the character FF is at
+ \ the end of a sorted list.
+ \ 3. Changed the name to COMPAREIA to avoid future conflicts.
+
+
+ code compareia ( adr1 len1 adr2 len2 -- n )
+ sub ebp, # 8
+ mov 0 [ebp], edi
+ mov 4 [ebp], esi
+ pop eax \ eax = adr2
+ pop ecx \ ecx = len1
+ pop esi \ esi = adr1
+ add esi, edi \ absolute address
+ add edi, eax \ edi = adr2 (abs)
+ sub eax, eax \ default is 0 (strings match)
+ cmp ecx, ebx \ compare lengths
+ je short @@2
+ ja short @@1
+ dec eax \ if len1 < len2, default is -1
+ jmp short @@2
+ @@1:
+ inc eax \ if len1 > len2, default is 1
+ mov ecx, ebx \ and use shorter length
+ @@2:
+ mov bl, BYTE [esi]
+ mov bh, BYTE [edi]
+ inc esi
+ inc edi
+ cmp bx, # $2F2F \ skip chars beteen 0 and 2F ( now lower case )
+ jle short @@7
+ or bx, # $2020 \ May 21st, 2003 or is better then xor
+ @@7:
+ cmp bh, bl
+ loopz @@2
+
+ je short @@4 \ if equal, return default
+ jnb short @@3 \ ** jnb for an unsigned test ( was jns )
+ mov eax, # 1 \ if str1 > str2, return 1
+ jmp short @@4
+ @@3:
+ mov eax, # -1 \ if str1 < str2, return -1
+ @@4:
+ mov ebx, eax
+ mov edi, 0 [ebp]
+ mov esi, 4 [ebp]
+ add ebp, # 8
+ next c;
+
\ Searchai str1 for substring str2 in a case-insenitive manner.
\ If found, return the address of the start of the
***************
*** 122,126 ****
dup -rot adr-search over CaseSensitive?
if compare
! else istr=
then
not dup
--- 176,180 ----
dup -rot adr-search over CaseSensitive?
if compare
! else compareia
then
not dup
|