skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

env_addmodif.c (403B)


      1 /* ISC license. */
      2 
      3 #include <sys/types.h>
      4 #include <skalibs/stralloc.h>
      5 #include <skalibs/env.h>
      6 
      7 int env_addmodif (stralloc *sa, char const *s, char const *t)
      8 {
      9   size_t oldlen = sa->len ;
     10   if (!s) return 1 ;
     11   if (!stralloc_cats(sa, s)) return 0 ;
     12   if ((t && (!stralloc_catb(sa, "=", 1) || !stralloc_cats(sa, t)))
     13    || !stralloc_0(sa))
     14   {
     15     sa->len = oldlen ;
     16     return 0 ;
     17   }
     18   return 1 ;
     19 }