diff options
Diffstat (limited to 'src/libstddjb/envdir.c')
-rw-r--r-- | src/libstddjb/envdir.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/libstddjb/envdir.c b/src/libstddjb/envdir.c index 7866c7a..6992654 100644 --- a/src/libstddjb/envdir.c +++ b/src/libstddjb/envdir.c @@ -1,6 +1,7 @@ /* ISC license. */ #include <unistd.h> +#include <string.h> #include <errno.h> #include <skalibs/bytestr.h> #include <skalibs/env.h> @@ -14,8 +15,8 @@ int envdir_internal (char const *path, stralloc *modifs, unsigned int options, c { char buf[MAXVARSIZE + 1] ; unsigned int n = 0 ; - unsigned int pathlen = str_len(path) ; - unsigned int modifbase = modifs->len ; + size_t pathlen = strlen(path) ; + size_t modifbase = modifs->len ; int wasnull = !modifs->s ; DIR *dir ; if (!nullis) return (errno = EINVAL, -1) ; @@ -24,19 +25,19 @@ int envdir_internal (char const *path, stralloc *modifs, unsigned int options, c for (;;) { direntry *d ; - unsigned int len ; - register int r ; + size_t len ; + ssize_t r ; errno = 0 ; d = readdir(dir) ; if (!d) break ; if (d->d_name[0] == '.') continue ; - len = str_len(d->d_name) ; + len = strlen(d->d_name) ; if (str_chr(d->d_name, '=') < len) continue ; { char tmp[pathlen + len + 2] ; - byte_copy(tmp, pathlen, path) ; + memcpy(tmp, path, pathlen) ; tmp[pathlen] = '/' ; - byte_copy(tmp + pathlen + 1, len + 1, d->d_name) ; + memcpy(tmp + pathlen + 1, d->d_name, len + 1) ; r = openreadnclose(tmp, buf, MAXVARSIZE) ; } if (r < 0) @@ -60,8 +61,8 @@ int envdir_internal (char const *path, stralloc *modifs, unsigned int options, c } } { - register unsigned int i = 0 ; - for (; i < (unsigned int)r ; i++) if (!buf[i]) buf[i] = nullis ; + size_t i = 0 ; + for (; i < (size_t)r ; i++) if (!buf[i]) buf[i] = nullis ; } buf[r++] = 0 ; if (!env_addmodif(modifs, d->d_name, buf)) goto err ; @@ -75,7 +76,7 @@ int envdir_internal (char const *path, stralloc *modifs, unsigned int options, c err: { - register int e = errno ; + int e = errno ; dir_close(dir) ; if (wasnull) stralloc_free(modifs) ; else modifs->len = modifbase ; errno = e ; |