# Copyright (c) 1979 Regents of the University of California
# char sccsid[] = "@(#)33iofile.s 4.2 10/14/80";
# FILE HOUSEKEEPING OPERATIONS
tstl 8(sp) #attempt to rewind only if stdin
bneq l3304 # and no name is given
addl2 $16,sp #clear stack
bicw2 $EOF+EOLN,stdin+FUNIT
tstl r0 #check for valid open
bbc $fTEMP,FUNIT(r6),eopen #if TEMP file, set at EOF
bisw2 $SYNC+FREAD,FUNIT(r6)
bisw2 $EOF+FWRITE,FUNIT(r6)
bbc $fWRITE,FUNIT(r7),l3306
movl (sp)+,r4 #r4 has max name length
movl (sp)+,r5 #r5 pts to name
locc $blank,r4,(r5) #check for trailing blanks
subl2 r0,r4 #deduct blanks if any
addl3 $2,r4,r6 #r6 has name + 1 aligned to word
subl2 r6,sp #allocate space
movc5 r4,(r5),$0,r6,(sp) #move in name with zero end
tstl r0 #check for errors
addl2 r6,sp #deallocate space
movl sp,_file #point to name