summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/execline/export.c13
-rw-r--r--src/execline/getcwd.c4
-rw-r--r--src/execline/heredoc.c2
-rw-r--r--src/execline/multisubstitute.c4
-rw-r--r--src/execline/trap.c4
-rw-r--r--src/execline/unexport.c7
-rw-r--r--src/libexecline/el_substitute.c8
-rw-r--r--src/libexecline/el_transform.c9
-rw-r--r--src/libexecline/el_vardupl.c7
-rw-r--r--src/libexecline/exlp.c9
-rw-r--r--src/libexecline/exlsn_define.c4
-rw-r--r--src/libexecline/exlsn_elglob.c6
-rw-r--r--src/libexecline/exlsn_import.c6
-rw-r--r--src/libexecline/exlsn_multidefine.c7
14 files changed, 42 insertions, 48 deletions
diff --git a/src/execline/export.c b/src/execline/export.c
index b189268..5319c71 100644
--- a/src/execline/export.c
+++ b/src/execline/export.c
@@ -1,7 +1,6 @@
/* ISC license. */
-#include <sys/types.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/strerr2.h>
#include <skalibs/env.h>
#include <skalibs/djbunix.h>
@@ -13,15 +12,15 @@ int main (int argc, char const *const *argv, char const *const *envp)
size_t len1 ;
PROG = "export" ;
if (argc < 4) strerr_dieusage(100, USAGE) ;
- len1 = str_len(argv[1]) ;
- if (byte_chr(argv[1], len1, '=') < len1)
+ len1 = strlen(argv[1]) ;
+ if (memchr(argv[1], '=', len1))
strerr_dief2x(100, "invalid variable name: ", argv[1]) ;
{
- size_t len2 = str_len(argv[2]) ;
+ size_t len2 = strlen(argv[2]) ;
char fmt[len1 + len2 + 2] ;
- byte_copy(fmt, len1, argv[1]) ;
+ memcpy(fmt, argv[1], len1) ;
fmt[len1] = '=' ;
- byte_copy(fmt + len1 + 1, len2 + 1, argv[2]) ;
+ memcpy(fmt + len1 + 1, argv[2], len2 + 1) ;
pathexec_r(argv+3, envp, env_len(envp), fmt, len1 + len2 + 2) ;
}
strerr_dieexec(111, argv[3]) ;
diff --git a/src/execline/getcwd.c b/src/execline/getcwd.c
index 116acab..aeb6691 100644
--- a/src/execline/getcwd.c
+++ b/src/execline/getcwd.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/strerr2.h>
#include <skalibs/env.h>
#include <skalibs/stralloc.h>
@@ -13,7 +13,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
stralloc sa = STRALLOC_ZERO ;
PROG = "getcwd" ;
if (argc < 3) strerr_dieusage(100, USAGE) ;
- if (argv[1][str_chr(argv[1], '=')])
+ if (strchr(argv[1], '='))
strerr_dief2x(100, "invalid variable name: ", argv[1]) ;
if (!stralloc_cats(&sa, argv[1]) || !stralloc_catb(&sa, "=", 1))
strerr_diefu1sys(111, "stralloc_catb") ;
diff --git a/src/execline/heredoc.c b/src/execline/heredoc.c
index 2e12451..77e69da 100644
--- a/src/execline/heredoc.c
+++ b/src/execline/heredoc.c
@@ -52,7 +52,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
}
fd_close(fd[1]) ;
- if (fd_move((int)fdr, fd[0]) == -1)
+ if (fd_move(fdr, fd[0]) == -1)
strerr_diefu2sys(111, "read on fd ", argv[0]) ;
}
pathexec_run(argv[2], argv+2, envp) ;
diff --git a/src/execline/multisubstitute.c b/src/execline/multisubstitute.c
index d7fbb4e..444ea47 100644
--- a/src/execline/multisubstitute.c
+++ b/src/execline/multisubstitute.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/strerr2.h>
#include <execline/execline.h>
#include "exlsn.h"
@@ -44,7 +44,7 @@ int main (int argc, char const **argv, char const *const *envp)
{
int n ;
unsigned int i = 0 ;
- for (; commands[i] ; i++) if (!str_diff(*argv, commands[i])) break ;
+ for (; commands[i] ; i++) if (!strcmp(*argv, commands[i])) break ;
if (!commands[i]) strerr_dief3x(100, "syntax error: unrecognized", " directive ", *argv) ;
n = (*(functions[i]))(argc1, argv, envp, &info) ;
if (n < 0) switch (n)
diff --git a/src/execline/trap.c b/src/execline/trap.c
index 79a00ff..29d13ef 100644
--- a/src/execline/trap.c
+++ b/src/execline/trap.c
@@ -115,8 +115,8 @@ 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] = "!=" ;
- size_t l = 2 + uint64_fmt(modif + 2, pids[NSIG+1]) ;
+ char modif[2 + PID_FMT] = "!=" ;
+ size_t l = 2 + pid_fmt(modif + 2, pids[NSIG+1]) ;
char const *newenvp[envlen + 2] ;
modif[l++] = 0 ;
if (!env_merge(newenvp, envlen + 2, envp, envlen, modif, l))
diff --git a/src/execline/unexport.c b/src/execline/unexport.c
index c7ffc77..e7350e8 100644
--- a/src/execline/unexport.c
+++ b/src/execline/unexport.c
@@ -1,7 +1,6 @@
/* ISC license. */
-#include <sys/types.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/strerr2.h>
#include <skalibs/env.h>
#include <skalibs/djbunix.h>
@@ -13,8 +12,8 @@ int main (int argc, char const *const *argv, char const *const *envp)
size_t len ;
PROG = "unexport" ;
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]) ;
pathexec_r(argv+2, envp, env_len(envp), argv[1], len+1) ;
strerr_dieexec(111, argv[2]) ;
diff --git a/src/libexecline/el_substitute.c b/src/libexecline/el_substitute.c
index 9fa2f70..6f50c2c 100644
--- a/src/libexecline/el_substitute.c
+++ b/src/libexecline/el_substitute.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <skalibs/bytestr.h>
#include <skalibs/stralloc.h>
#include <skalibs/genalloc.h>
@@ -65,12 +65,12 @@ static ssize_t parseword (stralloc *sa, genalloc *list, char const *s, char cons
unsigned int i = 0 ;
for (; i < nsubst ; i++)
{
- if (!str_diffn(vars + substs[i].var, s + mark, pos - mark) && !vars[substs[i].var + pos - mark])
+ if (!strncmp(vars + substs[i].var, s + mark, pos - mark) && !vars[substs[i].var + pos - mark])
{
sa->len -= esc >> 1 ; offset += esc >> 1 ;
if (esc & 1)
{
- byte_copy(sa->s + mark - offset - 2 - supp, pos - mark + 1 + supp, sa->s + mark - offset + (esc>>1) - 1 - supp) ;
+ memcpy(sa->s + mark - offset - 2 - supp, sa->s + mark - offset + (esc>>1) - 1 - supp, pos - mark + 1 + supp) ;
sa->len-- ; offset++ ;
}
else
@@ -118,7 +118,7 @@ static int substword (subsuinfo_t *info, size_t wordstart, size_t wordlen, unsig
stralloc_catb(&info->sa, info->sa.s + wordstart, l) ;
for (; i < list[n].subst->n ; i++)
{
- size_t plen = str_len(p) ;
+ size_t plen = strlen(p) ;
int r ;
info->sa.len = sabase + l ;
if (!stralloc_readyplus(&info->sa, plen + wordlen - l)) goto err ;
diff --git a/src/libexecline/el_transform.c b/src/libexecline/el_transform.c
index 6048d1e..59c146d 100644
--- a/src/libexecline/el_transform.c
+++ b/src/libexecline/el_transform.c
@@ -1,7 +1,6 @@
/* ISC license. */
-#include <sys/types.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/netstring.h>
#include <skalibs/skamisc.h>
#include <skalibs/stralloc.h>
@@ -14,7 +13,7 @@ static void el_crunch (stralloc *sa, size_t base, char const *delim)
for (; i < sa->len ; i++)
{
if (!crunching) sa->s[j++] = sa->s[i] ;
- if (delim[str_chr(delim, sa->s[i])]) crunching = 1 ;
+ if (strchr(delim, sa->s[i])) crunching = 1 ;
else if (crunching)
{
i-- ;
@@ -29,7 +28,7 @@ static int el_split (stralloc *sa, size_t base, eltransforminfo_t const *si, int
int n = 0 ;
size_t i = base ;
for (; i < sa->len ; i++)
- if (si->delim[str_chr(si->delim, sa->s[i])])
+ if (strchr(si->delim, sa->s[i]))
{
sa->s[i] = 0 ;
n++ ;
@@ -75,7 +74,7 @@ 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) ;
if (si->chomp && (sa->len > i)
- && si->delim[str_chr(si->delim, sa->s[sa->len-1])])
+ && strchr(si->delim, sa->s[sa->len-1]))
{
sa->len-- ;
chomped = 1 ;
diff --git a/src/libexecline/el_vardupl.c b/src/libexecline/el_vardupl.c
index 9efd586..d6c7dbf 100644
--- a/src/libexecline/el_vardupl.c
+++ b/src/libexecline/el_vardupl.c
@@ -1,13 +1,12 @@
/* ISC license. */
-#include <sys/types.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <execline/execline.h>
int el_vardupl (char const *key, char const *s, size_t len)
{
size_t i = 0 ;
- for (; i < len ; i += str_len(s + i) + 1)
- if (!str_diff(key, s + i)) return 1 ;
+ for (; i < len ; i += strlen(s + i) + 1)
+ if (!strcmp(key, s + i)) return 1 ;
return 0 ;
}
diff --git a/src/libexecline/exlp.c b/src/libexecline/exlp.c
index 5e323a9..1fae415 100644
--- a/src/libexecline/exlp.c
+++ b/src/libexecline/exlp.c
@@ -1,7 +1,6 @@
/* ISC license. */
-#include <sys/types.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/env.h>
#include <skalibs/strerr2.h>
#include <skalibs/stralloc.h>
@@ -42,7 +41,7 @@ int exlp (unsigned int nmin, char const *const *envp, exlsn_t *info)
blah.value = info->values.len ;
blah.n = 1 ;
if (!stralloc_catb(&info->vars, "#\0@", 4)
- || !stralloc_catb(&info->values, x, str_len(x) + 1)
+ || !stralloc_catb(&info->values, x, strlen(x) + 1)
|| !genalloc_append(elsubst_t, &info->data, &blah)) goto err ;
ntot = n > nmin ? n : nmin ;
poszero = info->values.len ;
@@ -58,11 +57,11 @@ int exlp (unsigned int nmin, char const *const *envp, exlsn_t *info)
blah.value = info->values.len ;
blah.n = 1 ;
if (!stralloc_catb(&info->vars, fmt, l+1)
- || !stralloc_catb(&info->values, x, str_len(x) + 1)
+ || !stralloc_catb(&info->values, x, strlen(x) + 1)
|| !genalloc_append(elsubst_t, &info->data, &blah)) goto err ;
}
blah.var = varbase + 2 ;
- blah.value = poszero + str_len(info->values.s + poszero) + 1 ;
+ blah.value = poszero + strlen(info->values.s + poszero) + 1 ;
blah.n = n ;
if (!genalloc_append(elsubst_t, &info->data, &blah)) goto err ;
return n ;
diff --git a/src/libexecline/exlsn_define.c b/src/libexecline/exlsn_define.c
index 066b8ff..3e7429c 100644
--- a/src/libexecline/exlsn_define.c
+++ b/src/libexecline/exlsn_define.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/sgetopt.h>
#include <skalibs/stralloc.h>
#include <skalibs/genalloc.h>
@@ -32,7 +32,7 @@ int exlsn_define (int argc, char const **argv, char const *const *envp, exlsn_t
if (argc < 2) return -3 ;
if (!*argv[0] || el_vardupl(argv[0], info->vars.s, info->vars.len)) return -2 ;
- if (!stralloc_catb(&info->vars, argv[0], str_len(argv[0]) + 1)) return -1 ;
+ if (!stralloc_catb(&info->vars, argv[0], strlen(argv[0]) + 1)) return -1 ;
if (!stralloc_cats(&info->values, argv[1])) goto err ;
{
int r = el_transform(&info->values, blah.value, &si) ;
diff --git a/src/libexecline/exlsn_elglob.c b/src/libexecline/exlsn_elglob.c
index e64c598..62734e6 100644
--- a/src/libexecline/exlsn_elglob.c
+++ b/src/libexecline/exlsn_elglob.c
@@ -2,7 +2,7 @@
#include <errno.h>
#include <glob.h>
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
#include <skalibs/stralloc.h>
@@ -46,7 +46,7 @@ int exlsn_elglob (int argc, char const **argv, char const *const *envp, exlsn_t
if (argc < 2) return -3 ;
if (!*argv[0] || el_vardupl(argv[0], info->vars.s, info->vars.len)) return -2 ;
- if (!stralloc_catb(&info->vars, argv[0], str_len(argv[0]) + 1)) return -1 ;
+ if (!stralloc_catb(&info->vars, argv[0], strlen(argv[0]) + 1)) return -1 ;
pglob.gl_offs = 0 ;
switch (glob(argv[1], flags, verbose ? &elgloberrfunc : 0, &pglob))
@@ -61,7 +61,7 @@ int exlsn_elglob (int argc, char const **argv, char const *const *envp, exlsn_t
default: goto err ;
}
for ( ; i < (unsigned int)pglob.gl_pathc ; i++)
- if (!stralloc_catb(&info->values, pglob.gl_pathv[i], str_len(pglob.gl_pathv[i]) + 1))
+ if (!stralloc_catb(&info->values, pglob.gl_pathv[i], strlen(pglob.gl_pathv[i]) + 1))
goto globerr ;
blah.n = pglob.gl_pathc ;
globfree(&pglob) ;
diff --git a/src/libexecline/exlsn_import.c b/src/libexecline/exlsn_import.c
index ff05113..254ab78 100644
--- a/src/libexecline/exlsn_import.c
+++ b/src/libexecline/exlsn_import.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/bytestr.h>
+#include <string.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
#include <skalibs/stralloc.h>
@@ -42,7 +42,7 @@ static int exlsn_import_as (int argc, char const **argv, char const *const *envp
if ((unsigned int)argc < 1+as) return -3 ;
if (!*argv[0] || el_vardupl(argv[0], info->vars.s, info->vars.len)) return -2 ;
- if (!stralloc_catb(&info->vars, argv[0], str_len(argv[0]) + 1)) return -1 ;
+ if (!stralloc_catb(&info->vars, argv[0], strlen(argv[0]) + 1)) return -1 ;
x = env_get2(envp, argv[as]) ;
if (!x)
{
@@ -51,7 +51,7 @@ static int exlsn_import_as (int argc, char const **argv, char const *const *envp
}
else if (unexport)
{
- if (!stralloc_catb(&info->modifs, argv[as], str_len(argv[as]) + 1)) goto err ;
+ if (!stralloc_catb(&info->modifs, argv[as], strlen(argv[as]) + 1)) goto err ;
}
if (!x) blah.n = 0 ;
else
diff --git a/src/libexecline/exlsn_multidefine.c b/src/libexecline/exlsn_multidefine.c
index 4d84055..bf50087 100644
--- a/src/libexecline/exlsn_multidefine.c
+++ b/src/libexecline/exlsn_multidefine.c
@@ -1,8 +1,7 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <skalibs/sgetopt.h>
-#include <skalibs/bytestr.h>
#include <skalibs/stralloc.h>
#include <skalibs/genalloc.h>
#include <execline/execline.h>
@@ -57,12 +56,12 @@ int exlsn_multidefine (int argc, char const **argv, char const *const *envp, exl
elsubst_t blah ;
blah.var = info->vars.len ;
if (el_vardupl(argv[i], info->vars.s, info->vars.len)) goto err2 ;
- if (!stralloc_catb(&info->vars, argv[i], str_len(argv[i]) + 1)) goto err ;
+ if (!stralloc_catb(&info->vars, argv[i], strlen(argv[i]) + 1)) goto err ;
blah.value = i < max ? pos : info->values.len - 1 ;
blah.n = (i < max) || !zeroword ;
if (!genalloc_append(elsubst_t, &info->data, &blah)) goto err ;
}
- if (i < max) pos += str_len(info->values.s + pos) + 1 ;
+ if (i < max) pos += strlen(info->values.s + pos) + 1 ;
}
if ((i < max) && likeread) genalloc_s(elsubst_t, &info->data)[i-1].n = max - i + 1 ;