aboutsummaryrefslogtreecommitdiff
path: root/src/compat.c
blob: 082a60239d1d542d686b9071e026487ecc15c59b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <string.h>
#include "config.h"

#ifndef HAVE_STRSEP
// credit: Dan Cross via https://unixpapa.com/incnote/string.html
char *strsep(char **sp, char *sep)
{
    char *p, *s;
    if (sp == NULL || *sp == NULL || **sp == '\0') return(NULL);
    s = *sp;
    p = s + strcspn(s, sep);
    if (*p != '\0') *p++ = '\0';
    *sp = p;
    return(s);
}
#endif