summaryrefslogtreecommitdiff
path: root/src/libstddjb/env_merge.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-02-21 12:05:07 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-02-21 12:05:07 +0000
commit49d8fa1058aaf23c29e074b2314492ae40d2f557 (patch)
tree393f884d5a99f984e992a0f35f1b02ac43536217 /src/libstddjb/env_merge.c
parentfdffefb8032922ce7ffe4c00816072a8ff2148fc (diff)
downloadskalibs-49d8fa1058aaf23c29e074b2314492ae40d2f557.tar.xz
Types change: big pass on libstddjb and libunixonacid
libdatastruct still missing, library still not functional
Diffstat (limited to 'src/libstddjb/env_merge.c')
-rw-r--r--src/libstddjb/env_merge.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/libstddjb/env_merge.c b/src/libstddjb/env_merge.c
index 2a0e5bd..f7ba335 100644
--- a/src/libstddjb/env_merge.c
+++ b/src/libstddjb/env_merge.c
@@ -1,22 +1,23 @@
/* ISC license. */
+#include <string.h>
#include <errno.h>
#include <skalibs/bytestr.h>
#include <skalibs/env.h>
-unsigned int env_merge (char const **v, unsigned int vmax, char const *const *envp, unsigned int envlen, char const *modifs, unsigned int modiflen)
+size_t env_merge (char const **v, size_t vmax, char const *const *envp, size_t envlen, char const *modifs, size_t modiflen)
{
- unsigned int n = byte_count(modifs, modiflen, '\0') ;
- unsigned int vlen = envlen ;
- register unsigned int i = 0 ;
+ size_t n = byte_count(modifs, modiflen, '\0') ;
+ size_t vlen = envlen ;
+ size_t i = 0 ;
if (envlen + n + 1 > vmax) return (errno = ENAMETOOLONG, 0) ;
for (; i < envlen ; i++) v[i] = envp[i] ;
- for (i = 0 ; i < modiflen ; i += str_len(modifs + i) + 1)
+ for (i = 0 ; i < modiflen ; i += strlen(modifs + i) + 1)
{
- unsigned int split = str_chr(modifs + i, '=') ;
- register unsigned int j = 0 ;
+ size_t split = str_chr(modifs + i, '=') ;
+ size_t j = 0 ;
for (; j < vlen ; j++)
- if (!byte_diff(modifs + i, split, v[j]) && (v[j][split] == '=')) break ;
+ if (!memcmp(modifs + i, v[j], split) && (v[j][split] == '=')) break ;
if (j < vlen) v[j] = v[--vlen] ;
if (modifs[i + split]) v[vlen++] = modifs + i ;
}