/********************************************************/ /* */ /* ROFF4, Version 1.60 */ /* */ /*(C) 1983,4 by Ernest E. Bergmann */ /* Physics, Building #16 */ /* Lehigh Univerisity */ /* Bethlehem, Pa. 18015 */ /* */ /* Permission is hereby granted for all commercial and */ /* non-commercial reproduction and distribution of this */ /* material provided this notice is included. */ /* */ /********************************************************/ /*MAR 10, 1984*/ #include "roff4.h" char *find2(), *calloc(); /****************************************/ int regist(s) char *s; { char *pw,*s2; int loc; pw=find2(s,RTAB,REND,&loc); if (pw) return(loc); REND++; pw = (char*) calloc(RTABSZ,1); if DEBUG fprintf(STDERR,"regist: pw is %lx\n",pw); RTAB[REND] = pw; s2=s; transfer(&s2,&pw,'\0'); if DEBUG fprintf(STDERR,"regist: <%s>\n",RTAB[REND]); return(REND); } /***************************************/ dovar() /*process .RG request */ {char typ, wbuf[MAXLINE]; int val, pw; getwrd(LINE,wbuf); skip_blanks(LINE); val=get_val(LINE,&typ); getwrd(LINE,wbuf); if DEBUG fprintf(STDERR,"dovar: wbuf <%s>\n",wbuf); if(wbuf[0]==NUMSIGN && wbuf[1]=='\0') {set(&NEWPAG,val,typ,NEWPAG,1,9999); } else {pw=regist(wbuf); set(&RTABVAL[pw],val,typ,REGDEF,1,9999); } } /****************************************/ source() { char name[MAXLINE]; getwrd(LINE,name); if(getwrd(LINE,name)!=WE_HAVE_A_WORD) {fprintf(STDERR,".SO has no name\n"); return; } ucstr(name); if(FPTR\n",name); } endso(); } /****************************************/ showr() /*lists register names and contents */ {int i; for (i=0;i<=REND;i++) { if (strlen(RTAB[i])<1) break; fprintf(STDERR,"reg: %s is %d\n",RTAB[i],RTABVAL[i]); } } /**************************************** showd() /*shows all diversions and status {int *pw; char *pc; struct divfd *pd; fprintf(STDERR, "Diversion files:\n"); pw=DLINK; while(pw) {pc=pw+1; fprintf(STDERR,"%s: ",pc); pd=pc+1+strlen(pc); fprintf(STDERR,"%d characters, %d lines [", pd->cs, pd->ls ); if(pd->bf) fprintf(STDERR,"open]\n"); else fprintf(STDERR,"closed]\n"); pw = *pw; } dashes(); } /**************************************** dsclose() /*flushes and closes all open diversions {int *pw; char *pc; struct divfd *pd; pw = DLINK; while(pw) {pc=pw+1; pd=pc+1+strlen(pc); if(pd->bf) dclose(pd); pw= *pw; } } /****************************************/ ucstr(s) /*convert s to upper case*/ char *s; {while(*s) {*s = toupper(*s); s++; } } /****************************************/ endso() /*called upon EOF to return to previous input file*/ {if(FPTR) {fclose(fp); fp=FSTACK[--FPTR]; } BINP=0; } /****************************************/ dashes() {fprintf(STDERR,"-----------\n"); }