Fixed FFIND doesn't find last character in file without CR/LF at EOF

Jun 2, 2008
21
0
TCC 18.00.30 x64 Windows 7 [Version 6.1.7601]
TCC Build 30 Windows 7 Build 7601 Service Pack 1

Using swedish keyboard and Regional and Language Options: Swedish

Counting occurrences in an Unicode/ANSI file with FFIND is incorrect if character/word is at end of file (on last line) and file doesn't end with cr/lf.
With cr/lf at eof the counting is correct.

Example 1:
Create an Unicode or ANSI file containing 1 line with letter A.
Add a CR/LF at end of file and close the file.
File should be 3 character long in ANSI or 8 character long in Unicode with BOM.
FFIND /t"A" /v fileName returns "1 line in 1 file" ==> Correct.

Test data:
41 0d 0a (Uppercase A) ANSI
ff fe 41 00 0d 00 0a 00 (Uppercase A) Unicode with BOM
[C:\]ffind /t"A" /v fileName

---- C:\Temp\fileName
A

1 line in 1 file

Example 2:
Create an Unicode or ANSI file containing 1 line with letter A.
Close the file.
File should be 1 character long in ANSI or 4 character long in Unicode with BOM.
FFIND /t"A" /v filename returns nothing ==> Incorrect.

Test data:
41 (Uppercase A) ANSI
ff fe 41 00 (Uppercase A) Unicode with BOM
ffind /t"A" /v 1
[C:\]ffind /t"A" /v fileName

---- C:\Temp\fileName

Reproducible: Always.

Best regard
Berndt Berg
 

rconn

Administrator
Staff member
May 14, 2008
10,930
97
Like LIST (with which it shares most of its code), FFIND is (1) slow, and (2) obsolete. LIST has been replaced by VIEW, and FFIND has been replaced by TPIPE.

FFIND (like LIST) has always been line based. If you don't have a CR/LF (or at least a LF), you don't have a line.