2 * The Regina Rexx Interpreter
3 * Copyright (C) 1992 Anders Christensen <anders@solan.unit.no>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 /* ==== config ==== */
22 conf
.truncate
= 1 /* truncates when writing line to middle of file */
31 if os
= 'UNIX' | os
= 'BEOS' | os
= 'QNX' | os
= 'LINUX' then
36 oslsl_root
= 'ls -l /'
37 tonul
= ' > /dev/null 2>&1'
38 file
= '/tmp/rexx.test'
39 'echo "First line" > simple'
40 'echo "Second line" >> simple'
41 'echo "Third line" >> simple'
45 else if os
= 'AMIGA' | os
= 'AROS' then
60 file
= 'c:\temp\rexx.tst'
61 'echo First line> simple'
62 'echo Second line>> simple'
63 'echo Third line>> simple'
65 eol_chars
= '0d'x
|| '0a'x
71 If Left( ver
, 11 ) = 'REXX-Regina' Then regina
= 1
76 /* === 001 : simple write and read ============================ */
79 if (0\
==lineout(file
,'This is the first line')) then
80 call complain
'Could not write first line'
81 if (0\
==lineout(file
,'of a very little file')) then
82 call complain
'Could not write second line'
83 if (0\
==lineout(file
,'that will be used')) then
84 call complain
'Could not write third line'
85 if (0\
==lineout(file
,'in this trip test')) then
86 call complain
'Could not write fourth line'
94 /* === 002 : simple reading ======================================== */
96 call stream file
, 'c', 'close'
98 if (res\
=='This is the first line') then
99 call complain
'didnt position at start after reopening after close'
103 if (res \
== "that will be used") then
104 call complain
'Didnt position properly after several reads'
111 /* === 003 : Test behavior at EOF ================================== */
114 res
= linein( file
, 3 )
116 if (res\
=='in this trip test') then
117 call complain
'did not manage to read last line'
122 call complain
'nullstring not returned at EOF'
124 call stream file
, 'c', 'close'
130 /* === 004 : are we able to read zero lines ======================== */
131 call notify
'zero_line'
133 res
= linein( file
, 3, 0 )
135 call complain
'Could not position without reading anything'
138 if (res\
=='that will be used') then
139 call complain
'Did not position correctly in the file'
141 res
= linein( file
, 2 )
142 if (res\
=='of a very little file') then
143 call complain
'Could not position and read simultaneously'
150 /* === 005 : Will it truncate when writing new lines ===================== */
151 call notify
'truncate'
153 oscopy file file
'.tmp' tonul
154 res
= lineout( file
'.tmp', '<<<foobar>>>', 2 )
156 call complain
'non-zero result from when just positioning'
158 res
= linein( file
'.tmp', 1 )
159 if (res\
=='This is the first line') then
160 call complain
'first line was corrupted'
162 res
= linein( file
'.tmp' )
163 if (res\
=='<<<foobar>>>') then
164 call complain
'second line not properly written'
167 res
= linein( file
'.tmp' )
169 call complain
'file was not truncated'
172 call lineout file
'.tmp'
178 /* === 006 : Can we read characters =================================== */
185 resstr1
= 'rst line'||'0a'x
||'of a v'
186 resstr2
= 'ery little file'||'0a'x
||'t'
190 resstr1
= 'rst line'||'0d'x
||'0a'x
||'of a v'
191 resstr2
= 'ery little file'||'0d'x
||'0a'x
||'t'
195 res
= charin( file
, 15, numcol1
)
196 if (res \
== resstr1
) then
197 call complain
'could not read characterbased from file'
199 res
= charin( file
,, numcol2
)
200 if (res \
== resstr2
) then
201 call complain
'charin cant position right'
204 if (res\
=='hat will be used') then
205 call complain
'character and line based io does not share read pointer'
213 /* === 007 : Is I/O faked when a file is in error? ==================== */
215 if regina
= 0 then signal test009
/* following tests only valid for Regina */
220 nonexist
= 'nonexistent'
224 osdel1 nonexist tonul
226 call on notready name trap007
227 res
= length(charin(nonexist
,,10)) + length('cp'(exist
,nonexist
)) + foo
+,
228 length(charin(nonexist
,,10)) + foo
+ length(linein(nonexist
)) + foo
+,
229 length(charin(nonexist
,,10)) + foo
+ length(linein(nonexist
)) + foo
231 call complain
"Condition NOTREADY don't fake further I/O properly"
234 call complain
"Help, I don't think condition handler was called"
236 call lineout nonexist
248 'echo "Here is the contents of nonexistent" >>' nonexist
249 'echo "Here is the second line of nonexistent" >>' nonexist
250 'echo "Here is the third line of nonexistent" >>' nonexist
257 /* === 008 : But I/O to other files is _not_ to be disturbed =========== */
260 call on notready name trap008
262 nonexist
= 'nonexistent'
266 sum
= 20 + length(linein(exist
)) + length(linein(exist
))
267 call stream exist
, 'c', 'close'
268 call stream nonexist
, 'c', 'close'
271 res
= length(charin(nonexist
,,10)) + length('cp'(exist
,nonexist
)) + foo
+,
272 length(charin(exist
,,10)) + foo
+ length(linein(exist
,1)) + foo
+,
273 length(charin(nonexist
,,10)) + foo
+ length(linein(nonexist
)) + foo
+,
274 length(charin(exist
,,10)) + foo
+ length(linein(exist
,2)) + foo
+,
275 length(charin(nonexist
,,10)) + foo
+ length(linein(nonexist
)) + foo
278 call complain
"Condition NOTREADY fake other files too"
281 call complain
"Help, I don't think condition handler was called"
284 call lineout nonexist
296 /* === 009 : If rest of line is a EOL, what does linein return? ====== */
297 call notify
'halfline'
300 if eol
= 'CRLF' then do
301 'echo First line>'file
302 'echo Second line>>'file
303 'echo Third line>>'file
306 'echo "First line" >'file
307 'echo "Second line" >>'file
308 'echo "Third line" >>'file
311 call stream file
, 'c', 'close'
313 res
= charin( file
,, 10 ) /* now at EOL */
314 if res\
=='First line' then
315 call complain
"Simple use of charin() failed: got:["res
"] expected [First line]"
317 res
= linein( file
) /* must be rest of line, i.e. nullstring */
319 call complain
"Linein() didn't return '' when next char was EOL; got["res
"]"
321 res
= charin( file
, 1, 10 )
322 if res\
=='First line' then
323 call complain
"Simple use of charin() does not work; got["res
"] expected [First line]"
325 res
= linein( file
, 1 )
326 if res\
=='First line' then
327 call complain
"Linein() didn't read whole line after positioning; got["res
"] expected [First line]"
334 /* === 010 : Are read and write positions independent? ================ */
335 call notify
'crp/cwp'
338 oscopy simple file tonul
340 res
= charin(file
,,5)
341 if res\
=='First' then
342 call complain
"Simple use of charin() failed"
344 res
= charout(file
,"IRST FIL",2)
346 call complain
"Simple use of charout() failed"
348 res
= charin(file
,,5)
349 if res\
==' FILe' then
350 call complain
"Charout() didn't overwrite data in file"
352 res
= charin(file
,1,10)
353 if res\
=='FIRST FILe' then
354 call complain
"Charout() write incorrect data to file"
356 res
= charout(file
, 'xyzzy' )
358 call complain
"Continuing charout() didn't work"
360 res
= charin(file
,, 10)
361 if eol
= 'CRLF' then str
= "yzzycond l"
362 else str
= "yzzyond li"
364 call complain
"Charin() or charout() doesn't work; got["res
"] expecting ["str
"]"
373 /* === : 011 I/O should only be faked when NOTREADY is trapped ======== */
374 call notify
'notready'
376 if eol
= 'CRLF' then none
= '\no\such\file'
377 else none
= '/no/such/file'
380 call stream none
, 'c', 'close'
383 call on notready name trap011
384 res
= lineout(none
,"Foobar") + lineout(none
,"HeppHepp")
386 call complain
"Don't fake line output after error output"
388 res
= lineout(none
,"Foobar") + lineout(none
,"HeppHepp")
390 call complain
"Doesn't fakes line output in next line after error output"
393 call complain
"Condition trap was not called"
396 res
= lineout(none
,"Foobar") + lineout(none
,"HeppHepp")
398 call complain
"Fakes line output in next line after error output"
401 call complain
"Condition trap called too many times"
404 call on notready name trap011
405 call stream none
, 'c', 'close'
407 res
= charout(none
,"Foobar") + charout(none
,"HeppHepp")
409 call complain
"Don't fake char output after error output"
411 res
= charout(none
,"Foobar") + charout(none
,"HeppHepp")
413 call complain
"Doesn't fake char output in next line after error output"
416 call complain
"Condition trap was not called"
419 res
= charout(none
,"Foobar") + charout(none
,"HeppHepp")
421 call complain
"Fakes char output in next line after error output"
425 call stream none
, 'c', 'close'
428 res
= lineout(none
,"Foobar") + lineout(none
,"HeppHepp")
430 call complain
"Did fake line output when not trapping NOTREADY"
432 res
= charout(none
,"Foobar") + charout(none
,"HeppHepp")
434 call complain
"Did fake char output when not trapping NOTREADY"
437 call complain
"Did call trap, when not enabled"
450 /* === 012 : Illegal to position more than one after EOF ============ */
451 /* in writeable files, and after EOF in readable files */
453 if regina
= 0 then signal test013
/* test only valid for Regina */
458 oscopy simple file tonul
460 call stream file
, 'c', 'close'
461 lines = lines( file
)
465 chars = chars + length(linein(file
)) + num_eol_chars
468 do while lines( file
)>0
469 chars = chars + length(linein(file
)) + num_eol_chars
472 call stream file
, 'c', 'close'
475 signal on notready name trap012a
476 signal on syntax name trap012a
478 call charin file
, chars, 0 /* at last char */
481 call stream file
, 'c', 'reset'
483 call complain
"Trapped when positioning read at last char in file"
486 signal on notready name trap012b
487 signal on syntax name trap012b
489 call charin file
, chars+1, 0 /* char 'after' EOF */
492 call stream file
, 'c', 'reset'
494 call complain
"Didn't trap positioning read after EOF"
496 signal on notready name trap012c
497 signal on syntax name trap012c
499 call charout file
,, chars+1 /* legal, don't truncate */
502 call stream file
, 'c', 'reset'
504 call complain
"Trapped when positioning write at EOF+1"
506 'cmp' simple file
">/dev/null"
508 call complain
"File changed when positioning at EOF+1"
510 signal on notready name trap012d
511 signal on syntax name trap012d
513 call charout file
,, chars+2 /* not legal */
516 call stream file
, 'c', 'reset'
518 call complain
"Not trapped when positioning write beyond EOF+1"
520 'cmp' simple file tonul
522 call complain
"File changed when positioning beyond EOF+1"
525 signal on notready name trap012e
526 signal on syntax name trap012e
528 call charout file
,, chars /* legal, may not truncate */
531 call stream file
, 'c', 'reset'
533 call complain
"Trapped when positioning at EOF"
535 'cmp' simple file tonul
537 call complain
"File was changed when char positioning in file"
548 /* === 013 : A line written to the middle of a file gets a ============ */
549 /* trailing, but not leading EOF ============================ */
550 call notify
'linecnt'
553 oscopy simple file tonul
556 call charout file
,, 14+num_eol_chars
557 call lineout file
, "<<<..--..>>>"
558 res
= charin( file
, 1, 30+(2*num_eol_chars
) )
560 if left(res
,25+(2*num_eol_chars
))\
=="First line"eol_chars
"Sec<<<..--..>>>"eol_chars
then
561 call complain
"Problems when inserting a line into a file"
563 if conf
.truncate
then do
564 last_line_len
= 25+(2*num_eol_chars
)
565 if length(res
)\
==last_line_len
then
566 call complain
"File was not truncated. End of file contents length should be" last_line_len
"; got" length(res
)
569 if length(res
)\
==30 & right(res
,3)\
=='d l' then
570 call complain
"Rest of line was mangled, after inserting line in file"
580 /* === 014 : When doing system() after fork() all files are closed, === */
581 /* Maybe we can trigger flushing twice? ===================== */
585 call stream file
, 'c', 'close'
586 call stream file
, 'c', 'open write replace'
587 call stream file
, 'c', 'close'
589 junk
= charout(file
, "<<<--->>>"'0a'x
)
591 address system
'rc 0'
592 call stream file
, 'c', 'close'
594 if lines(file
)\
==1 | chars(file
)\
==10 then
595 call complain
"Possibly double flushing during file output"
603 /* === 015 : Illegal to position on transient streams ================= */
604 /* Default input and output are transient =================== */
607 signal on syntax name trap015a
608 signal on notready name trap015a
610 call complain
"Didn't trap character repositioning on default input"
613 signal on syntax name trap015b
614 signal on notready name trap015b
616 call complain
"Didn't trap character repositioning on default output"
619 signal on syntax name trap015c
620 signal on notready name trap015c
622 call complain
"Didn't trap line repositioning on default input"
625 signal on syntax name trap015d
626 signal on notready name trap015d
628 call complain
"Didn't trap line repositioning on default output"
639 /* === 016 : Reading EOF for persistent file raises NOTREADY ========== */
640 call notify
'persist/eof'
643 oscopy simple file tonul
645 call stream file
, 'c', 'close'
646 call on notready name trap016
648 res
= charin(file
,28+(num_eol_chars
*2),10)
650 call complain
"Didn't raise NOTREADY when reading beyond EOF"
658 if res\
=='line'eol_chars
then
659 call complain
"Data not correct when reading beyond EOF"
668 /* === 017 : Let's try to write to <stdin> and vice versa ... ========== */
671 signal on notready name trap017a
672 call lineout 'stdin', 'foobar'
673 call complain
"Didn't trap writing to default input stream"
677 signal on notready name trap017b
679 call complain
"Didn't trap reading from default output stream"
688 /* === 018 : Let's read some really long lines ======================== */
689 call notify
'longlines'
695 call stream file
, 'c', 'open write replace'
696 hipp
= copies('x',len
)
697 written
= lineout( file
, copies('x', len
))
699 call complain
"Didn't manage to write out all the data"
700 hopp
= copies('x',len
)
701 line = linein( file
, 1 )
702 if line\
==copies('x',len
) | len\
=length(line) then
703 call complain
"Data read don't equal data written"
704 len
= trunc(len
* 1.5, 0) - 10
714 /* === 019 : Are we able to open 200 files? =========================== */
717 osdel1
'a*.tmp' tonul
721 res1
= lineout( "a" || i
|| ".tmp", "line 1 in file" i
"of test")
722 res2
= lineout( "a" || i
|| ".tmp", "line 2 in file" i
"of test")
723 if (res1
+ res2
> 0) then do
724 call complain
"Didn't manage to write to all" mf
"files (only "i
")"
730 fileno
= 1 + (i
*5) // (mf
-1)
731 lineno
= random( 1, 2 )
733 res
= linein( "a" || fileno
|| ".tmp", lineno
) ;
734 if (res\
=="line" lineno
"in file" fileno
"of test") then do
735 call complain
"Didn't manage to read back the data written"
742 call stream "a" || i
|| ".tmp", 'c', 'close' ;
745 osdel1
'a*.tmp' tonul
751 /* === 020 : Does chars() or lines() make an unopened file stick ======== */
752 /* in the rexx file table? ==================================== */
758 signal on notready name notr020a
759 call stream 'hepp', 'c', 'close'
760 oscopy
'simple hepp' tonul
763 call linein 'hepp', 1, 0
765 signal on syntax name trap020
766 if lines('hepp','C')\
==3 then
767 call complain
"Simple use of lines() didn't work"
770 call stream 'hepp', 'c', 'close' /* must close before delete */
772 line = linein('hepp',1)
775 call complain
"NOTREADY not triggered when reading nonex. file"
776 else if line=='First line' then
777 call complain
"File stuck in memory when counting lines()"
779 call complain
"Something is wrong with lines(), I think"
782 if line \
== "First line" then
783 call complain
"File wasn't found in memory"
793 /* Then, repeat for charin() */
797 signal on notready name notr020b
798 call stream 'hepp', 'c', 'close'
799 oscopy
'simple hepp' tonul
802 call lineout 'hepp', "hepp" /* opens for read and write */
804 hepp_size
= 31 + (num_eol_chars
* 3)
805 line_size
= 4 + num_eol_chars
806 if chars('hepp')\
==hepp_size
+ (time==2)*line_size
then
807 call complain
"Simple use of chars() didn't work"
809 call stream 'hepp', 'c', 'close' /* must close before delete */
811 line = linein('hepp',1)
814 call complain
"NOTREADY not triggered when reading nonex. file"
815 else if line=='First line' then
816 call complain
"File stuck in memory when counting chars()"
818 call complain
"Something is wrong with chars(), I think"
821 if line \
== "First line" then
822 call complain
"File wasn't found in memory"
835 call complain
"Interpreter does not support ANSI. LINES( fn, 'C' ) is valid ANSI."
839 /* === 021 : Test that close *always* close a file, even if ============= */
840 /* the file in error is in error state ======================== */
842 call on notready name notr021
845 res
= charin(file
,,5) charin(file
,500),
846 stream(file
,'c','close') charin(file
,,5)
848 call complain
"NOTREADY condition was not triggered"
855 if res
="First line" then
856 call complain
"Something very strange happened, failure not noticed"
857 else if res
='First' then
858 call complain
"Statement interrupted during execution"
859 else if res\
="First UNKNOWN First" then
860 call complain
"Didn't manage to read correct data"
868 /* === 022 : Does empty output without repositioning close the file? ===== */
869 call notify
'empty_out(default)'
872 call stream simple
, 'c', 'close'
873 line = linein( simple
) ;
875 if line\
=="First line" then
876 call complain
"STREAM(fn,'C','CLOSE') doesn't seem to have closed file"
879 line = linein( simple
)
881 if line\
=="First line" then
882 call complain
"LINEOUT(fn) should be the same as 'CLOSE'."
884 call stream simple
, 'c', 'close'
889 /* === 022 : Does empty output without repositioning close the file? STRICT_ANSI ===== */
890 call notify
'empty_out(STRICT_ANSI)'
894 call stream simple
, 'c', 'close'
895 line = linein( simple
) ;
897 if line\
=="First line" then
898 call complain
"STREAM(fn,'C','CLOSE') doesn't seem to have closed file"
901 line = linein( simple
)
903 if line\
=="Second line" then
904 call complain
"LINEOUT(fn) should be different to 'CLOSE' according to STRICT_ANSI."
906 call stream simple
, 'c', 'close'
907 OPTIONS NOSTRICT_ANSI
913 /* === 023 : Line positioning of file using STREAM ===== */
914 call notify
'line_pos'
917 call stream simple
, 'c', 'close'
918 call stream simple
, 'c', 'open write replace'
920 call lineout simple
, Left('line 'i
, 10, '*')
922 if eol
= 'LF' then line_length
= 11
923 else line_length
= 12
924 call stream simple
, 'c', 'close'
927 ret = stream( simple
, 'c', cmd
); correct
= 'READY:'
928 if ret \
= correct
then
929 call complain
"STREAM(fn,'C','"cmd
"') didn't work: got:" ret 'instead of:' correct
930 call checkseekpos
1, 1, 1+(100*line_length
), 101
933 * Move read pos to line 30, write pos to line 70
935 cmd
= 'SEEK =30 READ LINE'
936 ret = stream( simple
, 'c', cmd
); correct
= 30
937 if ret \
= correct
then
938 call complain
"STREAM(fn,'C','"cmd
"') didn't position correctly got:" ret 'instead of:' correct
939 call checkseekpos
1+(29*line_length
) , 30, 1+(100*line_length
), 101
941 cmd
= 'SEEK =70 WRITE LINE'
942 ret = stream( simple
, 'c', cmd
); correct
= 70
943 if ret \
= correct
then
944 call complain
"STREAM(fn,'C','"cmd
"') didn't position correctly got:" ret 'instead of:' correct
945 call checkseekpos
1+(29*line_length
) , 30, 1+(69*line_length
), 70
948 * Move read pos to line 60, write pos to line 50
950 cmd
= 'SEEK +30 READ LINE'
951 ret = stream( simple
, 'c', cmd
); correct
= 60
952 if ret \
= correct
then
953 call complain
"STREAM(fn,'C','"cmd
"') didn't position correctly got:" ret 'instead of:' correct
954 call checkseekpos
1+(59*line_length
) , 60, 1+(69*line_length
), 70
956 cmd
= 'SEEK -20 WRITE LINE'
957 ret = stream( simple
, 'c', cmd
); correct
= 50
958 if ret \
= correct
then
959 call complain
"STREAM(fn,'C','"cmd
"') didn't position correctly got:" ret 'instead of:' correct
960 call checkseekpos
1+(59*line_length
) , 60, 1+(49*line_length
), 50
963 * Move read pos to line 50, write pos to line 40
965 cmd
= 'SEEK -10 READ LINE'
966 ret = stream( simple
, 'c', cmd
); correct
= 50
967 if ret \
= correct
then
968 call complain
"STREAM(fn,'C','"cmd
"') didn't position correctly got:" ret 'instead of:' correct
969 call checkseekpos
1+(49*line_length
) , 50, 1+(49*line_length
), 50
971 cmd
= 'SEEK -10 WRITE LINE'
972 ret = stream( simple
, 'c', cmd
); correct
= 40
973 if ret \
= correct
then
974 call complain
"STREAM(fn,'C','"cmd
"') didn't position correctly got:" ret 'instead of:' correct
975 call checkseekpos
1+(49*line_length
) , 50, 1+(39*line_length
), 40
978 * Should now be able to read line 50
980 ret = linein( simple
); correct
= 'line 50***'
981 if ret \
= correct
then
982 call complain
"LINEIN(fn) returns the wrong value got:" '['ret']' 'instead of:' '['correct
']'
983 /* read pos should now be at line 51 */
984 call checkseekpos
1+(50*line_length
) , 51, 1+(39*line_length
), 40
987 * Move read pos to line 91, write pos to line 81
989 cmd
= 'SEEK <10 READ LINE'
990 ret = stream( simple
, 'c', cmd
); correct
= 91
991 if ret \
= correct
then
992 call complain
"STREAM(fn,'C','"cmd
"') didn't position correctly got:" ret 'instead of:' correct
993 call checkseekpos
1+(90*line_length
) , 91, 1+(39*line_length
), 40
995 cmd
= 'SEEK <20 WRITE LINE'
996 ret = stream( simple
, 'c', cmd
); correct
= 81
997 if ret \
= correct
then
998 call complain
"STREAM(fn,'C','"cmd
"') didn't position correctly got:" ret 'instead of:' correct
999 call checkseekpos
1+(90*line_length
) , 91, 1+(80*line_length
), 81
1001 call stream simple
, 'c', 'close'
1007 * If name is omitted, I/O skjer til standard input/output
1008 * Lesing starter normalt paa current read position
1009 * Error naar start er etter EOF
1010 * Dersom lengde er null, skjer bare positionering
1011 * Dersom det er sjanse for at flere tegn blir tilgjengelig
1012 (transiente) er I/O blokket.
1013 * EOF paa persistent filer gir NOTREADY
1017 * Returnerer remaining chars
1018 * Hvis string=nullstring, => rc=0
1019 * Default write=\= default read position
1020 * Initial read position and write position
1021 * Start for write kan spesifisere size(file)+1, mens read bare
1022 kan spesifisere size(file)
1023 * Dersom string=tom og start=tom, saa settes cur write pos til
1024 EOF, og evt filen lukkes
1025 * Utskrift er blokket, eller gir feil paa persistent files
1029 * Antallet inkluderer lkinjeskift
1030 * Returnerer 1 dersom ukjent
1034 * Kan returnere delvise linjer i kombinasjon med charing
1035 * Dersom start er oppgitt, starter read alltid paa starten av en
1036 linje, selv om start er current linje, og current er paa
1038 * Blokkerer I/O til fullstendig linje er tilgjenglig (transient)
1039 * Retuernerer ufullstendig linje og trigger NOTREADY for EOF
1040 paa persistent files
1044 * String='' skriver ut ebn EOL
1045 * Ved skriving til en file, terminerer lionjer *etter* nu linje,
1050 * Antall hele linjher som er igjen: a) halv linje paa slutten teller
1051 ikke, mens b) halv linje paa starten telles
1053 * Pull/linein og say/lineout bruker samme interface.
1055 * Status for en stream lagres ikke over subroutine kall
1059 * Skrive til <stdin> og lese fra <stdout>
1060 * Aapne filer en masse, og se om noe skjaerer seg.
1061 * Les lange (svaert lange) linjer
1062 * Proev aa forvirre med filer der siste linjer ikke har EOL
1063 * Posisjoner til en linjer som ikke finnes
1064 * Skrive inn, eller fjern EOL fra fil, og se om det forvirrer
1065 linjetellingen. Gjoer skrivingen baade innefra og utenfra Rexx
1066 * Apne tom filer for lesing
1067 * La lesepos vaere langt ute i fila, trunker paa et tidligere punkt
1068 * Forsoek posisjonering paa standard input og output
1069 * Test at lesing/skriving avc ASCII NUL fungerer baade for
1070 character og linje basert I/O
1071 * Klarer vi aa lang kroell med /dev/null? Vi skal ikke kunne lese,
1072 og ved skriving skal det bli kroell i linjetellingen
1073 * Har leseaccess; proever aa skrive, mistes leseakksess?
1074 * Omvendt, dersom vi starter med leseaccess.
1075 * Har leseaccess, denne fjernes (Av eksternt program), forsoeker aa
1076 faa skriveaksess, mistes leseacckess
1077 * samme for skriveaccess
1078 * Aapner fil for leseakses, flytter fila, aapner for skriveakksess
1079 * Kan vi lure den til aa flush'e to ganger: ved fork() og close()
1081 * Kan vi bruke cd() til aa faa den til aa operere paa en annen fil?
1083 * Naa trigger syntax dersom vi proever aa positionere oss til et
1092 say time('E') "seconds used"
1097 say 'Got an unwanted NOTREADY ... Ouch!'
1098 say 'cond("d")='condition("d")
1099 length = charout(,' (')
1103 ch: procedure expose sigl
1105 parse arg first
, second
1106 if first \
== second
then do
1108 say 'first = /'first
'/'
1109 say 'second = /'second
'/'
1110 say "FuncTrip: error in " sigl":" sourceline(sigl) ; end
1117 if arg() = 2 then lineno
= arg(2)
1119 say 'Tripped in line' lineno
':' arg(1)'.'
1120 length = charout(,' (')
1126 written
= written
+ length(word) + 2
1127 if written
>75 then do
1128 written
= length(word)
1131 call charout , word || ', '
1136 say 'Error discovered in function insert()'
1139 checkseekpos: Procedure Expose simple
sigl
1140 parse arg readchar
, readline
, writechar
, writeline
1143 cmd
= 'QUERY SEEK READ CHAR'
1144 ret = stream( simple
, 'c', cmd
); correct
= readchar
1145 if ret \
= correct
then
1146 call complain
"STREAM( fn,'C','"cmd
"') returns the wrong value got:" ret 'instead of:' correct
, lineno
1148 cmd
= 'QUERY SEEK READ LINE'
1149 ret = stream( simple
, 'c', cmd
); correct
= readline
1150 if ret \
= correct
then
1151 call complain
"STREAM(fn,'C','"cmd
"') returns the wrong value got:" ret 'instead of:' correct
, lineno
1153 cmd
= 'QUERY SEEK WRITE CHAR'
1154 ret = stream( simple
, 'c', cmd
); correct
= writechar
1155 if ret \
= correct
then
1156 call complain
"STREAM(fn,'C','"cmd
"') returns the wrong value got:" ret 'instead of:' correct
, lineno
1158 cmd
= 'QUERY SEEK WRITE LINE'
1159 ret = stream( simple
, 'c', cmd
); correct
= writeline
1160 if ret \
= correct
then
1161 call complain
"STREAM(fn,'C','"cmd
"') returns the wrong value got:" ret 'instead of:' correct
, lineno