|
|
1.1 ! root 1: /* Copyright Bell Telephone Laboratories Whippany, N.J. ! 2: ! 3: * ****************************************** ! 4: * ****************************************** ! 5: * *** IS STRING IN THERE ? IF SO WHERE ? *** ! 6: * ****** R. B. Drake WH 8C-005 X4163 ******* ! 7: * ******** Fri Aug 24 17:38:24 1979 ******** ! 8: * ****************************************** ! 9: * ****************************************** ! 10: ! 11: */ ! 12: /* "@(#) isthere.c: V 1.1 12/21/80" */ ! 13: ! 14: /* determine if a group of characters is in a string and if so ! 15: * return a pointer to the start of the group otherwise return ! 16: * -1 */ ! 17: #include "bas.h" ! 18: static char *beyond; /*pointer to first non-blank beyond group*/ ! 19: char *isthere(s,t,flg) ! 20: char *s,*t; ! 21: int flg; /* used to turn quote testing on and off */ ! 22: { ! 23: int i; ! 24: char *quot(); ! 25: for(;*t != 0;t++) ! 26: { ! 27: if((*t == '"') && ( flg ==1)) ! 28: { ! 29: t=quot(t); ! 30: if(t < (char *)0) ! 31: return(0); ! 32: if(*t == '\0') ! 33: return(0); ! 34: } ! 35: for(i=0; s[i] == 0 || s[i] == t[i];i++) ! 36: if(s[i] == '\0') ! 37: { ! 38: for(i=i;t[i] == ' ';i++); ! 39: beyond = &t[i]; ! 40: return(t); ! 41: } ! 42: } ! 43: return(0); ! 44: } ! 45: /* take the string starting at ptr and */ ! 46: shrink(ptr) ! 47: char *ptr; ! 48: { ! 49: extern char linbuf[]; ! 50: while(*beyond != '\0') ! 51: *ptr++ = *beyond++; ! 52: *ptr = '\0'; ! 53: } ! 54: /* routine to push the incoming pointer past anything enclosed ! 55: * in double quotes. If we hit the end of string first, its an error */ ! 56: char *quot(t) ! 57: char *t; ! 58: { ! 59: t++; /* get past the opening quote */ ! 60: while(*t++ != '"') ! 61: if(*t == '\0') ! 62: { ! 63: error(inst.thing.linno,11); ! 64: return(0); ! 65: } ! 66: return(t); ! 67: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.