home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume4 / bm1.2 / MkDescVec.c < prev    next >
C/C++ Source or Header  |  1986-11-30  |  750b  |  28 lines

  1. #include "bm.h"
  2. #include <string.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. /* some systems use "strchr" instead of "index" */
  15. /* while (*Pats && (EndPat = index(Pats,'\n')) && NPats < MAXPATS) { */
  16.     while (*Pats && (EndPat = strchr(Pats,'\n')) && NPats < MAXPATS) {
  17.         *EndPat = '\0';
  18.         DescVec[NPats] = MakeDesc(Pats);
  19.         Pats = EndPat + 1;
  20.         ++NPats;
  21.     } /* while */
  22.     if (*Pats && NPats < MAXPATS) {
  23.         DescVec[NPats] = MakeDesc(Pats);
  24.         ++NPats;
  25.     } /* if */
  26.     return(NPats);
  27. } /* MkDescVec */
  28.