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

#include <skalibs/stralloc.h>
#include <skalibs/env.h>

int env_addmodif (stralloc *sa, char const *s, char const *t)
{
  unsigned int oldlen = sa->len ;
  if (!s) return 1 ;
  if (!stralloc_cats(sa, s)) return 0 ;
  if ((t && (!stralloc_catb(sa, "=", 1) || !stralloc_cats(sa, t)))
   || !stralloc_0(sa))
  {
    sa->len = oldlen ;
    return 0 ;
  }
  return 1 ;
}