1*3757Sroot # 2*3757Sroot /* 3*3757Sroot * 4*3757Sroot * UNIX debugger 5*3757Sroot * 6*3757Sroot */ 7*3757Sroot 8*3757Sroot #include "defs.h" 9*3757Sroot static char sccsid[] = "@(#)input.c 4.1 05/14/81"; 10*3757Sroot 11*3757Sroot INT mkfault; 12*3757Sroot CHAR line[LINSIZ]; 13*3757Sroot INT infile; 14*3757Sroot CHAR *lp; 15*3757Sroot CHAR peekc,lastc = EOR; 16*3757Sroot INT eof; 17*3757Sroot 18*3757Sroot /* input routines */ 19*3757Sroot 20*3757Sroot eol(c) 21*3757Sroot CHAR c; 22*3757Sroot { 23*3757Sroot return(c==EOR ORF c==';'); 24*3757Sroot } 25*3757Sroot 26*3757Sroot rdc() 27*3757Sroot { REP readchar(); 28*3757Sroot PER lastc==SP ORF lastc==TB 29*3757Sroot DONE 30*3757Sroot return(lastc); 31*3757Sroot } 32*3757Sroot 33*3757Sroot readchar() 34*3757Sroot { 35*3757Sroot IF eof 36*3757Sroot THEN lastc=0; 37*3757Sroot ELSE IF lp==0 38*3757Sroot THEN lp=line; 39*3757Sroot REP eof = read(infile,lp,1)==0; 40*3757Sroot IF mkfault THEN error(0); FI 41*3757Sroot PER eof==0 ANDF *lp++!=EOR DONE 42*3757Sroot *lp=0; lp=line; 43*3757Sroot FI 44*3757Sroot IF lastc = peekc THEN peekc=0; 45*3757Sroot ELIF lastc = *lp THEN lp++; 46*3757Sroot FI 47*3757Sroot FI 48*3757Sroot return(lastc); 49*3757Sroot } 50*3757Sroot 51*3757Sroot nextchar() 52*3757Sroot { 53*3757Sroot IF eol(rdc()) 54*3757Sroot THEN lp--; return(0); 55*3757Sroot ELSE return(lastc); 56*3757Sroot FI 57*3757Sroot } 58*3757Sroot 59*3757Sroot quotchar() 60*3757Sroot { 61*3757Sroot IF readchar()=='\\' 62*3757Sroot THEN return(readchar()); 63*3757Sroot ELIF lastc=='\'' 64*3757Sroot THEN return(0); 65*3757Sroot ELSE return(lastc); 66*3757Sroot FI 67*3757Sroot } 68*3757Sroot 69*3757Sroot getformat(deformat) 70*3757Sroot STRING deformat; 71*3757Sroot { 72*3757Sroot REG STRING fptr; 73*3757Sroot REG BOOL quote; 74*3757Sroot fptr=deformat; quote=FALSE; 75*3757Sroot WHILE (quote ? readchar()!=EOR : !eol(readchar())) 76*3757Sroot DO IF (*fptr++ = lastc)=='"' 77*3757Sroot THEN quote = ~quote; 78*3757Sroot FI 79*3757Sroot OD 80*3757Sroot lp--; 81*3757Sroot IF fptr!=deformat THEN *fptr++ = '\0'; FI 82*3757Sroot } 83