Skip to content

Commit

Permalink
Merge pull request #75 from sgraham/whitespace
Browse files Browse the repository at this point in the history
Remove trailing whitespace
  • Loading branch information
tylov authored Oct 30, 2023
2 parents 85f6fc2 + eb21f59 commit 9a5644e
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 75 deletions.
12 changes: 6 additions & 6 deletions include/stc/carc.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ _c_DEFTYPES(_c_carc_types, i_type, i_key);
#endif
struct _c_MEMB(_rep_) { catomic_long counter; i_key value; };

STC_INLINE i_type _c_MEMB(_init)(void)
STC_INLINE i_type _c_MEMB(_init)(void)
{ return c_LITERAL(i_type){NULL, NULL}; }

STC_INLINE long _c_MEMB(_use_count)(const i_type* self)
{ return self->use_count ? *self->use_count : 0; }

STC_INLINE i_type _c_MEMB(_from_ptr)(_m_value* p) {
i_type arc = {p};
if (p)
if (p)
*(arc.use_count = _i_alloc(catomic_long)) = 1;
return arc;
}
Expand Down Expand Up @@ -158,7 +158,7 @@ STC_INLINE i_type _c_MEMB(_from)(_m_raw raw)
#else
STC_INLINE i_type _c_MEMB(_from)(_m_value val)
{ return _c_MEMB(_make)(val); }
#endif
#endif

