From 6a9ca73e10c3c4e8a95101313e9c5d46cf018f86 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Sat, 7 Jan 2017 20:31:02 +0000 Subject: Types fix: first pass This pass makes variable size_t-ready, so everything works when the prototypes are fixed in skalibs. Some code uses "unsigned int *" where it should be "size_t *"; it cannot be changed now, but it's been marked with XXX. It must change at the same time as the skalibs API. --- src/execline/background.c | 2 +- src/execline/backtick.c | 4 +-- src/execline/dollarat.c | 3 +- src/execline/elgetopt.c | 6 ++-- src/execline/emptyenv.c | 3 +- src/execline/exec.c | 3 +- src/execline/execlineb.c | 3 +- src/execline/export.c | 5 ++-- src/execline/forbacktickx.c | 4 +-- src/execline/forstdin.c | 14 +++++----- src/execline/forx.c | 10 +++---- src/execline/getpid.c | 5 ++-- src/execline/heredoc.c | 3 +- src/execline/loopwhilex.c | 2 +- src/execline/pipeline.c | 2 +- src/execline/runblock.c | 3 +- src/execline/trap.c | 12 ++++---- src/execline/tryexec.c | 3 +- src/execline/unexport.c | 3 +- src/execline/withstdinas.c | 4 +-- src/include-local/exlsn.h | 2 +- src/include/execline/execline.h | 14 +++++----- src/libexecline/el_execsequence.c | 2 +- src/libexecline/el_parse.c | 11 ++++---- src/libexecline/el_parse_from_buffer.c | 3 +- src/libexecline/el_popenv.c | 11 ++++---- src/libexecline/el_pushenv.c | 13 +++++---- src/libexecline/el_spawn1.c | 3 +- src/libexecline/el_substandrun.c | 3 +- src/libexecline/el_substandrun_str.c | 3 +- src/libexecline/el_substitute.c | 50 +++++++++++++++++++--------------- src/libexecline/el_transform.c | 21 +++++++------- src/libexecline/el_vardupl.c | 5 ++-- src/libexecline/exlp.c | 16 ++++++----- src/libexecline/exlsn_multidefine.c | 7 +++-- 35 files changed, 144 insertions(+), 114 deletions(-) (limited to 'src') diff --git a/src/execline/background.c b/src/execline/background.c index d3e96ff..79771af 100644 --- a/src/execline/background.c +++ b/src/execline/background.c @@ -64,7 +64,7 @@ int main (int argc, char const **argv, char const *const *envp) #else char fmt[UINT64_FMT + 2] = "!=" ; #endif - register unsigned int i = 2 ; + 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 ; diff --git a/src/execline/backtick.c b/src/execline/backtick.c index 38ab0af..5ab4dfa 100644 --- a/src/execline/backtick.c +++ b/src/execline/backtick.c @@ -19,7 +19,7 @@ int main (int argc, char const **argv, char const *const *envp) pid_t pid ; int argc1, fdwstat ; stralloc modif = STRALLOC_ZERO ; - unsigned int modifstart ; + size_t modifstart ; int insist = 0, chomp = 0 ; char const *def = 0 ; PROG = "backtick" ; @@ -74,7 +74,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") ; { - unsigned int reallen = str_len(modif.s) ; + size_t reallen = str_len(modif.s) ; if (reallen < modif.len - 1) { if (insist >= 2) diff --git a/src/execline/dollarat.c b/src/execline/dollarat.c index 66b5c61..136968b 100644 --- a/src/execline/dollarat.c +++ b/src/execline/dollarat.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -52,7 +53,7 @@ int main (int argc, char const *const *argv, char const *const *envp) } else { - unsigned int written = 0 ; + size_t written = 0 ; if (!netstring_put(buffer_1, x, str_len(x), &written)) strerr_diefu1sys(111, "write a netstring to stdout") ; } diff --git a/src/execline/elgetopt.c b/src/execline/elgetopt.c index 4dfd4d8..a48968f 100644 --- a/src/execline/elgetopt.c +++ b/src/execline/elgetopt.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -13,10 +14,11 @@ int main (int argc, char const *const *argv, char const *const *envp) { - unsigned int n, nbak ; - unsigned int envlen = env_len(envp) ; + size_t envlen = env_len(envp) ; stralloc modif = STRALLOC_ZERO ; char const *x = env_get2(envp, "#") ; + unsigned int n, nbak ; + PROG = "elgetopt" ; if (argc < 3) strerr_dieusage(100, USAGE) ; if (!x) strerr_dienotset(100, "#") ; diff --git a/src/execline/emptyenv.c b/src/execline/emptyenv.c index cae8869..90d72d1 100644 --- a/src/execline/emptyenv.c +++ b/src/execline/emptyenv.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -77,7 +78,7 @@ int main (int argc, char const *const *argv, char const *const *envp) { static char const *const list[12] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "#", "ELGETOPT_" } ; stralloc sa = STRALLOC_ZERO ; - unsigned int envlen = env_len(envp) ; + size_t envlen = env_len(envp) ; int n = el_popenv(&sa, envp, envlen, flagpos ? list : list + 11, 11 * flagpos + flagopt) ; if (n < 0) strerr_diefu1sys(111, "pop current execline environment") ; { diff --git a/src/execline/exec.c b/src/execline/exec.c index 2213ba4..9b923ab 100644 --- a/src/execline/exec.c +++ b/src/execline/exec.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -36,7 +37,7 @@ int main (int argc, char const **argv, char const *const *envp) if (argv0) argv[0] = argv0 ; if (dash) { - register unsigned int n = str_len(argv[0]) ; + register size_t n = str_len(argv[0]) ; char dashed[n+2] ; dashed[0] = '-' ; byte_copy(dashed+1, n+1, argv[0]) ; diff --git a/src/execline/execlineb.c b/src/execline/execlineb.c index fbbaeee..3b14fe5 100644 --- a/src/execline/execlineb.c +++ b/src/execline/execlineb.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -175,7 +176,7 @@ int main (int argc, char const *const *argv, char const *const *envp) if (flagpushenv > 1) { static char const *const list[11] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "#" } ; - unsigned int envlen = env_len(envp) ; + size_t envlen = env_len(envp) ; char const *w[envlen] ; if (el_pushenv(&satmp, envp, envlen, list, 11) < 0) goto errenv ; if (!env_make(w, envlen, satmp.s, satmp.len)) goto errenv ; diff --git a/src/execline/export.c b/src/execline/export.c index e7a7bbe..b189268 100644 --- a/src/execline/export.c +++ b/src/execline/export.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -9,14 +10,14 @@ int main (int argc, char const *const *argv, char const *const *envp) { - unsigned int len1 ; + size_t len1 ; PROG = "export" ; if (argc < 4) strerr_dieusage(100, USAGE) ; len1 = str_len(argv[1]) ; if (byte_chr(argv[1], len1, '=') < len1) strerr_dief2x(100, "invalid variable name: ", argv[1]) ; { - unsigned int len2 = str_len(argv[2]) ; + size_t len2 = str_len(argv[2]) ; char fmt[len1 + len2 + 2] ; byte_copy(fmt, len1, argv[1]) ; fmt[len1] = '=' ; diff --git a/src/execline/forbacktickx.c b/src/execline/forbacktickx.c index c0c617a..9833174 100644 --- a/src/execline/forbacktickx.c +++ b/src/execline/forbacktickx.c @@ -40,7 +40,7 @@ int main (int argc, char const *const *argv, char const *const *envp) case 'o' : { unsigned short okcodes[256] ; - unsigned int nbc ; + unsigned int nbc ; /* XXX */ if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ; codes = l.arg ; not = 0 ; @@ -49,7 +49,7 @@ int main (int argc, char const *const *argv, char const *const *envp) case 'x' : { unsigned short okcodes[256] ; - unsigned int nbc ; + unsigned int nbc ; /* XXX */ if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ; codes = l.arg ; not = 1 ; diff --git a/src/execline/forstdin.c b/src/execline/forstdin.c index 3b52fab..96b6e8b 100644 --- a/src/execline/forstdin.c +++ b/src/execline/forstdin.c @@ -33,11 +33,11 @@ static int isok (unsigned short *tab, unsigned int n, int code) static void parallel_sigchld_handler (int sig) { pid_t *tab = genalloc_s(pid_t, &pids) ; - unsigned int len = genalloc_len(pid_t, &pids) ; + size_t len = genalloc_len(pid_t, &pids) ; int wstat ; for (;;) { - register int r = wait_pids_nohang(tab, len, &wstat) ; + register ssize_t r = wait_pids_nohang(tab, len, &wstat) ; if (r <= 0) break ; tab[r-1] = tab[--len] ; } @@ -74,11 +74,11 @@ int main (int argc, char const **argv, char const *const *envp) case 'd' : delim = l.arg ; delimlen = str_len(delim) ; break ; case 'o' : not = 0 ; - if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ; + if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ; /* XXX */ break ; case 'x' : not = 1 ; - if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ; + if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ; /* XXX */ break ; default : dieusage() ; } @@ -88,8 +88,8 @@ int main (int argc, char const **argv, char const *const *envp) if (argc < 2) dieusage() ; { stralloc modif = STRALLOC_ZERO ; - unsigned int envlen = env_len(envp) ; - unsigned int modifstart = str_len(argv[0])+1 ; + size_t envlen = env_len(envp) ; + size_t modifstart = str_len(argv[0])+1 ; char const *newenv[envlen + 2] ; if (!stralloc_ready(&modif, modifstart+1)) strerr_diefu1sys(111, "stralloc_ready") ; @@ -118,7 +118,7 @@ int main (int argc, char const **argv, char const *const *envp) } else { - unsigned int unread = 0 ; + unsigned int unread = 0 ; /* XXX: change to size_t when the skalibs API changes */ 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 bae2f4b..327f168 100644 --- a/src/execline/forx.c +++ b/src/execline/forx.c @@ -60,11 +60,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() ; + if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ; /* XXX */ break ; case 'x' : not = 1 ; - if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ; + if (!ushort_scanlist(okcodes, 256, l.arg, &nbc)) dieusage() ; /* XXX */ break ; default : dieusage() ; } @@ -81,8 +81,8 @@ int main (int argc, char const **argv, char const *const *envp) if (argc1 >= argc) strerr_dief1x(100, "unterminated block") ; if (!argc1 || (argc1 + 1 == argc)) return 0 ; { - unsigned int envlen = env_len(envp) ; - unsigned int varlen = str_len(x) ; + size_t envlen = env_len(envp) ; + size_t varlen = str_len(x) ; unsigned int i = 0 ; pid_t pids[flagpar ? argc1 : 1] ; char const *newenv[envlen + 2] ; @@ -90,7 +90,7 @@ int main (int argc, char const **argv, char const *const *envp) for (; i < (unsigned int)argc1 ; i++) { pid_t pid ; - unsigned int vallen = str_len(argv[i]) ; + size_t vallen = str_len(argv[i]) ; char modif[varlen + vallen + 2] ; byte_copy(modif, varlen, x) ; modif[varlen] = '=' ; diff --git a/src/execline/getpid.c b/src/execline/getpid.c index 03a517c..0ade4d3 100644 --- a/src/execline/getpid.c +++ b/src/execline/getpid.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -11,15 +12,15 @@ int main (int argc, char const *const *argv, char const *const *envp) { - unsigned int len ; + size_t len ; PROG = "getpid" ; if (argc < 3) strerr_dieusage(100, USAGE) ; len = str_len(argv[1]) ; if (byte_chr(argv[1], len, '=') < len) strerr_dief2x(100, "invalid variable name: ", argv[1]) ; { + size_t i = len+1 ; char fmt[UINT_FMT + len + 2] ; - unsigned int i = len+1 ; byte_copy(fmt, len, argv[1]) ; fmt[len] = '=' ; i += uint_fmt(fmt+i, getpid()) ; fmt[i++] = 0 ; diff --git a/src/execline/heredoc.c b/src/execline/heredoc.c index 899c2d8..c3dd691 100644 --- a/src/execline/heredoc.c +++ b/src/execline/heredoc.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -42,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: { - unsigned int len = str_len(argv[1]) ; + size_t len = str_len(argv[1]) ; PROG = "heredoc (child)" ; fd_close(fd[0]) ; if (allwrite(fd[1], argv[1], len) < len) diff --git a/src/execline/loopwhilex.c b/src/execline/loopwhilex.c index d2955ad..0f1f5e4 100644 --- a/src/execline/loopwhilex.c +++ b/src/execline/loopwhilex.c @@ -23,7 +23,7 @@ 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 ; + unsigned int nbc = 0 ; /* XXX */ PROG = "loopwhilex" ; { subgetopt_t l = SUBGETOPT_ZERO ; diff --git a/src/execline/pipeline.c b/src/execline/pipeline.c index ca5ef0f..fea0b87 100644 --- a/src/execline/pipeline.c +++ b/src/execline/pipeline.c @@ -73,7 +73,7 @@ int main (int argc, char const **argv, char const *const *envp) #else char fmt[UINT64_FMT + 2] = "!=" ; #endif - register unsigned int i = 2 ; + 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 ; diff --git a/src/execline/runblock.c b/src/execline/runblock.c index 4e3808d..c36675f 100644 --- a/src/execline/runblock.c +++ b/src/execline/runblock.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -132,7 +133,7 @@ int main (int argc, char const *const *argv, char const *const *envp) else /* popenv, then exec */ { char const *list[11] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "#" } ; - unsigned int envlen = env_len(envp) ; + size_t envlen = env_len(envp) ; register int popped = el_popenv(&satmp, envp, envlen, list, 11) ; if (popped < 0) strerr_diefu1sys(111, "pop environment") ; else diff --git a/src/execline/trap.c b/src/execline/trap.c index bfb5733..9a21e49 100644 --- a/src/execline/trap.c +++ b/src/execline/trap.c @@ -114,12 +114,12 @@ int main (int argc, char const **argv, char const *const *envp) { iopause_fd x = { .fd = spfd, .events = IOPAUSE_READ } ; + size_t envlen = env_len(envp) ; char modif[2 + UINT64_FMT] = "!=" ; - unsigned int envlen = env_len(envp) ; + size_t l = 2 + uint64_fmt(modif + 2, pids[NSIG+1]) ; char const *newenvp[envlen + 2] ; - i = 2 + uint64_fmt(modif + 2, pids[NSIG+1]) ; - modif[i++] = 0 ; - if (!env_merge(newenvp, envlen + 2, envp, envlen, modif, i)) + modif[l++] = 0 ; + if (!env_merge(newenvp, envlen + 2, envp, envlen, modif, l)) strerr_diefu1sys(111, "adjust environment") ; for (;;) { @@ -142,8 +142,8 @@ int main (int argc, char const **argv, char const *const *envp) case SIGCHLD : for (;;) { - int id, wstat ; - id = wait_pids_nohang(pids, NSIG + 2, &wstat) ; + int wstat ; + ssize_t id = wait_pids_nohang(pids, NSIG + 2, &wstat) ; if (id < 0 && errno != ECHILD) strerr_diefu1sys(111, "wait") ; if (id <= 0) break ; diff --git a/src/execline/tryexec.c b/src/execline/tryexec.c index 0612210..9026603 100644 --- a/src/execline/tryexec.c +++ b/src/execline/tryexec.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -49,7 +50,7 @@ int main (int argc, char const **argv, char const *const *envp) if (argv0) dom[0] = argv0 ; if (dash) { - register unsigned int n = str_len(dom[0]) ; + register size_t n = str_len(dom[0]) ; char dashed[n+2] ; dashed[0] = '-' ; byte_copy(dashed+1, n+1, dom[0]) ; diff --git a/src/execline/unexport.c b/src/execline/unexport.c index 189249c..c7ffc77 100644 --- a/src/execline/unexport.c +++ b/src/execline/unexport.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -9,7 +10,7 @@ int main (int argc, char const *const *argv, char const *const *envp) { - unsigned int len ; + size_t len ; PROG = "unexport" ; if (argc < 3) strerr_dieusage(100, USAGE) ; len = str_len(argv[1]) ; diff --git a/src/execline/withstdinas.c b/src/execline/withstdinas.c index af7140f..7729024 100644 --- a/src/execline/withstdinas.c +++ b/src/execline/withstdinas.c @@ -17,7 +17,7 @@ int main (int argc, char const **argv, char const *const *envp) { subgetopt_t localopt = SUBGETOPT_ZERO ; stralloc modif = STRALLOC_ZERO ; - unsigned int modifstart ; + size_t modifstart ; int insist = 0, chomp = 0 ; char const *def = 0 ; PROG = "withstdinas" ; @@ -44,7 +44,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") ; { - unsigned int reallen = str_len(modif.s) ; + size_t reallen = str_len(modif.s) ; if (reallen < modif.len - 1) { if (insist >= 2) diff --git a/src/include-local/exlsn.h b/src/include-local/exlsn.h index 2bdcf58..238bd6b 100644 --- a/src/include-local/exlsn.h +++ b/src/include-local/exlsn.h @@ -32,7 +32,7 @@ extern exlsnfunc_t exlsn_multidefine ; extern int exlp (unsigned int, char const *const *, exlsn_t *) ; extern void el_substandrun (int, char const *const *, char const *const *, exlsn_t const *) gccattr_noreturn ; -extern void el_substandrun_str (stralloc *, unsigned int, char const *const *, exlsn_t const *) gccattr_noreturn ; +extern void el_substandrun_str (stralloc *, size_t, char const *const *, exlsn_t const *) gccattr_noreturn ; extern void exlsn_main (int, char const **, char const *const *, exlsnfunc_t *, char const *) gccattr_noreturn ; #endif diff --git a/src/include/execline/execline.h b/src/include/execline/execline.h index 45ee1e5..bbe4db9 100644 --- a/src/include/execline/execline.h +++ b/src/include/execline/execline.h @@ -26,14 +26,14 @@ extern int el_parse_from_buffer (stralloc *, buffer *) ; /* Basics */ -extern int el_vardupl (char const *, char const *, unsigned int) gccattr_pure ; +extern int el_vardupl (char const *, char const *, size_t) gccattr_pure ; extern unsigned int el_getstrict (void) gccattr_const ; /* Environment shifting */ -extern int el_pushenv (stralloc *, char const *const *, unsigned int, char const *const *, unsigned int) ; -extern int el_popenv (stralloc *, char const *const *, unsigned int, char const *const *, unsigned int) ; +extern int el_pushenv (stralloc *, char const *const *, size_t, char const *const *, size_t) ; +extern int el_popenv (stralloc *, char const *const *, size_t, char const *const *, size_t) ; /* Sequence */ @@ -61,7 +61,7 @@ struct eltransforminfo_s #define ELTRANSFORMINFO_ZERO { .delim = " \n\r\t", .crunch = 0, .chomp = 0, .split = 0 } -extern int el_transform (stralloc *, unsigned int, eltransforminfo_t const *) ; +extern int el_transform (stralloc *, size_t, eltransforminfo_t const *) ; /* Substitution */ @@ -69,11 +69,11 @@ extern int el_transform (stralloc *, unsigned int, eltransforminfo_t const *) ; typedef struct elsubst_s elsubst_t, *elsubst_t_ref ; struct elsubst_s { - unsigned int var ; - unsigned int value ; + size_t var ; + size_t value ; unsigned int n ; } ; -extern int el_substitute (stralloc *, char const *, unsigned int, char const *, char const *, elsubst_t const *, unsigned int) ; +extern int el_substitute (stralloc *, char const *, size_t, char const *, char const *, elsubst_t const *, unsigned int) ; #endif diff --git a/src/libexecline/el_execsequence.c b/src/libexecline/el_execsequence.c index 6b825af..d697f2e 100644 --- a/src/libexecline/el_execsequence.c +++ b/src/libexecline/el_execsequence.c @@ -19,8 +19,8 @@ void el_execsequence (char const *const *argv1, char const *const *argv2, char c } else { + size_t j = 2 ; int wstat ; - unsigned int j = 2 ; #ifdef EXECLINE_OLD_VARNAMES char fmt[UINT_FMT * 2 + 15] = "?=" ; #else diff --git a/src/libexecline/el_parse.c b/src/libexecline/el_parse.c index 1544f51..acff34a 100644 --- a/src/libexecline/el_parse.c +++ b/src/libexecline/el_parse.c @@ -1,6 +1,7 @@ /* ISC license. */ -#include +#include +#include #include #include #include @@ -10,7 +11,7 @@ int el_parse (stralloc *sa, el_chargen_func_t_ref next, void *source) { static unsigned char const class[256] = "`aaaaaaaaadaaaaaaaaaaaaaaaaaaaaaafcbffffffffffffjhhhhhhhiifffffffmmmmmmfffffffffffffffffffffeffffggmmmgfffffffkfffkfkfkflffnfoffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" ; - static uint16 const table[16][16] = + static uint16_t const table[16][16] = { { 0x0011, 0x4011, 0x0010, 0x0010, 0x0010, 0x0011, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x4091 }, { 0x0000, 0x4000, 0x8001, 0x8003, 0x8003, 0x0005, 0x0010, 0x8403, 0x8403, 0x8403, 0x8403, 0x0010, 0x8403, 0x8403, 0x0100, 0x4080 }, @@ -30,14 +31,14 @@ int el_parse (stralloc *sa, el_chargen_func_t_ref next, void *source) { 0x820f, 0x8001, 0x8001, 0x8003, 0x8003, 0x0005, 0x0010, 0x8403, 0x8403, 0x8403, 0x8403, 0x0010, 0x8403, 0x8403, 0x8001, 0x8001 } } ; - unsigned int mark = 0 ; - unsigned int n = 0 ; + size_t mark = 0 ; + int n = 0 ; unsigned int blevel = 0 ; unsigned char state = 0, base = 10 ; while (state < 0x10) { - uint16 c ; + uint16_t c ; unsigned char cur ; if (!(*next)(&cur, source)) return -1 ; c = table[class[cur]-'`'][state] ; diff --git a/src/libexecline/el_parse_from_buffer.c b/src/libexecline/el_parse_from_buffer.c index 802fe40..83862f3 100644 --- a/src/libexecline/el_parse_from_buffer.c +++ b/src/libexecline/el_parse_from_buffer.c @@ -1,12 +1,13 @@ /* ISC license. */ +#include #include #include #include static int next (unsigned char *c, void *p) { - register int r = buffer_get((buffer *)p, (char *)c, 1) ; + register 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 3726506..c0089d0 100644 --- a/src/libexecline/el_popenv.c +++ b/src/libexecline/el_popenv.c @@ -1,18 +1,19 @@ /* ISC license. */ +#include #include #include #include #include #include -int el_popenv (stralloc *sa, char const *const *envp, unsigned int envlen, char const *const *list, unsigned int listlen) +int el_popenv (stralloc *sa, char const *const *envp, size_t envlen, char const *const *list, size_t listlen) { - unsigned int i = 0, salen = sa->len, count = 0 ; + size_t i = 0, salen = sa->len ; + int count = 0 ; for (; i < envlen ; i++) { - unsigned int equal, colon, n ; - unsigned int j = 0 ; + 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]) ; @@ -34,7 +35,7 @@ int el_popenv (stralloc *sa, char const *const *envp, unsigned int envlen, char copyit: if (!stralloc_catb(sa, envp[i], str_len(envp[i]) + 1)) goto err ; } - return (int)count ; + return count ; badenv : errno = EINVAL ; diff --git a/src/libexecline/el_pushenv.c b/src/libexecline/el_pushenv.c index 9b9608d..4ec43bb 100644 --- a/src/libexecline/el_pushenv.c +++ b/src/libexecline/el_pushenv.c @@ -1,18 +1,19 @@ /* ISC license. */ +#include #include #include #include #include #include -int el_pushenv (stralloc *sa, char const *const *envp, unsigned int envlen, char const *const *list, unsigned int listlen) +int el_pushenv (stralloc *sa, char const *const *envp, size_t envlen, char const *const *list, size_t listlen) { - unsigned int i = 0, salen = sa->len, count = 0 ; + size_t i = 0, salen = sa->len ; + int count = 0 ; for (; i < envlen ; i++) { - unsigned int equal, colon ; - unsigned int j = 0 ; + size_t equal, colon, j = 0 ; for (; j < listlen ; j++) if (str_start(envp[i], list[j])) break ; if (j == listlen) goto copyit ; count++ ; @@ -27,8 +28,8 @@ int el_pushenv (stralloc *sa, char const *const *envp, unsigned int envlen, char } else { + size_t n ; char fmt[UINT_FMT+1] = ":" ; - unsigned int n ; if (colon + 1 + uint_scan(envp[i] + colon + 1, &n) != equal) goto copyit ; n = 1 + uint_fmt(fmt+1, n+1) ; if (!stralloc_catb(sa, envp[i], colon)) goto err ; @@ -39,7 +40,7 @@ int el_pushenv (stralloc *sa, char const *const *envp, unsigned int envlen, char copyit: if (!stralloc_catb(sa, envp[i], str_len(envp[i]) + 1)) goto err ; } - return (int)count ; + return count ; badenv : errno = EINVAL ; diff --git a/src/libexecline/el_spawn1.c b/src/libexecline/el_spawn1.c index f84b10a..f434d70 100644 --- a/src/libexecline/el_spawn1.c +++ b/src/libexecline/el_spawn1.c @@ -2,13 +2,14 @@ #include #include +#include #include pid_t el_spawn1 (char const *prog, char const *const *argv, char const *const *envp, int *fd, int w) { if (!argv[0]) { - static char const *const newargv[2] = { "/bin/true", 0 } ; + static char const *const newargv[3] = { EXECLINE_BINPREFIX "exit", "0", 0 } ; return child_spawn1_pipe(newargv[0], newargv, 0, fd, w) ; } else return child_spawn1_pipe(prog, argv, envp, fd, w) ; diff --git a/src/libexecline/el_substandrun.c b/src/libexecline/el_substandrun.c index 11502ea..8b8084a 100644 --- a/src/libexecline/el_substandrun.c +++ b/src/libexecline/el_substandrun.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -8,6 +9,6 @@ void el_substandrun (int argc, char const *const *argv, char const *const *envp, exlsn_t const *info) { satmp.len = 0 ; - if (!env_string(&satmp, argv, (unsigned int)argc)) strerr_diefu1sys(111, "env_string") ; + if (!env_string(&satmp, argv, (size_t)argc)) strerr_diefu1sys(111, "env_string") ; el_substandrun_str(&satmp, 0, envp, info) ; } diff --git a/src/libexecline/el_substandrun_str.c b/src/libexecline/el_substandrun_str.c index 8168287..a935b82 100644 --- a/src/libexecline/el_substandrun_str.c +++ b/src/libexecline/el_substandrun_str.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -9,7 +10,7 @@ #include #include "exlsn.h" -void el_substandrun_str (stralloc *src, unsigned int srcbase, char const *const *envp, exlsn_t const *info) +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)) ; diff --git a/src/libexecline/el_substitute.c b/src/libexecline/el_substitute.c index a94c16d..9fa2f70 100644 --- a/src/libexecline/el_substitute.c +++ b/src/libexecline/el_substitute.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -9,7 +10,7 @@ typedef struct elsubsu_s elsubsu_t, *elsubsu_t_ref ; struct elsubsu_s { elsubst_t const *subst ; - unsigned int pos ; + size_t pos ; } ; typedef struct subsuinfo_s subsuinfo_t, *subsuinfo_t_ref ; @@ -36,7 +37,7 @@ struct subsuinfo_s #define INVARBR 0x04 #define ACCEPT 0x05 -static int parseword (stralloc *sa, genalloc *list, char const *s, char const *vars, elsubst_t const *substs, unsigned int nsubst) +static ssize_t parseword (stralloc *sa, genalloc *list, char const *s, char const *vars, elsubst_t const *substs, unsigned int nsubst) { static char const class[5] = "\0\\${}" ; static unsigned char const table[6][5] = @@ -49,7 +50,8 @@ static int parseword (stralloc *sa, genalloc *list, char const *s, char const *v { INWORD, INVAR | MARK | KEEPESC, INVARBR | MARK | KEEPESC, INVAR | KEEPESC, INVARBR | KEEPESC } } ; - unsigned int mark = 0, pos = 0, offset = 0, esc = 0, salen = sa->len, listlen = genalloc_len(elsubsu_t, list) ; + size_t mark = 0, offset = 0, esc = 0, salen = sa->len, listlen = genalloc_len(elsubsu_t, list) ; + ssize_t pos = 0 ; unsigned char state = INWORD ; while (state != ACCEPT) @@ -93,7 +95,7 @@ static int parseword (stralloc *sa, genalloc *list, char const *s, char const *v state = c & STATE ; pos++ ; } sa->len-- ; - return (int)pos ; + return pos ; err: sa->len = salen ; @@ -101,23 +103,23 @@ err: return -1 ; } -static int substword (subsuinfo_t *info, unsigned int wordstart, unsigned int wordlen, unsigned int n, unsigned int offset) +static int substword (subsuinfo_t *info, size_t wordstart, size_t wordlen, unsigned int n, size_t offset) { if (n < genalloc_len(elsubsu_t, &info->list)) { elsubsu_t *list = genalloc_s(elsubsu_t, &info->list) ; char const *p = info->values + list[n].subst->value ; - unsigned int l = list[n].pos + offset ; - unsigned int dstbase = info->dst.len ; - unsigned int sabase = info->sa.len ; + size_t l = list[n].pos + offset ; + size_t dstbase = info->dst.len ; + size_t sabase = info->sa.len ; unsigned int i = 0 ; int nc = 0 ; if (!stralloc_readyplus(&info->sa, l)) return -1 ; stralloc_catb(&info->sa, info->sa.s + wordstart, l) ; - for ( ; i < list[n].subst->n ; i++) + for (; i < list[n].subst->n ; i++) { + size_t plen = str_len(p) ; int r ; - unsigned int plen = str_len(p) ; info->sa.len = sabase + l ; if (!stralloc_readyplus(&info->sa, plen + wordlen - l)) goto err ; stralloc_catb(&info->sa, p, plen) ; @@ -142,33 +144,37 @@ static int substword (subsuinfo_t *info, unsigned int wordstart, unsigned int wo } } -int el_substitute (stralloc *dst, char const *src, unsigned int len, char const *vars, char const *values, elsubst_t const *substs, unsigned int nsubst) +int el_substitute (stralloc *dst, char const *src, size_t len, char const *vars, char const *values, elsubst_t const *substs, unsigned int nsubst) { subsuinfo_t info = SUBSUINFO_ZERO ; - unsigned int nc = 0 ; - unsigned int i = 0 ; - unsigned int dstbase = dst->len ; + size_t i = 0 ; + size_t dstbase = dst->len ; + int nc = 0 ; int wasnull = !dst->s ; + info.dst = *dst ; info.values = values ; while (i < len) { - int r ; genalloc_setlen(elsubsu_t, &info.list, 0) ; info.sa.len = 0 ; - r = parseword(&info.sa, &info.list, src + i, vars, substs, nsubst) ; - if (r < 0) goto err ; - i += r ; - r = substword(&info, 0, info.sa.len, 0, 0) ; - if (r < 0) goto err ; - nc += r ; + { + ssize_t r = parseword(&info.sa, &info.list, src + i, vars, substs, nsubst) ; + if (r < 0) goto err ; + i += r ; + } + { + int r = substword(&info, 0, info.sa.len, 0, 0) ; + if (r < 0) goto err ; + nc += r ; + } } genalloc_free(elsubsu_t, &info.list) ; stralloc_free(&info.sa) ; if (!wasnull) stralloc_free(dst) ; *dst = info.dst ; - return (int)nc ; + return nc ; err : genalloc_free(elsubsu_t, &info.list) ; diff --git a/src/libexecline/el_transform.c b/src/libexecline/el_transform.c index ac84d1d..210cbdf 100644 --- a/src/libexecline/el_transform.c +++ b/src/libexecline/el_transform.c @@ -1,14 +1,15 @@ /* ISC license. */ +#include #include #include #include #include #include -static void el_crunch (stralloc *sa, unsigned int base, char const *delim) +static void el_crunch (stralloc *sa, size_t base, char const *delim) { - register unsigned int i = base, j = base ; + register size_t i = base, j = base ; register int crunching = 0 ; for (; i < sa->len ; i++) { @@ -23,10 +24,10 @@ static void el_crunch (stralloc *sa, unsigned int base, char const *delim) sa->len = j ; } -static int el_split (stralloc *sa, unsigned int base, eltransforminfo_t const *si, int chomped) +static int el_split (stralloc *sa, size_t base, eltransforminfo_t const *si, int chomped) { - unsigned int n = 0 ; - register unsigned int i = base ; + int n = 0 ; + register size_t i = base ; for (; i < sa->len ; i++) if (si->delim[str_chr(si->delim, sa->s[i])]) { @@ -44,13 +45,13 @@ static int el_split (stralloc *sa, unsigned int base, eltransforminfo_t const *s return n ; } -static int el_splitnetstring (stralloc *sa, unsigned int base) +static int el_splitnetstring (stralloc *sa, size_t base) { - unsigned int tmpbase = satmp.len ; - unsigned int n = 0, i = base ; + size_t tmpbase = satmp.len, i = base ; + int n = 0 ; while (i < sa->len) { - register int r = netstring_decode(&satmp, sa->s + i, sa->len - i) ; + register 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++ ; @@ -69,7 +70,7 @@ err: return -1 ; } -int el_transform (stralloc *sa, unsigned int i, eltransforminfo_t const *si) +int el_transform (stralloc *sa, size_t i, eltransforminfo_t const *si) { int chomped = 0 ; if (si->crunch && *si->delim) el_crunch(sa, i, si->delim) ; diff --git a/src/libexecline/el_vardupl.c b/src/libexecline/el_vardupl.c index 7583669..279e79d 100644 --- a/src/libexecline/el_vardupl.c +++ b/src/libexecline/el_vardupl.c @@ -1,11 +1,12 @@ /* ISC license. */ +#include #include #include -int el_vardupl (char const *key, char const *s, unsigned int len) +int el_vardupl (char const *key, char const *s, size_t len) { - register unsigned int i = 0 ; + register 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 060eb68..1ba37c0 100644 --- a/src/libexecline/exlp.c +++ b/src/libexecline/exlp.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -11,13 +12,14 @@ int exlp (unsigned int nmin, char const *const *envp, exlsn_t *info) { - unsigned int varbase = info->vars.len ; - unsigned int valbase = info->values.len ; - unsigned int datbase = genalloc_len(elsubst_t, &info->data) ; - unsigned int i = 0 ; - char const *x = env_get2(envp, "#") ; + size_t varbase = info->vars.len ; + size_t valbase = info->values.len ; + size_t datbase = genalloc_len(elsubst_t, &info->data) ; + size_t poszero ; elsubst_t blah ; - unsigned int n, ntot, poszero ; + char const *x = env_get2(envp, "#") ; + unsigned int n, ntot, i = 0 ; + if (!x) return -2 ; if (!uint0_scan(x, &n)) return -2 ; if (el_vardupl("#", info->vars.s, info->vars.len)) return -2 ; @@ -47,7 +49,7 @@ int exlp (unsigned int nmin, char const *const *envp, exlsn_t *info) for (; i <= ntot ; i++) { char fmt[UINT_FMT] ; - unsigned int l = uint_fmt(fmt, i) ; + size_t l = uint_fmt(fmt, i) ; fmt[l] = 0 ; if (el_vardupl(fmt, info->vars.s, info->vars.len)) goto err2 ; x = (i <= n) ? env_get2(envp, fmt) : "" ; diff --git a/src/libexecline/exlsn_multidefine.c b/src/libexecline/exlsn_multidefine.c index e64cbfd..9c5e248 100644 --- a/src/libexecline/exlsn_multidefine.c +++ b/src/libexecline/exlsn_multidefine.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -11,9 +12,9 @@ int exlsn_multidefine (int argc, char const **argv, char const *const *envp, exl { eltransforminfo_t si = ELTRANSFORMINFO_ZERO ; subgetopt_t localopt = SUBGETOPT_ZERO ; - unsigned int varbase = info->vars.len ; - unsigned int valbase = info->values.len ; - unsigned int pos = valbase ; + size_t varbase = info->vars.len ; + size_t valbase = info->values.len ; + size_t pos = valbase ; unsigned int i = 0 ; unsigned int max ; char const *x ; -- cgit 1.4.1