.title gets Read a string from stdin .ident /000002/ ; ;+ ; ; Index Read a line from stdin ; ; Usage ; ; char * ; gets(buffer); ; char *buffer; ; ; Description ; ; gets() reads a string into the buffer from the standard ; input (stdin). The string is terminated by a newline character, ; which is replaced in the buffer by a null. Gets() returns ; buffer or NULL on end of file or error. ; ; ; Bugs ; ;- ; ; Edit history ; 000001 10-Mar-80 MM Conversion for the newer library ; 000002 22-May-80 MM Use stdin, not fin ; .psect c$code gets:: jsr r5,csv$ ;Link environments mov stdin,r4 ;Read from standard input ;02 mov c$pmtr+0(r5),r3 ;r3 -> buffer 10$: call $$getc ;Get a byte cmp r0,#-1 ;End of file? bne 20$ ;no, continue clr r0 ;yes, return NULL jmp cret$ ; 20$: movb r0,(r3)+ ;Out the byte cmp r0,#12 ;Line feed? bne 10$ ;no, continue clrb -(r3) ;yes, overwrite it mov c$pmtr+0(r5),r0 ;and return buffer jmp cret$ ; .end