1*14470Ssam #ifndef lint 2*14470Ssam static char sccsid[] = "@(#)input.c 4.2 08/11/83"; 3*14470Ssam #endif 43757Sroot /* 53757Sroot * 63757Sroot * UNIX debugger 73757Sroot * 83757Sroot */ 93757Sroot 103757Sroot #include "defs.h" 113757Sroot 123757Sroot INT mkfault; 133757Sroot CHAR line[LINSIZ]; 143757Sroot INT infile; 153757Sroot CHAR *lp; 163757Sroot CHAR peekc,lastc = EOR; 173757Sroot INT eof; 183757Sroot 193757Sroot /* input routines */ 203757Sroot eol(c)213757Srooteol(c) 223757Sroot CHAR c; 233757Sroot { 243757Sroot return(c==EOR ORF c==';'); 253757Sroot } 263757Sroot rdc()273757Srootrdc() 283757Sroot { REP readchar(); 293757Sroot PER lastc==SP ORF lastc==TB 303757Sroot DONE 313757Sroot return(lastc); 323757Sroot } 333757Sroot readchar()343757Srootreadchar() 353757Sroot { 363757Sroot IF eof 373757Sroot THEN lastc=0; 383757Sroot ELSE IF lp==0 393757Sroot THEN lp=line; 403757Sroot REP eof = read(infile,lp,1)==0; 413757Sroot IF mkfault THEN error(0); FI 423757Sroot PER eof==0 ANDF *lp++!=EOR DONE 433757Sroot *lp=0; lp=line; 443757Sroot FI 453757Sroot IF lastc = peekc THEN peekc=0; 463757Sroot ELIF lastc = *lp THEN lp++; 473757Sroot FI 483757Sroot FI 493757Sroot return(lastc); 503757Sroot } 513757Sroot nextchar()523757Srootnextchar() 533757Sroot { 543757Sroot IF eol(rdc()) 553757Sroot THEN lp--; return(0); 563757Sroot ELSE return(lastc); 573757Sroot FI 583757Sroot } 593757Sroot quotchar()603757Srootquotchar() 613757Sroot { 623757Sroot IF readchar()=='\\' 633757Sroot THEN return(readchar()); 643757Sroot ELIF lastc=='\'' 653757Sroot THEN return(0); 663757Sroot ELSE return(lastc); 673757Sroot FI 683757Sroot } 693757Sroot getformat(deformat)703757Srootgetformat(deformat) 713757Sroot STRING deformat; 723757Sroot { 733757Sroot REG STRING fptr; 743757Sroot REG BOOL quote; 753757Sroot fptr=deformat; quote=FALSE; 763757Sroot WHILE (quote ? readchar()!=EOR : !eol(readchar())) 773757Sroot DO IF (*fptr++ = lastc)=='"' 783757Sroot THEN quote = ~quote; 793757Sroot FI 803757Sroot OD 813757Sroot lp--; 823757Sroot IF fptr!=deformat THEN *fptr++ = '\0'; FI 833757Sroot } 84