Skip to content

Commit 435a2e6

Browse files
committed
I to Z with a test. small string fix
1 parent 0dac6e8 commit 435a2e6

File tree

8 files changed

+165
-100
lines changed

8 files changed

+165
-100
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ CFLAGS += -DSRAND
6060
endif
6161

6262
TESTS = \
63+
tests/func/test_std_headers \
6364
tests/func/test_c11 \
6465
tests/func/test_container_composing \
6566
tests/func/test_deq \
@@ -116,6 +117,7 @@ examples/postfix: ALWAYS; $(CC) $(CFLAGS) $@.c -o $@
116117
examples/json: ALWAYS; $(CC) $(CFLAGS) $@.c -o $@
117118
examples/snow: ALWAYS; $(CC) $(CFLAGS) $@.c -o $@
118119
examples/6502: ALWAYS; $(CC) $(CFLAGS) $@.c -o $@
120+
tests/func/test_std_headers: ALWAYS; $(CC) $(CFLAGS) $@.c -o $@
119121
tests/func/test_c11: ALWAYS; $(CC) $(CFLAGS) $@.c -o $@
120122
tests/func/test_container_composing: ALWAYS; $(CXX) $(CFLAGS) $@.cc -o $@
121123
tests/func/test_deq: ALWAYS; $(CXX) $(CFLAGS) $@.cc -o $@

ctl/deq.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#define A JOIN(deq, T)
1212
#define B JOIN(A, bucket)
13-
#define I JOIN(A, it)
13+
#define Z JOIN(A, it)
1414

1515
#define DEQ_BUCKET_SIZE (512)
1616

@@ -34,17 +34,17 @@ typedef struct A
3434
}
3535
A;
3636

37-
typedef struct I
37+
typedef struct Z
3838
{
39-
void (*step)(struct I*);
39+
void (*step)(struct Z*);
4040
A* container;
4141
T* ref;
4242
size_t index;
4343
size_t index_next;
4444
size_t index_last;
4545
int done;
4646
}
47-
I;
47+
Z;
4848

4949
static inline B**
5050
JOIN(A, first)(A* self)
@@ -99,7 +99,7 @@ JOIN(A, end)(A* self)
9999
}
100100

101101
static inline void
102-
JOIN(I, step)(I* self)
102+
JOIN(Z, step)(Z* self)
103103
{
104104
self->index = self->index_next;
105105
if(self->index == self->index_last)
@@ -111,15 +111,15 @@ JOIN(I, step)(I* self)
111111
}
112112
}
113113

