Skip to content
Snippets Groups Projects
Commit 0d804cde authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Improved EOF handling in Stdio.FILE->read().

Rev: lib/modules/Stdio.pmod:1.9
parent 6b577500
No related branches found
No related tags found
No related merge requests found
...@@ -121,11 +121,19 @@ class FILE { ...@@ -121,11 +121,19 @@ class FILE {
return file::write(sprintf(fmt,@data)); return file::write(sprintf(fmt,@data));
} }
string read(int bytes) string read(int|void bytes)
{ {
if (!query_num_arg()) {
bytes = 0x7fffffff;
}
while(strlen(b) - bpos < bytes) while(strlen(b) - bpos < bytes)
if(!get_data()) if(!get_data()) {
break; // EOF.
string res = b[bpos..];
b = "";
bpos = 0;
return res;
}
return extract(bytes); return extract(bytes);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment