EOLDetect function can return questionable result

64 views
Skip to first unread message

Luigi Ferraris

unread,
Apr 24, 2023, 8:16:26 AM4/24/23
to Harbour Developers
Hi friends,
exploring Harbour code for my need,
I found a problem on source "harbour\bin\check.hb", function "EOLDetect".
It can returns not very true informations:
   1) about the EOL detected
   2) about lines number (minor problem)

I used these cases, as the content of a file to analyze.
I know, they are bad / stupid, probably none of us create these situations,
but in my two sources was happen (I don't konw why).

content := "line_1st" + CHR(13) + ;
           "line_2nd" + CHR(10)

or

content := "line_1st" + CHR(13) + ;
           "line_2nd" + CHR(10) + ;
           "line_3rd" + CHR(13)+CHR(10)

           
The current function returns EOL sequence as DOS style, because count CR and LF.
On the other hand, the number of lines returned is questionable.

So, I rewrote the function.
The main difference is that it returns a numeric value instead of EOL byte sequence.
Where (my choose):
-1 mixed EOL
0  no EOL found at all
1  DOS style
2  NIX style
3  MAC style

in attachment, simple source to compare two solutions.
Regards.
Luigi
xxcheck.zip
Reply all
Reply to author
Forward
0 new messages