------------------------------------------------------------ [BUG/PRB.] VFP 9.0 FIX - SYS(2001) FUNCTION January 2024 ------------------------------------------------------------ CCB 1. BUG: In vfp9 (and vfp6, vfp7, vfp8), the SYS(2001,"INDEX") function returns the incorrect result (2001). There is the bug for the following SYS(2001) functions: SYS(2001,"INDEX") SYS(2001,"NOCPTRANS") SYS(2001,"RELATION") SYS(2001,"FIELDS",1) There is no the bug for the SYS(2001,"ORDER") function and other SYS(2001) functions. There is a test program: *PROC testsys2001indexfunction SET INDEX TO tmp2.idx ADDITIVE ?SET("INDEX") && returns the correct result ?SYS(2001,"INDEX") && returns the incorrect result (2001) in vfp9! WAIT RETURN * END OF PROC TESTSYS2001INDEXFUNCTION. 2. CAUSE: There are some BUGs in the following code. 3. RESOLUTION: We can write some code to fix the BUG. Label60c1ac :: mov eax , dword ptr [ Data9370f8 ] ;0x0060c1ac : a1f8709300 mov eax , dword ptr [eax] ;0x0060c1b1 : 8b00 mov eax , dword ptr [ eax + 32 ] ;0x0060c1b3 : 8b4020 or dword ptr [ ebp + 12 ] , 0FFFFFFFFh ;0x0060c1b6 : 834d0cff test eax , eax ;0x0060c1ba : 85c0 je Label60c1cb ;0x0060c1bc : 740d test byte ptr [ eax + 16 ] , 020h ;0x0060c1be : f6401020 je Label60c1cb ;0x0060c1c2 : 7407 mov eax , dword ptr [eax] ;0x0060c1c4 : 8b00 mov edi , dword ptr [ eax + 104 ] ;0x0060c1c6 : 8b7868 jmp Label60c1cd ;0x0060c1c9 : eb02 Label60c1cb :: xor edi , edi ;0x0060c1cb : 33ff Label60c1cd :: mov eax , dword ptr [ ebp + 20 ] ;0x0060c1cd : 8b4514 ; ; ------------------------------------------------------- ; VFP 9.0 FIX - SYS(2001,"INDEX") FUNCTION ; January 2023 ; ------------------------------------------------------- ; CCB ; ; In vfp9, the SYS(2001,"INDEX") function returns 2001. ; ; 2023/1/10, by ccb ; mov byte ptr [eax] , 048h and dword ptr [ eax + 8 ] , 00h ;0x0060c1d0 : 83600800 test edi , edi ;0x0060c1d4 : 85ff je Label60c274 ;0x0060c1d6 : 0f8498000000 Label60c1dc :: mov eax , dword ptr [ Data9370f8 ] ;0x0060c1dc : a1f8709300 mov eax , dword ptr [eax] ;0x0060c1e1 : 8b00 mov eax , dword ptr [ eax + 32 ] ;0x0060c1e3 : 8b4020 lea esi , dword ptr [ ebp + 0FFFFFD90h ] ;0x0060c1e6 : 8db590fdffff call Fun435d6b ;0x0060c1ec : e87a9be2ff mov esi , eax ;0x0060c1f1 : 8bf0 mov eax , dword ptr [ ebp + 12 ] ;0x0060c1f3 : 8b450c cmp eax , dword ptr [esi] ;0x0060c1f6 : 3b06 je Label60c252 ;0x0060c1f8 : 7458 mov ebx , dword ptr [ ebp + 8 ] ;0x0060c1fa : 8b5d08 cmp byte ptr [ebx] , 00h ;0x0060c1fd : 803b00 jne Label60c20b ;0x0060c200 : 7509 cmp dword ptr [ ebp + 0FFFFFDBCh ] , 0FFFFFFFCh ;0x0060c202 : 83bdbcfdfffffc jne Label60c218 ;0x0060c209 : 750d Label60c20b :: lea eax , dword ptr [ ebp + 0FFFFFDB0h ] ;0x0060c20b : 8d85b0fdffff mov ecx , ebx ;0x0060c211 : 8bcb call Fun62bb05 ;0x0060c213 : e8edf80100 Label60c218 :: mov eax , ebx ;0x0060c218 : 8bc3 lea ecx , dword ptr [ eax + 1 ] ;0x0060c21a : 8d4801 Label60c21d :: mov dl , byte ptr [eax] ;0x0060c21d : 8a10 inc eax ;0x0060c21f : 40 test dl , dl ;0x0060c220 : 84d2 jne Label60c21d ;0x0060c222 : 75f9 sub eax , ecx ;0x0060c224 : 2bc1 mov ecx , dword ptr [esi] ;0x0060c226 : 8b0e mov esi , dword ptr [ ebp + 8 ] ;0x0060c228 : 8b7508 lea edx , dword ptr [ esi + eax ] ;0x0060c22b : 8d1406 mov dword ptr [ ebp + 12 ] , ecx ;0x0060c22e : 894d0c call Fun52d969 ;0x0060c231 : e83317f2ff mov ebx , dword ptr [ ebp + 20 ] ;0x0060c236 : 8b5d14 pushd 0106h ;0x0060c239 : 6806010000 push esi ;0x0060c23e : 56 call Fun8e5cef ;0x0060c23f : e8ab9a2d00 test eax , eax ;0x0060c244 : 85c0 je Label60c252 ;0x0060c246 : 740a mov dword ptr [ ebp + 0FFFFFDBCh ] , 0FFFFFFFCh ;0x0060c248 : c785bcfdfffffcffffff Label60c252 :: mov eax , dword ptr [edi] ;0x0060c252 : 8b07 mov edi , dword ptr [ eax + 48 ] ;0x0060c254 : 8b7830 test edi , edi ;0x0060c257 : 85ff jne Label60c1dc ;0x0060c259 : 7581 cmp dword ptr [ ebp + 0FFFFFDBCh ] , 0FFFFFFFCh ;0x0060c25b : 83bdbcfdfffffc jne Label60c274 ;0x0060c262 : 7510 mov ebx , dword ptr [ ebp + 20 ] ;0x0060c264 : 8b5d14 pushd 0106h ;0x0060c267 : 6806010000 push dword ptr [ ebp + 8 ] ;0x0060c26c : ff7508 call Fun8e5cef ;0x0060c26f : e87b9a2d00 Label60c274 :: mov eax , dword ptr [ Data9370f8 ] ;0x0060c274 : a1f8709300 mov eax , dword ptr [eax] ;0x0060c279 : 8b00 mov eax , dword ptr [ eax + 32 ] ;0x0060c27b : 8b4020 test eax , eax ;0x0060c27e : 85c0 je Label60c3c5 ;0x0060c280 : 0f843f010000 test byte ptr [ eax + 16 ] , 020h ;0x0060c286 : f6401020 je Label60c3c5 ;0x0060c28a : 0f8435010000 cmp dword ptr [ eax + 52 ] , 00h ;0x0060c290 : 83783400 je Label60c3c5 ;0x0060c294 : 0f842b010000 mov ecx , dword ptr [ ebp + 8 ] ;0x0060c29a : 8b4d08 mov eax , ecx ;0x0060c29d : 8bc1 lea esi , dword ptr [ eax + 1 ] ;0x0060c29f : 8d7001 Label60c2a2 :: mov dl , byte ptr [eax] ;0x0060c2a2 : 8a10 inc eax ;0x0060c2a4 : 40 test dl , dl ;0x0060c2a5 : 84d2 jne Label60c2a2 ;0x0060c2a7 : 75f9 sub eax , esi ;0x0060c2a9 : 2bc6 pushd 08091h ;0x0060c2ab : 6891800000 add eax , ecx ;0x0060c2b0 : 03c1 pushd offset Data92b024 ;0x0060c2b2 : 6824b09200 push eax ;0x0060c2b7 : 50 call Fun43089c ;0x0060c2b8 : e8df45e2ff add esp , 0Ch ;0x0060c2bd : 83c40c 4. APPLIES TO: VFP 6.0.8167.0 VFP 6.0.8961.0 (SP5) VFP 7.0.0.9262 VFP 7.0.0.9465 (SP1) VFP 8.0.0.2521 VFP 8.0.0.3117 (SP1) VFP 9.0.0.2412 VFP 9.0.0.3504 (SP1) VFP 9.0.0.4611 (SP2) VFP 9.0.0.5015 (SP2) VFP 9.0.0.5411 (SP2) VFP 9.0.0.5721 (SP2) VFP 9.0.0.5815 (SP2) VFP 9.0.0.6303 (SP2) VFP 9.0.0.6602 (SP2) VFP 9.0.0.7423 (SP2) The bug has been fixed in VFP Advanced. 5. REFERENCE WEBSITES: 1, baiyujia.com: http://www.baiyujia.com 6. OTHER: For reference only, there is no guarantees. Any questions or suggestions, please send me an email at ccb2000@163.com. |