Hi Viktor

I see that you have vastly improved the fclass1, ffile1, ft_funcs by getting rid of most of the chr(10), chr(13) mess and using hb_OSNewLine(). I haven't build the new system yet but see a problem for systems that use anything but CRLF as the EOL terminator.

looking at the code:
  cB       := ""
  nSavePos := FSEEK( nH, 0, FS_RELATIVE )
  nNumRead := FREAD( nH, @cLine, nMaxLine )
  IF ( nEol := AT( hb_OSNewLine(), SUBSTR( cLine, 1, nNumRead ) ) ) == 0
     cB := cLine
  ELSE
     cB := SUBSTR( cLine, 1, nEol - 1 )
     FSEEK( nH, nSavePos + nEol + 1, FS_SET )
  ENDIF

Say the line is as follows:
Pos
1234567890123
xxxxLCxxxxxLC  where L is LF and C is CR

If nSavePos = 1, nEol = 5 you seek to 1+5+1=7 which is correct. However for systems with only LF or CR as EOL you still seek to 7 which is incorrect.
It seems you should seek to:

FSEEK( nH, nSavePos + len( hb_OSNewLine() ) - 1, FS_SET )

1234567890123
xxxxLxxxxxxLx

nSavePos =1, nEOL = 5 len( hb_OSNewLine() ) - 1 = 0

So you now seek to Pos 6 for LF systems and Pos 7 for MS systems which is correct. It even works for the 3 and 4 byte EOL of some mainframes.

Additionaly, the chr(13) stripping at line 911 isn't needed. It should have always been chr(10) anyway to remove the dangling LF from the CRLF that was always left in the way.
FUNCTION FT_FReadLn()
  RETURN FReadLn()

_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to