------------------------------------------------------------
                     [BUG/PRB.] VFP 9.0 FIX - FIND OR REPLACE DIALOG BOX
                                 January 2024
                 ------------------------------------------------------------
                                    CCB



1. BUG:

     In the Find or Replace Dialog Box, if we select "Match whole word", sometimes vfp will crash.

     The bug occurs in vfp7, vfp8 and vfp9, it does not occur in vfp6.

     The bug only occurs in DBCS (Double-Byte Character Sets) environments.

     Please refer to the picture find.jpg:

     In the Replace Dialog Box, if we find "\r" (but not "\r\n"), and click the "Replace All" button, vfp will enter an infinite loop.

     The bug only occurs in vfp9, it does not occur in vfp6, vfp7 and vfp8.

     In the Find or Replace Dialog Box, sometimes we have found the text, but we can't see the text (vfp scrolls to the top of the file).
     In the MODIFY COMMAND or MODIFY FILE window, sometimes when we paste long text, but we can't see the text (vfp scrolls to the top of the file).

     The bug occurs in vfp6, vfp7, vfp8 and vfp9.


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Label7319bc ::
             cmp  byte ptr [ Data947519 ] , 00h                              ;0x007319bc :        803d1975940000
             mov  dword ptr [ ebp + 0FFFFFE20h ] , 01h                       ;0x007319c3 :        c78520feffff01000000
             je Label731a9e                                                  ;0x007319cd :        0f84cb000000
             mov  edi , dword ptr [ ebp + 0FFFFFE48h ]                       ;0x007319d3 :        8bbd48feffff
             test edi , edi                                                  ;0x007319d9 :        85ff
             jle Label731a1a                                                 ;0x007319db :        7e3d
             sub  edi , dword ptr [ ebp + 0FFFFFE2Ch ]                       ;0x007319dd :        2bbd2cfeffff
             lea eax ,  dword ptr [ ebp + 0FFFFFE58h ]                       ;0x007319e3 :        8d8558feffff
             dec edi                                                         ;0x007319e9 :        4f


     ;
     ;                 -------------------------------------------------
     ;                      VFP 9.0 FIX - FIND OR REPLACE DIALOG BOX
     ;                                   July 2014
     ;                 -------------------------------------------------
     ;                                     CCB
     ;
     ; In the Find or Replace Dialog Box, if we select "Match whole word", sometimes vfp will crash.
     ;
     ; 2014/7/19, by ccb
     ;

             cmp dword ptr vfpa_sys9162_data,00h
             je Label7319ea
             test edi , edi                                                  ;0x00731a29 :        85d2
             jl Label7319f3                                                  ;0x00731a2b :        7c1c
             cmp  edi , dword ptr [ ebp + 108 ]                              ;0x00731a2d :        3b556c
             jnl Label7319f3                                                 ;0x00731a30 :        7d17
             cmp edi , 0200h                                                 ;0x00731a32 :        81fa00020000
             jnb Label7319f3                                                 ;0x00731a38 :        730f


     Label7319ea ::
             call Fun4b3f3f                                                  ;0x007319ea :        e85025d8ff
             test eax , eax                                                  ;0x007319ef :        85c0
             jne Label731a72                                                 ;0x007319f1 :        757f

     Label7319f3 ::
             mov  edi , dword ptr [ ebp + 0FFFFFE48h ]                       ;0x007319f3 :        8bbd48feffff
             push  dword ptr [ ebp + 0FFFFFE44h ]                            ;0x007319f9 :        ffb544feffff
             dec edi                                                         ;0x007319ff :        4f
             lea esi ,  dword ptr [ ebp + 0FFFFFE50h ]                       ;0x00731a00 :        8db550feffff
             call Fun72f8cc                                                  ;0x00731a06 :        e8c1deffff
             movzx eax , al                                                  ;0x00731a0b :        0fb6c0
             test  word ptr [ 2 * eax + offset Data937360 ] , 0107h                   ;0x00731a0e :        66f70445607393000701
             jne Label731a72                                                 ;0x00731a18 :        7558


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
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix334.asp

     2, mzvfp.com:
     http://www.mzvfp.com/read.php?tid=86253
     http://www.mzvfp.com/read.php?tid=42354
     http://www.mzvfp.com/read.php?tid=79444


6. OTHER:

     For reference only, there is no guarantees.

     Any questions or suggestions, please send me an email at ccb2000@163.com.