suitcase

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 2f4242279fb029b463a4b41a3dff2d5c39a970da
parent 28603430eb4c5a645887b5aa8cf6c6d0eba8788f
Author: Lightning Bjornsson <lightning@chatspeed.net>
Date:   Sat, 26 Nov 2022 20:07:41 +0000

committed by Amelia pursuant to Lightning modifying ta_stralloc and adding djbbyte

Diffstat:
Ahead/byte/byte.h | 14++++++++++++++
Asrc/byte/QUELLE | 3+++
Asrc/byte/byte_chr.c | 18++++++++++++++++++
Asrc/byte/byte_copy.c | 11+++++++++++
Asrc/byte/byte_cr.c | 13+++++++++++++
Asrc/byte/byte_rchr.c | 20++++++++++++++++++++
Asrc/byte/byte_zero.c | 14++++++++++++++
Msrc/ta_stralloc/QUELLE | 2++
Msrc/ta_stralloc/stralloc_arts.c | 2++
Msrc/ta_stralloc/stralloc_catb.c | 1+
10 files changed, 98 insertions(+), 0 deletions(-)

diff --git a/head/byte/byte.h b/head/byte/byte.h @@ -0,0 +1,14 @@ +#ifndef BYTE_H +#define BYTE_H + +#include <string.h> + +extern unsigned int byte_chr(); +extern unsigned int byte_rchr(); +extern void byte_copy(); +extern void byte_copyr(); +extern void byte_zero(); + +#define byte_equal(s,n,t) (memcmp((s),(t),(n)) == 0) + +#endif diff --git a/src/byte/QUELLE b/src/byte/QUELLE @@ -0,0 +1,3 @@ +/pkg/umbrellix.net/prog/suitcase/src/byte Statement of Origin + +The headers and source files herewithin ultimately come from the byte facility of qmail, which was retrieved from https://github.com/notqmail/notqmail.git version @8c53cd40a3329d682a905decb1f8734fa1ba2e9a. The proximate source is the byte facility of nightmaremail version @4b667230f5d92b26795f35d3ae27cb7f1eef8e67. The ultimate source library is also present in some PD and non-free DJB wares. diff --git a/src/byte/byte_chr.c b/src/byte/byte_chr.c @@ -0,0 +1,18 @@ +#include "byte.h" + +unsigned int byte_chr(char *s, unsigned int n, int c) +{ + char ch; + char *t; + + ch = c; + t = s; + for (;;) { + if (!n) break; if (*t == ch) break; ++t; --n; + if (!n) break; if (*t == ch) break; ++t; --n; + if (!n) break; if (*t == ch) break; ++t; --n; + if (!n) break; if (*t == ch) break; ++t; --n; + } + /* loop unrolling? smart bernstein. */ + return t - s; +} diff --git a/src/byte/byte_copy.c b/src/byte/byte_copy.c @@ -0,0 +1,11 @@ +#include "byte.h" + +void byte_copy(char *to, unsigned int n, char *from) +{ + for (;;) { + if (!n) return; *to++ = *from++; --n; + if (!n) return; *to++ = *from++; --n; + if (!n) return; *to++ = *from++; --n; + if (!n) return; *to++ = *from++; --n; + } +} diff --git a/src/byte/byte_cr.c b/src/byte/byte_cr.c @@ -0,0 +1,13 @@ +#include "byte.h" + +void byte_copyr(char *to, unsigned int n, char *from) +{ + to += n; + from += n; + for (;;) { + if (!n) return; *--to = *--from; --n; + if (!n) return; *--to = *--from; --n; + if (!n) return; *--to = *--from; --n; + if (!n) return; *--to = *--from; --n; + } +} diff --git a/src/byte/byte_rchr.c b/src/byte/byte_rchr.c @@ -0,0 +1,20 @@ +#include "byte.h" + +unsigned int byte_rchr(char *s, unsigned int n, int c) +{ + char ch; + char *t; + char *u; + + ch = c; + t = s; + u = 0; + for (;;) { + if (!n) break; if (*t == ch) u = t; ++t; --n; + if (!n) break; if (*t == ch) u = t; ++t; --n; + if (!n) break; if (*t == ch) u = t; ++t; --n; + if (!n) break; if (*t == ch) u = t; ++t; --n; + } + if (!u) u = t; + return u - s; +} diff --git a/src/byte/byte_zero.c b/src/byte/byte_zero.c @@ -0,0 +1,14 @@ +#include "byte.h" + +/* void byte_zero(byte pointer s, unsigned int n) + * zero up to n bytes of a byte array lodged at s. + */ +void byte_zero(char *s, unsigned int n) +{ + for (;;) { + if (!n) break; *s++ = 0; --n; + if (!n) break; *s++ = 0; --n; + if (!n) break; *s++ = 0; --n; + if (!n) break; *s++ = 0; --n; + } +} diff --git a/src/ta_stralloc/QUELLE b/src/ta_stralloc/QUELLE @@ -3,3 +3,5 @@ The headers and source files herewithin ultimately come from the stralloc facility of qmail, which was retrieved from https://github.com/notqmail/notqmail.git version @8c53cd40a3329d682a905decb1f8734fa1ba2e9a. The proximate source is the stralloc facility of nightmaremail. The ultimate source library is also present in some PD and non-free DJB wares. This portion does not require skalibs. skalibs includes its own implementation of strallocs. + +This portion requires the byte library. diff --git a/src/ta_stralloc/stralloc_arts.c b/src/ta_stralloc/stralloc_arts.c @@ -2,6 +2,8 @@ #include "str.h" #include "ta_stralloc/stralloc.h" +/* Whose idea was calling this 'arts.c'?! Daniel? What was happening? Some 15ch filename limit? */ + int stralloc_starts(stralloc *sa, char *s) // PTYPE { unsigned int len; diff --git a/src/ta_stralloc/stralloc_catb.c b/src/ta_stralloc/stralloc_catb.c @@ -15,5 +15,6 @@ int stralloc_catb(stralloc *sa, char *s, unsigned int n) // PTYPE byte_copy(sa->s + sa->len,n,s); sa->len += n; sa->s[sa->len] = 'Z'; /* ``offensive programming'' */ + /* Lightning NOTE: Shouldn't that be a nullis, so I can feed sa->s into things that need a null-terminated string? */ return 1; }