// does not use i_keyclone, so OK to always define.
STC_INLINE i_type _c_MEMB(_clone)(i_type arc) {
Expand Down Expand Up @@ -210,8 +210,8 @@ STC_INLINE void _c_MEMB(_assign)(i_type* self, i_type arc) {
STC_INLINE uint64_t _c_MEMB(_raw_hash)(const _m_raw* rx)
{ return i_hash(rx); }

STC_INLINE uint64_t _c_MEMB(_hash)(const i_type* self) {
_m_raw rx = i_keyto(self->get);
STC_INLINE uint64_t _c_MEMB(_hash)(const i_type* self) {
_m_raw rx = i_keyto(self->get);
return i_hash((&rx));
}
#else
Expand All @@ -224,4 +224,4 @@ STC_INLINE void _c_MEMB(_assign)(i_type* self, i_type arc) {
#undef _i_atomic_dec_and_test
#undef _i_carc
#include "priv/template2.h"
#include "priv/linkage2.h"
#include "priv/linkage2.h"
12 changes: 6 additions & 6 deletions include/stc/cbits.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ STC_INLINE _llong _cbits_count(const uint64_t* set, const _llong sz) {
return count;
}

STC_INLINE char* _cbits_to_str(const uint64_t* set, const _llong sz,
STC_INLINE char* _cbits_to_str(const uint64_t* set, const _llong sz,
char* out, _llong start, _llong stop) {
if (stop > sz) stop = sz;
c_assert(start <= stop);

c_memset(out, '0', stop - start);
for (_llong i = start; i < stop; ++i)
for (_llong i = start; i < stop; ++i)
if ((set[i>>6] & _cbits_bit(i)) != 0)
out[i - start] = '1';
out[stop - start] = '\0';
Expand Down Expand Up @@ -163,7 +163,7 @@ STC_INLINE void cbits_resize(cbits* self, const _llong size, const bool value) {
c_memset(self->data64 + old_n, -(int)value, (new_n - old_n)*8);
if (old_n > 0) {
uint64_t mask = _cbits_bit(osize) - 1;
if (value) self->data64[old_n - 1] |= ~mask;
if (value) self->data64[old_n - 1] |= ~mask;
else self->data64[old_n - 1] &= mask;
}
}
Expand Down Expand Up @@ -210,7 +210,7 @@ STC_INLINE i_type* _i_memb(_take)(i_type* self, i_type other)
STC_INLINE i_type _i_memb(_clone)(i_type other)
{ return other; }

STC_INLINE i_type* _i_memb(_copy)(i_type* self, const i_type* other)
STC_INLINE i_type* _i_memb(_copy)(i_type* self, const i_type* other)
{ *self = *other; return self; }

STC_INLINE void _i_memb(_set_all)(i_type *self, const bool value);
Expand Down Expand Up @@ -239,7 +239,7 @@ STC_INLINE void _i_memb(_set_pattern)(i_type *self, const uint64_t pattern) {
while (n--) self->data64[n] = pattern;
}

STC_INLINE bool _i_memb(_test)(const i_type* self, const _llong i)
STC_INLINE bool _i_memb(_test)(const i_type* self, const _llong i)
{ return (self->data64[i>>6] & _cbits_bit(i)) != 0; }

STC_INLINE bool _i_memb(_at)(const i_type* self, const _llong i)
Expand Down Expand Up @@ -295,7 +295,7 @@ STC_INLINE _llong _i_memb(_count)(const i_type* self)
STC_INLINE char* _i_memb(_to_str)(const i_type* self, char* out, _llong start, _llong stop)
{ return _cbits_to_str(self->data64, _i_memb(_size)(self), out, start, stop); }

STC_INLINE bool _i_memb(_subset_of)(const i_type* self, const i_type* other) {
STC_INLINE bool _i_memb(_subset_of)(const i_type* self, const i_type* other) {
_i_assert(self->_size == other->_size);
return _cbits_subset_of(self->data64, other->data64, _i_memb(_size)(self));
}
Expand Down
6 changes: 3 additions & 3 deletions include/stc/cbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ STC_INLINE void _c_MEMB(_drop)(i_type* self) {
}

STC_INLINE i_type _c_MEMB(_move)(i_type* self) {
i_type box = *self;
i_type box = *self;
self->get = NULL;
return box;
}
Expand Down Expand Up @@ -189,8 +189,8 @@ STC_INLINE void _c_MEMB(_assign)(i_type* self, i_type* moved) {
STC_INLINE uint64_t _c_MEMB(_raw_hash)(const _m_raw* rx)
{ return i_hash(rx); }

STC_INLINE uint64_t _c_MEMB(_hash)(const i_type* self) {
_m_raw rx = i_keyto(self->get);
STC_INLINE uint64_t _c_MEMB(_hash)(const i_type* self) {
_m_raw rx = i_keyto(self->get);
return i_hash((&rx));
}
#else
Expand Down
4 changes: 2 additions & 2 deletions include/stc/ccommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ typedef long long _llong;
#define _c_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, \
_14, _15, _16, N, ...) N

#ifndef __cplusplus
#ifndef __cplusplus
#define _i_alloc(T) ((T*)i_malloc(c_sizeof(T)))
#define _i_new(T, ...) ((T*)memcpy(_i_alloc(T), ((T[]){__VA_ARGS__}), sizeof(T)))
#define c_new(T, ...) ((T*)memcpy(malloc(sizeof(T)), ((T[]){__VA_ARGS__}), sizeof(T)))
Expand Down Expand Up @@ -159,7 +159,7 @@ STC_INLINE uint64_t _stc_hash_mix(uint64_t h[], int n) { // n > 0
return h[0];
}

STC_INLINE char* stc_strnstrn(const char *str, intptr_t slen,
STC_INLINE char* stc_strnstrn(const char *str, intptr_t slen,
const char *needle, intptr_t nlen) {
if (!nlen) return (char *)str;
if (nlen > slen) return NULL;
Expand Down
4 changes: 2 additions & 2 deletions include/stc/cdeq.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ _c_MEMB(_emplace_back)(i_type* self, const _m_raw raw)
{ return _c_MEMB(_push)(self, i_keyfrom(raw)); }

STC_INLINE _m_iter
_c_MEMB(_emplace_at)(i_type* self, _m_iter it, const _m_raw raw)
_c_MEMB(_emplace_at)(i_type* self, _m_iter it, const _m_raw raw)
{ return _c_MEMB(_insert_at)(self, it, i_keyfrom(raw)); }
#endif

Expand Down Expand Up @@ -148,7 +148,7 @@ _c_MEMB(_push_front)(i_type* self, _m_value value) {
STC_DEF void
_c_MEMB(_erase_n)(i_type* self, const intptr_t idx, const intptr_t n) {
const intptr_t len = _c_MEMB(_size)(self);
for (intptr_t i = idx + n - 1; i >= idx; --i)
for (intptr_t i = idx + n - 1; i >= idx; --i)
i_keydrop(_c_MEMB(_at_mut)(self, i));
for (intptr_t i = idx, j = i + n; j < len; ++i, ++j)
*_c_MEMB(_at_mut)(self, i) = *_c_MEMB(_at)(self, j);
Expand Down
6 changes: 3 additions & 3 deletions include/stc/clist.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@
}

#define _clist_tonode(vp) c_container_of(vp, _m_node, value)

#define _c_clist_insert_entry_after(ref, val) \
_m_node *entry = (_m_node *)i_malloc(c_sizeof *entry); entry->value = val; \
_c_clist_insert_after_node(ref, entry)

#define _c_clist_insert_after_node(ref, entry) \
if (ref) entry->next = ref->next, ref->next = entry; \
else entry->next = entry
// +: set self->last based on node
// +: set self->last based on node

#endif // CLIST_H_INCLUDED

Expand Down Expand Up @@ -400,7 +400,7 @@ STC_DEF bool _c_MEMB(_sort_with)(i_type* self, int(*cmp)(const _m_value*, const
arr[len++] = *i.ref;
}
qsort(arr, (size_t)len, sizeof *arr, (int(*)(const void*, const void*))cmp);
c_foreach (i, i_type, *self)
c_foreach (i, i_type, *self)
*i.ref = *p++;
done: i_free(arr, cap*c_sizeof *arr);
return p != NULL;
Expand Down
10 changes: 5 additions & 5 deletions include/stc/cmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ STC_INLINE _m_value* _c_MEMB(_push)(i_type* self, _m_value _val) {
}

STC_INLINE void _c_MEMB(_put_n)(i_type* self, const _m_raw* raw, intptr_t n) {
while (n--)
while (n--)
#if defined _i_isset && defined i_no_emplace
_c_MEMB(_insert)(self, *raw++);
#elif defined _i_isset
Expand All @@ -215,7 +215,7 @@ STC_API _m_iter _c_MEMB(_begin)(const i_type* self);
STC_INLINE _m_iter _c_MEMB(_end)(const i_type* self)
{ (void)self; return c_LITERAL(_m_iter){NULL}; }

STC_INLINE void _c_MEMB(_next)(_m_iter* it) {
STC_INLINE void _c_MEMB(_next)(_m_iter* it) {
while ((++it->ref, (++it->_sref)->hashx == 0)) ;
if (it->ref == it->_end) it->ref = NULL;
}
Expand All @@ -229,7 +229,7 @@ STC_INLINE _m_iter
_c_MEMB(_find)(const i_type* self, _m_keyraw rkey) {
_m_result b;
if (self->size && !(b = _c_MEMB(_bucket_)(self, &rkey)).inserted)
return c_LITERAL(_m_iter){b.ref,
return c_LITERAL(_m_iter){b.ref,
self->table + self->bucket_count,
self->slot + (b.ref - self->table)};
return _c_MEMB(_end)(self);
Expand Down Expand Up @@ -334,7 +334,7 @@ STC_DEF void _c_MEMB(_clear)(i_type* self) {
_m_mapped* _mp = _res.ref ? &_res.ref->second : &_mapped;
if (_res.inserted)
_res.ref->first = _key;
else
else
{ i_keydrop((&_key)); i_valdrop(_mp); }
*_mp = _mapped;
return _res;
Expand Down Expand Up @@ -367,7 +367,7 @@ _c_MEMB(_bucket_)(const i_type* self, const _m_keyraw* rkeyptr) {
if (s[_idx].hashx == b.hashx) {
const _m_keyraw _raw = i_keyto(_i_keyref(self->table + _idx));
if (i_eq((&_raw), rkeyptr)) {
b.inserted = false;
b.inserted = false;
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions include/stc/coption.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static int coption_get(coption *opt, int argc, char *argv[],
if (o) {
opt->opt = optc = o->val;
if (o->type != coption_no_argument) {
if (argv[opt->_i][j] == '=')
if (argv[opt->_i][j] == '=')
opt->arg = &argv[opt->_i][j + 1];
else if (argv[opt->_i][j] == '\0' && opt->_i < argc - 1 && (o->type == coption_required_argument ||
argv[opt->_i + 1][0] != '-'))
Expand All @@ -160,7 +160,7 @@ static int coption_get(coption *opt, int argc, char *argv[],
} else if (p[1] == ':') {
if (argv[opt->_i][opt->_pos] != '\0')
opt->arg = &argv[opt->_i][opt->_pos];
else if (opt->_i < argc - 1 && (p[2] != ':' || argv[opt->_i + 1][0] != '-'))
else if (opt->_i < argc - 1 && (p[2] != ':' || argv[opt->_i + 1][0] != '-'))
opt->arg = argv[++opt->_i];
else if (p[2] != ':')
optc = ':';
Expand Down
4 changes: 2 additions & 2 deletions include/stc/coroutine.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ struct cco_runtime;

typedef cco_task_struct(cco_task, /**/) cco_task;

typedef struct cco_runtime {
typedef struct cco_runtime {
int result, top; cco_task* stack[];
} cco_runtime;

Expand Down Expand Up @@ -218,7 +218,7 @@ typedef struct { intptr_t count; } cco_sem;
#ifdef __cplusplus
#define _c_LINKC extern "C" __declspec(dllimport)
#else
#define _c_LINKC __declspec(dllimport)
#define _c_LINKC __declspec(dllimport)
#endif
#if 1 // _WIN32_WINNT < _WIN32_WINNT_WIN8 || defined __TINYC__
#define _c_getsystime GetSystemTimeAsFileTime
Expand Down
6 changes: 3 additions & 3 deletions include/stc/crawstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ STC_INLINE csview crawstr_sv(crawstr rs) { return c_sv_2(rs.str, rs.size); }
STC_INLINE intptr_t crawstr_size(crawstr rs) { return rs.size; }
STC_INLINE bool crawstr_empty(crawstr rs) { return rs.size == 0; }

STC_INLINE bool crawstr_equals(crawstr rs, const char* str) {
intptr_t n = c_strlen(str);
STC_INLINE bool crawstr_equals(crawstr rs, const char* str) {
intptr_t n = c_strlen(str);
return rs.size == n && !c_memcmp(rs.str, str, n);
}

Expand All @@ -67,7 +67,7 @@ STC_INLINE bool crawstr_ends_with(crawstr rs, const char* str) {
}

/* utf8 iterator */
STC_INLINE crawstr_iter crawstr_begin(const crawstr* self) {
STC_INLINE crawstr_iter crawstr_begin(const crawstr* self) {
if (!self->size) return c_LITERAL(crawstr_iter){.ref = NULL};
return c_LITERAL(crawstr_iter){.chr = {self->str, utf8_chr_size(self->str)}};
}
Expand Down
8 changes: 4 additions & 4 deletions include/stc/cregex.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ THE SOFTWARE.
#define CREGEX_H_INCLUDED
/*
* cregex.h
*
* This is a extended version of regexp9, supporting UTF8 input, common
*
* This is a extended version of regexp9, supporting UTF8 input, common
* shorthand character classes, ++.
*/
#include <stdbool.h>
#include <string.h>
#include "forward.h" // csview
#include "forward.h" // csview
#include "ccommon.h"

enum {
Expand Down Expand Up @@ -145,7 +145,7 @@ cstr cregex_replace_sv_6(const cregex* re, csview input, const char* replace, in
#define cregex_replace(...) c_MACRO_OVERLOAD(cregex_replace, __VA_ARGS__)
#define cregex_replace_3(re, input, replace) cregex_replace_4(re, input, replace, INT32_MAX)

STC_INLINE cstr cregex_replace_4(const cregex* re, const char* input, const char* replace, int count) {
STC_INLINE cstr cregex_replace_4(const cregex* re, const char* input, const char* replace, int count) {
csview sv = {input, c_strlen(input)};
return cregex_replace_sv_4(re, sv, replace, count);
}
Expand Down
12 changes: 6 additions & 6 deletions include/stc/csmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ _c_MEMB(_with_capacity)(const intptr_t cap) {
}

STC_INLINE void
_c_MEMB(_clear)(i_type* self)
_c_MEMB(_clear)(i_type* self)
{ _c_MEMB(_drop)(self); *self = _c_MEMB(_init)(); }

STC_INLINE _m_raw
_c_MEMB(_value_toraw)(const _m_value* val) {
return _i_SET_ONLY( i_keyto(val) )
_i_MAP_ONLY( c_LITERAL(_m_raw){i_keyto((&val->first)),
_i_MAP_ONLY( c_LITERAL(_m_raw){i_keyto((&val->first)),
i_valto((&val->second))} );
}

Expand Down Expand Up @@ -197,7 +197,7 @@ STC_API _m_result _c_MEMB(_insert_entry_)(i_type* self, _m_keyraw rkey);

STC_INLINE _m_iter
_c_MEMB(_end)(const i_type* self) {
_m_iter it; (void)self;
_m_iter it; (void)self;
it.ref = NULL, it._top = 0, it._tn = 0;
return it;
}
Expand Down Expand Up @@ -225,7 +225,7 @@ _c_MEMB(_insert)(i_type* self, _m_key _key _i_MAP_ONLY(, _m_mapped _mapped)) {
_m_result _res = _c_MEMB(_insert_entry_)(self, i_keyto((&_key)));
if (_res.inserted)
{ *_i_keyref(_res.ref) = _key; _i_MAP_ONLY( _res.ref->second = _mapped; )}
else
else
{ i_keydrop((&_key)); _i_MAP_ONLY( i_valdrop((&_mapped)); )}
return _res;
}
Expand All @@ -242,7 +242,7 @@ _c_MEMB(_push)(i_type* self, _m_value _val) {

STC_INLINE void
_c_MEMB(_put_n)(i_type* self, const _m_raw* raw, intptr_t n) {
while (n--)
while (n--)
#if defined _i_isset && defined i_no_emplace
_c_MEMB(_insert)(self, *raw++);
#elif defined _i_isset
Expand Down Expand Up @@ -524,7 +524,7 @@ _c_MEMB(_erase_at)(i_type* self, _m_iter it) {

STC_DEF _m_iter
_c_MEMB(_erase_range)(i_type* self, _m_iter it1, _m_iter it2) {
if (!it2.ref) {
if (!it2.ref) {
while (it1.ref)
it1 = _c_MEMB(_erase_at)(self, it1);
return it1;
Expand Down
10 changes: 5 additions & 5 deletions include/stc/cspan.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ using_cspan(Intspan, int);
int demo1() {
float raw[4*5];
Span2f ms = cspan_md(raw, 4, 5);
for (int i=0; i<ms.shape[0]; i++)
for (int j=0; j<ms.shape[1]; j++)
*cspan_at(&ms, i, j) = i*1000 + j;
Expand All @@ -42,11 +42,11 @@ int demo1() {
int demo2() {
int array[] = {10, 20, 30, 23, 22, 21};
Intspan span = cspan_from_array(array);
c_foreach (i, Intspan, span)
printf(" %d", *i.ref);
puts("");
c_forfilter (i, Intspan, span,
c_flt_skipwhile(i, *i.ref < 25) &&
(*i.ref & 1) == 0 && // even only
Expand Down Expand Up @@ -356,8 +356,8 @@ STC_DEF cstride_t* _cspan_shape2stride(cspan_layout layout, cstride_t shpstri[],
return shpstri;
}

STC_DEF intptr_t _cspan_slice(cextent_t oshape[], cstride_t ostride[], int* orank,
const cextent_t shape[], const cstride_t stride[],
STC_DEF intptr_t _cspan_slice(cextent_t oshape[], cstride_t ostride[], int* orank,
const cextent_t shape[], const cstride_t stride[],
const intptr_t args[][3], int rank) {
intptr_t end, off = 0;
int i = 0, oi = 0;
Expand Down
Loading

0 comments on commit 9a5644e

Please sign in to comment.