| 1 |
#!/usr/bin/env regina |
| 2 |
/* this program tests the behaviour of reaching EOF using LINEIN */ |
| 3 |
|
| 4 |
Parse Source os . fn |
| 5 |
do while lines(fn) > 0 |
| 6 |
say '1-->' linein(fn) |
| 7 |
end |
| 8 |
call stream fn, 'C', 'CLOSE' |
| 9 |
|
| 10 |
signal on notready name eof |
| 11 |
do forever |
| 12 |
say '2-->' linein(fn) |
| 13 |
end |
| 14 |
Say "Shouldn't get here!" |
| 15 |
Return |
| 16 |
eof: |
| 17 |
say 'Got NOTREADY from' sigl 'This is correct!' |
| 18 |
|
| 19 |
file='eoftest.dat' |
| 20 |
if os = 'UNIX' Then |
| 21 |
call charout file,'a'|| '0a'x || '1a'x,1 |
| 22 |
else |
| 23 |
call charout file,'a'|| '0d0a'x || '1a'x,1 |
| 24 |
call stream file, 'c', 'close' |
| 25 |
call on notready name linein_err |
| 26 |
rc=0 |
| 27 |
do while rc=0 |
| 28 |
say c2x(linein(file)) |
| 29 |
end |
| 30 |
say 'Should get here! Returning...' |
| 31 |
return |
| 32 |
linein_err: |
| 33 |
say 'got NOTREADY from line' sigl 'This is correct!' |
| 34 |
rc=1 |
| 35 |
return |
| 36 |
/* last line */ |