currenteol,preveol:integer;\r
fileeof,reachedeof:boolean;\r
eoltype:integer;\r
currenteol,preveol:integer;\r
fileeof,reachedeof:boolean;\r
eoltype:integer;\r
+ procedure checkandread;\r
end;\r
\r
implementation\r
end;\r
\r
implementation\r
sourcestream := asourcestream;\r
destroysourcestream := adestroysourcestream;\r
\r
sourcestream := asourcestream;\r
destroysourcestream := adestroysourcestream;\r
\r
- if sourcestream.Position >= sourcestream.size then fileeof := true;\r
+ //if sourcestream.Position >= sourcestream.size then fileeof := true;\r
bufpointer := bufsize;\r
end;\r
\r
bufpointer := bufsize;\r
end;\r
\r
+procedure treadtxt.checkandread;\r
+begin\r
+ if bufpointer >= numread then begin\r
+ numread := sourcestream.read(buf,bufsize);\r
+ bufpointer := 0;\r
+ if numread = 0 then fileeof := true;\r
+ \r
+ end;\r
+end;\r
+\r
function treadtxt.readline;\r
var\r
a,b,c,d:integer;\r
function treadtxt.readline;\r
var\r
a,b,c,d:integer;\r
\r
result := '';\r
repeat\r
\r
result := '';\r
repeat\r
- if bufpointer >= bufsize then begin\r
- numread := sourcestream.read(buf,bufsize);\r
- bufpointer := 0;\r
- if sourcestream.Position >= sourcestream.size then fileeof := true;\r
- end;\r
b := numread-1;\r
\r
{core search loop begin}\r
b := numread-1;\r
\r
{core search loop begin}\r
setlength(result,c+b);\r
move(buf[bufpointer],result[c+1],b);\r
bufpointer := numread;\r
setlength(result,c+b);\r
move(buf[bufpointer],result[c+1],b);\r
bufpointer := numread;\r
- if numread < bufsize then begin\r
+ if fileeof then begin\r
+ {we reached the end of the file, return what we have}\r
reachedeof := true;\r
exit;\r
end;\r
reachedeof := true;\r
exit;\r
end;\r
\r
function treadtxt.eof:boolean;\r
begin\r
\r
function treadtxt.eof:boolean;\r
begin\r
-\r
- result := ((bufpointer >= bufsize) and fileeof) or reachedeof;\r
+ checkandread;\r
+ result := ((bufpointer >= numread) and fileeof) or reachedeof;\r
end;\r
\r
destructor treadtxt.destroy;\r
end;\r
\r
destructor treadtxt.destroy;\r