X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/2b84abb596f52ab2068d52108adc96838ad4340a..31cef89cb428866f787983e68246030321893df4:/usr/src/cmd/px/30read.s diff --git a/usr/src/cmd/px/30read.s b/usr/src/cmd/px/30read.s index 7780671420..d45f6c4803 100644 --- a/usr/src/cmd/px/30read.s +++ b/usr/src/cmd/px/30read.s @@ -1,23 +1,29 @@ # -# 30read.s +# Copyright (c) 1979 Regents of the University of California +# +# char sccsid[] = "@(#)30read.s 4.2 10/29/80"; # # READ OPERATIONS # _GET: incl r10 calls $0,_iosync #insure that something is in the window + jbs $fEOF,FUNIT(r7),eeof bisw2 $SYNC,FUNIT(r7) #throw it away jmp (r8) +eeof: + movw $EPASTEOF,_perrno + jbr error _FNIL: incl r10 movl (sp),r0 - bbs $fWRITE,FUNIT(r0),l3002 #ignore sync of output files - movl r7,r2 - movl _file,r3 + jbs $fWRITE,FUNIT(r0),l3002 #ignore sync of output files + movl r7,r6 calls $0,_unit #do not discard arguement to unit on return calls $0,_iosync - movl r2,r7 - movl r3,_file + jbs $fEOF,FUNIT(r7),eeof + movl r6,r7 + movl PFNAME(r7),_file l3002: jmp (r8) _READ4: @@ -53,20 +59,60 @@ efread: _READLN: incl r10 calls $0,_iosync - bbs $fEOLN,FUNIT(r7),l3005 #check for already at end of line - pushal rdln - pushl FBUF(r7) - calls $2,_fscanf + jbs $fEOLN,FUNIT(r7),l3005 #check for already at end of line + movab -1024(sp),sp #temp space + pushl FBUF(r7) #file + pushl $1024 #buffer + pushal 8(sp) #ptr to buffer + calls $3,_fgets + movab 1024(sp),sp #pop temp space l3005: + jbs $fEOF,FUNIT(r7),eeof bisw2 $SYNC,FUNIT(r7) jmp (r8) _READC: incl r10 calls $0,_iosync cvtbw (r7),-(sp) + jbs $fEOF,FUNIT(r7),eeof bisw2 $SYNC,FUNIT(r7) jmp (r8) +_READE: + incl r10 + calls $0,_unsync #push back char if present + subl2 $bufsze,sp #allocate space for name + pushl sp #ptr to buffer + pushal rden #format string + pushl FBUF(r7) #FILE ptr + calls $3,_fscanf #read name + cmpl r0,$1 #check for valid input + bneq entfd + locc $0,$bufsze,(sp) #find size of input + subl3 r0,$bufsze+1,r6 #r6 has length of input + addl3 (r10),ap,r5 #r5 points to candidate data + cvtwl (r5)+,r4 #r4 has number of candidates + movaw 2(r5)[r4],r1 #r1 has addr of candidate name list +l3006: + subw3 (r5)+,(r5),r0 #r0 has candidate length + cmpw r0,r6 #check for correct length + bneq l3007 + cmpc3 r0,(r1),(sp) #check for actual match + beql l3008 +l3007: + addl2 r0,r1 #update ptr to next candidate + sobgtr r4,l3006 +entfd: + addl2 $bufsze,sp #deallocate buffer + addl2 $4,r10 + movw $ENUMNTFD,_perrno + jbr error +l3008: + addl2 $bufsze,sp #deallocate buffer + addl3 (r10)+,ap,r0 #r0 has number of cases + subw3 r4,(r0),-(sp) #push internal value + jmp (r8) -rd4: .byte '%,'l,'d, 0 -rd8: .byte '%,'l,'f, 0 -rdln: .byte '%,'*,'[,'^,linefeed,'],'%,'*,'c, 0 + .set bufsze,84 +rd4: .asciz "%ld" +rd8: .asciz "%lf" +rden: .asciz "%*[ \t\n]%80[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]",