diff --git a/array/array_allocate.c b/array/array_allocate.c index a9c1c4a..586e787 100644 --- a/array/array_allocate.c +++ b/array/array_allocate.c @@ -1,9 +1,9 @@ -#include "likely.h" +#include #include #include -#include "safemult.h" -#include "array.h" -#include "byte.h" +#include +#include +#include #if 0 static array x; @@ -46,26 +46,26 @@ void* array_allocate(array* x,uint64 membersize,int64 pos) { uint64 wanted; - if (__unlikely(x->allocated<0)) return 0; /* array is failed */ - if (__unlikely(pos+1<1)) return 0; + if (unlikely(x->allocated<0)) return 0; /* array is failed */ + if (unlikely(pos+1<1)) return 0; /* second case of overflow: pos*membersize too large */ - if (__unlikely(!umult64(membersize,pos+1,&wanted))) return 0; + if (unlikely(!umult64(membersize,pos+1,&wanted))) return 0; if (wanted > (uint64)x->initialized) { - if (__unlikely(wanted >= (uint64)x->allocated)) { + if (unlikely(wanted >= (uint64)x->allocated)) { /* round up a little */ if (membersize<8) wanted=(wanted+127)&(-128ll); /* round up to multiple of 128 */ else wanted=(wanted+4095)&(-4096ll); /* round up to 4k pages */ - if (__unlikely(wanted<128)) return 0; /* overflow during rounding */ + if (unlikely(wanted<128)) return 0; /* overflow during rounding */ - if (sizeof(size_t) != sizeof(int64) && __unlikely((size_t)(wanted) != wanted)) + if (sizeof(size_t) != sizeof(int64) && unlikely((size_t)(wanted) != wanted)) return 0; { char* tmp=realloc(x->p,wanted); - if (__unlikely(!tmp)) return 0; + if (unlikely(!tmp)) return 0; x->p=tmp; } x->allocated=wanted; diff --git a/array/array_bytes.c b/array/array_bytes.c index b75a238..46dc57e 100644 --- a/array/array_bytes.c +++ b/array/array_bytes.c @@ -1,4 +1,4 @@ -#include "array.h" +#include int64 array_bytes(const array* const x) { if (x->allocated<0) return -1; diff --git a/array/array_cat.c b/array/array_cat.c index 80bc6bc..92c9a32 100644 --- a/array/array_cat.c +++ b/array/array_cat.c @@ -1,5 +1,5 @@ -#include "array.h" -#include "byte.h" +#include +#include void array_cat(array* to,const array* const from) { if (from->allocated<0) { diff --git a/array/array_cat0.c b/array/array_cat0.c index 883043b..d92630b 100644 --- a/array/array_cat0.c +++ b/array/array_cat0.c @@ -1,4 +1,4 @@ -#include "array.h" +#include void array_cat0(array* to) { static char zero; diff --git a/array/array_catb.c b/array/array_catb.c index c2bc7f3..5ba7647 100644 --- a/array/array_catb.c +++ b/array/array_catb.c @@ -1,5 +1,5 @@ -#include "array.h" -#include "byte.h" +#include +#include void array_catb(array* to,const char* from,uint64 len) { long l; diff --git a/array/array_cate.c b/array/array_cate.c index 8eba573..ec9f3cf 100644 --- a/array/array_cate.c +++ b/array/array_cate.c @@ -1,4 +1,4 @@ -#include "array.h" +#include void array_cate(array* to,const array* const from,int64 pos,int64 stop) { if (pos<0 || stop +#include void array_cats(array* to,const char* from) { array_catb(to,from,str_len(from)); diff --git a/array/array_cats0.c b/array/array_cats0.c index 6981afb..f9c94ff 100644 --- a/array/array_cats0.c +++ b/array/array_cats0.c @@ -1,5 +1,5 @@ -#include "array.h" -#include "str.h" +#include +#include void array_cats0(array* to,const char* from) { array_catb(to,from,str_len(from)+1); diff --git a/array/array_equal.c b/array/array_equal.c index 41a1208..e6156cf 100644 --- a/array/array_equal.c +++ b/array/array_equal.c @@ -1,5 +1,5 @@ -#include "byte.h" -#include "array.h" +#include +#include int array_equal(const array* const x,const array* const y) { if (x->initialized!=y->initialized) return 0; diff --git a/array/array_fail.c b/array/array_fail.c index dcccc78..941974e 100644 --- a/array/array_fail.c +++ b/array/array_fail.c @@ -1,5 +1,5 @@ #include -#include "array.h" +#include void array_fail(array* x) { if (x->p) free(x->p); diff --git a/array/array_get.c b/array/array_get.c index d1e25a5..a68531d 100644 --- a/array/array_get.c +++ b/array/array_get.c @@ -1,6 +1,6 @@ -#include "likely.h" -#include "safemult.h" -#include "array.h" +#include +#include +#include #if 0 static array x; @@ -17,9 +17,9 @@ void* array_get(const array* const x,uint64 membersize,int64 pos) { uint64 wanted; - if (__unlikely(pos+1<1)) return 0; - if (__unlikely(!umult64(membersize,pos,&wanted))) return 0; + if (unlikely(pos+1<1)) return 0; + if (unlikely(!umult64(membersize,pos,&wanted))) return 0; - if (__unlikely((int64)wanted >= x->allocated || wanted>=x->initialized)) return 0; + if (unlikely((int64)wanted >= x->allocated || wanted>=x->initialized)) return 0; return (void*)(x->p+pos*membersize); } diff --git a/array/array_length.c b/array/array_length.c index 122a1f7..eac057b 100644 --- a/array/array_length.c +++ b/array/array_length.c @@ -1,4 +1,4 @@ -#include "array.h" +#include int64 array_length(const array* const x,uint64 membersize) { if (x->allocated<0) return -1; diff --git a/array/array_reset.c b/array/array_reset.c index 52cbca3..daabffa 100644 --- a/array/array_reset.c +++ b/array/array_reset.c @@ -1,5 +1,5 @@ #include -#include "array.h" +#include void array_reset(array* x) { if (x->p) free(x->p); diff --git a/array/array_start.c b/array/array_start.c index d8dcb45..00fbacb 100644 --- a/array/array_start.c +++ b/array/array_start.c @@ -1,4 +1,4 @@ -#include "array.h" +#include void* array_start(const array* const x) { return x->p; diff --git a/array/array_trunc.c b/array/array_trunc.c index 08a2b7d..bf406b9 100644 --- a/array/array_trunc.c +++ b/array/array_trunc.c @@ -1,4 +1,4 @@ -#include "array.h" +#include void array_trunc(array* x) { x->initialized=0; diff --git a/array/array_truncate.c b/array/array_truncate.c index 8a3e25d..d3de4b5 100644 --- a/array/array_truncate.c +++ b/array/array_truncate.c @@ -1,12 +1,12 @@ -#include "likely.h" -#include "safemult.h" -#include "array.h" +#include +#include +#include /* I'm not sure I understand what this function is good for */ void array_truncate(array* x,uint64 membersize,int64 len) { uint64 wanted; - if (__unlikely(len<0)) return; - if (__unlikely(!umult64(membersize,len,&wanted))) return; - if (__unlikely(wanted > x->initialized)) return; + if (unlikely(len<0)) return; + if (unlikely(!umult64(membersize,len,&wanted))) return; + if (unlikely(wanted > x->initialized)) return; x->initialized=wanted; } diff --git a/array/iarray_allocate.c b/array/iarray_allocate.c index a7bb3d2..5144d8d 100644 --- a/array/iarray_allocate.c +++ b/array/iarray_allocate.c @@ -1,11 +1,10 @@ -#include "likely.h" #include #ifndef _WIN32 #include #include #include #endif -#include "iarray.h" +#include #ifdef __dietlibc__ #include #else diff --git a/array/iarray_free.c b/array/iarray_free.c index f042b30..ffed8f4 100644 --- a/array/iarray_free.c +++ b/array/iarray_free.c @@ -4,7 +4,7 @@ #else #include #endif -#include "iarray.h" +#include static void freechain(iarray_page* p,size_t pagesize) { while (p) { diff --git a/array/iarray_get.c b/array/iarray_get.c index 66b730d..932d05b 100644 --- a/array/iarray_get.c +++ b/array/iarray_get.c @@ -1,4 +1,4 @@ -#include "iarray.h" +#include void* iarray_get(iarray* ia,size_t pos) { size_t index; diff --git a/array/iarray_init.c b/array/iarray_init.c index f77bf71..8fdd4e7 100644 --- a/array/iarray_init.c +++ b/array/iarray_init.c @@ -1,4 +1,4 @@ -#include "iarray.h" +#include void iarray_init(iarray* ia,size_t elemsize) { size_t i; diff --git a/array/iarray_length.c b/array/iarray_length.c index 6abbaf3..d4beeb3 100644 --- a/array/iarray_length.c +++ b/array/iarray_length.c @@ -1,4 +1,4 @@ -#include "iarray.h" +#include size_t iarray_length(iarray* ia) { return ia->len; diff --git a/buffer/buffer_get_token.c b/buffer/buffer_get_token.c index 7b151ff..b5c91e3 100644 --- a/buffer/buffer_get_token.c +++ b/buffer/buffer_get_token.c @@ -1,6 +1,5 @@ -#include "byte.h" -#include "buffer.h" -#include "scan.h" +#include +#include #include /* for memccpy */ diff --git a/buffer/buffer_get_token_pred.c b/buffer/buffer_get_token_pred.c index 69c59a6..531f780 100644 --- a/buffer/buffer_get_token_pred.c +++ b/buffer/buffer_get_token_pred.c @@ -1,6 +1,5 @@ -#include "byte.h" -#include "buffer.h" -#include "scan.h" +#include +#include ssize_t buffer_get_token_pred(buffer* b,char* x,size_t len, string_predicate p) { diff --git a/buffer/buffer_put8long.c b/buffer/buffer_put8long.c index 8ee0a7b..2d1b78b 100644 --- a/buffer/buffer_put8long.c +++ b/buffer/buffer_put8long.c @@ -1,5 +1,5 @@ -#include "buffer.h" -#include "fmt.h" +#include +#include int buffer_put8long(buffer *b,unsigned long l) { char buf[FMT_8LONG]; diff --git a/buffer/buffer_putlong.c b/buffer/buffer_putlong.c index c622f34..0a7a26f 100644 --- a/buffer/buffer_putlong.c +++ b/buffer/buffer_putlong.c @@ -1,5 +1,5 @@ -#include "buffer.h" -#include "fmt.h" +#include +#include int buffer_putlong(buffer *b,signed long l) { char buf[FMT_LONG]; diff --git a/buffer/buffer_putlonglong.c b/buffer/buffer_putlonglong.c index efbcbfe..3ed4946 100644 --- a/buffer/buffer_putlonglong.c +++ b/buffer/buffer_putlonglong.c @@ -1,5 +1,5 @@ -#include "buffer.h" -#include "fmt.h" +#include +#include int buffer_putlonglong(buffer *b,signed long long l) { char buf[FMT_LONG]; diff --git a/buffer/buffer_putulong.c b/buffer/buffer_putulong.c index 0e6da90..9e3576e 100644 --- a/buffer/buffer_putulong.c +++ b/buffer/buffer_putulong.c @@ -1,5 +1,5 @@ -#include "buffer.h" -#include "fmt.h" +#include +#include int buffer_putulong(buffer *b,unsigned long l) { char buf[FMT_ULONG]; diff --git a/buffer/buffer_putulonglong.c b/buffer/buffer_putulonglong.c index 861acf5..b6c52d0 100644 --- a/buffer/buffer_putulonglong.c +++ b/buffer/buffer_putulonglong.c @@ -1,5 +1,5 @@ -#include "buffer.h" -#include "fmt.h" +#include +#include int buffer_putulonglong(buffer *b,unsigned long long l) { char buf[FMT_ULONG]; diff --git a/buffer/buffer_putxlong.c b/buffer/buffer_putxlong.c index 7938646..e7ecb15 100644 --- a/buffer/buffer_putxlong.c +++ b/buffer/buffer_putxlong.c @@ -1,5 +1,5 @@ -#include "buffer.h" -#include "fmt.h" +#include +#include int buffer_putxlong(buffer *b,unsigned long l) { char buf[FMT_XLONG]; diff --git a/case/case_diffb.c b/case/case_diffb.c index 822f76b..4951016 100644 --- a/case/case_diffb.c +++ b/case/case_diffb.c @@ -1,4 +1,4 @@ -#include "case.h" +#include int case_diffb(register const void* S,register size_t len,register const void* T) { diff --git a/case/case_diffs.c b/case/case_diffs.c index 683977a..af98e79 100644 --- a/case/case_diffs.c +++ b/case/case_diffs.c @@ -1,4 +1,4 @@ -#include "case.h" +#include int case_diffs(register const char *s,register const char *t) { diff --git a/case/case_lowerb.c b/case/case_lowerb.c index 2a2c9e3..41e4dc9 100644 --- a/case/case_lowerb.c +++ b/case/case_lowerb.c @@ -1,4 +1,4 @@ -#include "case.h" +#include void case_lowerb(void *S,size_t len) { char* s=(char*)S; diff --git a/case/case_lowers.c b/case/case_lowers.c index 774b97a..5bf2377 100644 --- a/case/case_lowers.c +++ b/case/case_lowers.c @@ -1,4 +1,4 @@ -#include "case.h" +#include void case_lowers(char *s) { unsigned char x; diff --git a/case/case_starts.c b/case/case_starts.c index d5eb945..6410e7c 100644 --- a/case/case_starts.c +++ b/case/case_starts.c @@ -1,4 +1,4 @@ -#include "case.h" +#include /* str_start returns 1 if the b is a prefix of a, 0 otherwise */ int case_starts(const char* a, const char* b) { diff --git a/fmt.h b/fmt.h index 27c49f4..673f405 100644 --- a/fmt.h +++ b/fmt.h @@ -260,6 +260,11 @@ size_t fmt_netstring(char* dest,const char* src,size_t len) noexcept; att_write(1) size_t fmt_escapecharxml(char* dest,uint32_t ch) noexcept; +/* XML escaping but only for necessary codepoints. + * Others emitted as UTF-8 */ +att_write(1) +size_t fmt_xmlescape(char* dest,uint32_t ch) noexcept; + /* HTML escaping is the same as XML escaping. */ att_write(1) size_t fmt_escapecharhtml(char* dest,uint32_t ch) noexcept; diff --git a/fmt/fmt_8long.c b/fmt/fmt_8long.c index f44c242..a580062 100644 --- a/fmt/fmt_8long.c +++ b/fmt/fmt_8long.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_8long(char *dest,unsigned long i) { register unsigned long len,tmp; diff --git a/fmt/fmt_8longlong.c b/fmt/fmt_8longlong.c index f2638c8..a9ba142 100644 --- a/fmt/fmt_8longlong.c +++ b/fmt/fmt_8longlong.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_8longlong(char *dest,unsigned long long i) { register unsigned long len; diff --git a/fmt/fmt_asn1derlength.c b/fmt/fmt_asn1derlength.c index 160a2d5..f4814d7 100644 --- a/fmt/fmt_asn1derlength.c +++ b/fmt/fmt_asn1derlength.c @@ -1,15 +1,21 @@ -#include "fmt.h" +#include + +static size_t asn1derlengthbytesneeded(unsigned long long l) { + size_t needed; + for (needed=1; (l>>=8)>0; ++needed) ; + return needed; +} /* write int in least amount of bytes, return number of bytes */ /* as used in ASN.1 length */ size_t fmt_asn1derlength(char* dest,unsigned long long l) { /* encoding is either l%128 or (0x80+number of bytes,bytes) */ - size_t needed=(sizeof l),i; + size_t i; if (l<128) { if (dest) *dest=l&0x7f; return 1; } - for (i=1; i>(i*8))) break; if (dest) { diff --git a/fmt/fmt_asn1dertag.c b/fmt/fmt_asn1dertag.c index 3f50ea7..04e8a80 100644 --- a/fmt/fmt_asn1dertag.c +++ b/fmt/fmt_asn1dertag.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include /* write int in least amount of bytes, return number of bytes */ /* as used in ASN.1 DER tag */ diff --git a/fmt/fmt_double.c b/fmt/fmt_double.c index f6d4d5d..9c35d20 100644 --- a/fmt/fmt_double.c +++ b/fmt/fmt_double.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_double(char *dest, double d,int maxlen,int prec) { union { diff --git a/fmt/fmt_escapecharc.c b/fmt/fmt_escapecharc.c index f67f12d..9906cf6 100644 --- a/fmt/fmt_escapecharc.c +++ b/fmt/fmt_escapecharc.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include #ifdef UNITTEST #include "fmt_tohex.c" diff --git a/fmt/fmt_escapecharquotedprintable.c b/fmt/fmt_escapecharquotedprintable.c index 790275d..24282d8 100644 --- a/fmt/fmt_escapecharquotedprintable.c +++ b/fmt/fmt_escapecharquotedprintable.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include #ifdef UNITTEST #undef UNITTEST diff --git a/fmt/fmt_escapecharquotedprintableutf8.c b/fmt/fmt_escapecharquotedprintableutf8.c index f3d9e86..098c854 100644 --- a/fmt/fmt_escapecharquotedprintableutf8.c +++ b/fmt/fmt_escapecharquotedprintableutf8.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_escapecharquotedprintableutf8(char* dest,uint32_t ch) { char buf[FMT_UTF8]; diff --git a/fmt/fmt_escapecharxml.c b/fmt/fmt_escapecharxml.c index 810e597..62950d0 100644 --- a/fmt/fmt_escapecharxml.c +++ b/fmt/fmt_escapecharxml.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_escapecharxml(char* dest,uint32_t ch) { char a[FMT_LONG], b[FMT_XLONG+1]; diff --git a/fmt/fmt_fill.c b/fmt/fmt_fill.c index bc74ba4..de593c8 100644 --- a/fmt/fmt_fill.c +++ b/fmt/fmt_fill.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include /* "foo" -> "foo " * append padlen-srclen spaces after dest, if that is >= 0. Truncate diff --git a/fmt/fmt_httpdate.c b/fmt/fmt_httpdate.c index 89efaad..568b7c1 100644 --- a/fmt/fmt_httpdate.c +++ b/fmt/fmt_httpdate.c @@ -1,5 +1,5 @@ -#include "fmt.h" -#include "byte.h" +#include +#include #include static unsigned int fmt_2digits(char* dest,int i) { diff --git a/fmt/fmt_human.c b/fmt/fmt_human.c index 2115023..8a9741a 100644 --- a/fmt/fmt_human.c +++ b/fmt/fmt_human.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_human(char* dest,unsigned long long l) { char unit; diff --git a/fmt/fmt_humank.c b/fmt/fmt_humank.c index f325ed2..629be51 100644 --- a/fmt/fmt_humank.c +++ b/fmt/fmt_humank.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_humank(char* dest,unsigned long long l) { char unit; diff --git a/fmt/fmt_iso8601.c b/fmt/fmt_iso8601.c index d4e34b5..fdd27eb 100644 --- a/fmt/fmt_iso8601.c +++ b/fmt/fmt_iso8601.c @@ -1,5 +1,5 @@ -#include "fmt.h" -#include "byte.h" +#include +#include #include static unsigned int fmt_2digits(char* dest,int i) { diff --git a/fmt/fmt_long.c b/fmt/fmt_long.c index 0162c4e..6cfd90d 100644 --- a/fmt/fmt_long.c +++ b/fmt/fmt_long.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_long(char *dest,long int i) { if (i<0) { diff --git a/fmt/fmt_longlong.c b/fmt/fmt_longlong.c index d6ae657..2d90aa3 100644 --- a/fmt/fmt_longlong.c +++ b/fmt/fmt_longlong.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_longlong(char *dest,signed long long int i) { if (i<0) { diff --git a/fmt/fmt_minus.c b/fmt/fmt_minus.c index af58369..520c6aa 100644 --- a/fmt/fmt_minus.c +++ b/fmt/fmt_minus.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_minus(char *dest,int i) { if (i<0) { diff --git a/fmt/fmt_netstring.c b/fmt/fmt_netstring.c index 2da4c07..4fd8958 100644 --- a/fmt/fmt_netstring.c +++ b/fmt/fmt_netstring.c @@ -1,5 +1,5 @@ -#include "fmt.h" -#include "rangecheck.h" +#include +#include #include size_t fmt_netstring(char* dest,const char* src,size_t len) { diff --git a/fmt/fmt_pad.c b/fmt/fmt_pad.c index 23e8cbd..ac0a76e 100644 --- a/fmt/fmt_pad.c +++ b/fmt/fmt_pad.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include /* "foo" -> " foo" * write padlen-srclen spaces, if that is >= 0. Then copy srclen diff --git a/fmt/fmt_pb_double.c b/fmt/fmt_pb_double.c index 50969a2..7d735b4 100644 --- a/fmt/fmt_pb_double.c +++ b/fmt/fmt_pb_double.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_pb_double(char* dest,size_t fieldno,double d) { size_t n=fmt_pb_tag(dest,fieldno,1); diff --git a/fmt/fmt_pb_float.c b/fmt/fmt_pb_float.c index 0812313..0dc8042 100644 --- a/fmt/fmt_pb_float.c +++ b/fmt/fmt_pb_float.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_pb_float(char* dest,size_t fieldno,float f) { size_t n=fmt_pb_tag(dest,fieldno,5); diff --git a/fmt/fmt_pb_int.c b/fmt/fmt_pb_int.c index 76296ab..9a81591 100644 --- a/fmt/fmt_pb_int.c +++ b/fmt/fmt_pb_int.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_pb_int(char* dest,size_t fieldno,unsigned long long l) { size_t n=fmt_pb_tag(dest,fieldno,0); diff --git a/fmt/fmt_pb_sint.c b/fmt/fmt_pb_sint.c index 2cb13bd..97dbe11 100644 --- a/fmt/fmt_pb_sint.c +++ b/fmt/fmt_pb_sint.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_pb_sint(char* dest,size_t fieldno,signed long long l) { size_t n=fmt_pb_tag(dest,fieldno,0); diff --git a/fmt/fmt_pb_string.c b/fmt/fmt_pb_string.c index 4bcb066..e6819e0 100644 --- a/fmt/fmt_pb_string.c +++ b/fmt/fmt_pb_string.c @@ -1,5 +1,5 @@ -#include "fmt.h" -#include "rangecheck.h" +#include +#include size_t fmt_pb_string(char* dest,size_t fieldno,const char* s,size_t l) { size_t n=fmt_pb_tag(dest,fieldno,2); diff --git a/fmt/fmt_pb_tag.c b/fmt/fmt_pb_tag.c index 4b39bba..605e43a 100644 --- a/fmt/fmt_pb_tag.c +++ b/fmt/fmt_pb_tag.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_pb_tag(char* dest,size_t fieldno,unsigned char type) { if (type>5 || (fieldno >> (sizeof(fieldno)*8-3))) return 0; diff --git a/fmt/fmt_pb_type0_sint.c b/fmt/fmt_pb_type0_sint.c index 41353c0..985ce99 100644 --- a/fmt/fmt_pb_type0_sint.c +++ b/fmt/fmt_pb_type0_sint.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_pb_type0_sint(char* dest,signed long long l) { return fmt_varint(dest,(l << 1) ^ (l >> (sizeof(l)*8-1))); diff --git a/fmt/fmt_pb_type1_double.c b/fmt/fmt_pb_type1_double.c index f29b259..b7ce275 100644 --- a/fmt/fmt_pb_type1_double.c +++ b/fmt/fmt_pb_type1_double.c @@ -1,5 +1,5 @@ -#include "fmt.h" -#include "compiletimeassert.h" +#include +#include size_t fmt_pb_type1_double(char* dest,double d) { union { diff --git a/fmt/fmt_pb_type1_fixed64.c b/fmt/fmt_pb_type1_fixed64.c index 67aaf36..a35200d 100644 --- a/fmt/fmt_pb_type1_fixed64.c +++ b/fmt/fmt_pb_type1_fixed64.c @@ -1,5 +1,5 @@ -#include "fmt.h" -#include "uint64.h" +#include +#include size_t fmt_pb_type1_fixed64(char* dest,uint64_t l) { if (dest) uint64_pack(dest,l); diff --git a/fmt/fmt_pb_type2_string.c b/fmt/fmt_pb_type2_string.c index aa6b516..d0f9c32 100644 --- a/fmt/fmt_pb_type2_string.c +++ b/fmt/fmt_pb_type2_string.c @@ -1,5 +1,5 @@ -#include "fmt.h" -#include "rangecheck.h" +#include +#include #include size_t fmt_pb_type2_string(char* dest,const char* s,size_t l) { diff --git a/fmt/fmt_pb_type5_fixed32.c b/fmt/fmt_pb_type5_fixed32.c index 70d7c5b..a6244a0 100644 --- a/fmt/fmt_pb_type5_fixed32.c +++ b/fmt/fmt_pb_type5_fixed32.c @@ -1,5 +1,5 @@ -#include "fmt.h" -#include "uint32.h" +#include +#include size_t fmt_pb_type5_fixed32(char* dest,uint32_t l) { if (dest) uint32_pack(dest,l); diff --git a/fmt/fmt_pb_type5_float.c b/fmt/fmt_pb_type5_float.c index 408bfd2..b489426 100644 --- a/fmt/fmt_pb_type5_float.c +++ b/fmt/fmt_pb_type5_float.c @@ -1,5 +1,5 @@ -#include "fmt.h" -#include "compiletimeassert.h" +#include +#include size_t fmt_pb_type5_float(char* dest,float f) { union { diff --git a/fmt/fmt_plusminus.c b/fmt/fmt_plusminus.c index 9fc722a..402d726 100644 --- a/fmt/fmt_plusminus.c +++ b/fmt/fmt_plusminus.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_plusminus(char *dest,int i) { if (i) { diff --git a/fmt/fmt_str.c b/fmt/fmt_str.c index e81c77e..d8893a9 100644 --- a/fmt/fmt_str.c +++ b/fmt/fmt_str.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_str(char *out,const char *in) { register char* s=out; diff --git a/fmt/fmt_strm_internal.c b/fmt/fmt_strm_internal.c index cbca151..ef728be 100644 --- a/fmt/fmt_strm_internal.c +++ b/fmt/fmt_strm_internal.c @@ -1,5 +1,5 @@ #include -#include "fmt.h" +#include size_t fmt_strm_internal(char* dest, ...) { size_t n; diff --git a/fmt/fmt_strn.c b/fmt/fmt_strn.c index 1be2f1f..1fd60be 100644 --- a/fmt/fmt_strn.c +++ b/fmt/fmt_strn.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_strn(char *out,const char *in,size_t limit) { register char* s=out; diff --git a/fmt/fmt_tohex.c b/fmt/fmt_tohex.c index 1f68704..6ef1841 100644 --- a/fmt/fmt_tohex.c +++ b/fmt/fmt_tohex.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include char fmt_tohex(char c) { return (char)(c>=10?c-10+'a':c+'0'); diff --git a/fmt/fmt_ulong.c b/fmt/fmt_ulong.c index ea123b3..f9264b4 100644 --- a/fmt/fmt_ulong.c +++ b/fmt/fmt_ulong.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_ulong(char *dest,unsigned long i) { register unsigned long len,tmp,len2; diff --git a/fmt/fmt_ulong0.c b/fmt/fmt_ulong0.c index 575e23f..f4c9f78 100644 --- a/fmt/fmt_ulong0.c +++ b/fmt/fmt_ulong0.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_ulong0(char *dest,unsigned long i,size_t pad) { register unsigned int len; diff --git a/fmt/fmt_ulonglong.c b/fmt/fmt_ulonglong.c index 704953d..c6ea0e0 100644 --- a/fmt/fmt_ulonglong.c +++ b/fmt/fmt_ulonglong.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include size_t fmt_ulonglong(char *dest,unsigned long long int i) { register unsigned long len; diff --git a/fmt/fmt_varint.c b/fmt/fmt_varint.c index 0276b06..e77efe8 100644 --- a/fmt/fmt_varint.c +++ b/fmt/fmt_varint.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include /* write int in least amount of bytes, return number of bytes */ /* as used in varints from Google protocol buffers */ diff --git a/fmt/fmt_xlong.c b/fmt/fmt_xlong.c index 06c4654..8a174c0 100644 --- a/fmt/fmt_xlong.c +++ b/fmt/fmt_xlong.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include #include "haveinline.h" static inline char tohex(char c) { diff --git a/fmt/fmt_xlonglong.c b/fmt/fmt_xlonglong.c index 113ef93..cdf03a5 100644 --- a/fmt/fmt_xlonglong.c +++ b/fmt/fmt_xlonglong.c @@ -1,4 +1,4 @@ -#include "fmt.h" +#include static inline char tohex(char c) { return (char)(c>=10?c-10+'a':c+'0'); diff --git a/fmt/fmt_xmlescape.c b/fmt/fmt_xmlescape.c index 6b47d84..50c38b6 100644 --- a/fmt/fmt_xmlescape.c +++ b/fmt/fmt_xmlescape.c @@ -1,6 +1,6 @@ -#include "fmt.h" +#include -/* This is NOT fmt_escapexml, which will escape everything, whether it +/* This is NOT fmt_escapecharxml, which will escape everything, whether it * needs escaping or not. This will only escape what needs escaping, and * reject invalid inputs */ size_t fmt_xmlescape(char* dest,uint32_t ch) { diff --git a/io/io_debugstring.c b/io/io_debugstring.c index 7f94869..0d92185 100644 --- a/io/io_debugstring.c +++ b/io/io_debugstring.c @@ -1,7 +1,7 @@ #include "io_internal.h" -#include +#include #include -#include "fmt.h" +#include #include unsigned int io_debugstring(int64 s,char* buf,unsigned int bufsize) { diff --git a/io/io_waituntil2.c b/io/io_waituntil2.c index d79d882..19f35db 100644 --- a/io/io_waituntil2.c +++ b/io/io_waituntil2.c @@ -29,7 +29,7 @@ #endif #ifdef __dietlibc__ -#include "fmt.h" +#include #include #endif diff --git a/io_internal.h b/io_internal.h index aaa170a..1bcc641 100644 --- a/io_internal.h +++ b/io_internal.h @@ -2,12 +2,12 @@ #define my_extern extern #endif -#include "libowfat/io.h" -#include "libowfat/array.h" -#include "libowfat/iarray.h" +#include +#include +#include #ifdef __MINGW32__ #include -#include "socket.h" +#include my_extern HANDLE io_comport; #else #include "haveepoll.h" diff --git a/iob_internal.h b/iob_internal.h index e468f8f..79af8e2 100644 --- a/iob_internal.h +++ b/iob_internal.h @@ -1,5 +1,5 @@ -#include "iob.h" -#include "array.h" +#include +#include typedef struct iob_entry { enum { FROMBUF, FROMFILE } type; diff --git a/iopause.h1 b/iopause.h1 index 3e2b3ce..920978b 100644 --- a/iopause.h1 +++ b/iopause.h1 @@ -13,7 +13,7 @@ typedef struct { #define IOPAUSE_READ 1 #define IOPAUSE_WRITE 4 -#include "taia.h" +#include extern void iopause(iopause_fd *,unsigned int,struct taia *,struct taia *); diff --git a/iopause.h2 b/iopause.h2 index 54a3323..1444795 100644 --- a/iopause.h2 +++ b/iopause.h2 @@ -12,7 +12,7 @@ typedef struct pollfd iopause_fd; #define IOPAUSE_READ POLLIN #define IOPAUSE_WRITE POLLOUT -#include "taia.h" +#include extern void iopause(iopause_fd *,unsigned int,struct taia *,struct taia *); diff --git a/ip4.h b/ip4.h index 83ec400..bfd0fc7 100644 --- a/ip4.h +++ b/ip4.h @@ -6,6 +6,8 @@ extern "C" { #endif +#include + size_t scan_ip4(const char *src,char ip[4]); size_t fmt_ip4(char *dest,const char ip[4]); diff --git a/likely.h b/likely.h index 5d01ca5..6d7f651 100644 --- a/likely.h +++ b/likely.h @@ -1,3 +1,5 @@ +// no longer needed. Use likely and unlikely from libowfat/compiler.h + #ifdef __dietlibc__ #include #else diff --git a/readclose.h b/readclose.h index 0e142dd..1b55c9f 100644 --- a/readclose.h +++ b/readclose.h @@ -4,7 +4,7 @@ /* for ssize_t */ #include -#include "stralloc.h" +#include #ifdef __cplusplus extern "C" { diff --git a/scan/scan_8int.c b/scan/scan_8int.c index 46f8a71..2172694 100644 --- a/scan/scan_8int.c +++ b/scan/scan_8int.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include size_t scan_8int(const char* src,unsigned int* dest) { /* make a copy of src so we can return the number of bytes we progressed */ diff --git a/scan/scan_8long.c b/scan/scan_8long.c index 46b6ff6..beb1838 100644 --- a/scan/scan_8long.c +++ b/scan/scan_8long.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include #ifdef UNITTEST #undef UNITTEST diff --git a/scan/scan_8longlong.c b/scan/scan_8longlong.c index dfb6614..57d2efa 100644 --- a/scan/scan_8longlong.c +++ b/scan/scan_8longlong.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include size_t scan_8longlong(const char *src,unsigned long long *dest) { /* make a copy of src so we can return the number of bytes we progressed */ diff --git a/scan/scan_8longn.c b/scan/scan_8longn.c index c7f6be0..fe4426e 100644 --- a/scan/scan_8longn.c +++ b/scan/scan_8longn.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include size_t scan_8longn(const char *src,size_t n,unsigned long *dest) { /* make a copy of src so we can return the number of bytes we progressed */ diff --git a/scan/scan_8short.c b/scan/scan_8short.c index 5549da8..1877609 100644 --- a/scan/scan_8short.c +++ b/scan/scan_8short.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include size_t scan_8short(const char* src,unsigned short* dest) { /* make a copy of src so we can return the number of bytes we progressed */ diff --git a/scan/scan_charsetnskip.c b/scan/scan_charsetnskip.c index 9bc67b0..3b5bd8f 100644 --- a/scan/scan_charsetnskip.c +++ b/scan/scan_charsetnskip.c @@ -1,5 +1,4 @@ -#include "scan.h" -#include +#include /* Return the number of leading chars in s that are in charset, but no * more than limit */ diff --git a/scan/scan_double.c b/scan/scan_double.c index 6680487..8683948 100644 --- a/scan/scan_double.c +++ b/scan/scan_double.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include #ifdef __GNUC__ static inline int isdigit(int c) { return (c>='0' && c<='9'); } diff --git a/scan/scan_fromhex.c b/scan/scan_fromhex.c index 8b52b28..da0b25a 100644 --- a/scan/scan_fromhex.c +++ b/scan/scan_fromhex.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include int scan_fromhex(unsigned char c) { c=(unsigned char)(c-'0'); diff --git a/scan/scan_httpdate.c b/scan/scan_httpdate.c index d71ff0b..261b086 100644 --- a/scan/scan_httpdate.c +++ b/scan/scan_httpdate.c @@ -2,9 +2,9 @@ #ifdef __dietlibc__ #define __deprecated__ #endif -#include "scan.h" -#include "byte.h" -#include "case.h" +#include +#include +#include #include #include diff --git a/scan/scan_int.c b/scan/scan_int.c index b33ff17..e5224ce 100644 --- a/scan/scan_int.c +++ b/scan/scan_int.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include static const unsigned int maxint = ((unsigned int)-1)>>1; diff --git a/scan/scan_iso8601.c b/scan/scan_iso8601.c index ce0bafc..5d3cf66 100644 --- a/scan/scan_iso8601.c +++ b/scan/scan_iso8601.c @@ -2,9 +2,7 @@ #ifdef __dietlibc__ #define __deprecated__ #endif -#include "scan.h" -#include "byte.h" -#include "case.h" +#include #include #include diff --git a/scan/scan_long.c b/scan/scan_long.c index a81b72e..9450a68 100644 --- a/scan/scan_long.c +++ b/scan/scan_long.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include #ifdef UNITTEST #undef UNITTEST diff --git a/scan/scan_longlong.c b/scan/scan_longlong.c index 3d0934c..585e875 100644 --- a/scan/scan_longlong.c +++ b/scan/scan_longlong.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include static const unsigned long maxlong = ((unsigned long)-1)>>1; diff --git a/scan/scan_longn.c b/scan/scan_longn.c index 497d4e7..1e64fc7 100644 --- a/scan/scan_longn.c +++ b/scan/scan_longn.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include static const unsigned long maxlong = ((unsigned long)-1)>>1; diff --git a/scan/scan_netstring.c b/scan/scan_netstring.c index 83a688b..dfa21ae 100644 --- a/scan/scan_netstring.c +++ b/scan/scan_netstring.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include /* parse a netstring, input buffer is in (len bytes). * if parsing is successful: diff --git a/scan/scan_noncharsetnskip.c b/scan/scan_noncharsetnskip.c index d280fd5..ea31fef 100644 --- a/scan/scan_noncharsetnskip.c +++ b/scan/scan_noncharsetnskip.c @@ -1,5 +1,4 @@ -#include "scan.h" -#include +#include size_t scan_noncharsetnskip(const char *s,const char *charset,size_t limit) { register const char *t=s; diff --git a/scan/scan_nonwhitenskip.c b/scan/scan_nonwhitenskip.c index 2771069..f25e154 100644 --- a/scan/scan_nonwhitenskip.c +++ b/scan/scan_nonwhitenskip.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include #include size_t scan_nonwhitenskip(const char *s,size_t limit) { diff --git a/scan/scan_pb_tag.c b/scan/scan_pb_tag.c index d4b4f5e..a1df31f 100644 --- a/scan/scan_pb_tag.c +++ b/scan/scan_pb_tag.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include size_t scan_pb_tag(const char* in,size_t len, size_t* fieldno,unsigned char* type) { unsigned long long l; diff --git a/scan/scan_pb_type0_sint.c b/scan/scan_pb_type0_sint.c index 07fe9f1..00a66ef 100644 --- a/scan/scan_pb_type0_sint.c +++ b/scan/scan_pb_type0_sint.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include size_t scan_pb_type0_sint(const char* in,size_t len,signed long long* l) { unsigned long long m; diff --git a/scan/scan_pb_type1_double.c b/scan/scan_pb_type1_double.c index 2740f24..9a29970 100644 --- a/scan/scan_pb_type1_double.c +++ b/scan/scan_pb_type1_double.c @@ -1,5 +1,5 @@ -#include "scan.h" -#include "compiletimeassert.h" +#include +#include size_t scan_pb_type1_double(const char* in,size_t len,double* d) { union { diff --git a/scan/scan_pb_type1_fixed64.c b/scan/scan_pb_type1_fixed64.c index 86fce5d..da1ea4a 100644 --- a/scan/scan_pb_type1_fixed64.c +++ b/scan/scan_pb_type1_fixed64.c @@ -1,5 +1,5 @@ -#include "scan.h" -#include "uint64.h" +#include +#include size_t scan_pb_type1_fixed64(const char* in,size_t len,uint64_t* d) { if (len<8) return 0; diff --git a/scan/scan_pb_type2_stringlen.c b/scan/scan_pb_type2_stringlen.c index 9224f55..8c46313 100644 --- a/scan/scan_pb_type2_stringlen.c +++ b/scan/scan_pb_type2_stringlen.c @@ -1,5 +1,5 @@ -#include "scan.h" -#include "rangecheck.h" +#include +#include size_t scan_pb_type2_stringlen(const char* in,size_t len,const char** string, size_t* slen) { unsigned long long l; diff --git a/scan/scan_pb_type5_fixed32.c b/scan/scan_pb_type5_fixed32.c index 9516311..9d058c1 100644 --- a/scan/scan_pb_type5_fixed32.c +++ b/scan/scan_pb_type5_fixed32.c @@ -1,5 +1,5 @@ -#include "scan.h" -#include "uint32.h" +#include +#include size_t scan_pb_type5_fixed32(const char* in,size_t len,uint32_t* d) { if (len<4) return 0; diff --git a/scan/scan_pb_type5_float.c b/scan/scan_pb_type5_float.c index 7630423..cb37792 100644 --- a/scan/scan_pb_type5_float.c +++ b/scan/scan_pb_type5_float.c @@ -1,5 +1,5 @@ -#include "scan.h" -#include "compiletimeassert.h" +#include +#include size_t scan_pb_type5_float(const char* in,size_t len,float* f) { union { diff --git a/scan/scan_plusminus.c b/scan/scan_plusminus.c index 3916208..0d6c12b 100644 --- a/scan/scan_plusminus.c +++ b/scan/scan_plusminus.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include size_t scan_plusminus(const char *src,signed int *dest) { *dest=1; diff --git a/scan/scan_short.c b/scan/scan_short.c index ec9ecc4..3eb1711 100644 --- a/scan/scan_short.c +++ b/scan/scan_short.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include static const unsigned short maxshort = ((unsigned short)-1)>>1; diff --git a/scan/scan_uint.c b/scan/scan_uint.c index b37cbd9..7e90f4b 100644 --- a/scan/scan_uint.c +++ b/scan/scan_uint.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include /* this is cut and paste from scan_ulong instead of calling scan_ulong * because this way scan_uint can abort scanning when the number would diff --git a/scan/scan_ulong.c b/scan/scan_ulong.c index d69f2a9..39a0d00 100644 --- a/scan/scan_ulong.c +++ b/scan/scan_ulong.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include size_t scan_ulong(const char* src,unsigned long int* dest) { return scan_ulongn(src,((size_t)-1)/2,dest); diff --git a/scan/scan_ulonglong.c b/scan/scan_ulonglong.c index 3b03a80..0c63a79 100644 --- a/scan/scan_ulonglong.c +++ b/scan/scan_ulonglong.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include size_t scan_ulonglong(const char *src,unsigned long long *dest) { register const char *tmp=src; diff --git a/scan/scan_ulongn.c b/scan/scan_ulongn.c index 3f08002..2e54a51 100644 --- a/scan/scan_ulongn.c +++ b/scan/scan_ulongn.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include #ifndef INTERNAL #include "haveuint128.h" #endif diff --git a/scan/scan_ushort.c b/scan/scan_ushort.c index eb78e6c..5290cb9 100644 --- a/scan/scan_ushort.c +++ b/scan/scan_ushort.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include /* this is cut and paste from scan_ulong instead of calling scan_ulong * because this way scan_ushort can abort scanning when the number would diff --git a/scan/scan_varint.c b/scan/scan_varint.c index 00453a8..54f731f 100644 --- a/scan/scan_varint.c +++ b/scan/scan_varint.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include size_t scan_varint(const char* in,size_t len, unsigned long long* n) { size_t i; diff --git a/scan/scan_whitenskip.c b/scan/scan_whitenskip.c index 634ae85..3d68775 100644 --- a/scan/scan_whitenskip.c +++ b/scan/scan_whitenskip.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include #include size_t scan_whitenskip(const char *s,size_t limit) { diff --git a/scan/scan_xint.c b/scan/scan_xint.c index 5a11f7e..bd9f28f 100644 --- a/scan/scan_xint.c +++ b/scan/scan_xint.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include #ifdef UNITTEST #undef UNITTEST diff --git a/scan/scan_xlong.c b/scan/scan_xlong.c index 314ba06..7495d90 100644 --- a/scan/scan_xlong.c +++ b/scan/scan_xlong.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include size_t scan_xlong(const char *src,unsigned long *dest) { return scan_xlongn(src,((size_t)-1)/2,dest); diff --git a/scan/scan_xlonglong.c b/scan/scan_xlonglong.c index 350a315..14bc309 100644 --- a/scan/scan_xlonglong.c +++ b/scan/scan_xlonglong.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include size_t scan_xlonglong(const char* src,unsigned long long* dest) { register const char *tmp=src; diff --git a/scan/scan_xlongn.c b/scan/scan_xlongn.c index 2c3958d..8a8c565 100644 --- a/scan/scan_xlongn.c +++ b/scan/scan_xlongn.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include #ifdef UNITTEST #undef UNITTEST diff --git a/scan/scan_xshort.c b/scan/scan_xshort.c index f7659da..a682c77 100644 --- a/scan/scan_xshort.c +++ b/scan/scan_xshort.c @@ -1,4 +1,4 @@ -#include "scan.h" +#include #ifdef UNITTEST #undef UNITTEST