1: #include "bm.h" 2: #include <strings.h> 3: /* scan a newline-separated string of patterns and set up the 4: * vector of descriptors, one pattern descriptor per pattern. 5: * Return the number of patterns */ 6: int 7: MkDescVec(DescVec, Pats) 8: struct PattDesc *DescVec[]; 9: char *Pats; 10: { 11: int NPats = 0; 12: char *EndPat; 13: extern struct PattDesc *MakeDesc(); 14: while (*Pats && (EndPat = index(Pats,'\n')) && NPats < MAXPATS) { 15: *EndPat = '\0'; 16: DescVec[NPats] = MakeDesc(Pats); 17: Pats = EndPat + 1; 18: ++NPats; 19: } /* while */ 20: if (*Pats && NPats < MAXPATS) { 21: DescVec[NPats] = MakeDesc(Pats); 22: ++NPats; 23: } /* if */ 24: return(NPats); 25: } /* MkDescVec */