home *** CD-ROM | disk | FTP | other *** search
- extern long howmany;
- extern char *patterns[];
- extern void *AllocMem();
- void split_string(string)
- char *string;
-
- {
- long i=0, wc=0;
- char substr[20];
- substr[0]=0;
-
- while(*string==' ' || *string == '\t') /* skip leading blanks */
- string++;
-
- while(*string && wc<50)
- {
- while(*string != ' ' && *string != '\t' && *string != 0)
- {
- substr[i]=*string;
- string++;
- i++;
- }
- substr[i] = 0;
- if(patterns[wc])
- FreeMem(patterns[wc], strlen(patterns[wc]) + 1L);
-
- patterns[wc]=AllocMem(strlen(substr)+1L, MEMF_CLEAR);
-
- if(!patterns[wc])
- quit("Could not allocate memory for patterns!\n");
- else
- strcpy(patterns[wc], substr);
- wc++;
- i=substr[0]=0;
-
- while(*string == ' ' || *string == '\t')
- string++;
- }
- #ifdef DEBUG
- Printf("I found %ld words in this line.\n", wc);
- #endif
- howmany=wc; /* set extern wordcount variable */
- #ifdef DEBUG
- for(i=0; i<howmany; i++)
- Printf("Word %ld: %s\n", i, patterns[i]);
- #endif
- return;
- }
-