diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-03-11 12:16:25 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-03-11 12:16:25 +0000 |
commit | 1b5312d5c01fd5e12b938cfe65cda562e822619d (patch) | |
tree | 60f086613e97aae5cb2635b8b9e3251c7b3c55cf /src | |
parent | ac77200b30d6c8bbe9093655dd0f8d8bf6e88feb (diff) | |
download | s6-portable-utils-1b5312d5c01fd5e12b938cfe65cda562e822619d.tar.gz s6-portable-utils-1b5312d5c01fd5e12b938cfe65cda562e822619d.tar.xz s6-portable-utils-1b5312d5c01fd5e12b938cfe65cda562e822619d.zip |
Adapt to skalibs-2.5.0.0
Diffstat (limited to 'src')
38 files changed, 200 insertions, 223 deletions
diff --git a/src/skaembutils/s6-basename.c b/src/skaembutils/s6-basename.c index 6ca6217..7122858 100644 --- a/src/skaembutils/s6-basename.c +++ b/src/skaembutils/s6-basename.c @@ -1,9 +1,8 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <skalibs/sgetopt.h> #include <skalibs/allreadwrite.h> -#include <skalibs/bytestr.h> #include <skalibs/strerr2.h> #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> @@ -19,7 +18,7 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "n", &l) ; + int opt = subgetopt_r(argc, argv, "n", &l) ; if (opt == -1) break ; switch (opt) { @@ -30,12 +29,12 @@ int main (int argc, char const *const *argv) argc -= l.ind ; argv += l.ind ; } if (!argc) strerr_dieusage(100, USAGE) ; - if (!sabasename(&sa, argv[0], str_len(argv[0]))) + if (!sabasename(&sa, argv[0], strlen(argv[0]))) strerr_diefu2sys(111, "get basename of ", argv[0]) ; if (argc >= 2) { - size_t n = str_len(argv[1]) ; - if ((n < sa.len) && !byte_diff(argv[1], n, sa.s + sa.len - n)) + size_t n = strlen(argv[1]) ; + if ((n < sa.len) && !strncmp(argv[1], sa.s + sa.len - n, n)) sa.len -= n ; } if (nl && !stralloc_catb(&sa, "\n", 1)) diff --git a/src/skaembutils/s6-cat.c b/src/skaembutils/s6-cat.c index f0166be..094342c 100644 --- a/src/skaembutils/s6-cat.c +++ b/src/skaembutils/s6-cat.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include <errno.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> diff --git a/src/skaembutils/s6-chmod.c b/src/skaembutils/s6-chmod.c index 95f350f..6e05b53 100644 --- a/src/skaembutils/s6-chmod.c +++ b/src/skaembutils/s6-chmod.c @@ -1,7 +1,7 @@ /* ISC license. */ #include <sys/stat.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #define USAGE "s6-chmod mode file" diff --git a/src/skaembutils/s6-chown.c b/src/skaembutils/s6-chown.c index 02b7ca7..a557642 100644 --- a/src/skaembutils/s6-chown.c +++ b/src/skaembutils/s6-chown.c @@ -1,11 +1,8 @@ /* ISC license. */ -#include <sys/types.h> #include <unistd.h> #include <skalibs/sgetopt.h> -#include <skalibs/uint64.h> -#include <skalibs/gidstuff.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> @@ -20,15 +17,13 @@ int main (int argc, char const *const *argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "Uu:g:", &l) ; + int opt = subgetopt_r(argc, argv, "Uu:g:", &l) ; if (opt == -1) break ; switch (opt) { case 'u': { - uint64 u ; - if (!uint640_scan(l.arg, &u)) strerr_dieusage(100, USAGE) ; - uid = u ; + if (!uid0_scan(l.arg, &uid)) strerr_dieusage(100, USAGE) ; break ; } case 'g': @@ -38,11 +33,9 @@ int main (int argc, char const *const *argv, char const *const *envp) } case 'U': { - uint64 u ; char const *s = env_get2(envp, "UID") ; if (!s) strerr_dienotset(100, "UID") ; - if (!uint640_scan(s, &u)) strerr_dieinvalid(100, "UID") ; - uid = u ; + if (!uid0_scan(s, &uid)) strerr_dieinvalid(100, "UID") ; s = env_get2(envp, "GID") ; if (!s) strerr_dienotset(100, "GID") ; if (!gid0_scan(s, &gid)) strerr_dieinvalid(100, "GID") ; diff --git a/src/skaembutils/s6-cut.c b/src/skaembutils/s6-cut.c index d843222..934bb51 100644 --- a/src/skaembutils/s6-cut.c +++ b/src/skaembutils/s6-cut.c @@ -1,12 +1,11 @@ /* ISC license. */ -#include <sys/types.h> #include <errno.h> #include <stdlib.h> #include <skalibs/sgetopt.h> #include <skalibs/bytestr.h> -#include <skalibs/uint.h> -#include <skalibs/diuint.h> +#include <skalibs/types.h> +#include <skalibs/disize.h> #include <skalibs/buffer.h> #include <skalibs/strerr2.h> #include <skalibs/stralloc.h> @@ -16,44 +15,44 @@ #define USAGE "s6-cut [ -b list | -c list | -f list ] [ -d delim ] [ -n ] [ -s ] [ file... ]" -static int diuint_cmpleft (void const *a, void const *b) +static int disize_cmpleft (void const *a, void const *b) { - return ((diuint const *)a)->left - ((diuint const *)b)->left ; + return ((disize const *)a)->left - ((disize const *)b)->left ; } -static void diuintalloc_normalize (genalloc *list) +static void disizealloc_normalize (genalloc *list) { size_t i = 1, cur = 0 ; - size_t len = genalloc_len(diuint, list) ; - register diuint *const s = genalloc_s(diuint, list) ; - qsort(s, len, sizeof(diuint), &diuint_cmpleft) ; + size_t len = genalloc_len(disize, list) ; + disize *const s = genalloc_s(disize, list) ; + qsort(s, len, sizeof(disize), &disize_cmpleft) ; for (; i < len ; i++) if (!s[cur].right) break ; else if (s[i].left > s[cur].right) s[++cur] = s[i] ; else if (s[cur].right < s[i].right) s[cur].right = s[i].right ; - genalloc_setlen(diuint, list, cur+1) ; + genalloc_setlen(disize, list, cur+1) ; } static void scanlist (genalloc *list, char const *s) { - register size_t i = 0 ; - genalloc_setlen(diuint, list, 0) ; + size_t i = 0 ; + genalloc_setlen(disize, list, 0) ; while (s[i]) { char const sep[4] = ", \t" ; - diuint iv ; + disize iv ; if (s[i] == '-') iv.left = 1 ; else { - size_t j = uint_scan(s+i, &iv.left) ; + size_t j = size_scan(s+i, &iv.left) ; if (!j || !iv.left) strerr_dief2x(100, "invalid list argument: ", s) ; i += j ; } if (s[i] != '-') iv.right = iv.left ; else { - size_t j = uint_scan(s + ++i, &iv.right) ; + size_t j = size_scan(s + ++i, &iv.right) ; if (!j) iv.right = 0 ; else if (iv.right < iv.left) strerr_dief2x(100, "invalid list argument: ", s) ; @@ -68,12 +67,12 @@ static void scanlist (genalloc *list, char const *s) case 4 : strerr_dief2x(100, "invalid list argument: ", s) ; } - if (!genalloc_append(diuint, list, &iv)) + if (!genalloc_append(disize, list, &iv)) strerr_diefu1sys(111, "build interval list") ; } } -static int doit (int fd, diuint const *s, size_t len, unsigned int flags, char delim) +static int doit (int fd, disize const *s, size_t len, unsigned int flags, char delim) { char buf[BUFFER_INSIZE] ; buffer b = BUFFER_INIT(&buffer_flush1read, fd, buf, BUFFER_INSIZE) ; @@ -86,10 +85,10 @@ static int doit (int fd, diuint const *s, size_t len, unsigned int flags, char d if (!r) break ; if (flags & 2) { - register size_t i = 0 ; + size_t i = 0 ; for (; i < len ; i++) { - register size_t j = s[i].right ; + size_t j = s[i].right ; if (s[i].left >= satmp.len) break ; if (!j || (j > satmp.len)) { @@ -102,7 +101,7 @@ static int doit (int fd, diuint const *s, size_t len, unsigned int flags, char d } else { - register size_t i = 0, j = 0, count = 1 ; + size_t i = 0, j = 0, count = 1 ; for (; i < len ; i++) { for (; count < s[i].left ; count++) @@ -123,7 +122,7 @@ static int doit (int fd, diuint const *s, size_t len, unsigned int flags, char d } for (; !s[i].right || (count <= s[i].right) ; count++) { - register size_t k = byte_chr(satmp.s + j, satmp.len - j, delim) ; + size_t k = byte_chr(satmp.s + j, satmp.len - j, delim) ; if ((count > s[0].left) && (buffer_put(buffer_1, &delim, 1) < 0)) return 0 ; if (buffer_put(buffer_1, satmp.s + j, k) < 0) return 0 ; j += k ; @@ -144,7 +143,7 @@ static int doit (int fd, diuint const *s, size_t len, unsigned int flags, char d int main (int argc, char const *const *argv) { - genalloc list = GENALLOC_ZERO ; /* array of diuint */ + genalloc list = GENALLOC_ZERO ; /* array of disize */ char delim = '\t' ; unsigned int what = 0 ; PROG = "s6-cut" ; @@ -153,7 +152,7 @@ int main (int argc, char const *const *argv) int flagnodel = 1 ; for (;;) { - register int opt = subgetopt_r(argc, argv, "nsb:c:f:d:", &l) ; + int opt = subgetopt_r(argc, argv, "nsb:c:f:d:", &l) ; if (opt == -1) break ; switch (opt) { @@ -181,12 +180,12 @@ int main (int argc, char const *const *argv) what += flagnodel ; argc -= l.ind ; argv += l.ind ; } - if (!genalloc_len(diuint, &list)) strerr_dieusage(100, USAGE) ; - diuintalloc_normalize(&list) ; + if (!genalloc_len(disize, &list)) strerr_dieusage(100, USAGE) ; + disizealloc_normalize(&list) ; if (!argc) { - if (!doit(0, genalloc_s(diuint, &list), genalloc_len(diuint, &list), what, delim)) + if (!doit(0, genalloc_s(disize, &list), genalloc_len(disize, &list), what, delim)) strerr_diefu1sys(111, "cut stdin") ; } else @@ -195,7 +194,7 @@ int main (int argc, char const *const *argv) { if ((argv[0][0] == '-') && !argv[0][1]) { - if (!doit(0, genalloc_s(diuint, &list), genalloc_len(diuint, &list), what, delim)) + if (!doit(0, genalloc_s(disize, &list), genalloc_len(disize, &list), what, delim)) strerr_diefu1sys(111, "process stdin") ; } else @@ -203,7 +202,7 @@ int main (int argc, char const *const *argv) int fd = open_readb(*argv) ; if (fd == -1) strerr_diefu3sys(111, "open ", *argv, " for reading") ; - if (!doit(fd, genalloc_s(diuint, &list), genalloc_len(diuint, &list), what, delim)) + if (!doit(fd, genalloc_s(disize, &list), genalloc_len(disize, &list), what, delim)) strerr_diefu2sys(111, "cut ", *argv) ; fd_close(fd) ; } diff --git a/src/skaembutils/s6-dirname.c b/src/skaembutils/s6-dirname.c index 5883180..9bc089d 100644 --- a/src/skaembutils/s6-dirname.c +++ b/src/skaembutils/s6-dirname.c @@ -1,8 +1,8 @@ /* ISC license. */ +#include <string.h> #include <skalibs/sgetopt.h> #include <skalibs/allreadwrite.h> -#include <skalibs/bytestr.h> #include <skalibs/strerr2.h> #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> @@ -18,7 +18,7 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "n", &l) ; + int opt = subgetopt_r(argc, argv, "n", &l) ; if (opt == -1) break ; switch (opt) { @@ -30,7 +30,7 @@ int main (int argc, char const *const *argv) } if (!argc) strerr_dieusage(100, USAGE) ; - if (!sadirname(&sa, argv[0], str_len(argv[0]))) + if (!sadirname(&sa, argv[0], strlen(argv[0]))) strerr_diefu2sys(111, "get dirname of ", argv[0]) ; if (nl && !stralloc_catb(&sa, "\n", 1)) strerr_diefu2sys(111, "get dirname of ", argv[0]) ; diff --git a/src/skaembutils/s6-dumpenv.c b/src/skaembutils/s6-dumpenv.c index 7439c51..55028b3 100644 --- a/src/skaembutils/s6-dumpenv.c +++ b/src/skaembutils/s6-dumpenv.c @@ -1,9 +1,9 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <sys/stat.h> #include <errno.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/bytestr.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> @@ -22,7 +22,7 @@ int main (int argc, char const *const *argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "m:", &l) ; + int opt = subgetopt_r(argc, argv, "m:", &l) ; if (opt == -1) break ; switch (opt) { @@ -46,17 +46,17 @@ int main (int argc, char const *const *argv, char const *const *envp) strerr_diefu2sys(111, "mkdir ", argv[0]) ; } } - dirlen = str_len(argv[0]) ; + dirlen = strlen(argv[0]) ; for (; *envp ; envp++) { size_t varlen = str_chr(*envp, '=') ; char fn[dirlen + varlen + 2] ; - byte_copy(fn, dirlen, argv[0]) ; + memcpy(fn, argv[0], dirlen) ; fn[dirlen] = '/' ; - byte_copy(fn + dirlen + 1, varlen, *envp) ; + memcpy(fn + dirlen + 1, *envp, varlen) ; fn[dirlen + 1 + varlen] = 0 ; - if (!openwritenclose_suffix(fn, *envp + varlen + 1, str_len(*envp + varlen + 1), "=.tmp")) + if (!openwritenclose_suffix(fn, *envp + varlen + 1, strlen(*envp + varlen + 1), "=.tmp")) strerr_diefu2sys(111, "open ", fn) ; } return 0 ; diff --git a/src/skaembutils/s6-echo.c b/src/skaembutils/s6-echo.c index 6d30576..5d8f665 100644 --- a/src/skaembutils/s6-echo.c +++ b/src/skaembutils/s6-echo.c @@ -15,7 +15,7 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "ns:", &l) ; + int opt = subgetopt_r(argc, argv, "ns:", &l) ; if (opt == -1) break ; switch (opt) { @@ -28,9 +28,9 @@ int main (int argc, char const *const *argv) } for ( ; *argv ; argv++) if ((buffer_puts(buffer_1small, *argv) < 0) - || (argv[1] && (buffer_put(buffer_1small, &sep, 1) == -1))) + || (argv[1] && (buffer_put(buffer_1small, &sep, 1) < 0))) goto err ; - if (donl && (buffer_put(buffer_1small, "\n", 1) == -1)) goto err ; + if (donl && (buffer_put(buffer_1small, "\n", 1) < 0)) goto err ; if (!buffer_flush(buffer_1small)) goto err ; return 0 ; err: diff --git a/src/skaembutils/s6-env.c b/src/skaembutils/s6-env.c index b2e1312..8db6288 100644 --- a/src/skaembutils/s6-env.c +++ b/src/skaembutils/s6-env.c @@ -1,8 +1,8 @@ /* ISC license. */ +#include <string.h> #include <errno.h> #include <skalibs/sgetopt.h> -#include <skalibs/bytestr.h> #include <skalibs/strerr2.h> #include <skalibs/env.h> #include <skalibs/djbunix.h> @@ -20,7 +20,7 @@ int main (int argc, char const *const *argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "i", &l) ; + int opt = subgetopt_r(argc, argv, "i", &l) ; if (opt == -1) break ; switch (opt) { @@ -32,7 +32,7 @@ int main (int argc, char const *const *argv, char const *const *envp) } for (; argc ; argc--, argv++) { - if (!(*argv)[str_chr(*argv, '=')]) break ; + if (!strchr(*argv, '=')) break ; if (!stralloc_cats(&modifs, *argv) || !stralloc_0(&modifs)) strerr_diefu1sys(111, "stralloc_cats") ; } diff --git a/src/skaembutils/s6-expr.c b/src/skaembutils/s6-expr.c index accb0e6..a36f422 100644 --- a/src/skaembutils/s6-expr.c +++ b/src/skaembutils/s6-expr.c @@ -1,11 +1,8 @@ /* ISC license. */ -#include <sys/types.h> -#include <unistd.h> +#include <string.h> #include <skalibs/allreadwrite.h> -#include <skalibs/bytestr.h> -#include <skalibs/ulong.h> -#include <skalibs/fmtscan.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #define USAGE "s6-expr arithmetic expression" @@ -68,13 +65,13 @@ static unsigned int lex (struct node *tree, char const *const *argv) { "&", T_AND, 5 }, { 0, 0, 0 } } ; - register unsigned int pos = 0 ; + unsigned int pos = 0 ; for (; argv[pos] ; pos++) { - register unsigned int i = 0 ; + unsigned int i = 0 ; for (i = 0 ; tokens[i].string ; i++) - if (!str_diff(argv[pos], tokens[i].string)) + if (!strcmp(argv[pos], tokens[i].string)) { tree[pos].op = tokens[i].op ; tree[pos].type = tokens[i].type ; @@ -90,7 +87,7 @@ static unsigned int lex (struct node *tree, char const *const *argv) return pos ; } -static void reduce (struct node *tree, register unsigned int *stack, register unsigned int *sp, unsigned int type) +static void reduce (struct node *tree, unsigned int *stack, unsigned int *sp, unsigned int type) { if (tree[stack[*sp-1]].type == type) { @@ -191,7 +188,7 @@ static long run (struct node const *tree, unsigned int root) int main (int argc, char const *const *argv) { - char fmt[ULONG_FMT+1] ; + char fmt[LONG_FMT] ; long val ; size_t len ; PROG = "s6-expr" ; diff --git a/src/skaembutils/s6-false.c b/src/skaembutils/s6-false.c index 0e78d8b..75f483e 100644 --- a/src/skaembutils/s6-false.c +++ b/src/skaembutils/s6-false.c @@ -1,6 +1,8 @@ /* ISC license. */ +#include <unistd.h> + int main (void) { - return 1 ; + _exit(1) ; } diff --git a/src/skaembutils/s6-format-filter.c b/src/skaembutils/s6-format-filter.c index 78e4437..afe6a21 100644 --- a/src/skaembutils/s6-format-filter.c +++ b/src/skaembutils/s6-format-filter.c @@ -22,7 +22,7 @@ int main (int argc, char const *const *argv) if (argc > 9) argc = 9 ; vars[argc+2] = 0 ; { - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < (unsigned int)argc ; i++) args[2+i] = argv[i] ; } if (!string_format(&dst, vars, format, args)) @@ -30,7 +30,7 @@ int main (int argc, char const *const *argv) for (;;) { - register int r ; + int r ; src.len = 0 ; dst.len = 0 ; r = skagetln(buffer_0f1, &src, '\n') ; diff --git a/src/skaembutils/s6-grep.c b/src/skaembutils/s6-grep.c index 0af770c..bd48cea 100644 --- a/src/skaembutils/s6-grep.c +++ b/src/skaembutils/s6-grep.c @@ -1,13 +1,13 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <errno.h> #include <regex.h> #include <string.h> #include <skalibs/bytestr.h> #include <skalibs/sgetopt.h> #include <skalibs/buffer.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/stralloc.h> #include <skalibs/skamisc.h> @@ -36,7 +36,7 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "EFicnqv", &l) ; + int opt = subgetopt_r(argc, argv, "EFicnqv", &l) ; if (opt == -1) break ; switch (opt) { @@ -57,10 +57,10 @@ int main (int argc, char const *const *argv) stralloc line = STRALLOC_ZERO ; regex_t re ; unsigned int num = 0 ; - size_t arglen = str_len(argv[0]) ; + size_t arglen = strlen(argv[0]) ; if (!flags.fixed) { - register int e = regcomp(&re, argv[0], REG_NOSUB | (flags.extended ? REG_EXTENDED : 0) | (flags.ignorecase ? REG_ICASE : 0)) ; + int e = regcomp(&re, argv[0], REG_NOSUB | (flags.extended ? REG_EXTENDED : 0) | (flags.ignorecase ? REG_ICASE : 0)) ; if (e) { char buf[256] ; @@ -71,7 +71,7 @@ int main (int argc, char const *const *argv) for (;;) { - register int r ; + int r ; line.len = 0 ; r = skagetln(buffer_0f1, &line, '\n') ; if (!r) break ; @@ -107,12 +107,12 @@ int main (int argc, char const *const *argv) if (flags.num) { char fmt[UINT_FMT] ; - register size_t n = uint_fmt(fmt, num) ; + size_t n = uint_fmt(fmt, num) ; fmt[n++] = ':' ; - if (buffer_put(buffer_1, fmt, n) < (int)n) + if (buffer_put(buffer_1, fmt, n) < (ssize_t)n) strerr_diefu1sys(111, "write to stdout") ; } - if (buffer_put(buffer_1, line.s, line.len) < (int)line.len) + if (buffer_put(buffer_1, line.s, line.len) < (ssize_t)line.len) strerr_diefu1sys(111, "write to stdout") ; } } @@ -124,7 +124,7 @@ int main (int argc, char const *const *argv) if (flags.count) { char fmt[UINT_FMT] ; - register size_t n = uint_fmt(fmt, count) ; + size_t n = uint_fmt(fmt, count) ; fmt[n++] = '\n' ; if (buffer_put(buffer_1, fmt, n) < (ssize_t)n) strerr_diefu1sys(111, "write to stdout") ; diff --git a/src/skaembutils/s6-head.c b/src/skaembutils/s6-head.c index 589ff45..196f2c8 100644 --- a/src/skaembutils/s6-head.c +++ b/src/skaembutils/s6-head.c @@ -1,11 +1,12 @@ /* ISC license. */ #include <sys/types.h> +#include <sys/uio.h> #include <errno.h> #include <skalibs/allreadwrite.h> #include <skalibs/sgetopt.h> #include <skalibs/bytestr.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/buffer.h> #include <skalibs/siovec.h> #include <skalibs/strerr2.h> @@ -22,7 +23,7 @@ static int dolines (int fd, size_t lines) char buf[BUFFER_INSIZE] ; buffer in = BUFFER_INIT(&buffer_read, fd, buf, BUFFER_INSIZE) ; buffer out = BUFFER_INIT(&buffer_write, 1, buf, BUFFER_INSIZE) ; - siovec_t v[2] ; + struct iovec v[2] ; while (lines) { size_t w = 0 ; @@ -62,7 +63,7 @@ static int safedolines (int fd, size_t lines) size_t r = allread(fd, tmp, lines) ; if ((r < lines) && (errno != EPIPE)) return 0 ; lines -= byte_count(tmp, r, '\n') ; - if (buffer_put(buffer_1, tmp, r) < (int)r) return 0 ; + if (buffer_put(buffer_1, tmp, r) < (ssize_t)r) return 0 ; } if (!buffer_flush(buffer_1)) return 0 ; return 1 ; @@ -84,7 +85,7 @@ int main (int argc, char const *const *argv) int done = 0 ; for (;;) { - register int opt = subgetopt_r(argc, argv, "S123456789n:c:", &l) ; + int opt = subgetopt_r(argc, argv, "S123456789n:c:", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/skaembutils/s6-linkname.c b/src/skaembutils/s6-linkname.c index a9425a1..72fe288 100644 --- a/src/skaembutils/s6-linkname.c +++ b/src/skaembutils/s6-linkname.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include <skalibs/bytestr.h> #include <skalibs/buffer.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> @@ -19,7 +18,7 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "nf", &l) ; + int opt = subgetopt_r(argc, argv, "nf", &l) ; if (opt == -1) break ; switch(opt) { diff --git a/src/skaembutils/s6-ln.c b/src/skaembutils/s6-ln.c index 9ed0730..59b85a4 100644 --- a/src/skaembutils/s6-ln.c +++ b/src/skaembutils/s6-ln.c @@ -6,14 +6,13 @@ #include <skalibs/nonposix.h> #endif -#include <sys/types.h> +#include <string.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> #include <stdio.h> #include <skalibs/sgetopt.h> -#include <skalibs/bytestr.h> #include <skalibs/strerr2.h> #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> @@ -54,7 +53,7 @@ static void force (char const *old, char const *new, linkfunc_t_ref doit) size_t base = satmp.len ; if (errno != EEXIST) strerr_diefu5sys(111, "make a link", " from ", new, " to ", old) ; - if (!stralloc_catb(&satmp, new, str_len(new)) + if (!stralloc_cats(&satmp, new) || !random_sauniquename(&satmp, 8) || !stralloc_0(&satmp)) strerr_diefu2sys(111, "make a unique name for ", old) ; @@ -84,7 +83,7 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "sfLP", &l) ; + int opt = subgetopt_r(argc, argv, "sfLP", &l) ; if (opt == -1) break ; switch (opt) { @@ -111,7 +110,7 @@ int main (int argc, char const *const *argv) for (; i < (unsigned int)(argc-1) ; i++) { sa.len = base ; - if (!sabasename(&sa, argv[i], str_len(argv[i]))) + if (!sabasename(&sa, argv[i], strlen(argv[i]))) strerr_diefu1sys(111, "sabasename") ; if (!stralloc_0(&sa)) strerr_diefu1sys(111, "stralloc_0") ; (*f)(argv[i], sa.s, mylink) ; @@ -138,7 +137,7 @@ int main (int argc, char const *const *argv) stralloc sa = STRALLOC_ZERO ; if (!stralloc_cats(&sa, argv[1]) || !stralloc_catb(&sa, "/", 1) - || !sabasename(&sa, argv[0], str_len(argv[0])) + || !sabasename(&sa, argv[0], strlen(argv[0])) || !stralloc_0(&sa)) strerr_diefu1sys(111, "stralloc_catb") ; (*f)(argv[0], sa.s, mylink) ; diff --git a/src/skaembutils/s6-ls.c b/src/skaembutils/s6-ls.c index 25045a7..369cede 100644 --- a/src/skaembutils/s6-ls.c +++ b/src/skaembutils/s6-ls.c @@ -18,7 +18,7 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "0aAx:", &l) ; + int opt = subgetopt_r(argc, argv, "0aAx:", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/skaembutils/s6-maximumtime.c b/src/skaembutils/s6-maximumtime.c index b5c8eab..5752d9a 100644 --- a/src/skaembutils/s6-maximumtime.c +++ b/src/skaembutils/s6-maximumtime.c @@ -1,12 +1,11 @@ /* ISC license. */ -#include <sys/types.h> #include <sys/wait.h> #include <signal.h> #include <errno.h> #include <unistd.h> #include <skalibs/sgetopt.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/error.h> #include <skalibs/sig.h> #include <skalibs/tai.h> @@ -29,7 +28,7 @@ int main (int argc, char const *const *argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "0abikqtx12", &l) ; + int opt = subgetopt_r(argc, argv, "0abikqtx12", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/skaembutils/s6-mkdir.c b/src/skaembutils/s6-mkdir.c index baec9a0..2a8fc74 100644 --- a/src/skaembutils/s6-mkdir.c +++ b/src/skaembutils/s6-mkdir.c @@ -1,12 +1,11 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <sys/stat.h> #include <unistd.h> #include <errno.h> #include <skalibs/sgetopt.h> -#include <skalibs/bytestr.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/buffer.h> #include <skalibs/strerr2.h> @@ -34,13 +33,13 @@ static int doit (char const *s, unsigned int mode, int verbose, int ee) static int doparents (char const *s, unsigned int mode, int verbose) { - size_t n = str_len(s), i = 0 ; + size_t n = strlen(s), i = 0 ; char tmp[n+1] ; for (; i < n ; i++) { if ((s[i] == '/') && i) { - register int e ; + int e ; tmp[i] = 0 ; e = doit(tmp, mode, verbose, 0) ; if (e) return e ; @@ -60,7 +59,7 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "pvm:", &l) ; + int opt = subgetopt_r(argc, argv, "pvm:", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/skaembutils/s6-mkfifo.c b/src/skaembutils/s6-mkfifo.c index 9278eb9..b728db5 100644 --- a/src/skaembutils/s6-mkfifo.c +++ b/src/skaembutils/s6-mkfifo.c @@ -1,9 +1,8 @@ /* ISC license. */ -#include <sys/types.h> #include <sys/stat.h> #include <skalibs/sgetopt.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> @@ -17,7 +16,7 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "m:", &l) ; + int opt = subgetopt_r(argc, argv, "m:", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/skaembutils/s6-nice.c b/src/skaembutils/s6-nice.c index ec9f477..29b7ff6 100644 --- a/src/skaembutils/s6-nice.c +++ b/src/skaembutils/s6-nice.c @@ -3,8 +3,7 @@ #include <unistd.h> #include <errno.h> #include <skalibs/sgetopt.h> -#include <skalibs/uint.h> -#include <skalibs/fmtscan.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> @@ -19,7 +18,7 @@ int main (int argc, char const *const *argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "Iin:", &l) ; + int opt = subgetopt_r(argc, argv, "Iin:", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/skaembutils/s6-nuke.c b/src/skaembutils/s6-nuke.c index cda1279..df6916d 100644 --- a/src/skaembutils/s6-nuke.c +++ b/src/skaembutils/s6-nuke.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include <sys/types.h> #include <signal.h> #include <errno.h> #include <skalibs/sgetopt.h> @@ -17,7 +16,7 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "htk", &l) ; + int opt = subgetopt_r(argc, argv, "htk", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/skaembutils/s6-pause.c b/src/skaembutils/s6-pause.c index df09594..760dede 100644 --- a/src/skaembutils/s6-pause.c +++ b/src/skaembutils/s6-pause.c @@ -2,7 +2,7 @@ #include <unistd.h> #include <signal.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/sig.h> @@ -16,12 +16,12 @@ int main (int argc, char const *const *argv) { PROG = "s6-pause" ; unsigned int sigs[MAX] ; - unsigned int nsig = 0 ; + size_t nsig = 0 ; { subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "thaqbip:", &l) ; + int opt = subgetopt_r(argc, argv, "thaqbip:", &l) ; if (opt == -1) break ; switch (opt) { @@ -33,7 +33,7 @@ int main (int argc, char const *const *argv) case 'i' : if (nsig >= MAX) dieusage() ; sigs[nsig++] = SIGINT ; break ; case 'p' : { - unsigned int n ; + size_t n ; if (!uint_scanlist(sigs + nsig, MAX - nsig, l.arg, &n)) dieusage() ; nsig += n ; break ; diff --git a/src/skaembutils/s6-printenv.c b/src/skaembutils/s6-printenv.c index 85a252d..9f2698e 100644 --- a/src/skaembutils/s6-printenv.c +++ b/src/skaembutils/s6-printenv.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include <skalibs/bytestr.h> +#include <string.h> #include <skalibs/sgetopt.h> #include <skalibs/buffer.h> #include <skalibs/strerr2.h> @@ -17,7 +17,7 @@ int main (int argc, char const *const *argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "nd:0", &l) ; + int opt = subgetopt_r(argc, argv, "nd:0", &l) ; if (opt == -1) break ; switch (opt) { @@ -40,8 +40,8 @@ int main (int argc, char const *const *argv, char const *const *envp) } else { - unsigned int written = 0 ; /* XXX */ - if (!netstring_put(buffer_1, *envp, str_len(*envp), &written)) + size_t written = 0 ; + if (!netstring_put(buffer_1, *envp, strlen(*envp), &written)) strerr_diefu1sys(111, "write a netstring to stdout") ; } } diff --git a/src/skaembutils/s6-quote-filter.c b/src/skaembutils/s6-quote-filter.c index 3308f22..2e26011 100644 --- a/src/skaembutils/s6-quote-filter.c +++ b/src/skaembutils/s6-quote-filter.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <errno.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> @@ -22,7 +22,7 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "ud:", &l) ; + int opt = subgetopt_r(argc, argv, "ud:", &l) ; if (opt == -1) break ; switch (opt) { @@ -33,7 +33,7 @@ int main (int argc, char const *const *argv) } argc -= l.ind ; argv += l.ind ; } - delimlen = str_len(delim) ; + delimlen = strlen(delim) ; if (startquote) { if(!delimlen) strerr_dief1x(100, "no character to quote with!") ; diff --git a/src/skaembutils/s6-quote.c b/src/skaembutils/s6-quote.c index 6925806..24662e8 100644 --- a/src/skaembutils/s6-quote.c +++ b/src/skaembutils/s6-quote.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/allreadwrite.h> @@ -21,7 +21,7 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "nud:", &l) ; + int opt = subgetopt_r(argc, argv, "nud:", &l) ; if (opt == -1) break ; switch (opt) { @@ -34,14 +34,14 @@ int main (int argc, char const *const *argv) argc -= l.ind ; argv += l.ind ; } if (!argc) strerr_dieusage(100, USAGE) ; - delimlen = str_len(delim) ; + delimlen = strlen(delim) ; if (startquote) { if (!delimlen) strerr_dief1x(100, "no character to quote with!") ; if (!stralloc_catb(&sa, delim, 1)) strerr_diefu1sys(111, "stralloc_catb") ; } - if (!string_quote_nodelim_mustquote(&sa, *argv, str_len(*argv), delim, delimlen)) + if (!string_quote_nodelim_mustquote(&sa, *argv, strlen(*argv), delim, delimlen)) strerr_diefu1sys(111, "quote") ; if (startquote) { diff --git a/src/skaembutils/s6-rename.c b/src/skaembutils/s6-rename.c index 55c92fa..19fd7e0 100644 --- a/src/skaembutils/s6-rename.c +++ b/src/skaembutils/s6-rename.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include <unistd.h> #include <stdio.h> #include <skalibs/strerr2.h> diff --git a/src/skaembutils/s6-seq.c b/src/skaembutils/s6-seq.c index db319e6..66be435 100644 --- a/src/skaembutils/s6-seq.c +++ b/src/skaembutils/s6-seq.c @@ -1,7 +1,7 @@ /* ISC license. */ -#include <sys/types.h> -#include <skalibs/uint.h> +#include <string.h> +#include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/buffer.h> #include <skalibs/strerr2.h> @@ -20,12 +20,12 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "ws:", &l) ; + int opt = subgetopt_r(argc, argv, "ws:", &l) ; if (opt == -1) break ; switch (opt) { case 'w': fixed = 1 ; break ; - case 's': sep = l.arg ; seplen = str_len(sep) ; break ; + case 's': sep = l.arg ; seplen = strlen(sep) ; break ; default : dieusage() ; } } diff --git a/src/skaembutils/s6-sleep.c b/src/skaembutils/s6-sleep.c index ea25514..5519d0d 100644 --- a/src/skaembutils/s6-sleep.c +++ b/src/skaembutils/s6-sleep.c @@ -1,9 +1,8 @@ /* ISC license. */ -#include <unistd.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/tai.h> #include <skalibs/djbunix.h> #include <skalibs/iopause.h> @@ -19,7 +18,7 @@ int main (int argc, char const *const *argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "m", &l) ; + int opt = subgetopt_r(argc, argv, "m", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/skaembutils/s6-sort.c b/src/skaembutils/s6-sort.c index ec22e0d..a603d2e 100644 --- a/src/skaembutils/s6-sort.c +++ b/src/skaembutils/s6-sort.c @@ -1,6 +1,5 @@ /* ISC license. */ -#include <sys/types.h> #include <string.h> #include <strings.h> #include <stdlib.h> @@ -25,9 +24,9 @@ static int flagnoblanks = 0, flagreverse = 0, flaguniq = 0 ; static strncmp_t_ref comp = &strncmp ; -static int compit (register char const *s1, register size_t n1, register char const *s2, register size_t n2) +static int compit (char const *s1, size_t n1, char const *s2, size_t n2) { - register int r ; + int r ; if (flagnoblanks) { while ((*s1 == ' ') || (*s1 == '\t')) (s1++, n1--) ; @@ -62,15 +61,15 @@ static ssize_t slurplines (genalloc *lines, char sep) static void uniq (genalloc *lines) { size_t len = genalloc_len(stralloc, lines) ; - register stralloc *s = genalloc_s(stralloc, lines) ; - register size_t i = 1 ; + stralloc *s = genalloc_s(stralloc, lines) ; + size_t i = 1 ; for (; i < len ; i++) if (!sacmp(s+i-1, s+i)) stralloc_free(s+i-1) ; } static ssize_t outputlines (stralloc const *s, size_t len) { - register size_t i = 0 ; + size_t i = 0 ; for (; i < len ; i++) if (buffer_put(buffer_1, s[i].s, s[i].len) < 0) return 0 ; return buffer_flush(buffer_1) ; @@ -78,7 +77,7 @@ static ssize_t outputlines (stralloc const *s, size_t len) static int check (stralloc const *s, size_t len) { - register size_t i = 1 ; + size_t i = 1 ; for (; i < len ; i++) if (sacmp(s+i-1, s+i) >= !flaguniq) return 0 ; return 1 ; @@ -94,7 +93,7 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "bcfru0", &l) ; + int opt = subgetopt_r(argc, argv, "bcfru0", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/skaembutils/s6-sync.c b/src/skaembutils/s6-sync.c index a8829cd..34e3e73 100644 --- a/src/skaembutils/s6-sync.c +++ b/src/skaembutils/s6-sync.c @@ -5,5 +5,5 @@ int main (void) { sync() ; - return 0 ; + _exit(0) ; } diff --git a/src/skaembutils/s6-tail.c b/src/skaembutils/s6-tail.c index 4c71f9c..479f950 100644 --- a/src/skaembutils/s6-tail.c +++ b/src/skaembutils/s6-tail.c @@ -1,11 +1,11 @@ /* ISC license. */ #include <sys/types.h> +#include <sys/uio.h> #include <errno.h> #include <skalibs/sgetopt.h> #include <skalibs/allreadwrite.h> -#include <skalibs/bytestr.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/buffer.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> @@ -23,14 +23,14 @@ static int pluslines (int fd, size_t n) { char buf[BUFFER_INSIZE] ; buffer b = BUFFER_INIT(&buffer_read, fd, buf, BUFFER_INSIZE) ; - unsigned int count = 0 ; + size_t count = 0 ; while (count < n) { - register ssize_t r = buffer_fill(&b) ; + ssize_t r = buffer_fill(&b) ; if (r <= 0) return !r ; while (!buffer_isempty(&b) && (count < n)) { - siovec_t v[2] ; + struct iovec v[2] ; size_t i ; buffer_rpeek(&b, v) ; i = siovec_bytechr(v, 2, '\n') ; @@ -56,7 +56,7 @@ static int pluschars (int fd, size_t n) if (nil < 0) return 0 ; if (!fd_catn(fd, nil, n)) { - register int e = errno ; + int e = errno ; fd_close(nil) ; errno = e ; return 0 ; @@ -76,7 +76,7 @@ static int minuslines (int fd, size_t n) head = 0 ; for (;;) { - register int r ; + int r ; r = skagetln(&b, tab + tail, '\n') ; if (!r) break ; if (r < 0) @@ -110,7 +110,7 @@ static int minuschars (int fd, size_t n) buffer b = BUFFER_INIT(&buffer_read, fd, buf, BUFFER_INSIZE + n) ; for (;;) { - register ssize_t r = buffer_fill(&b) ; + ssize_t r = buffer_fill(&b) ; if (!r) break ; if (r < 0) return 0 ; buffer_rseek(&b, buffer_len(&b)) ; @@ -131,7 +131,7 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "123456789n:c:", &l) ; + int opt = subgetopt_r(argc, argv, "123456789n:c:", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/skaembutils/s6-test.c b/src/skaembutils/s6-test.c index 36b7b15..d2d3b76 100644 --- a/src/skaembutils/s6-test.c +++ b/src/skaembutils/s6-test.c @@ -1,11 +1,9 @@ /* ISC license. */ -#include <sys/types.h> #include <sys/stat.h> #include <unistd.h> -#include <skalibs/uint.h> -#include <skalibs/bytestr.h> -#include <skalibs/fmtscan.h> +#include <string.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/env.h> #include <skalibs/djbunix.h> @@ -124,14 +122,14 @@ static unsigned int lex (struct node *tree, char const *const *argv) { "-v", T_ENV, 2 }, { 0, 0, 0 } } ; - register unsigned int pos = 0 ; + unsigned int pos = 0 ; for (; argv[pos] ; pos++) { unsigned int i = 0 ; tree[pos].data = argv[pos] ; for (i = 0 ; tokens[i].string ; i++) - if (!str_diff(argv[pos], tokens[i].string)) + if (!strcmp(argv[pos], tokens[i].string)) { tree[pos].op = tokens[i].op ; tree[pos].type = tokens[i].type ; @@ -433,17 +431,17 @@ static int run (struct node const *tree, unsigned int root) case T_ZERO : return !tree[tree[root].arg1].data[0] ; case T_STREQUAL : - return !str_diff(tree[tree[root].arg1].data, tree[tree[root].arg2].data) ; + return !strcmp(tree[tree[root].arg1].data, tree[tree[root].arg2].data) ; case T_STRNEQUAL : - return !!str_diff(tree[tree[root].arg1].data, tree[tree[root].arg2].data) ; + return !!strcmp(tree[tree[root].arg1].data, tree[tree[root].arg2].data) ; case T_STRLESSER : - return str_diff(tree[tree[root].arg1].data, tree[tree[root].arg2].data) < 0 ; + return strcmp(tree[tree[root].arg1].data, tree[tree[root].arg2].data) < 0 ; case T_STRLESSERE : - return str_diff(tree[tree[root].arg1].data, tree[tree[root].arg2].data) <= 0 ; + return strcmp(tree[tree[root].arg1].data, tree[tree[root].arg2].data) <= 0 ; case T_STRGREATER : - return str_diff(tree[tree[root].arg1].data, tree[tree[root].arg2].data) > 0 ; + return strcmp(tree[tree[root].arg1].data, tree[tree[root].arg2].data) > 0 ; case T_STRGREATERE : - return str_diff(tree[tree[root].arg1].data, tree[tree[root].arg2].data) >= 0 ; + return strcmp(tree[tree[root].arg1].data, tree[tree[root].arg2].data) >= 0 ; case T_NUMEQUAL : { int n1, n2 ; diff --git a/src/skaembutils/s6-true.c b/src/skaembutils/s6-true.c index 65c3af4..f372d43 100644 --- a/src/skaembutils/s6-true.c +++ b/src/skaembutils/s6-true.c @@ -1,6 +1,8 @@ /* ISC license. */ -int main () +#include <unistd.h> + +int main (void) { - return 0 ; + _exit(0) ; } diff --git a/src/skaembutils/s6-uniquename.c b/src/skaembutils/s6-uniquename.c index 2ac3adb..b3abfe3 100644 --- a/src/skaembutils/s6-uniquename.c +++ b/src/skaembutils/s6-uniquename.c @@ -2,7 +2,7 @@ #include <skalibs/allreadwrite.h> #include <skalibs/sgetopt.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/stralloc.h> #include <skalibs/skamisc.h> @@ -20,7 +20,7 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "n:", &l) ; + int opt = subgetopt_r(argc, argv, "n:", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/skaembutils/s6-unquote-filter.c b/src/skaembutils/s6-unquote-filter.c index 887b517..edf2682 100644 --- a/src/skaembutils/s6-unquote-filter.c +++ b/src/skaembutils/s6-unquote-filter.c @@ -1,10 +1,9 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <errno.h> #include <skalibs/sgetopt.h> -#include <skalibs/bytestr.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/buffer.h> #include <skalibs/stralloc.h> @@ -18,11 +17,11 @@ static size_t delimlen = 1 ; static void fillfmt (char *fmt, char const *s, size_t len) { - register size_t n = len < 39 ? len+1 : 36 ; - byte_copy(fmt, n, s) ; + size_t n = len < 39 ? len+1 : 36 ; + memcpy(fmt, s, n) ; if (len >= 39) { - byte_copy(fmt+n, 3, "...") ; + memcpy(fmt+n, "...", 3) ; n += 3 ; } fmt[n] = 0 ; @@ -47,7 +46,7 @@ static int doit (char const *s, size_t len) } return 1 ; } - if (byte_chr(delim, delimlen, *s) >= delimlen) + if (!memchr(delim, delimlen, *s)) { switch (strictness) { @@ -74,7 +73,7 @@ static int doit (char const *s, size_t len) } } { - unsigned int r, w ; /* XXX */ + size_t r, w ; char d[len] ; if (!string_unquote_withdelim(d, &w, s + !!delimlen, len - !!delimlen, &r, delim, delimlen)) { @@ -134,16 +133,16 @@ static int doit (char const *s, size_t len) } else if ((r+2 < len) && (strictness >= 2)) { - char fmtnum[UINT_FMT] ; - char fmtden[UINT_FMT] ; + char fmtnum[SIZE_FMT] ; + char fmtden[SIZE_FMT] ; char fmt[40] ; fillfmt(fmt, s, len) ; - fmtnum[uint_fmt(fmtnum, r+1)] = 0 ; - fmtden[uint_fmt(fmtden, len-1)] = 0 ; + fmtnum[size_fmt(fmtnum, r+1)] = 0 ; + fmtden[size_fmt(fmtden, len-1)] = 0 ; strerr_warnw7x("found ending quote character at position ", fmtnum, "/", fmtden, ", ignoring remainder of ", "line: ", fmt) ; } } - if (buffer_put(buffer_1, d, w) < (int)w) + if (buffer_put(buffer_1, d, w) < (ssize_t)w) strerr_diefu1sys(111, "write to stdout") ; } return 1 ; @@ -158,7 +157,7 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "qQvwd:", &l) ; + int opt = subgetopt_r(argc, argv, "qQvwd:", &l) ; if (opt == -1) break ; switch (opt) { @@ -172,7 +171,7 @@ int main (int argc, char const *const *argv) } argc -= l.ind ; argv += l.ind ; } - delimlen = str_len(delim) ; + delimlen = strlen(delim) ; for (;;) { int r ; @@ -186,7 +185,7 @@ int main (int argc, char const *const *argv) else src.len-- ; if (!doit(src.s, src.len)) { - if (buffer_put(buffer_1, src.s, src.len) < (int)src.len) + if (buffer_put(buffer_1, src.s, src.len) < (ssize_t)src.len) strerr_diefu1sys(111, "write to stdout") ; } if (r > 0) diff --git a/src/skaembutils/s6-unquote.c b/src/skaembutils/s6-unquote.c index 1da51e8..3bca196 100644 --- a/src/skaembutils/s6-unquote.c +++ b/src/skaembutils/s6-unquote.c @@ -1,9 +1,8 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <skalibs/sgetopt.h> -#include <skalibs/bytestr.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/allreadwrite.h> #include <skalibs/skamisc.h> @@ -21,7 +20,7 @@ int main (int argc, char const *const *argv) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "nd:", &l) ; + int opt = subgetopt_r(argc, argv, "nd:", &l) ; if (opt == -1) break ; switch (opt) { @@ -34,21 +33,21 @@ int main (int argc, char const *const *argv) } if (!argc) strerr_dieusage(100, USAGE) ; string = *argv ; - len = str_len(string) ; - delimlen = str_len(delim) ; + len = strlen(string) ; + delimlen = strlen(delim) ; if (delimlen) { if (!len--) strerr_dief1x(100, "the empty string isn't a quoted string") ; - if (byte_chr(delim, delimlen, *string++) >= delimlen) + if (!memchr(delim, *string++, delimlen)) strerr_dief1x(100, "invalid starting quote character") ; } { - unsigned int r = 0, w = 0 ; /* XXX */ + size_t r = 0, w = 0 ; char buf[len+1] ; if (!string_unquote_withdelim(buf, &w, string, len, &r, delim, delimlen)) { - char fmt[UINT_FMT] ; - fmt[uint_fmt(fmt, r + !!delimlen)] = 0 ; + char fmt[SIZE_FMT] ; + fmt[size_fmt(fmt, r + !!delimlen)] = 0 ; strerr_diefu2sys(100, "unquote at character ", fmt) ; } if (delimlen) @@ -56,10 +55,10 @@ int main (int argc, char const *const *argv) if (r == len) strerr_dief1x(100, "no ending quote character") ; else if (r < len - 1) { - char fmtnum[UINT_FMT] ; - char fmtden[UINT_FMT] ; - fmtnum[uint_fmt(fmtnum, r+1)] = 0 ; - fmtden[uint_fmt(fmtden, len)] = 0 ; + char fmtnum[SIZE_FMT] ; + char fmtden[SIZE_FMT] ; + fmtnum[size_fmt(fmtnum, r+1)] = 0 ; + fmtden[size_fmt(fmtden, len)] = 0 ; strerr_warnw5x("found ending quote character at position ", fmtnum, "/", fmtden, "; ignoring remainder") ; } } diff --git a/src/skaembutils/s6-update-symlinks.c b/src/skaembutils/s6-update-symlinks.c index b99317b..7ef3eb5 100644 --- a/src/skaembutils/s6-update-symlinks.c +++ b/src/skaembutils/s6-update-symlinks.c @@ -1,11 +1,10 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <sys/stat.h> #include <unistd.h> #include <errno.h> #include <stdio.h> -#include <skalibs/bytestr.h> #include <skalibs/direntry.h> #include <skalibs/strerr2.h> #include <skalibs/stralloc.h> @@ -39,7 +38,7 @@ struct stralloc3 static void cleanup (stralloc *sa, unsigned int pos) { - register int e = errno ; + int e = errno ; rm_rf_in_tmp(sa, pos) ; errno = e ; } @@ -47,7 +46,7 @@ static void cleanup (stralloc *sa, unsigned int pos) static int makeuniquename (stralloc *sa, char const *path, char const *magic) { - unsigned int base = sa->len ; + size_t base = sa->len ; int wasnull = !sa->s ; if (!stralloc_cats(sa, path)) return 0 ; if (!stralloc_cats(sa, magic)) goto err ; @@ -76,7 +75,7 @@ static int addlink (stralloc3 *blah, unsigned int dstpos, unsigned int srcpos) int collect = 1 ; { - register size_t n = str_len(blah->dst.s + dstpos) ; + size_t n = strlen(blah->dst.s + dstpos) ; if (!stralloc_readyplus(&blah->dst, n+1)) return ERROR ; stralloc_catb(&blah->dst, blah->dst.s + dstpos, n) ; } @@ -98,7 +97,7 @@ static int addlink (stralloc3 *blah, unsigned int dstpos, unsigned int srcpos) r = sareadlink(&blah->src, blah->dst.s + dstpos) ; if ((r == -1) && (errno != EINVAL)) { - register int e = errno ; + int e = errno ; blah->dst.len = dstbase ; dir_close(dir) ; errno = e ; @@ -108,7 +107,7 @@ static int addlink (stralloc3 *blah, unsigned int dstpos, unsigned int srcpos) { for (;;) { - register direntry *d ; + direntry *d ; errno = 0 ; d = readdir(dir) ; if (!d) break ; @@ -118,7 +117,7 @@ static int addlink (stralloc3 *blah, unsigned int dstpos, unsigned int srcpos) } if (errno) { - register int e = errno ; + int e = errno ; blah->src.len = srcbase ; blah->dst.len = dstbase ; dir_close(dir) ; @@ -130,7 +129,7 @@ static int addlink (stralloc3 *blah, unsigned int dstpos, unsigned int srcpos) || (mkdir(blah->dst.s + dstpos, 0777) == -1) || !stralloc_catb(&blah->src, "/", 1)) { - register int e = errno ; + int e = errno ; blah->src.len = srcbase ; blah->dst.len = dstbase ; dir_close(dir) ; @@ -142,7 +141,7 @@ static int addlink (stralloc3 *blah, unsigned int dstpos, unsigned int srcpos) srcstop = blah->src.len ; for (;;) { - register direntry *d ; + direntry *d ; errno = 0 ; d = readdir(dir) ; if (!d) break ; @@ -155,7 +154,7 @@ static int addlink (stralloc3 *blah, unsigned int dstpos, unsigned int srcpos) || !stralloc_cats(&blah->src, d->d_name) || !stralloc_0(&blah->src) || (symlink(blah->src.s + srcbase, blah->dst.s + dstbase) == -1)) { - register int e = errno ; + int e = errno ; blah->src.len = srcbase ; blah->dst.len = dstbase ; dir_close(dir) ; @@ -165,7 +164,7 @@ static int addlink (stralloc3 *blah, unsigned int dstpos, unsigned int srcpos) } if (errno) { - register int e = errno ; + int e = errno ; blah->src.len = srcbase ; blah->dst.len = dstbase ; dir_close(dir) ; @@ -178,7 +177,7 @@ static int addlink (stralloc3 *blah, unsigned int dstpos, unsigned int srcpos) blah->src.len = srcbase ; { - register size_t n = str_len(blah->src.s + srcpos) ; + size_t n = strlen(blah->src.s + srcpos) ; if (!stralloc_readyplus(&blah->src, n+1)) { blah->dst.len = dstbase ; @@ -207,7 +206,7 @@ static int addlink (stralloc3 *blah, unsigned int dstpos, unsigned int srcpos) } for (;;) { - register direntry *d ; + direntry *d ; errno = 0 ; d = readdir(dir) ; if (!d) break ; @@ -215,7 +214,7 @@ static int addlink (stralloc3 *blah, unsigned int dstpos, unsigned int srcpos) continue ; if (!stralloc_cats(&blah->tmp, d->d_name) || !stralloc_0(&blah->tmp)) { - register int e = errno ; + int e = errno ; blah->tmp.len = tmpbase ; blah->src.len = srcbase ; blah->dst.len = dstbase ; @@ -226,7 +225,7 @@ static int addlink (stralloc3 *blah, unsigned int dstpos, unsigned int srcpos) } if (errno) { - register int e = errno ; + int e = errno ; blah->tmp.len = tmpbase ; blah->src.len = srcbase ; blah->dst.len = dstbase ; @@ -248,7 +247,7 @@ static int addlink (stralloc3 *blah, unsigned int dstpos, unsigned int srcpos) blah->dst.len = dststop ; blah->src.len = srcstop ; { - register size_t n = str_len(blah->tmp.s + i) + 1 ; + size_t n = strlen(blah->tmp.s + i) + 1 ; if (!stralloc_catb(&blah->dst, blah->tmp.s + i, n) || !stralloc_catb(&blah->src, blah->tmp.s + i, n)) { @@ -299,11 +298,11 @@ int main (int argc, char *const *argv) PROG = "s6-update-symlinks" ; if (argc < 3) strerr_dieusage(100, USAGE) ; { - register char *const *p = argv + 1 ; + char *const *p = argv + 1 ; for (; *p ; p++) if (**p != '/') strerr_dieusage(100, USAGE) ; } { - register size_t i = str_len(argv[1]) ; + size_t i = strlen(argv[1]) ; while (i && (argv[1][i-1] == '/')) argv[1][--i] = 0 ; if (!i) strerr_diefu1x(100, "replace root directory") ; } @@ -318,7 +317,7 @@ int main (int argc, char *const *argv) char *const *p = argv + 2 ; for (; *p ; p++) { - register int r ; + int r ; blah.src.len = 0 ; if (!stralloc_cats(&blah.src, *p) || !stralloc_0(&blah.src)) strerr_diefu1sys(111, "make stralloc") ; |