diff options
49 files changed, 189 insertions, 252 deletions
diff --git a/src/execline/background.c b/src/execline/background.c index 79771af..4635146 100644 --- a/src/execline/background.c +++ b/src/execline/background.c @@ -2,14 +2,11 @@ #include <sys/types.h> #include <unistd.h> -#ifdef EXECLINE_OLD_VARNAMES -#include <skalibs/bytestr.h> -#endif #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/env.h> #include <skalibs/djbunix.h> -#include <skalibs/uint64.h> +#include <skalibs/types.h> #include <execline/execline.h> #define USAGE "background [ -d ] { command... }" @@ -24,7 +21,7 @@ int main (int argc, char const **argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "d", &l) ; + int opt = subgetopt_r(argc, argv, "d", &l) ; if (opt == -1) break ; switch (opt) { @@ -59,17 +56,9 @@ int main (int argc, char const **argv, char const *const *envp) } if (argc1 + 1 == argc) return 0 ; { -#ifdef EXECLINE_OLD_VARNAMES - char fmt[UINT64_FMT * 2 + 10] = "!=" ; -#else - char fmt[UINT64_FMT + 2] = "!=" ; -#endif - register size_t i = 2 ; - i += uint64_fmt(fmt+i, (uint64)pid) ; fmt[i++] = 0 ; -#ifdef EXECLINE_OLD_VARNAMES - byte_copy(fmt+i, 8, "LASTPID=") ; i += 8 ; - i += uint64_fmt(fmt+i, (uint64)pid) ; fmt[i++] = 0 ; -#endif + char fmt[PID_FMT + 2] = "!=" ; + size_t i = 2 ; + i += pid_fmt(fmt+i, pid) ; fmt[i++] = 0 ; pathexec_r(argv + argc1 + 1, envp, env_len(envp), fmt, i) ; } strerr_dieexec(111, argv[argc1+1]) ; diff --git a/src/execline/backtick.c b/src/execline/backtick.c index 5ab4dfa..e3f93c5 100644 --- a/src/execline/backtick.c +++ b/src/execline/backtick.c @@ -1,9 +1,8 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <sys/wait.h> #include <unistd.h> -#include <skalibs/bytestr.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/stralloc.h> @@ -25,7 +24,7 @@ int main (int argc, char const **argv, char const *const *envp) PROG = "backtick" ; for (;;) { - register int opt = subgetopt_r(argc, argv, "iInD:", &localopt) ; + int opt = subgetopt_r(argc, argv, "iInD:", &localopt) ; if (opt < 0) break ; switch (opt) { @@ -74,7 +73,7 @@ int main (int argc, char const **argv, char const *const *envp) if (argc1 == argc - 1) return 0 ; if (!stralloc_0(&modif)) strerr_diefu1sys(111, "stralloc_catb") ; { - size_t reallen = str_len(modif.s) ; + size_t reallen = strlen(modif.s) ; if (reallen < modif.len - 1) { if (insist >= 2) @@ -88,7 +87,7 @@ int main (int argc, char const **argv, char const *const *envp) else if (def) { modif.len = modifstart ; - if (!stralloc_catb(&modif, def, str_len(def)+1)) + if (!stralloc_catb(&modif, def, strlen(def)+1)) strerr_diefu1sys(111, "stralloc_catb") ; strerr_warnw2x("child process output contained a null character", " - using default instead") ; } diff --git a/src/execline/dollarat.c b/src/execline/dollarat.c index 1f257d0..04fe51c 100644 --- a/src/execline/dollarat.c +++ b/src/execline/dollarat.c @@ -1,12 +1,11 @@ /* ISC license. */ -#include <sys/types.h> -#include <skalibs/bytestr.h> +#include <string.h> #include <skalibs/sgetopt.h> #include <skalibs/buffer.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/netstring.h> #define USAGE "dollarat [ -n ] [ -0 | -d delimchar ]" @@ -23,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, "nd:0", &l) ; + int opt = subgetopt_r(argc, argv, "nd:0", &l) ; if (opt == -1) break ; switch (opt) { @@ -53,8 +52,8 @@ int main (int argc, char const *const *argv, char const *const *envp) } else { - unsigned int written = 0 ; /* XXX */ - if (!netstring_put(buffer_1, x, str_len(x), &written)) + size_t written = 0 ; + if (!netstring_put(buffer_1, x, strlen(x), &written)) strerr_diefu1sys(111, "write a netstring to stdout") ; } } diff --git a/src/execline/elgetopt.c b/src/execline/elgetopt.c index a48968f..b7f0362 100644 --- a/src/execline/elgetopt.c +++ b/src/execline/elgetopt.c @@ -1,13 +1,12 @@ /* ISC license. */ #include <sys/types.h> -#include <skalibs/bytestr.h> #include <skalibs/sgetopt.h> #include <skalibs/env.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> #include <skalibs/skamisc.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <execline/execline.h> #define USAGE "elgetopt optstring prog..." @@ -27,7 +26,7 @@ int main (int argc, char const *const *argv, char const *const *envp) { subgetopt_t l = SUBGETOPT_ZERO ; char const *args[n+1] ; - register unsigned int i = 0 ; + unsigned int i = 0 ; for ( ; i < n ; i++) { char fmt[UINT_FMT] ; @@ -39,7 +38,7 @@ int main (int argc, char const *const *argv, char const *const *envp) for (;;) { char hmpf[11] = "ELGETOPT_?" ; - register int opt = sgetopt_r(n, args, argv[1], &l) ; + int opt = sgetopt_r(n, args, argv[1], &l) ; if (opt == -1) break ; if (opt == '?') return 1 ; hmpf[9] = opt ; diff --git a/src/execline/emptyenv.c b/src/execline/emptyenv.c index 90d72d1..658276e 100644 --- a/src/execline/emptyenv.c +++ b/src/execline/emptyenv.c @@ -1,8 +1,7 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <skalibs/sgetopt.h> -#include <skalibs/bytestr.h> #include <skalibs/strerr2.h> #include <skalibs/stralloc.h> #include <skalibs/env.h> @@ -15,16 +14,13 @@ static void cleanupenv (char const *const *argv, char const *const *envp) { stralloc sa = STRALLOC_ZERO ; if (!pathexec_env("!", 0) || !pathexec_env("?", 0)) goto err ; -#ifdef EXECLINE_OLD_VARNAMES - if (!pathexec_env("LASTPID", 0) || !pathexec_env("LASTEXITCODE", 0)) goto err ; -#endif for (; *envp ; envp++) { char const *s = *envp ; sa.len = 0 ; - if (!str_diffn(s, "ELGETOPT_", 9) - || !str_diffn(s, "EXECLINE_", 9) - || !str_diffn(s, "FD", 2) + if (!strncmp(s, "ELGETOPT_", 9) + || !strncmp(s, "EXECLINE_", 9) + || !strncmp(s, "FD", 2) || (s[0] == '#') || ((s[0] >= '0') && (s[0] <= '9'))) if (!stralloc_catb(&sa, s, str_chr(s, '=')) @@ -47,7 +43,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, "pcoP", &l) ; + int opt = subgetopt_r(argc, argv, "pcoP", &l) ; if (opt == -1) break ; switch (opt) { @@ -67,7 +63,7 @@ int main (int argc, char const *const *argv, char const *const *envp) char const *newenv[2] = { 0, 0 } ; if (flagpath) for (; *envp ; envp++) - if (!str_diffn(*envp, "PATH=", 5)) + if (!strncmp(*envp, "PATH=", 5)) { newenv[0] = *envp ; break ; diff --git a/src/execline/exec.c b/src/execline/exec.c index 9b923ab..e35d7ba 100644 --- a/src/execline/exec.c +++ b/src/execline/exec.c @@ -1,7 +1,6 @@ /* ISC license. */ -#include <sys/types.h> -#include <skalibs/bytestr.h> +#include <string.h> #include <skalibs/djbunix.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> @@ -19,7 +18,7 @@ int main (int argc, char const **argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "cla:", &l) ; + int opt = subgetopt_r(argc, argv, "cla:", &l) ; if (opt == -1) break ; switch (opt) { @@ -37,10 +36,10 @@ int main (int argc, char const **argv, char const *const *envp) if (argv0) argv[0] = argv0 ; if (dash) { - register size_t n = str_len(argv[0]) ; + size_t n = strlen(argv[0]) ; char dashed[n+2] ; dashed[0] = '-' ; - byte_copy(dashed+1, n+1, argv[0]) ; + memcpy(dashed+1, argv[0], n+1) ; argv[0] = (char const *)dashed ; pathexec_run(executable, argv, envp) ; } diff --git a/src/execline/execlineb.c b/src/execline/execlineb.c index 3b14fe5..31cc3ff 100644 --- a/src/execline/execlineb.c +++ b/src/execline/execlineb.c @@ -1,11 +1,10 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <errno.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/allreadwrite.h> #include <skalibs/sgetopt.h> -#include <skalibs/bytestr.h> #include <skalibs/buffer.h> #include <skalibs/strerr2.h> #include <skalibs/stralloc.h> @@ -33,7 +32,7 @@ static int myexlp (stralloc *sa, char const *const *argv, unsigned int argc, uns blah[0].var = 0 ; blah[0].value = 0 ; blah[0].n = 1 ; if (!stralloc_catb(&info.values, fmt, uint_fmt(fmt, argc)) || !stralloc_0(&info.values)) goto err ; blah[1].var = 2 ; blah[1].value = info.values.len ; blah[1].n = 1 ; - if (!stralloc_catb(&info.values, dollar0, str_len(dollar0) + 1)) goto err ; + if (!stralloc_catb(&info.values, dollar0, strlen(dollar0) + 1)) goto err ; blah[2].var = 4 ; blah[2].value = info.values.len ; blah[2].n = doshift && n == nmin ? 0 : argc ; genalloc_catb(elsubst_t, &info.data, blah, 3) ; } @@ -42,7 +41,7 @@ static int myexlp (stralloc *sa, char const *const *argv, unsigned int argc, uns elsubst_t blah = { .var = info.vars.len, .value = info.values.len, .n = 1 } ; char fmt[UINT_FMT] ; if (!stralloc_catb(&info.vars, fmt, uint_fmt(fmt, i+1)) || !stralloc_0(&info.vars)) goto err ; - if (!stralloc_catb(&info.values, i < argc ? argv[i] : "", i < argc ? str_len(argv[i]) + 1 : 1)) goto err ; + if (!stralloc_catb(&info.values, i < argc ? argv[i] : "", i < argc ? strlen(argv[i]) + 1 : 1)) goto err ; genalloc_append(elsubst_t, &info.data, &blah) ; if (i == nmin && doshift) { @@ -81,7 +80,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, "pPqwWc:S:s:", &l) ; + int opt = subgetopt_r(argc, argv, "pPqwWc:S:s:", &l) ; if (opt == -1) break ; switch (opt) { @@ -114,7 +113,7 @@ int main (int argc, char const *const *argv, char const *const *envp) dollar0 = *argv++ ; fd = open_readb(dollar0) ; if (fd < 0) strerr_diefu3sys(111, "open ", dollar0, " for reading") ; - buffer_init(&b, &fd_readsv, fd, buf, BUFFER_INSIZE) ; + buffer_init(&b, &fd_readv, fd, buf, BUFFER_INSIZE) ; nc = el_parse_from_buffer(&sa, &b) ; e = errno ; fd_close(fd) ; @@ -157,7 +156,7 @@ int main (int argc, char const *const *argv, char const *const *envp) else if (flagpushenv) { char fmt[UINT_FMT] ; - register unsigned int i = 0 ; + unsigned int i = 0 ; fmt[uint_fmt(fmt, argc)] = 0 ; if (!env_addmodif(&modif, "#", fmt)) goto errenv ; if (!env_addmodif(&modif, "0", dollar0)) goto errenv ; diff --git a/src/execline/exit.c b/src/execline/exit.c index d9c6c20..bdfe4a0 100644 --- a/src/execline/exit.c +++ b/src/execline/exit.c @@ -1,7 +1,8 @@ /* ISC license. */ +#include <unistd.h> #include <skalibs/strerr2.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #define USAGE "exit [ exitcode ]" @@ -11,5 +12,5 @@ int main (int argc, char const *const *argv) PROG = "exit" ; if (argc < 2) return 0 ; if (!uint0_scan(argv[1], &e)) strerr_dieusage(100, USAGE) ; - return (int)e ; + _exit(e) ; } diff --git a/src/execline/fdblock.c b/src/execline/fdblock.c index 486591e..ec68900 100644 --- a/src/execline/fdblock.c +++ b/src/execline/fdblock.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> @@ -16,7 +16,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, "n", &l) ; + int opt = subgetopt_r(argc, argv, "n", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/execline/fdclose.c b/src/execline/fdclose.c index 33b5941..47780c9 100644 --- a/src/execline/fdclose.c +++ b/src/execline/fdclose.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> @@ -11,7 +11,7 @@ int main (int argc, char const *const *argv, char const *const *envp) unsigned int fd ; PROG = "fdclose" ; if ((argc < 3) || !uint0_scan(argv[1], &fd)) strerr_dieusage(100, USAGE) ; - fd_close((int)fd) ; + fd_close(fd) ; pathexec_run(argv[2], argv+2, envp) ; strerr_dieexec(111, argv[2]) ; } diff --git a/src/execline/fdmove.c b/src/execline/fdmove.c index 8b7417e..6f97b11 100644 --- a/src/execline/fdmove.c +++ b/src/execline/fdmove.c @@ -1,7 +1,7 @@ /* ISC license. */ #include <skalibs/sgetopt.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> @@ -16,7 +16,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, "c", &l) ; + int opt = subgetopt_r(argc, argv, "c", &l) ; if (opt == -1) break ; switch (opt) { @@ -28,7 +28,7 @@ int main (int argc, char const *const *argv, char const *const *envp) } if ((argc < 3) || !uint0_scan(argv[0], &to) || !uint0_scan(argv[1], &from)) strerr_dieusage(100, USAGE) ; - if ((flagcopy ? fd_copy((int)to, (int)from) : fd_move((int)to, (int)from)) == -1) + if ((flagcopy ? fd_copy(to, from) : fd_move(to, from)) == -1) strerr_diefu4sys(111, "move fd ", argv[1], " to fd ", argv[0]) ; pathexec_run(argv[2], argv+2, envp) ; strerr_dieexec(111, argv[2]) ; diff --git a/src/execline/fdreserve.c b/src/execline/fdreserve.c index 2df721a..00d5c7d 100644 --- a/src/execline/fdreserve.c +++ b/src/execline/fdreserve.c @@ -2,7 +2,7 @@ #include <unistd.h> #include <sys/resource.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/env.h> #include <skalibs/djbunix.h> @@ -13,7 +13,7 @@ unsigned int doit (char *modif, unsigned int i, int fd) { - register unsigned int pos = 2 ; + unsigned int pos = 2 ; modif[0] = 'F' ; modif[1] = 'D' ; pos += uint_fmt(modif + pos, i) ; modif[pos++] = '=' ; @@ -38,13 +38,13 @@ int main (int argc, char const *const *argv, char const *const *envp) unsigned int j = 0 ; { int fd[n >> 1][2] ; - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < (n>>1) ; i++) if (pipe(fd[i]) < 0) strerr_diefu1sys(111, "reserve fds") ; if (n & 1) { - register int lastfd = open_read("/dev/null") ; + int lastfd = open_read("/dev/null") ; if (lastfd < 0) strerr_diefu1sys(111, "reserve last fd") ; fd_close(lastfd) ; diff --git a/src/execline/fdswap.c b/src/execline/fdswap.c index 13ac98b..b19494e 100644 --- a/src/execline/fdswap.c +++ b/src/execline/fdswap.c @@ -1,7 +1,6 @@ /* ISC license. */ -#include <unistd.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> diff --git a/src/execline/forbacktickx.c b/src/execline/forbacktickx.c index 9833174..b1b49fa 100644 --- a/src/execline/forbacktickx.c +++ b/src/execline/forbacktickx.c @@ -1,10 +1,9 @@ /* ISC license. */ +#include <string.h> #include <unistd.h> #include <errno.h> -#include <skalibs/ushort.h> -#include <skalibs/uint.h> -#include <skalibs/bytestr.h> +#include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> @@ -26,7 +25,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, "epnCc0d:o:x:", &l) ; + int opt = subgetopt_r(argc, argv, "epnCc0d:o:x:", &l) ; if (opt == -1) break ; switch (opt) { @@ -40,7 +39,7 @@ int main (int argc, char const *const *argv, char const *const *envp) case 'o' : { unsigned short okcodes[256] ; - unsigned int nbc ; /* XXX */ + size_t nbc ; if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ; codes = l.arg ; not = 0 ; @@ -49,7 +48,7 @@ int main (int argc, char const *const *argv, char const *const *envp) case 'x' : { unsigned short okcodes[256] ; - unsigned int nbc ; /* XXX */ + size_t nbc ; if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ; codes = l.arg ; not = 1 ; @@ -86,7 +85,7 @@ int main (int argc, char const *const *argv, char const *const *envp) if (chomp) newargv[m++] = "-n" ; if (crunch) newargv[m++] = "-C" ; if (!delim) newargv[m++] = "-0" ; - else if (str_diff(delim, DELIM_DEFAULT)) + else if (strcmp(delim, DELIM_DEFAULT)) { newargv[m++] = "-d" ; newargv[m++] = delim ; diff --git a/src/execline/forstdin.c b/src/execline/forstdin.c index 96b6e8b..95ec4d5 100644 --- a/src/execline/forstdin.c +++ b/src/execline/forstdin.c @@ -1,11 +1,11 @@ /* ISC license. */ #include <sys/types.h> +#include <string.h> #include <errno.h> +#include <skalibs/types.h> #include <skalibs/sgetopt.h> -#include <skalibs/bytestr.h> #include <skalibs/buffer.h> -#include <skalibs/fmtscan.h> #include <skalibs/strerr2.h> #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> @@ -14,7 +14,6 @@ #include <skalibs/djbunix.h> #include <skalibs/skamisc.h> #include <skalibs/netstring.h> -#include <skalibs/ushort.h> #include <execline/config.h> #include <execline/execline.h> @@ -25,7 +24,7 @@ static genalloc pids = GENALLOC_ZERO ; /* pid_t */ static int isok (unsigned short *tab, unsigned int n, int code) { - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < n ; i++) if ((unsigned short)code == tab[i]) break ; return i < n ; } @@ -37,7 +36,7 @@ static void parallel_sigchld_handler (int sig) int wstat ; for (;;) { - register ssize_t r = wait_pids_nohang(tab, len, &wstat) ; + ssize_t r = wait_pids_nohang(tab, len, &wstat) ; if (r <= 0) break ; tab[r-1] = tab[--len] ; } @@ -48,16 +47,16 @@ static void parallel_sigchld_handler (int sig) int main (int argc, char const **argv, char const *const *envp) { char const *delim = " \n\r\t" ; - unsigned int delimlen = 4 ; + size_t delimlen = 4 ; + size_t nbc = 0 ; unsigned short okcodes[256] ; - unsigned int nbc = 0 ; int crunch = 0, chomp = 0, not = 1 ; PROG = "forstdin" ; { subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "pnCc0d:o:x:", &l) ; + int opt = subgetopt_r(argc, argv, "pnCc0d:o:x:", &l) ; if (opt == -1) break ; switch (opt) { @@ -71,14 +70,14 @@ int main (int argc, char const **argv, char const *const *envp) case 'C' : crunch = 1 ; break ; case 'c' : crunch = 0 ; break ; case '0' : delim = "" ; delimlen = 1 ; break ; - case 'd' : delim = l.arg ; delimlen = str_len(delim) ; break ; + case 'd' : delim = l.arg ; delimlen = strlen(delim) ; break ; case 'o' : not = 0 ; - if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ; /* XXX */ + if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ; break ; case 'x' : not = 1 ; - if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ; /* XXX */ + if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ; break ; default : dieusage() ; } @@ -89,11 +88,11 @@ int main (int argc, char const **argv, char const *const *envp) { stralloc modif = STRALLOC_ZERO ; size_t envlen = env_len(envp) ; - size_t modifstart = str_len(argv[0])+1 ; + size_t modifstart = strlen(argv[0]) + 1 ; char const *newenv[envlen + 2] ; if (!stralloc_ready(&modif, modifstart+1)) strerr_diefu1sys(111, "stralloc_ready") ; - byte_copy(modif.s, modifstart-1, argv[0]) ; + memcpy(modif.s, argv[0], modifstart - 1) ; modif.s[modifstart-1] = '=' ; if (pids.s) { @@ -106,7 +105,7 @@ int main (int argc, char const **argv, char const *const *envp) modif.len = modifstart ; if (delimlen) { - register int r = skagetlnsep(buffer_0, &modif, delim, delimlen) ; + int r = skagetlnsep(buffer_0, &modif, delim, delimlen) ; if (!r) break ; else if (r < 0) { @@ -118,7 +117,7 @@ int main (int argc, char const **argv, char const *const *envp) } else { - unsigned int unread = 0 ; /* XXX: change to size_t when the skalibs API changes */ + size_t unread = 0 ; if (netstring_get(buffer_0, &modif, &unread) <= 0) { if (netstring_okeof(buffer_0, unread)) break ; diff --git a/src/execline/forx.c b/src/execline/forx.c index 327f168..06e6b39 100644 --- a/src/execline/forx.c +++ b/src/execline/forx.c @@ -1,13 +1,14 @@ /* ISC license. */ -#include <sys/types.h> +#include <sys/wait.h> +#include <string.h> #include <skalibs/sgetopt.h> #include <skalibs/bytestr.h> #include <skalibs/strerr2.h> #include <skalibs/env.h> #include <skalibs/djbunix.h> #include <skalibs/skamisc.h> -#include <skalibs/ushort.h> +#include <skalibs/types.h> #include <execline/config.h> #include <execline/execline.h> @@ -16,7 +17,7 @@ static int isok (unsigned short const *tab, unsigned int n, int code) { - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < n ; i++) if ((unsigned short)code == tab[i]) break ; return i < n ; } @@ -27,8 +28,8 @@ static int waitn_code (unsigned short const *tab, unsigned int nbc, pid_t *pids, while (n) { int wstat ; - register unsigned int i = 0 ; - register pid_t pid = wait_nointr(&wstat) ; + unsigned int i = 0 ; + pid_t pid = wait_nointr(&wstat) ; if (pid < 0) return -1 ; for (; i < n ; i++) if (pid == pids[i]) break ; if (i < n) @@ -45,14 +46,14 @@ int main (int argc, char const **argv, char const *const *envp) char const *x ; int argc1 ; unsigned short okcodes[256] ; - unsigned int nbc = 0 ; + size_t nbc = 0 ; int flagpar = 0, not = 1 ; PROG = "forx" ; { subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "epo:x:", &l) ; + int opt = subgetopt_r(argc, argv, "epo:x:", &l) ; if (opt == -1) break ; switch (opt) { @@ -60,11 +61,11 @@ int main (int argc, char const **argv, char const *const *envp) case 'p' : flagpar = 1 ; break ; case 'o' : not = 0 ; - if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ; /* XXX */ + if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ; break ; case 'x' : not = 1 ; - if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ; /* XXX */ + if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ; break ; default : dieusage() ; } @@ -82,7 +83,7 @@ int main (int argc, char const **argv, char const *const *envp) if (!argc1 || (argc1 + 1 == argc)) return 0 ; { size_t envlen = env_len(envp) ; - size_t varlen = str_len(x) ; + size_t varlen = strlen(x) ; unsigned int i = 0 ; pid_t pids[flagpar ? argc1 : 1] ; char const *newenv[envlen + 2] ; @@ -90,11 +91,11 @@ int main (int argc, char const **argv, char const *const *envp) for (; i < (unsigned int)argc1 ; i++) { pid_t pid ; - size_t vallen = str_len(argv[i]) ; + size_t vallen = strlen(argv[i]) ; char modif[varlen + vallen + 2] ; - byte_copy(modif, varlen, x) ; + memcpy(modif, x, varlen) ; modif[varlen] = '=' ; - byte_copy(modif + varlen + 1, vallen, argv[i]) ; + memcpy(modif + varlen + 1, argv[i], vallen) ; modif[varlen + vallen + 1] = 0 ; if (!env_merge(newenv, envlen + 2, envp, envlen, modif, varlen + vallen + 2)) strerr_diefu1sys(111, "build new environment") ; @@ -113,7 +114,7 @@ int main (int argc, char const **argv, char const *const *envp) if (flagpar) { - register int r = waitn_code(okcodes, nbc, pids, argc1, not) ; + int r = waitn_code(okcodes, nbc, pids, argc1, not) ; if (r < 0) strerr_diefu1sys(111, "waitn") ; else if (!r) return 1 ; } diff --git a/src/execline/getpid.c b/src/execline/getpid.c index 0ade4d3..7fb39ac 100644 --- a/src/execline/getpid.c +++ b/src/execline/getpid.c @@ -1,9 +1,8 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <unistd.h> -#include <skalibs/bytestr.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/env.h> #include <skalibs/djbunix.h> @@ -15,13 +14,13 @@ int main (int argc, char const *const *argv, char const *const *envp) size_t len ; PROG = "getpid" ; if (argc < 3) strerr_dieusage(100, USAGE) ; - len = str_len(argv[1]) ; - if (byte_chr(argv[1], len, '=') < len) + len = strlen(argv[1]) ; + if (!memchr(argv[1], '=', len)) strerr_dief2x(100, "invalid variable name: ", argv[1]) ; { size_t i = len+1 ; char fmt[UINT_FMT + len + 2] ; - byte_copy(fmt, len, argv[1]) ; + memcpy(fmt, argv[1], len) ; fmt[len] = '=' ; i += uint_fmt(fmt+i, getpid()) ; fmt[i++] = 0 ; pathexec_r(argv+2, envp, env_len(envp), fmt, i) ; diff --git a/src/execline/heredoc.c b/src/execline/heredoc.c index c3dd691..2e12451 100644 --- a/src/execline/heredoc.c +++ b/src/execline/heredoc.c @@ -1,10 +1,10 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <unistd.h> #include <skalibs/sgetopt.h> #include <skalibs/bytestr.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/allreadwrite.h> #include <skalibs/strerr2.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, "d", &l) ; + int opt = subgetopt_r(argc, argv, "d", &l) ; if (opt == -1) break ; switch (opt) { @@ -34,7 +34,7 @@ int main (int argc, char const *const *argv, char const *const *envp) { int fd[2] ; unsigned int fdr ; - int pid ; + pid_t pid ; if (!uint0_scan(argv[0], &fdr)) strerr_dieusage(100, USAGE) ; if (pipe(fd) < 0) strerr_diefu1sys(111, "pipe") ; pid = df ? doublefork() : fork() ; @@ -43,7 +43,7 @@ int main (int argc, char const *const *argv, char const *const *envp) case -1: strerr_diefu2sys(111, df ? "double" : "", "fork") ; case 0: { - size_t len = str_len(argv[1]) ; + size_t len = strlen(argv[1]) ; PROG = "heredoc (child)" ; fd_close(fd[0]) ; if (allwrite(fd[1], argv[1], len) < len) diff --git a/src/execline/if.c b/src/execline/if.c index 410e118..3e34c36 100644 --- a/src/execline/if.c +++ b/src/execline/if.c @@ -1,9 +1,8 @@ /* ISC license. */ -#include <sys/types.h> #include <sys/wait.h> #include <skalibs/sgetopt.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> #include <skalibs/ushort.h> @@ -22,7 +21,7 @@ int main (int argc, char const **argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "nXtx:", &l) ; + int opt = subgetopt_r(argc, argv, "nXtx:", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/execline/ifelse.c b/src/execline/ifelse.c index 1a4cb3e..c1a2e80 100644 --- a/src/execline/ifelse.c +++ b/src/execline/ifelse.c @@ -5,7 +5,7 @@ #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <execline/execline.h> #define USAGE "ifelse [ -n ] [ -X ] { command-if } { command-then... } command-else..." @@ -20,7 +20,7 @@ int main (int argc, char const **argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "nX", &l) ; + int opt = subgetopt_r(argc, argv, "nX", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/execline/ifte.c b/src/execline/ifte.c index eae19c6..1bb499e 100644 --- a/src/execline/ifte.c +++ b/src/execline/ifte.c @@ -1,9 +1,8 @@ /* ISC license. */ -#include <sys/types.h> #include <sys/wait.h> #include <skalibs/sgetopt.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> #include <execline/execline.h> @@ -20,7 +19,7 @@ int main (int argc, char const **argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "Xn", &l) ; + int opt = subgetopt_r(argc, argv, "Xn", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/execline/ifthenelse.c b/src/execline/ifthenelse.c index 2d71fec..b36f549 100644 --- a/src/execline/ifthenelse.c +++ b/src/execline/ifthenelse.c @@ -3,7 +3,7 @@ #include <sys/types.h> #include <sys/wait.h> #include <skalibs/sgetopt.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> #include <execline/execline.h> @@ -20,7 +20,7 @@ int main (int argc, char const **argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "Xs", &l) ; + int opt = subgetopt_r(argc, argv, "Xs", &l) ; if (opt == -1) break ; switch (opt) { @@ -61,7 +61,7 @@ int main (int argc, char const **argv, char const *const *envp) } if (magicscope) /* undocumented voodoo - dangerous and powerful */ { - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; remainder[i] ; i++) argv[argc2+i] = remainder[i] ; argv[argc2+i] = 0 ; pathexec0_run(argv, envp) ; diff --git a/src/execline/loopwhilex.c b/src/execline/loopwhilex.c index 0f1f5e4..38ca6e0 100644 --- a/src/execline/loopwhilex.c +++ b/src/execline/loopwhilex.c @@ -4,7 +4,7 @@ #include <sys/wait.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> -#include <skalibs/ushort.h> +#include <skalibs/types.h> #include <skalibs/djbunix.h> #include <execline/execline.h> @@ -13,7 +13,7 @@ static int isok (unsigned short *tab, unsigned int n, int code) { - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < n ; i++) if ((unsigned short)code == tab[i]) break ; return i < n ; } @@ -23,13 +23,13 @@ int main (int argc, char const *const *argv, char const *const *envp) int wstat ; int not = 0, cont = 1, rev = 0 ; unsigned short okcodes[256] ; - unsigned int nbc = 0 ; /* XXX */ + size_t nbc = 0 ; PROG = "loopwhilex" ; { subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "no:x:", &l) ; + int opt = subgetopt_r(argc, argv, "no:x:", &l) ; if (opt == -1) break ; switch (opt) { diff --git a/src/execline/pipeline.c b/src/execline/pipeline.c index fea0b87..b07d495 100644 --- a/src/execline/pipeline.c +++ b/src/execline/pipeline.c @@ -2,11 +2,8 @@ #include <sys/types.h> #include <unistd.h> -#ifdef EXECLINE_OLD_VARNAMES -#include <skalibs/bytestr.h> -#endif #include <skalibs/sgetopt.h> -#include <skalibs/uint64.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/env.h> #include <skalibs/djbunix.h> @@ -23,7 +20,7 @@ int main (int argc, char const **argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "drw", &l) ; + int opt = subgetopt_r(argc, argv, "drw", &l) ; if (opt == -1) break ; switch (opt) { @@ -68,17 +65,9 @@ int main (int argc, char const **argv, char const *const *envp) if (fd_move(w, fd) < 0) strerr_diefu1sys(111, "fd_move") ; if (w == fd) uncoe(fd) ; { -#ifdef EXECLINE_OLD_VARNAMES - char fmt[UINT64_FMT * 2 + 10] = "!=" ; -#else - char fmt[UINT64_FMT + 2] = "!=" ; -#endif - register size_t i = 2 ; - i += uint64_fmt(fmt+i, (uint64)pid) ; fmt[i++] = 0 ; -#ifdef EXECLINE_OLD_VARNAMES - byte_copy(fmt+i, 8, "LASTPID=") ; i += 8 ; - i += uint64_fmt(fmt+i, (uint64)pid) ; fmt[i++] = 0 ; -#endif + char fmt[PID_FMT + 2] = "!=" ; + size_t i = 2 ; + i += pid_fmt(fmt+i, pid) ; fmt[i++] = 0 ; pathexec_r(argv + argc1 + 1, envp, env_len(envp), fmt, i) ; } strerr_dieexec(111, argv[argc1 + 1]) ; diff --git a/src/execline/piperw.c b/src/execline/piperw.c index 9d24947..8affbde 100644 --- a/src/execline/piperw.c +++ b/src/execline/piperw.c @@ -1,7 +1,7 @@ /* ISC license. */ #include <unistd.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> diff --git a/src/execline/redirfd.c b/src/execline/redirfd.c index d9dca14..8a5c8ef 100644 --- a/src/execline/redirfd.c +++ b/src/execline/redirfd.c @@ -3,7 +3,7 @@ #include <fcntl.h> #include <errno.h> #include <skalibs/sgetopt.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> @@ -21,7 +21,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, "rwuacxnb", &l) ; + int opt = subgetopt_r(argc, argv, "rwuacxnb", &l) ; if (opt == -1) break ; switch (opt) { @@ -44,7 +44,7 @@ int main (int argc, char const *const *argv, char const *const *envp) fd2 = open3(argv[1], flags, 0666) ; if ((fd2 == -1) && (what == O_WRONLY) && (errno == ENXIO)) { - register int e ; + int e ; int fdr = open_read(argv[1]) ; if (fdr == -1) strerr_diefu2sys(111, "open_read ", argv[1]) ; fd2 = open3(argv[1], flags, 0666) ; diff --git a/src/execline/runblock.c b/src/execline/runblock.c index c36675f..16fc52a 100644 --- a/src/execline/runblock.c +++ b/src/execline/runblock.c @@ -2,7 +2,7 @@ #include <sys/types.h> #include <skalibs/sgetopt.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/stralloc.h> #include <skalibs/env.h> @@ -25,7 +25,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, "Prn:", &l) ; + int opt = subgetopt_r(argc, argv, "Prn:", &l) ; if (opt == -1) break ; switch (opt) { @@ -48,7 +48,7 @@ int main (int argc, char const *const *argv, char const *const *envp) /* Skip n-1 blocks (n if flagr) */ { - register unsigned int i = 1 ; + unsigned int i = 1 ; for (; i < n + flagr ; i++) { unsigned int base = m ; @@ -134,7 +134,7 @@ int main (int argc, char const *const *argv, char const *const *envp) { char const *list[11] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "#" } ; size_t envlen = env_len(envp) ; - register int popped = el_popenv(&satmp, envp, envlen, list, 11) ; + int popped = el_popenv(&satmp, envp, envlen, list, 11) ; if (popped < 0) strerr_diefu1sys(111, "pop environment") ; else { diff --git a/src/execline/shift.c b/src/execline/shift.c index b09ba38..e936f23 100644 --- a/src/execline/shift.c +++ b/src/execline/shift.c @@ -1,7 +1,7 @@ /* ISC license. */ #include <skalibs/sgetopt.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> #include <execline/execline.h> @@ -21,7 +21,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, "n:b:", &l) ; + int opt = subgetopt_r(argc, argv, "n:b:", &l) ; if (opt == -1) break ; switch (opt) { @@ -103,7 +103,7 @@ int main (int argc, char const *const *argv, char const *const *envp) /* n = shift value; modify the env */ { - register unsigned int i = 1 ; + unsigned int i = 1 ; char fmt[UINT_FMT] ; fmt[uint_fmt(fmt, sharp - n)] = 0 ; if (!pathexec_env("#", fmt)) strerr_diefu1sys(111, "pathexec_env") ; diff --git a/src/execline/trap.c b/src/execline/trap.c index 9a21e49..6a43424 100644 --- a/src/execline/trap.c +++ b/src/execline/trap.c @@ -1,11 +1,10 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <errno.h> #include <signal.h> -#include <skalibs/bytestr.h> #include <skalibs/sgetopt.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/nsig.h> #include <skalibs/sig.h> #include <skalibs/strerr2.h> @@ -47,7 +46,7 @@ int main (int argc, char const **argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "xt:", &l) ; + int opt = subgetopt_r(argc, argv, "xt:", &l) ; if (opt == -1) break ; switch (opt) { @@ -76,8 +75,8 @@ int main (int argc, char const **argv, char const *const *envp) while (i < (unsigned int)argc1) { int argc2 ; - unsigned int sig = (unsigned int)sig_number(argv[i] + (case_diffb(argv[i], 3, "sig") ? 0 : 3)) ; - if (!sig && !uint0_scan(argv[i], &sig) && case_diffs(argv[i], "timeout")) + unsigned int sig = (unsigned int)sig_number(argv[i] + (strncasecmp(argv[i], "sig", 3) ? 0 : 3)) ; + if (!sig && !uint0_scan(argv[i], &sig) && strcasecmp(argv[i], "timeout")) strerr_dief3x(100, "unrecognized", " directive: ", argv[i]) ; argc2 = el_semicolon(argv + ++i) ; if (!argc2) @@ -124,7 +123,7 @@ int main (int argc, char const **argv, char const *const *envp) for (;;) { tain_t deadline ; - register int r ; + int r ; tain_add_g(&deadline, &tto) ; r = iopause_g(&x, 1, &deadline) ; if (r < 0) strerr_diefu1sys(111, "iopause") ; diff --git a/src/execline/tryexec.c b/src/execline/tryexec.c index 9026603..9ba2008 100644 --- a/src/execline/tryexec.c +++ b/src/execline/tryexec.c @@ -1,7 +1,6 @@ /* ISC license. */ -#include <sys/types.h> -#include <skalibs/bytestr.h> +#include <string.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> @@ -23,7 +22,7 @@ int main (int argc, char const **argv, char const *const *envp) subgetopt_t l = SUBGETOPT_ZERO ; for (;;) { - register int opt = subgetopt_r(argc, argv, "ncla:", &l) ; + int opt = subgetopt_r(argc, argv, "ncla:", &l) ; if (opt == -1) break ; switch (opt) { @@ -50,10 +49,10 @@ int main (int argc, char const **argv, char const *const *envp) if (argv0) dom[0] = argv0 ; if (dash) { - register size_t n = str_len(dom[0]) ; + size_t n = strlen(dom[0]) ; char dashed[n+2] ; dashed[0] = '-' ; - byte_copy(dashed+1, n+1, dom[0]) ; + memcpy(dashed+1, dom[0], n+1) ; dom[0] = dashed ; pathexec_run(executable, dom, dom_envp) ; } diff --git a/src/execline/umask.c b/src/execline/umask.c index 81217b6..ab91b37 100644 --- a/src/execline/umask.c +++ b/src/execline/umask.c @@ -1,8 +1,7 @@ /* ISC license. */ -#include <sys/types.h> #include <sys/stat.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/strerr2.h> #include <skalibs/djbunix.h> diff --git a/src/execline/wait.c b/src/execline/wait.c index 764d503..7233304 100644 --- a/src/execline/wait.c +++ b/src/execline/wait.c @@ -1,10 +1,8 @@ /* ISC license. */ -#include <sys/types.h> #include <sys/wait.h> #include <errno.h> -#include <skalibs/uint64.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/tai.h> @@ -73,7 +71,7 @@ static inline void mainloop (tain_t *deadline, int insist, actfunc_t_ref f, pid_ tain_add_g(deadline, deadline) ; while ((*f)(tab, n)) { - register int r = iopause_g(&x, 1, deadline) ; + int r = iopause_g(&x, 1, deadline) ; if (r < 0) strerr_diefu1sys(111, "iopause") ; else if (!r) { @@ -98,7 +96,7 @@ int main (int argc, char const **argv, char const *const *envp) unsigned int t = 0 ; for (;;) { - register int opt = subgetopt_r(argc, argv, "iIrt:", &l) ; + int opt = subgetopt_r(argc, argv, "iIrt:", &l) ; if (opt == -1) break ; switch (opt) { @@ -123,13 +121,9 @@ int main (int argc, char const **argv, char const *const *envp) pid_t tab[n] ; if (argc1) { - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < n ; i++) - { - uint64_t pid ; - if (!uint640_scan(argv[i], &pid)) strerr_dieusage(100, USAGE) ; - tab[i] = (pid_t)pid ; - } + if (!pid0_scan(argv[i], tab+i)) strerr_dieusage(100, USAGE) ; } mainloop(&tto, insist, f, tab, &n) ; } diff --git a/src/execline/withstdinas.c b/src/execline/withstdinas.c index 7729024..5f62261 100644 --- a/src/execline/withstdinas.c +++ b/src/execline/withstdinas.c @@ -3,8 +3,6 @@ #include <sys/types.h> #include <sys/wait.h> #include <string.h> -#include <skalibs/uint64.h> -#include <skalibs/bytestr.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr2.h> #include <skalibs/stralloc.h> @@ -23,7 +21,7 @@ int main (int argc, char const **argv, char const *const *envp) PROG = "withstdinas" ; for (;;) { - register int opt = subgetopt_r(argc, argv, "iInD:", &localopt) ; + int opt = subgetopt_r(argc, argv, "iInD:", &localopt) ; if (opt < 0) break ; switch (opt) { @@ -44,7 +42,7 @@ int main (int argc, char const **argv, char const *const *envp) if (!slurp(&modif, 0)) strerr_diefu1sys(111, "slurp") ; if (!stralloc_0(&modif)) strerr_diefu1sys(111, "stralloc_catb") ; { - size_t reallen = str_len(modif.s) ; + size_t reallen = strlen(modif.s) ; if (reallen < modif.len - 1) { if (insist >= 2) @@ -58,7 +56,7 @@ int main (int argc, char const **argv, char const *const *envp) else if (def) { modif.len = modifstart ; - if (!stralloc_catb(&modif, def, str_len(def)+1)) + if (!stralloc_catb(&modif, def, strlen(def)+1)) strerr_diefu1sys(111, "stralloc_catb") ; strerr_warnw2x("stdin contained a null character", " - using default instead") ; } diff --git a/src/libexecline/el_execsequence.c b/src/libexecline/el_execsequence.c index d697f2e..42ef104 100644 --- a/src/libexecline/el_execsequence.c +++ b/src/libexecline/el_execsequence.c @@ -1,41 +1,23 @@ /* ISC license. */ -#include <sys/types.h> -#ifdef EXECLINE_OLD_VARNAMES -#include <skalibs/bytestr.h> -#endif +#include <unistd.h> #include <skalibs/djbunix.h> #include <skalibs/env.h> #include <skalibs/strerr2.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <execline/execline.h> void el_execsequence (char const *const *argv1, char const *const *argv2, char const *const *envp) { - if (!argv2[0]) - { - pathexec0_run(argv1, envp) ; - strerr_dieexec(111, argv1[0]) ; - } - else - { - size_t j = 2 ; - int wstat ; -#ifdef EXECLINE_OLD_VARNAMES - char fmt[UINT_FMT * 2 + 15] = "?=" ; -#else - char fmt[UINT_FMT + 1] = "?=" ; -#endif - pid_t pid = el_spawn0(argv1[0], argv1, envp) ; - if (!pid) strerr_warnwu2sys("spawn ", argv1[0]) ; - if (wait_pid(pid, &wstat) < 0) - strerr_diefu2sys(111, "wait for ", argv1[0]) ; - j += uint_fmt(fmt + j, wait_status(wstat)) ; fmt[j++] = 0 ; -#ifdef EXECLINE_OLD_VARNAMES - byte_copy(fmt + j, 13, "LASTEXITCODE=") ; j += 13 ; - j += uint_fmt(fmt + j, wait_status(wstat)) ; fmt[j++] = 0 ; -#endif - pathexec_r(argv2, envp, env_len(envp), fmt, j) ; - } + size_t j = 2 ; + int wstat ; + char fmt[UINT_FMT + 1] = "?=" ; + pid_t pid = el_spawn0(argv1[0], argv1, envp) ; + if (!pid) strerr_warnwu2sys("spawn ", argv1[0]) ; + if (wait_pid(pid, &wstat) < 0) + strerr_diefu2sys(111, "wait for ", argv1[0]) ; + if (!argv2[0]) _exit(0) ; + j += uint_fmt(fmt + j, wait_status(wstat)) ; fmt[j++] = 0 ; + pathexec_r(argv2, envp, env_len(envp), fmt, j) ; strerr_dieexec(111, argv2[0]) ; } diff --git a/src/libexecline/el_getstrict.c b/src/libexecline/el_getstrict.c index 091845c..50127be 100644 --- a/src/libexecline/el_getstrict.c +++ b/src/libexecline/el_getstrict.c @@ -1,7 +1,7 @@ /* ISC license. */ #include <skalibs/env.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <execline/execline.h> unsigned int el_getstrict (void) diff --git a/src/libexecline/el_parse.c b/src/libexecline/el_parse.c index acff34a..53644ed 100644 --- a/src/libexecline/el_parse.c +++ b/src/libexecline/el_parse.c @@ -2,7 +2,7 @@ #include <sys/types.h> #include <stdint.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <skalibs/bytestr.h> #include <skalibs/stralloc.h> #include <skalibs/djbunix.h> @@ -56,7 +56,7 @@ int el_parse (stralloc *sa, el_chargen_func_t_ref next, void *source) if (c & 0x0200) { char tilde = EXECLINE_BLOCK_QUOTE_CHAR ; - register unsigned int i = blevel ; + unsigned int i = blevel ; if (!stralloc_readyplus(sa, i<<1)) return -1 ; while (i--) stralloc_catb(sa, &tilde, 1) ; } diff --git a/src/libexecline/el_parse_from_buffer.c b/src/libexecline/el_parse_from_buffer.c index 83862f3..f0d0578 100644 --- a/src/libexecline/el_parse_from_buffer.c +++ b/src/libexecline/el_parse_from_buffer.c @@ -7,7 +7,7 @@ static int next (unsigned char *c, void *p) { - register ssize_t r = buffer_get((buffer *)p, (char *)c, 1) ; + ssize_t r = buffer_get((buffer *)p, (char *)c, 1) ; if (r < 0) return 0 ; if (!r) *c = 0 ; return 1 ; diff --git a/src/libexecline/el_popenv.c b/src/libexecline/el_popenv.c index c0089d0..eff82cc 100644 --- a/src/libexecline/el_popenv.c +++ b/src/libexecline/el_popenv.c @@ -1,10 +1,10 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <errno.h> #include <skalibs/bytestr.h> #include <skalibs/stralloc.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <execline/execline.h> int el_popenv (stralloc *sa, char const *const *envp, size_t envlen, char const *const *list, size_t listlen) @@ -16,7 +16,7 @@ int el_popenv (stralloc *sa, char const *const *envp, size_t envlen, char const size_t equal, colon, n, j = 0 ; for (; j < listlen ; j++) if (str_start(envp[i], list[j])) break ; if (j == listlen) goto copyit ; - j = str_len(list[j]) ; + j = strlen(list[j]) ; colon = j + str_chr(envp[i] + j, ':') ; equal = j + str_chr(envp[i] + j, '=') ; if (!envp[i][equal]) goto badenv ; @@ -30,10 +30,10 @@ int el_popenv (stralloc *sa, char const *const *envp, size_t envlen, char const n = 1 + uint_fmt(fmt+1, n-1) ; if (!stralloc_catb(sa, fmt, n)) goto err ; } - if (!stralloc_catb(sa, envp[i] + equal, str_len(envp[i] + equal) + 1)) goto err ; + if (!stralloc_catb(sa, envp[i] + equal, strlen(envp[i] + equal) + 1)) goto err ; continue ; copyit: - if (!stralloc_catb(sa, envp[i], str_len(envp[i]) + 1)) goto err ; + if (!stralloc_catb(sa, envp[i], strlen(envp[i]) + 1)) goto err ; } return count ; diff --git a/src/libexecline/el_pushenv.c b/src/libexecline/el_pushenv.c index 4ec43bb..9af5ec5 100644 --- a/src/libexecline/el_pushenv.c +++ b/src/libexecline/el_pushenv.c @@ -1,10 +1,10 @@ /* ISC license. */ -#include <sys/types.h> +#include <string.h> #include <errno.h> #include <skalibs/bytestr.h> #include <skalibs/stralloc.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <execline/execline.h> int el_pushenv (stralloc *sa, char const *const *envp, size_t envlen, char const *const *list, size_t listlen) @@ -17,7 +17,7 @@ int el_pushenv (stralloc *sa, char const *const *envp, size_t envlen, char const for (; j < listlen ; j++) if (str_start(envp[i], list[j])) break ; if (j == listlen) goto copyit ; count++ ; - j = str_len(list[j]) ; + j = strlen(list[j]) ; colon = j + str_chr(envp[i] + j, ':') ; equal = j + str_chr(envp[i] + j, '=') ; if (!envp[i][equal]) goto badenv ; @@ -35,10 +35,10 @@ int el_pushenv (stralloc *sa, char const *const *envp, size_t envlen, char const if (!stralloc_catb(sa, envp[i], colon)) goto err ; if (!stralloc_catb(sa, fmt, n)) goto err ; } - if (!stralloc_catb(sa, envp[i] + equal, str_len(envp[i] + equal) + 1)) goto err ; + if (!stralloc_catb(sa, envp[i] + equal, strlen(envp[i] + equal) + 1)) goto err ; continue ; copyit: - if (!stralloc_catb(sa, envp[i], str_len(envp[i]) + 1)) goto err ; + if (!stralloc_catb(sa, envp[i], strlen(envp[i]) + 1)) goto err ; } return count ; diff --git a/src/libexecline/el_semicolon.c b/src/libexecline/el_semicolon.c index dc99daf..cfbfffd 100644 --- a/src/libexecline/el_semicolon.c +++ b/src/libexecline/el_semicolon.c @@ -2,17 +2,17 @@ #include <skalibs/env.h> #include <skalibs/strerr2.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <execline/execline.h> int el_semicolon (char const **argv) { static unsigned int nblock = 0 ; - register int argc1 = 0 ; + int argc1 = 0 ; nblock++ ; for (;; argc1++, argv++) { - register char const *arg = *argv ; + char const *arg = *argv ; if (!arg) return argc1 + 1 ; if ((arg[0] == EXECLINE_BLOCK_END_CHAR) && (!EXECLINE_BLOCK_END_CHAR || !arg[1])) return argc1 ; else if (arg[0] == EXECLINE_BLOCK_QUOTE_CHAR) ++*argv ; diff --git a/src/libexecline/el_substandrun_str.c b/src/libexecline/el_substandrun_str.c index a935b82..f87bddf 100644 --- a/src/libexecline/el_substandrun_str.c +++ b/src/libexecline/el_substandrun_str.c @@ -13,7 +13,7 @@ void el_substandrun_str (stralloc *src, size_t srcbase, char const *const *envp, exlsn_t const *info) { stralloc dst = STRALLOC_ZERO ; - register int r = el_substitute(&dst, src->s + srcbase, src->len, info->vars.s, info->values.s, genalloc_s(elsubst_t const, &info->data), genalloc_len(elsubst_t const, &info->data)) ; + int r = el_substitute(&dst, src->s + srcbase, src->len, info->vars.s, info->values.s, genalloc_s(elsubst_t const, &info->data), genalloc_len(elsubst_t const, &info->data)) ; if (r < 0) strerr_diefu1sys(111, "el_substitute") ; if (!r) _exit(0) ; stralloc_free(src) ; diff --git a/src/libexecline/el_transform.c b/src/libexecline/el_transform.c index 210cbdf..6048d1e 100644 --- a/src/libexecline/el_transform.c +++ b/src/libexecline/el_transform.c @@ -9,8 +9,8 @@ static void el_crunch (stralloc *sa, size_t base, char const *delim) { - register size_t i = base, j = base ; - register int crunching = 0 ; + size_t i = base, j = base ; + int crunching = 0 ; for (; i < sa->len ; i++) { if (!crunching) sa->s[j++] = sa->s[i] ; @@ -27,7 +27,7 @@ static void el_crunch (stralloc *sa, size_t base, char const *delim) static int el_split (stralloc *sa, size_t base, eltransforminfo_t const *si, int chomped) { int n = 0 ; - register size_t i = base ; + size_t i = base ; for (; i < sa->len ; i++) if (si->delim[str_chr(si->delim, sa->s[i])]) { @@ -51,7 +51,7 @@ static int el_splitnetstring (stralloc *sa, size_t base) int n = 0 ; while (i < sa->len) { - register ssize_t r = netstring_decode(&satmp, sa->s + i, sa->len - i) ; + ssize_t r = netstring_decode(&satmp, sa->s + i, sa->len - i) ; if (r < 0) goto err ; if (!stralloc_0(&satmp)) goto err ; i += r ; n++ ; diff --git a/src/libexecline/el_vardupl.c b/src/libexecline/el_vardupl.c index 279e79d..9efd586 100644 --- a/src/libexecline/el_vardupl.c +++ b/src/libexecline/el_vardupl.c @@ -6,7 +6,7 @@ int el_vardupl (char const *key, char const *s, size_t len) { - register size_t i = 0 ; + size_t i = 0 ; for (; i < len ; i += str_len(s + i) + 1) if (!str_diff(key, s + i)) return 1 ; return 0 ; diff --git a/src/libexecline/exlp.c b/src/libexecline/exlp.c index 1ba37c0..5e323a9 100644 --- a/src/libexecline/exlp.c +++ b/src/libexecline/exlp.c @@ -6,7 +6,7 @@ #include <skalibs/strerr2.h> #include <skalibs/stralloc.h> #include <skalibs/genalloc.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include <execline/execline.h> #include "exlsn.h" @@ -25,7 +25,7 @@ int exlp (unsigned int nmin, char const *const *envp, exlsn_t *info) if (el_vardupl("#", info->vars.s, info->vars.len)) return -2 ; if (el_vardupl("@", info->vars.s, info->vars.len)) return -2 ; { - register unsigned int strict = el_getstrict() ; + unsigned int strict = el_getstrict() ; if (strict && (n < nmin)) { char fmta[UINT_FMT] ; diff --git a/src/libexecline/exlsn_define.c b/src/libexecline/exlsn_define.c index 3abe516..066b8ff 100644 --- a/src/libexecline/exlsn_define.c +++ b/src/libexecline/exlsn_define.c @@ -16,7 +16,7 @@ int exlsn_define (int argc, char const **argv, char const *const *envp, exlsn_t blah.value = info->values.len ; for (;;) { - register int opt = subgetopt_r(argc, argv, "nsCcd:", &localopt) ; + int opt = subgetopt_r(argc, argv, "nsCcd:", &localopt) ; if (opt < 0) break ; switch (opt) { @@ -35,7 +35,7 @@ int exlsn_define (int argc, char const **argv, char const *const *envp, exlsn_t if (!stralloc_catb(&info->vars, argv[0], str_len(argv[0]) + 1)) return -1 ; if (!stralloc_cats(&info->values, argv[1])) goto err ; { - register int r = el_transform(&info->values, blah.value, &si) ; + int r = el_transform(&info->values, blah.value, &si) ; if (r < 0) goto err ; blah.n = r ; } diff --git a/src/libexecline/exlsn_elglob.c b/src/libexecline/exlsn_elglob.c index 67e939b..e64c598 100644 --- a/src/libexecline/exlsn_elglob.c +++ b/src/libexecline/exlsn_elglob.c @@ -29,7 +29,7 @@ int exlsn_elglob (int argc, char const **argv, char const *const *envp, exlsn_t blah.value = info->values.len ; for (;;) { - register int opt = subgetopt_r(argc, argv, "vwsme0", &localopt) ; + int opt = subgetopt_r(argc, argv, "vwsme0", &localopt) ; if (opt < 0) break ; switch (opt) { diff --git a/src/libexecline/exlsn_exlp.c b/src/libexecline/exlsn_exlp.c index 4ca513e..3a2e24b 100644 --- a/src/libexecline/exlsn_exlp.c +++ b/src/libexecline/exlsn_exlp.c @@ -1,7 +1,7 @@ /* ISC license. */ #include <skalibs/sgetopt.h> -#include <skalibs/uint.h> +#include <skalibs/types.h> #include "exlsn.h" int exlsn_exlp (int argc, char const **argv, char const *const *envp, exlsn_t *info) @@ -11,7 +11,7 @@ int exlsn_exlp (int argc, char const **argv, char const *const *envp, exlsn_t *i int n ; for (;;) { - register int opt = subgetopt_r(argc, argv, "P:", &localopt) ; + int opt = subgetopt_r(argc, argv, "P:", &localopt) ; if (opt < 0) break ; switch (opt) { diff --git a/src/libexecline/exlsn_import.c b/src/libexecline/exlsn_import.c index 6e37fd0..3b3ddf9 100644 --- a/src/libexecline/exlsn_import.c +++ b/src/libexecline/exlsn_import.c @@ -23,7 +23,7 @@ static int exlsn_import_as (int argc, char const **argv, char const *const *envp for (;;) { - register int opt = subgetopt_r(argc, argv, "iuD:nsCcd:", &localopt) ; + int opt = subgetopt_r(argc, argv, "iuD:nsCcd:", &localopt) ; if (opt < 0) break ; switch (opt) { @@ -56,7 +56,7 @@ static int exlsn_import_as (int argc, char const **argv, char const *const *envp if (!x) blah.n = 0 ; else { - register int r ; + int r ; if (!stralloc_cats(&info->values, x)) goto err ; r = el_transform(&info->values, blah.value, &si) ; if (r < 0) goto err ; @@ -73,6 +73,7 @@ static int exlsn_import_as (int argc, char const **argv, char const *const *envp int exlsn_import (int argc, char const **argv, char const *const *envp, exlsn_t *info) { + strerr_warn1x("the import command and directive are obsolescent, please use importas instead!") ; return exlsn_import_as(argc, argv, envp, info, 0) ; } diff --git a/src/libexecline/exlsn_multidefine.c b/src/libexecline/exlsn_multidefine.c index 9c5e248..4d84055 100644 --- a/src/libexecline/exlsn_multidefine.c +++ b/src/libexecline/exlsn_multidefine.c @@ -23,7 +23,7 @@ int exlsn_multidefine (int argc, char const **argv, char const *const *envp, exl si.split = 1 ; for (;;) { - register int opt = subgetopt_r(argc, argv, "0rnCcd:", &localopt) ; + int opt = subgetopt_r(argc, argv, "0rnCcd:", &localopt) ; if (opt < 0) break ; switch (opt) { @@ -45,7 +45,7 @@ int exlsn_multidefine (int argc, char const **argv, char const *const *envp, exl if (argc1 >= argc) return -3 ; if (!stralloc_cats(&info->values, x)) return -1 ; { - register int r = el_transform(&info->values, valbase, &si) ; + int r = el_transform(&info->values, valbase, &si) ; if (r < 0) goto err ; max = r ; } |