|
|
1.1 ! root 1: #include <stdio.h> ! 2: # ! 3: #include "def.h" ! 4: #define bufsize 1601 ! 5: char buffer[bufsize]; ! 6: int bufcount; ! 7: extern int errflag; ! 8: long stchars; /* counts number of chars at most recent \n read */ ! 9: #ifndef unix ! 10: long ostchars; ! 11: extern long ftell(); ! 12: #endif ! 13: int newline; /* counts number of lines read so far in file */ ! 14: extern int rdfree(), comfree(),labfree(), contfree(); ! 15: extern int rdstand(), comstand(), labstand(), contstand(); ! 16: extern int (*rline[])(); ! 17: extern int (*comment[])(); ! 18: extern int (*getlabel[])(); ! 19: extern int (*chkcont[])(); ! 20: ! 21: ! 22: ! 23: flush() ! 24: {bufcount = 0; } ! 25: ! 26: addchar(c) ! 27: { ! 28: buffer[bufcount++] = c; ! 29: } ! 30: ! 31: getline(lastline,lastchar,linecom,charcom) ! 32: int *lastline, *linecom; ! 33: long *lastchar, *charcom; ! 34: /* set *lastline to number of last line of statement, ! 35: set *lastchar to number of last char of statement, ! 36: set *linecom to number of last line of comment preceding statement */ ! 37: { ! 38: ! 39: int i; ! 40: flush(); ! 41: while ( unput1(input1()) != EOF) ! 42: { ! 43: while ( (*comment[inputform])(0) || blankline() ) ! 44: { ! 45: (*rline[inputform])(addchar); ! 46: flush(); ! 47: } ! 48: *linecom = newline; ! 49: /* set charcom to number of last char of comment, starting at 0 ! 50: if at start of file and no comment, will be -1 */ ! 51: *charcom = stchars - 1; ! 52: if (unput1(input1()) == EOF) break; ! 53: (*getlabel[inputform])(addchar); ! 54: (*rline[inputform])(addchar); ! 55: ! 56: while ( blankline() || ( !(*comment[inputform])(0) && (*chkcont[inputform])() )) ! 57: (*rline[inputform])(addchar); ! 58: ! 59: addchar('\0'); ! 60: *lastline = newline; ! 61: *lastchar = stchars - 1; ! 62: if (debug == 40) ! 63: fprintf(stderr,"line %d; bufcount: %d\n",newline,bufcount); ! 64: ! 65: for (i = 5; i < bufcount; ++i) ! 66: if (buffer[i] == ' ' || buffer[i] == '\t' || buffer[i] == '\n') ! 67: buffer[i] = '~'; ! 68: return(bufcount); ! 69: } ! 70: return(-1); ! 71: } ! 72: ! 73: ! 74: int linechars; /* counts number of chars read so far in current line */ ! 75: long newchar; /* counts number of chars read so far in file */ ! 76: ! 77: ! 78: input1() ! 79: { ! 80: static int c; ! 81: if (c == '\n') linechars = 0; ! 82: c = inchar(); ! 83: ++linechars; ! 84: ++newchar; ! 85: if (c == '\n') ! 86: { ! 87: ++newline; ! 88: #ifdef unix ! 89: stchars = newchar; ! 90: #else ! 91: ostchars=stchars; stchars=ftell(infd); ! 92: #endif ! 93: } ! 94: return(c); ! 95: } ! 96: ! 97: unput1(c) ! 98: { ! 99: --linechars; ! 100: --newchar; ! 101: unchar(c); ! 102: if (c == '\n') ! 103: { ! 104: #ifdef unix ! 105: stchars = newchar; ! 106: #else ! 107: stchars=ostchars; ! 108: #endif ! 109: --newline; ! 110: } ! 111: return(c); ! 112: } ! 113: ! 114: ! 115: ! 116:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.