diff options
| author | Tyge Løvset <[email protected]> | 2023-04-05 14:44:31 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-04-05 14:44:31 +0200 |
| commit | 2ad41420a973a3f1bd1ca47ab0f61b8f59ab9e66 (patch) | |
| tree | 047454272a19544d0a99db7ca07394c81894b474 | |
| parent | a3dc31d5393d051ad4dacb314452d3c6ec8a74b7 (diff) | |
| download | STC-modified-2ad41420a973a3f1bd1ca47ab0f61b8f59ab9e66.tar.gz STC-modified-2ad41420a973a3f1bd1ca47ab0f61b8f59ab9e66.zip | |
Internal: renamed untemplate.h to template2.h
| -rw-r--r-- | include/c11/print.h | 31 | ||||
| -rw-r--r-- | include/stc/algo/csort.h | 2 | ||||
| -rw-r--r-- | include/stc/carc.h | 2 | ||||
| -rw-r--r-- | include/stc/cbox.h | 2 | ||||
| -rw-r--r-- | include/stc/cdeq.h | 2 | ||||
| -rw-r--r-- | include/stc/clist.h | 2 | ||||
| -rw-r--r-- | include/stc/cmap.h | 2 | ||||
| -rw-r--r-- | include/stc/cpque.h | 2 | ||||
| -rw-r--r-- | include/stc/csmap.h | 2 | ||||
| -rw-r--r-- | include/stc/cstack.h | 2 | ||||
| -rw-r--r-- | include/stc/cvec.h | 2 | ||||
| -rw-r--r-- | include/stc/priv/template2.h (renamed from include/stc/priv/untemplate.h) | 0 | ||||
| -rw-r--r-- | misc/examples/triples.c | 10 |
13 files changed, 32 insertions, 29 deletions
diff --git a/include/c11/print.h b/include/c11/print.h index 1302d9cc..7c155875 100644 --- a/include/c11/print.h +++ b/include/c11/print.h @@ -1,7 +1,10 @@ #ifndef FMT_H_INCLUDED
#define FMT_H_INCLUDED
/*
-VER 2.0: NEW API:
+VER 2.1: NEW API:
+void print(fmt, ...);
+void println(fmt, ...);
+void printd(dest, fmt, ...);
void fmt_print(fmt, ...);
void fmt_println(fmt, ...);
@@ -40,21 +43,21 @@ int main() { unsigned char r = 123, g = 214, b = 90, w = 110;
char buffer[64];
- fmt_print("Color: ({} {} {}), {}\n", r, g, b, flag);
- fmt_println("Wide: {}, {}", wstr, L"wide world");
- fmt_println("{:10} {:10} {:10.2f}", 42ull, 43, pi);
- fmt_println("{:>10} {:>10} {:>10}", z, z, w);
- fmt_printd(stdout, "{:10} {:10} {:10}\n", "Hello", "Mad", "World");
- fmt_printd(stderr, "100%: {:<20} {:.*} {}\n", string, 4, pi, x);
- fmt_printd(buffer, "Precision: {} {:.10} {}", string, pi, x);
- fmt_println("{}", buffer);
- fmt_println("Vector: ({}, {}, {})", 3.2, 3.3, pi);
+ print("Color: ({} {} {}), {}\n", r, g, b, flag);
+ println("Wide: {}, {}", wstr, L"wide world");
+ println("{:10} {:10} {:10.2f}", 42ull, 43, pi);
+ println("{:>10} {:>10} {:>10}", z, z, w);
+ printd(stdout, "{:10} {:10} {:10}\n", "Hello", "Mad", "World");
+ printd(stderr, "100%: {:<20} {:.*} {}\n", string, 4, pi, x);
+ printd(buffer, "Precision: {} {:.10} {}", string, pi, x);
+ println("{}", buffer);
+ println("Vector: ({}, {}, {})", 3.2, 3.3, pi);
fmt_buffer out[1] = {{.stream=1}};
- fmt_printd(out, "{} {}", "Pi is:", pi);
- fmt_print("{}, len={}, cap={}\n", out->data, out->len, out->cap);
- fmt_printd(out, "{} {}", ", Pi squared is:", pi*pi);
- fmt_print("{}, len={}, cap={}\n", out->data, out->len, out->cap);
+ printd(out, "{} {}", "Pi is:", pi);
+ print("{}, len={}, cap={}\n", out->data, out->len, out->cap);
+ printd(out, "{} {}", ", Pi squared is:", pi*pi);
+ print("{}, len={}, cap={}\n", out->data, out->len, out->cap);
fmt_destroy(out);
}
*/
diff --git a/include/stc/algo/csort.h b/include/stc/algo/csort.h index 02ac4e34..53fe9fcc 100644 --- a/include/stc/algo/csort.h +++ b/include/stc/algo/csort.h @@ -86,4 +86,4 @@ static inline void c_PASTE(cqsort_, i_tag)(i_val arr[], intptr_t lo, intptr_t hi static inline void c_PASTE(csort_, i_tag)(i_val arr[], intptr_t n) { c_PASTE(cqsort_, i_tag)(arr, 0, n - 1); } -#include "../priv/untemplate.h" +#include "../priv/template2.h" diff --git a/include/stc/carc.h b/include/stc/carc.h index 16d3a2d4..8ef80b12 100644 --- a/include/stc/carc.h +++ b/include/stc/carc.h @@ -210,4 +210,4 @@ STC_INLINE uint64_t _cx_memb(_hash)(const _cx_self* self) #undef _i_eq #undef _i_atomic_inc #undef _i_atomic_dec_and_test -#include "priv/untemplate.h" +#include "priv/template2.h" diff --git a/include/stc/cbox.h b/include/stc/cbox.h index 4d2cb1f1..ca88fc66 100644 --- a/include/stc/cbox.h +++ b/include/stc/cbox.h @@ -194,4 +194,4 @@ STC_INLINE uint64_t _cx_memb(_hash)(const _cx_self* self) #endif #undef _i_eq -#include "priv/untemplate.h" +#include "priv/template2.h" diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h index ef1700f5..ff6e744f 100644 --- a/include/stc/cdeq.h +++ b/include/stc/cdeq.h @@ -443,4 +443,4 @@ _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y) { #endif // !_i_queue #endif // IMPLEMENTATION #define CDEQ_H_INCLUDED -#include "priv/untemplate.h" +#include "priv/template2.h" diff --git a/include/stc/clist.h b/include/stc/clist.h index 6e6b6d45..f7fb4152 100644 --- a/include/stc/clist.h +++ b/include/stc/clist.h @@ -404,4 +404,4 @@ STC_DEF bool _cx_memb(_sort_with)(_cx_self* self, int(*cmp)(const _cx_value*, co #endif // !c_no_cmp #endif // i_implement #define CLIST_H_INCLUDED -#include "priv/untemplate.h" +#include "priv/template2.h" diff --git a/include/stc/cmap.h b/include/stc/cmap.h index 1976738d..9a503367 100644 --- a/include/stc/cmap.h +++ b/include/stc/cmap.h @@ -481,4 +481,4 @@ _cx_memb(_erase_entry)(_cx_self* self, _cx_value* _val) { #undef _i_MAP_ONLY #undef _i_SET_ONLY #define CMAP_H_INCLUDED -#include "priv/untemplate.h" +#include "priv/template2.h" diff --git a/include/stc/cpque.h b/include/stc/cpque.h index 023c9d27..b95b5020 100644 --- a/include/stc/cpque.h +++ b/include/stc/cpque.h @@ -160,4 +160,4 @@ _cx_memb(_push)(_cx_self* self, _cx_value value) { #endif #define CPQUE_H_INCLUDED -#include "priv/untemplate.h" +#include "priv/template2.h" diff --git a/include/stc/csmap.h b/include/stc/csmap.h index 716c1bfe..22607196 100644 --- a/include/stc/csmap.h +++ b/include/stc/csmap.h @@ -595,4 +595,4 @@ _cx_memb(_drop)(_cx_self* self) { #undef _i_MAP_ONLY #undef _i_SET_ONLY #define CSMAP_H_INCLUDED -#include "priv/untemplate.h" +#include "priv/template2.h" diff --git a/include/stc/cstack.h b/include/stc/cstack.h index 1fc3f377..c2792358 100644 --- a/include/stc/cstack.h +++ b/include/stc/cstack.h @@ -189,4 +189,4 @@ STC_INLINE void _cx_memb(_next)(_cx_iter* it) STC_INLINE _cx_iter _cx_memb(_advance)(_cx_iter it, size_t n) { if ((it.ref += n) >= it.end) it.ref = NULL ; return it; } -#include "priv/untemplate.h" +#include "priv/template2.h" diff --git a/include/stc/cvec.h b/include/stc/cvec.h index e257f85a..a1aa74b2 100644 --- a/include/stc/cvec.h +++ b/include/stc/cvec.h @@ -438,4 +438,4 @@ STC_DEF int _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y) { #endif // !c_no_cmp #endif // i_implement #define CVEC_H_INCLUDED -#include "priv/untemplate.h" +#include "priv/template2.h" diff --git a/include/stc/priv/untemplate.h b/include/stc/priv/template2.h index 27c6a890..27c6a890 100644 --- a/include/stc/priv/untemplate.h +++ b/include/stc/priv/template2.h diff --git a/misc/examples/triples.c b/misc/examples/triples.c index aac7967a..520bf012 100644 --- a/misc/examples/triples.c +++ b/misc/examples/triples.c @@ -4,12 +4,12 @@ #include <stdio.h> void triples_vanilla(int n) { - for (int i = 5, c = 1;; ++c) { + for (int c = 5; n; ++c) { for (int a = 1; a < c; ++a) { for (int b = a + 1; b < c; ++b) { if ((int64_t)a*a + (int64_t)b*b == (int64_t)c*c) { - if (i++ == n) goto done; printf("{%d, %d, %d}\n", a, b, c); + if (--n == 0) goto done; } } } @@ -25,12 +25,12 @@ struct triples { bool triples_next(struct triples* I) { cco_begin(I); - for (I->c = 5;; ++I->c) { + for (I->c = 5; I->n; ++I->c) { for (I->a = 1; I->a < I->c; ++I->a) { for (I->b = I->a + 1; I->b < I->c; ++I->b) { if ((int64_t)I->a*I->a + (int64_t)I->b*I->b == (int64_t)I->c*I->c) { - if (I->n-- == 0) cco_return; cco_yield(true); + if (--I->n == 0) cco_return; } } } @@ -61,7 +61,7 @@ int main() while (triples_next(&t)) { if (gcd(t.a, t.b) > 1) continue; - if (t.c < 1000) + if (t.c < 100) printf("%d: {%d, %d, %d}\n", ++n, t.a, t.b, t.c); else cco_stop(&t); |
