size = (nelem + 1) * sizeof (ptr);
ptr = REALLOC(*list, size, char *);
if (NULL != ptr) {
- ptr[nelem] = s;
+ ptr[nelem] = strsep(&s, ",");
nelem++;
*list = ptr;
*nlist = nelem;
- s = strchr (s, ',');
- if (NULL != s) {
- *s = '\0';
- s++;
- }
}
}
size = (nelem + 1) * sizeof (ptr);
* all 4 of them and save the starting addresses in fields[].
*/
- for (cp = sgrbuf, i = 0; (i < FIELDS) && (NULL != cp); i++) {
- fields[i] = cp;
- cp = strchr (cp, ':');
- if (NULL != cp) {
- *cp++ = '\0';
- }
- }
+ for (cp = sgrbuf, i = 0; (i < FIELDS) && (NULL != cp); i++)
+ fields[i] = strsep(&cp, ":");
/*
* If there was an extra field somehow, or perhaps not enough,
}
if (!s || s[0] == '\0')
break;
- members[i++] = s;
- s = strchrnul(s, ',');
- if ('\0' != *s) {
- *s++ = '\0';
- }
+ members[i++] = strsep(&s, ",");
}
members[i] = NULL;
return members;
*cp = '\0';
}
- for (cp = grpbuf, i = 0; (i < NFIELDS) && (NULL != cp); i++) {
- grpfields[i] = cp;
- cp = strchr (cp, ':');
- if (NULL != cp) {
- *cp = '\0';
- cp++;
- }
- }
+ for (cp = grpbuf, i = 0; (i < NFIELDS) && (NULL != cp); i++)
+ grpfields[i] = strsep(&cp, ":");
+
if (i < (NFIELDS - 1) || *grpfields[2] == '\0' || cp != NULL) {
return NULL;
}
* field. The fields are converted into NUL terminated strings.
*/
- for (cp = pwdbuf, i = 0; (i < NFIELDS) && (NULL != cp); i++) {
- fields[i] = cp;
- cp = strchrnul(cp, ':');
-
- if ('\0' != *cp) {
- *cp = '\0';
- cp++;
- } else {
- cp = NULL;
- }
- }
+ for (cp = pwdbuf, i = 0; (i < NFIELDS) && (NULL != cp); i++)
+ fields[i] = strsep(&cp, ":");
/* something at the end, columns over shot */
if ( cp != NULL ) {
* field. The fields are converted into NUL terminated strings.
*/
- for (cp = rangebuf, i = 0; (i < SUBID_NFIELDS) && (NULL != cp); i++) {
- fields[i] = cp;
- cp = strchrnul(cp, ':');
-
- if ('\0' != *cp) {
- *cp = '\0';
- cp++;
- } else {
- cp = NULL;
- }
- }
+ for (cp = rangebuf, i = 0; (i < SUBID_NFIELDS) && (NULL != cp); i++)
+ fields[i] = strsep(&cp, ":");
/*
* There must be exactly SUBID_NFIELDS colon separated fields or