I suspect that several people have had trouble because if you try to
use sysopen to access a file in "line" mode, e.g.
sysopen(filename, 0, "line") -> device;
then lines containing more than 511 characters get truncated because
of the internal buffer size, even if you give sysread a big enough
buffer to read lines into, e.g. in this form:
sysread(device, string, stringlen) -> charsread;
Similarly the system procedure sys_read_lines and the
library procedure line_repeater both truncate lines longer than
some internal buffer size (despite what the documentation on
line_repeater says).
I have just sent in a bug report about this. sysread should be
fixed to extend its internal buffer if necessary when lines are
longer than the default maximum.
However, there is a usable workaround since the new procedure (since
Poplog V14.2) -vedfile_line_repeater- does not have this limitation. So
you can use it to create a string repeater for a file containing long
lines (with second argument true to prevent it trying to do special
VED processing.) E.g.
lvars
string,
nextline = vedfile_line_repeater(filename, true);
for string from_repeater nextline do
if length(string) > 600 then string => endif;
endfor;
This will print out all lines of length > 600 characters in the
specified file.
Although this is simpler and more elegant than repeatedly reading the
next line into a fixed buffer using sysread, it has a garbage collection
overhead in that it creates a new string for each line, includling the
lines that are not used by the program.
So I hope that sysread will be fixed, for programs where GCs are to be
minimised.
Aaron
|