MkDescVec.c 691 B

12345678910111213141516171819202122232425262728
  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. {
  16. *EndPat = '\0';
  17. DescVec[NPats] = MakeDesc(Pats);
  18. Pats = EndPat + 1;
  19. ++NPats;
  20. } /* while */
  21. if (*Pats && NPats < MAXPATS)
  22. {
  23. DescVec[NPats] = MakeDesc(Pats);
  24. ++NPats;
  25. } /* if */
  26. return(NPats);
  27. } /* MkDescVec */