--------------------------------------------------------------------------------------
                      [ENHANCED] VFP 9.0 FIX - SYS(9072) ENABLES OR DISABLES FAST STRING FUNCTIONS
                                 January 2022
                 --------------------------------------------------------------------------------------
                                     CCB



1. THE SYS(9072) FUNCTION:

     SYS(9072) - Enables or disables fast string functions

     Enables or disables fast string functions.

     SYS(9072 [, 0 | 1])

     Parameters
     0
     Disables fast string functions. 0 is the startup default for Visual FoxPro Advanced.
     1
     Enables fast string functions.

     Return Value
     Character

     Remarks
     If we enable fast string functions in Visual FoxPro Advanced, it is the same as enabling the SYS(9900,9010-9073) functions,
     Visual FoxPro Advanced will be faster.

     There are some test results:

     LEN(): 10 MB
     LOOP COUNT: 10000
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9010-9073) Functions                                            | Optimized Parameters | Disable  | Enable  |  Rate    |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9010,0|1) - Enables or disables fast SUBSTR(), SUBSTRC() functions.            | p1    |     32   |  0.02   | 1500 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9011,0|1) - Enables or disables fast LEFT(), LEFTC() functions.                | p1    |     36   |  0.01   | 3600 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9012,0|1) - Enables or disables fast RIGHT(), RIGHTC() functions.              | p1    |     32   |  0.02   | 1500 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9013,0|1) - Enables or disables fast UPPER() function.                         | p1    |    270   |   250   |  1.1 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9014,0|1) - Enables or disables fast LOWER() function.                         | p1    |    270   |   250   |  1.1 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9015,0|1) - Enables or disables fast PROPER() function.                        | p1    |    340   |   420   |  0.8 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9016,0|1) - Enables or disables fast LEN(), LENC() functions.                  | p1    |     63   |  0.01   | 6300 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9017,0|1) - Enables or disables fast EMPTY() function.                         | p1    |     52   |  0.01   | 5200 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9018,0|1) - Enables or disables fast VARTYPE() function.                       | p1    |     52   |  0.01   | 5200 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9019,0|1) - Enables or disables fast LTRIM() function.                         | p1    |    111   |    87   |  1.3 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9020,0|1) - Enables or disables fast RTRIM(), TRIM() functions.                | p1    |     93   |    87   |  1.1 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9021,0|1) - Enables or disables fast ALLTRIM() function.                       | p1    |    110   |    87   |  1.3 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9022,0|1) - Enables or disables fast PADL(), PADR(), PADC() functions.         | p1    |    108   |   107   |    1 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9023,0|1) - Enables or disables fast STUFF(), STUFFC() functions.              | p1    |     81   |    77   |    1 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9024,0|1) - Enables or disables fast CHRTRAN(), CHRTRANC() functions.          | p1    |    554   |   492   |  1.1 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9025,0|1|2) - Enables or disables fast STRTRAN() function.                     | p1    |  51000|50000|1950  |  25:25:1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9026,0|1) - Enables or disables fast AT(), AT_C(), ATC(), ATCC() functions.    | p2    |     16   |  0.02   |  800 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9027,0|1) - Enables or disables fast RAT(), RATC() functions.                  | p2    |     20   |  0.02   | 1000 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9028,0|1) - Enables or disables fast ATLINE(), ATCLINE(), RATLINE() functions. | p2    |     19   |  0.02   |  950 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9029,0|1) - Enables or disables fast OCCURS() function.                        | p2    |   2100   |  1900   |  1.1 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9030,0|1) - Enables or disables fast GETWORDCOUNT() function.                  | p1    |   4100   |  3900   |    1 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9031,0|1) - Enables or disables fast GETWORDNUM() function.                    | p1    |     27   |  0.01   | 2700 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9032,0|1) - Enables or disables fast TRANSFORM() function.                     | p1    |     21   |  0.03   |  700 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9033,0|1) - Enables or disables fast TEXTMERGE() function.                     | p1    |    167   |   147   |  1.1 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9034,0|1) - Enables or disables fast STREXTRACT() function.                    | p1    |   1800   |  1800   |    1 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9035,0|1) - Enables or disables fast STRCONV() function.                       | p1    |    207   |   205   |    1 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9036,0|1) - Enables or disables fast STRTOFILE() function.                     | p1    |    117   |    67   |  1.7 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9037,0|1) - Enables or disables fast SYS(2007) function.                       | p1    |    877   |   866   |    1 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9038,0|1) - Enables or disables fast TYPE() function.                          | p1    |     16   |  0.01   | 1600 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9039,0|1) - Enables or disables fast FWRITE(), FPUTS() functions.              | p2    |     62   |    19   |    3 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9040,0|1) - Enables or disables fast XMLTOCURSOR() function.                   | p1    |  47550   | 47220   |    1 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9041,0|1) - Enables or disables fast ALINES() function.                        | p2    |     38   |    36   |    1 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9042,0|1) - Enables or disables fast ISNULL() function.                        | p1    |     42   |  0.01   | 4200 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9043,0|1) - Enables or disables fast ISBLANK() function.                       | p1    |     42   |  0.01   | 4200 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9044,0|1) - Enables or disables fast ISALPHA() function.                       | p1    |     43   |  0.01   | 4300 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9045,0|1) - Enables or disables fast ISDIGIT() function.                       | p1    |     43   |  0.01   | 4300 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9046,0|1) - Enables or disables fast ISUPPER() function.                       | p1    |     43   |  0.01   | 4300 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9047,0|1) - Enables or disables fast ISLOWER() function.                       | p1    |     43   |  0.01   | 4300 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9048,0|1) - Enables or disables fast ISLEADBYTE() function.                    | p1    |     43   |  0.01   | 4300 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9049,0|1) - Enables or disables fast NVL() function.                           | p1    |     32   |    31   |    1 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9050,0|1) - Enables or disables fast EVL() function.                           | p1    |     34   |    32   |    1 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9051,0|1) - Enables or disables fast BETWEEN() function.                       | p1    |     42   |  0.01   | 4200 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9052,0|1) - Enables or disables fast INLIST() function.                        | p1    |     42   |  0.01   | 4200 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9053,0|1) - Enables or disables fast LIKE(), LIKEC() functions.                | p2    |     42   |  0.01   | 4200 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9054,0|1) - Enables or disables fast $ operator.                               | p1,p2 |     16   |  0.01   | 1600 : 1 |
     ----------------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9055,0|1) - Enables or disables fast + operator.                               | p1,p2 |     53   |    35   |  1.5 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9056,0|1) - Enables or disables fast - operator.                               | p1,p2 |     50   |    34   |  1.5 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9057,0|1) - Enables or disables fast < operator.                               | p1,p2 |     42   |  0.01   | 4200 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9058,0|1) - Enables or disables fast <= operator.                              | p1,p2 |     39   |  0.01   | 3900 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9059,0|1) - Enables or disables fast != operator.                              | p1,p2 |     40   |  0.01   | 4000 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9060,0|1) - Enables or disables fast = operator.                               | p1,p2 |     44   |  0.01   | 4400 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9061,0|1) - Enables or disables fast > operator.                               | p1,p2 |     45   |  0.01   | 4500 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9062,0|1) - Enables or disables fast >= operator.                              | p1,p2 |     44   |  0.01   | 4400 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9063,0|1) - Enables or disables fast == operator.                              | p1,p2 |     16   |  0.01   | 1600 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9064,0|1) - Enables or disables fast REPLICATE() function.                     | p1    |    200   |   168   |  1.2 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9065,0|1) - Enables or disables fast += operator.                                      |  0.00275 | 0.00139 |    2 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9066,0|1) - Enables or disables fast -= operator.                                      |  0.00275 | 0.00139 |    2 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9067,0|1) - Enables or disables fast *= operator.                                      |  0.00632 | 0.00632 |    1 : 1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9068,0|1) - Enables or disables fast /= operator.                                      |    ---   |   ---   |    ---   |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9069,0|1) - Enables or disables fast %= operator.                                      |    ---   |   ---   |    ---   |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9070,0|1|2) - Enables or disables fast memcpy(), memmove() functions (SUBSTR()).       |     15   |  15|11  |1.3:1.3:1 |
     | SYS(9900,9070,0|1|2) - Enables or disables fast memcpy(), memmove() functions (LEFT()).         |     15   |  15|11  |1.3:1.3:1 |
     | SYS(9900,9070,0|1|2) - Enables or disables fast memcpy(), memmove() functions (RIGHT()).        |     15   |  15|11  |1.3:1.3:1 |
     | SYS(9900,9070,0|1|2) - Enables or disables fast memcpy(), memmove() functions (LEN()).          |     40   |  40|32  |1.3:1.3:1 |
     | SYS(9900,9070,0|1|2) - Enables or disables fast memcpy(), memmove() functions (STRTRAN()).      |  48000|48000|48000 |    1:1:1 |
     | SYS(9900,9070,0|1|2) - Enables or disables fast memcpy(), memmove() functions (STREXTRACT()).   |   1850   |1850|1850|    1:1:1 |
     | SYS(9900,9070,0|1|2) - Enables or disables fast memcpy(), memmove() functions (XMLTOCURSOR()).  |  15500|15100|15100 |    1:1:1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9071,0|1|2) - Enables or disables fast strchr(), strchri() functions (CHRTRAN()).      |    583   | 555|550 |    1:1:1 |
     | SYS(9900,9071,0|1|2) - Enables or disables fast strchr(), strchri() functions (GETWORDCOUNT()). |   2560   | 660|690 |  3.7:1:1 |
     | SYS(9900,9071,0|1|2) - Enables or disables fast strchr(), strchri() functions (GETWORDNUM()).   |     19   |  19|19  |    1:1:1 |
     | SYS(9900,9071,0|1|2) - Enables or disables fast strchr(), strchri() functions (TEXTMERGE()).    |    137   |  94|83  |  1.6:1:1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9072,0|1|2) - Enables or disables fast strstr(), strstri() functions (STRTRAN()).      |  51200|50000|50000 |    1:1:1 |
     | SYS(9900,9072,0|1|2) - Enables or disables fast strstr(), strstri() functions (ATLINE()).       |     19   |  19|19  |    1:1:1 |
     | SYS(9900,9072,0|1|2) - Enables or disables fast strstr(), strstri() functions (OCCURS()).       |   1900   | 160|160 |   12:1:1 |
     | SYS(9900,9072,0|1|2) - Enables or disables fast strstr(), strstri() functions (STREXTRACT()).   |   1850   |  65|65  |   28:1:1 |
     -----------------------------------------------------------------------------------------------------------------------------------
     | SYS(9900,9073,0|1|2) - Enables or disables fast strlen() function.                              |    ---   |    ---  |    ---   |
     -----------------------------------------------------------------------------------------------------------------------------------


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Fun529fca :: ; proc near
             push ebp                                                        ;0x00529fca :        55
             mov ebp , esp                                                   ;0x00529fcb :        8bec
             pushd 0FFFFFFFFh                                                ;0x00529fcd :        6aff
             pushd offset Data922268                                                  ;0x00529fcf :        6868229200
             pushd offset Label9160f9                                                  ;0x00529fd4 :        68f9609100
             mov eax ,  dword ptr fs:[00h]                                   ;0x00529fd9 :        64a100000000
             push eax                                                        ;0x00529fdf :        50
             mov  dword ptr fs:[00h] , esp                                   ;0x00529fe0 :        64892500000000
             push ecx                                                        ;0x00529fe7 :        51
             push ecx                                                        ;0x00529fe8 :        51
             mov eax , 02FBCh                                                ;0x00529fe9 :        b8bc2f0000
             call Fun42c118                                                  ;0x00529fee :        e82521f0ff
             mov eax ,  dword ptr [ Data937090 ]                             ;0x00529ff3 :        a190729300
             mov  dword ptr [ ebp - 28 ] , eax                               ;0x00529ff8 :        8945e4
             push ebx                                                        ;0x00529ffb :        53
             push esi                                                        ;0x00529ffc :        56
             push edi                                                        ;0x00529ffd :        57
             mov  dword ptr [ ebp - 24 ] , esp                               ;0x00529ffe :        8965e8
             xor edi , edi                                                   ;0x0052a001 :        33ff
             mov  dword ptr [ ebp + 0FFFFD114h ] , edi                       ;0x0052a003 :        89bd14d1ffff
             push edi                                                        ;0x0052a009 :        57
             pushd 02710h                                                    ;0x0052a00a :        6810270000
             push edi                                                        ;0x0052a00f :        57
             mov  ebx , dword ptr [ ebp + 8 ]                                ;0x0052a010 :        8b5d08
             mov eax , ebx                                                   ;0x0052a013 :        8bc3
             call Fun529bc5                                                  ;0x0052a015 :        e8abfbffff
             mov  dword ptr [ ebp + 0FFFFD0E4h ] , eax                       ;0x0052a01a :        8985e4d0ffff
             mov  dword ptr [ ebp + 0FFFFD10Ch ] , edi                       ;0x0052a020 :        89bd0cd1ffff
             lea ecx ,  dword ptr [ ebp + 0FFFFFDE0h ]                       ;0x0052a026 :        8d8de0fdffff
             mov  dword ptr [ ebp + 0FFFFD100h ] , ecx                       ;0x0052a02c :        898d00d1ffff
             mov  byte ptr [ ebp + 0FFFFFDE0h ] , 00h                        ;0x0052a032 :        c685e0fdffff00
             movsx eax , ax                                                  ;0x0052a039 :        0fbfc0


     ;
     ;                 ---------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - SYS(9072) ENABLES OR DISABLES FAST STRING FUNCTIONS
     ;                                December 2021
     ;                 ---------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; SYS(9072) - Enables or disables fast string functions.
     ;
     ; 2021/12/8, by ccb
     ;

             cmp eax,9072
             je vfpa_sys9072_start


             pushd 064h                                                      ;0x0052a03c :        6a64
             pop esi                                                         ;0x0052a03e :        5e
             cmp eax , esi                                                   ;0x0052a03f :        3bc6
             jle Label52a0d0                                                 ;0x0052a041 :        0f8e89067000
             mov ecx , 07EAh                                                 ;0x0052a047 :        b9ea070000
             cmp eax , ecx                                                   ;0x0052a04c :        3bc1
             jg Label52a164                                                  ;0x0052a04e :        0f8f10010000
             je Label609b33                                                  ;0x0052a054 :        0f84d9fa0d00
             mov ecx , 04F6h                                                 ;0x0052a05a :        b9f6040000
             cmp eax , ecx                                                   ;0x0052a05f :        3bc1
             jle Label52b6e0                                                 ;0x0052a061 :        0f8e79160000
             mov ecx , 07DBh                                                 ;0x0052a067 :        b9db070000
             cmp eax , ecx                                                   ;0x0052a06c :        3bc1
             jg Label51f355                                                  ;0x0052a06e :        0f8fe152ffff
             je Label609700                                                  ;0x0052a074 :        0f8486f60d00
             add ecx , 0FFFFFFF9h                                            ;0x0052a07a :        83c1f9
             cmp eax , ecx                                                   ;0x0052a07d :        3bc1
             jg Label4a4938                                                  ;0x0052a07f :        0f8fb3a8f7ff
             je Label4f6b07                                                  ;0x0052a085 :        0f847ccafcff
             sub eax , 04F7h                                                 ;0x0052a08b :        2df7040000
             je Label60951e                                                  ;0x0052a090 :        0f8488f40d00
             dec eax                                                         ;0x0052a096 :        48
             je Label60950f                                                  ;0x0052a097 :        0f8472f40d00
             sub eax , 0E4h                                                  ;0x0052a09d :        2de4000000
             je Label609492                                                  ;0x0052a0a2 :        0f84eaf30d00
             sub eax , 01F4h                                                 ;0x0052a0a8 :        2df4010000
             jne Label462026                                                 ;0x0052a0ad :        0f85737ff3ff
             lea eax ,  dword ptr [ ebp + 0FFFFFDE0h ]                       ;0x0052a0b3 :        8d85e0fdffff
             push eax                                                        ;0x0052a0b9 :        50
             push  dword ptr [ ebp + 12 ]                                    ;0x0052a0ba :        ff750c
             mov edx , ebx                                                   ;0x0052a0bd :        8bd3
             call Fun4dc923                                                  ;0x0052a0bf :        e85f28fbff


4. APPLIES TO:

     VFP 10.0.0.0 (VFP Advanced)


5. REFERENCE WEBSITES:

     1, baiyujia.com:
     http://www.baiyujia.com
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix95.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix96.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix199.asp

     2, west-wind.com:
     https://west-wind.com/wconnect/weblog/ShowEntry.blog?id=962
     https://west-wind.com/wconnect/weblog/ShowEntry.blog?id=882

     3, stevenblack.com:
     http://stevenblack.com/articles/text-and-string-handling-in-VFP/

     4, agner.org:
     https://www.agner.org/optimize/


6. OTHER:

     For reference only, there is no guarantees.

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