summaryrefslogtreecommitdiff
path: root/src/libstddjb/skagetlnsep_loose.c
blob: ad0fd0a768e7834afaf23702ae9b810962d78b2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* ISC license. */

#include <errno.h>
#include <skalibs/stralloc.h>
#include <skalibs/skamisc.h>

int skagetlnsep_loose (buffer *b, stralloc *sa, char const *sep, size_t seplen)
{
  int e = errno ;
  int r = skagetlnsep(b, sa, sep, seplen) ;
  if (r >= 0) return r ;
  if (errno != EPIPE) return -1 ;
  if (!stralloc_0(sa)) return -1 ;
  return (errno = e, 3) ;
}