I've run into a limitation in READ-LINE while writing some CVS handling tools. While parsing the output from a log command, a few lines are quite long, namely the ones containing the "RCS file:" string, since they list the full path of a file. Using READ-LINE, the maximum returned value (u2) is 128. Thus, you example in Files-Tutorial.html is wrong!

<x-tad-bigger>256 Constant max-line
Create line-buffer max-line 2 + allot

: scan-file ( addr u -- )
begin
line-buffer max-line fd-in read-line throw
while
>r 2dup line-buffer r> compare 0=
until
else
drop
then
2drop ;


read-line ( addr u1 fd -- u2 flag ior )</x-tad-bigger>
reads up to u1 bytes into the buffer at addr, and returns the number of bytes read, a flag that is false when the end of file is reached, and an error code.

It would be nice to fix the limitation, but if not, then it would at least be advisable to change the example and list it as an environmental dependency.

DaR

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to