aboutsummaryrefslogtreecommitdiff
path: root/lib/splitmem.c
blob: f5d13aafca5458b10ce97e891fa8b3a14cec2ebc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
unsigned int splitmem(char **v, char *s, char c) /*EXTRACT_INCL*/ {
  if (v) {
    char **w=v;
    *w++=s;
    for (;;) {
      while (*s && *s!=c) s++;
      if (*s==0) break;
      *s=0;
      *w++ = ++s;
    }
    *w=0;
    return (w-v);
  } else {
    unsigned int n=1;
    for (; *s; s++) if (*s==c) n++;
    return n;
  }
}