114-
static inline I
115-
JOIN(I, range)(A* container, T* begin, T* end)
114+
static inline Z
115+
JOIN(Z, range)(A* container, T* begin, T* end)
116116
{
117-
static I zero;
118-
I self = zero;
117+
static Z zero;
118+
Z self = zero;
119119
if(begin && end)
120120
{
121121
self.container = container;
122-
self.step = JOIN(I, step);
122+
self.step = JOIN(Z, step);
123123
self.index = begin - JOIN(A, begin)(container);
124124
self.index_next = self.index + 1;
125125
self.index_last = container->size - (JOIN(A, end)(container) - end);
@@ -136,12 +136,12 @@ JOIN(A, empty)(A* self)
136136
return self->size == 0;
137137
}
138138

139-
static inline I
140-
JOIN(I, each)(A* a)
139+
static inline Z
140+
JOIN(Z, each)(A* a)
141141
{
142142
return JOIN(A, empty)(a)
143-
? JOIN(I, range)(a, NULL, NULL)
144-
: JOIN(I, range)(a, JOIN(A, begin)(a), JOIN(A, end)(a));
143+
? JOIN(Z, range)(a, NULL, NULL)
144+
: JOIN(Z, range)(a, JOIN(A, begin)(a), JOIN(A, end)(a));
145145
}
146146

147147
static inline T
@@ -155,8 +155,8 @@ JOIN(A, equal)(A* self, A* other, int _equal(T*, T*))
155155
{
156156
if(self->size != other->size)
157157
return 0;
158-
I a = JOIN(I, each)(self);
159-
I b = JOIN(I, each)(other);
158+
Z a = JOIN(Z, each)(self);
159+
Z b = JOIN(Z, each)(other);
160160
while(!a.done && !b.done)
161161
{
162162
if(!_equal(a.ref, b.ref))
@@ -465,6 +465,6 @@ JOIN(A, find)(A* self, T key, int _equal(T*, T*))
465465
#undef T
466466
#undef A
467467
#undef B
468-
#undef I
468+
#undef Z
469469

470470
#undef DEQ_BUCKET_SIZE

ctl/lst.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#define A JOIN(lst, T)
1212
#define B JOIN(A, node)
13-
#define I JOIN(A, it)
13+
#define Z JOIN(A, it)
1414

1515
typedef struct B
1616
{
@@ -30,17 +30,17 @@ typedef struct A
3030
}
3131
A;
3232

33-
typedef struct I
33+
typedef struct Z
3434
{
35-
void (*step)(struct I*);
35+
void (*step)(struct Z*);
3636
T* ref;
3737
B* begin;
3838
B* node;
3939
B* next;
4040
B* end;
4141
int done;
4242
}
43-
I;
43+
Z;
4444

4545
static inline T*
4646
JOIN(A, front)(A* self)
@@ -68,7 +68,7 @@ JOIN(A, end)(A* self)
6868
}
6969

7070
static inline void
71-
JOIN(I, step)(I* self)
71+
JOIN(Z, step)(Z* self)
7272
{
7373
if(self->next == self->end)
7474
self->done = 1;
@@ -80,15 +80,15 @@ JOIN(I, step)(I* self)
8080
}
8181
}
8282

83-
static inline I
84-
JOIN(I, range)(A* container, B* begin, B* end)
83+
static inline Z
84+
JOIN(Z, range)(A* container, B* begin, B* end)
8585
{
8686
(void) container;
87-
static I zero;
88-
I self = zero;
87+
static Z zero;
88+
Z self = zero;
8989
if(begin)
9090
{
91-
self.step = JOIN(I, step);
91+
self.step = JOIN(Z, step);
9292
self.begin = begin;
9393
self.end = end;
9494
self.next = begin->next;
@@ -106,12 +106,12 @@ JOIN(A, empty)(A* self)
106106
return self->size == 0;
107107
}
108108

109-
static inline I
110-
JOIN(I, each)(A* a)
109+
static inline Z
110+
JOIN(Z, each)(A* a)
111111
{
112112
return JOIN(A, empty)(a)
113-
? JOIN(I, range)(a, NULL, NULL)
114-
: JOIN(I, range)(a, JOIN(A, begin)(a), JOIN(A, end)(a));
113+
? JOIN(Z, range)(a, NULL, NULL)
114+
: JOIN(Z, range)(a, JOIN(A, begin)(a), JOIN(A, end)(a));
115115
}
116116

117117
static inline T
@@ -125,8 +125,8 @@ JOIN(A, equal)(A* self, A* other, int _equal(T*, T*))
125125
{
126126
if(self->size != other->size)
127127
return 0;
128-
I a = JOIN(I, each)(self);
129-
I b = JOIN(I, each)(other);
128+
Z a = JOIN(Z, each)(self);
129+
Z b = JOIN(Z, each)(other);
130130
while(!a.done && !b.done)
131131
{
132132
if(!_equal(a.ref, b.ref))
@@ -414,4 +414,4 @@ JOIN(A, find)(A* self, T key, int _equal(T*, T*))
414414
#undef T
415415
#undef A
416416
#undef B
417-
#undef I
417+
#undef Z

ctl/set.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#define A JOIN(set, T)
1212
#define B JOIN(A, node)
13-
#define I JOIN(A, it)
13+
#define Z JOIN(A, it)
1414

1515
typedef struct B
1616
{
@@ -32,16 +32,16 @@ typedef struct A
3232
}
3333
A;
3434

35-
typedef struct I
35+
typedef struct Z
3636
{
37-
void (*step)(struct I*);
37+
void (*step)(struct Z*);
3838
B* end;
3939
B* node;
4040
T* ref;
4141
B* next;
4242
int done;
4343
}
44-
I;
44+
Z;
4545

4646
static inline B*
4747
JOIN(A, begin)(A* self)
@@ -95,7 +95,7 @@ JOIN(B, next)(B* self)
9595
}
9696

9797
static inline void
98-
JOIN(I, step)(I* self)
98+
JOIN(Z, step)(Z* self)
9999
{
100100
if(self->next == self->end)
101101
self->done = 1;
@@ -107,15 +107,15 @@ JOIN(I, step)(I* self)
107107
}
108108
}
109109

110-
static inline I
111-
JOIN(I, range)(A* container, B* begin, B* end)
110+
static inline Z
111+
JOIN(Z, range)(A* container, B* begin, B* end)
112112
{
113113
(void) container;
114-
static I zero;
115-
I self = zero;
114+
static Z zero;
115+
Z self = zero;
116116
if(begin)
117117
{
118-
self.step = JOIN(I, step);
118+
self.step = JOIN(Z, step);
119119
self.node = JOIN(B, min)(begin);
120120
self.ref = &self.node->key;
121121
self.next = JOIN(B, next)(self.node);
@@ -132,12 +132,12 @@ JOIN(A, empty)(A* self)
132132
return self->size == 0;
133133
}
134134

135-
static inline I
136-
JOIN(I, each)(A* a)
135+
static inline Z
136+
JOIN(Z, each)(A* a)
137137
{
138138
return JOIN(A, empty)(a)
139-
? JOIN(I, range)(a, NULL, NULL)
140-
: JOIN(I, range)(a, JOIN(A, begin)(a), JOIN(A, end)(a));
139+
? JOIN(Z, range)(a, NULL, NULL)
140+
: JOIN(Z, range)(a, JOIN(A, begin)(a), JOIN(A, end)(a));
141141
}
142142

143143
static inline T
@@ -151,8 +151,8 @@ JOIN(A, equal)(A* self, A* other, int _equal(T*, T*))
151151
{
152152
if(self->size != other->size)
153153
return 0;
154-
I a = JOIN(I, each)(self);
155-
I b = JOIN(I, each)(other);
154+
Z a = JOIN(Z, each)(self);
155+
Z b = JOIN(Z, each)(other);
156156
while(!a.done && !b.done)
157157
{
158158
if(!_equal(a.ref, b.ref))
@@ -689,7 +689,7 @@ JOIN(A, free)(A* self)
689689
static inline A
690690
JOIN(A, copy)(A* self)
691691
{
692-
I it = JOIN(I, each)(self);
692+
Z it = JOIN(Z, each)(self);
693693
A copy = JOIN(A, init)(self->compare);
694694
while(!it.done)
695695
{
@@ -754,7 +754,7 @@ JOIN(A, symmetric_difference)(A* a, A* b)
754754
#undef T
755755
#undef A
756756
#undef B
757-
#undef I
757+
#undef Z
758758

759759
#ifdef USE_INTERNAL_VERIFY
760760
#undef USE_INTERNAL_VERIFY

0 commit comments

Comments
 (0)