| 1 | rem demonstrates bug in FFIND /R
|
|---|
| 2 | setlocal
|
|---|
| 3 | set BinFileN=`All_Characters`
|
|---|
| 4 | if exist %BinFileN *del /q %BinFileN
|
|---|
| 5 | rem write the file with Rexx to avoid problems with special characters
|
|---|
| 6 | set RexxCmd=`Str = '';`
|
|---|
| 7 | set RexxCmd=%RexxCmd `do ChrD = 0 to 255 ; Str=Str''d2c(ChrD) ; end ;`
|
|---|
| 8 | set RexxCmd=%RexxCmd `call charout '`%BinFileN`', Str ;`
|
|---|
| 9 | set RexxCmd=%RexxCmd `return stream('`%BinFileN`', 'c', 'CLOSE')`
|
|---|
| 10 | set ret=%@rexx[%RexxCmd]
|
|---|
| 11 | iff "%ret" ne "READY:" then
|
|---|
| 12 | echo `Rexx returned `"%ret" `for file %BinFileN`
|
|---|
| 13 | echo `Something went wrong`
|
|---|
| 14 | quit 99
|
|---|
| 15 | endiff
|
|---|
| 16 | echo `file '`%BinFileN`' has been created. It is a string of all 256 characters.`
|
|---|
| 17 | echo `Now search it with "FFIND /R /V /M /X" for each character.`
|
|---|
| 18 | echo `It should find each character 'nn' at offset 'nn', but`
|
|---|
| 19 | echo `it finds nothing after character 0A (LineFeed)`
|
|---|
| 20 | gosub DoFFIND
|
|---|
| 21 |
|
|---|
| 22 | set BinFileN=`All_Characters_except_LF`
|
|---|
| 23 | if exist %BinFileN *del /q %BinFileN
|
|---|
| 24 | set RexxCmd=`Str = '';`
|
|---|
| 25 | set RexxCmd=%RexxCmd `do ChrD = 0 to 9 ; Str=Str''d2c(ChrD) ; end ;`
|
|---|
| 26 | set RexxCmd=%RexxCmd `call charout '`%BinFileN`', Str ;`
|
|---|
| 27 | set RexxCmd=%RexxCmd `return stream('`%BinFileN`', 'c', 'CLOSE')`
|
|---|
| 28 | set ret=%@rexx[%RexxCmd]
|
|---|
| 29 | iff "%ret" ne "READY:" then
|
|---|
| 30 | echo `Rexx returned `"%ret" `for file %BinFileN`
|
|---|
| 31 | echo `Something went wrong`
|
|---|
| 32 | quit 99
|
|---|
| 33 | endiff
|
|---|
| 34 | set RexxCmd=`Str = '';`
|
|---|
| 35 | set RexxCmd=%RexxCmd `do ChrD = 11 to 255 ; Str=Str''d2c(ChrD) ; end ;`
|
|---|
| 36 | set RexxCmd=%RexxCmd `call charout '`%BinFileN`', Str ;`
|
|---|
| 37 | set RexxCmd=%RexxCmd `return stream('`%BinFileN`', 'c', 'CLOSE')`
|
|---|
| 38 | set ret=%@rexx[%RexxCmd]
|
|---|
| 39 | iff "%ret" ne "READY:" then
|
|---|
| 40 | echo `Rexx returned `"%ret" `for file %BinFileN`
|
|---|
| 41 | echo `Something went wrong`
|
|---|
| 42 | quit 99
|
|---|
| 43 | endiff
|
|---|
| 44 | echo.
|
|---|
| 45 | echo `=============================================`
|
|---|
| 46 | echo `file '`%BinFileN`' has been created. It is a string of all characters except 0A`
|
|---|
| 47 | echo `without a character 0A, FFIND starts the reverse search at character 0D`
|
|---|
| 48 | echo `If I delete the character 0D also, it finds nothing at all`
|
|---|
| 49 | gosub DoFFIND
|
|---|
| 50 | quit
|
|---|
| 51 |
|
|---|
| 52 | :DoFFIND
|
|---|
| 53 | echo.
|
|---|
| 54 | do chD = 0 to 255
|
|---|
| 55 | set chX=%@right[2,0%@convert[10,16,%chD]]
|
|---|
| 56 | echo `search for character `%chX`h, FFIND says:`
|
|---|
| 57 | ffind /r /v /m /x"%chX" %BinFileN
|
|---|
| 58 | echo `---------------------------------------------`
|
|---|
| 59 | enddo
|
|---|
| 60 |
|
|---|