summaryrefslogtreecommitdiff
path: root/src/libexecline/el_transform.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-01-07 20:31:02 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-01-07 20:31:02 +0000
commit6a9ca73e10c3c4e8a95101313e9c5d46cf018f86 (patch)
tree41ae80cb08fa1e280012b799ad0d1e63090b19bc /src/libexecline/el_transform.c
parent6245dcef12eed3b12b129519eeaf11f7e221d278 (diff)
downloadexecline-6a9ca73e10c3c4e8a95101313e9c5d46cf018f86.tar.xz
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.
Diffstat (limited to 'src/libexecline/el_transform.c')
-rw-r--r--src/libexecline/el_transform.c21
1 files changed, 11 insertions, 10 deletions
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 <sys/types.h>
#include <skalibs/bytestr.h>
#include <skalibs/netstring.h>
#include <skalibs/skamisc.h>
#include <skalibs/stralloc.h>
#include <execline/execline.h>
-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) ;