aboutsummaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-07-02 16:59:45 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-07-02 16:59:45 -0700
commitda98d5314731206cd03038d589d10c5c32a0ce8c (patch)
tree4b7dd002a5edda8f2e6561c29bf6aee80a3e9303 /share
parent94ed05fe4df6a657884596bdabd03c7666a63de7 (diff)
downloadcppawk-da98d5314731206cd03038d589d10c5c32a0ce8c.tar.gz
cppawk-da98d5314731206cd03038d589d10c5c32a0ce8c.tar.bz2
cppawk-da98d5314731206cd03038d589d10c5c32a0ce8c.zip
Restructure cppawk installation.
cppawk now expects to be installed in some directory (typically "bin"), such that the include files are in a "share/cppawk/include" directory where "share" is a sibling of "bin". The git repository is restructured to match this shape; cppawk is moved into "bin", and the include files into "share/cppawk/include".
Diffstat (limited to 'share')
-rw-r--r--share/cppawk/include/array.h98
-rw-r--r--share/cppawk/include/base.h60
-rw-r--r--share/cppawk/include/case-priv.h93
-rw-r--r--share/cppawk/include/case.h46
-rw-r--r--share/cppawk/include/cons-priv.h906
-rw-r--r--share/cppawk/include/cons.h92
-rw-r--r--share/cppawk/include/field.h88
-rw-r--r--share/cppawk/include/fun-priv.h50
-rw-r--r--share/cppawk/include/fun.h39
-rw-r--r--share/cppawk/include/iter-priv.h45
-rw-r--r--share/cppawk/include/iter.h329
-rw-r--r--share/cppawk/include/narg-priv.h367
-rw-r--r--share/cppawk/include/narg.h44
-rw-r--r--share/cppawk/include/varg-priv.h392
-rw-r--r--share/cppawk/include/varg.h46
15 files changed, 2695 insertions, 0 deletions
diff --git a/share/cppawk/include/array.h b/share/cppawk/include/array.h
new file mode 100644
index 0000000..f3b7a22
--- /dev/null
+++ b/share/cppawk/include/array.h
@@ -0,0 +1,98 @@
+// cppawk: C preprocessor wrapper around awk
+// Copyright 2022 Kaz Kylheku <kaz@kylheku.com>
+//
+// BSD-2 License
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef __CPPAWK_ARRAY_H
+#define __CPPAWK_ARRAY_H
+
+#ifndef __CPPAWK_BASE_H
+#include "base.h"
+#endif
+
+#ifndef __CPPAWK_ITER_PRIV_H
+#include "iter-priv.h"
+#endif
+
+#ifndef __CPPAWK_CONS_PRIV_H
+#include "cons-priv.h"
+#endif
+
+#if __have_indirect_functions
+#ifndef __CPPAWK_FUN_PRIV_H
+#include "fun-priv.h"
+#endif
+#endif
+
+function fields_to_array(__to_array,
+ __i, __val)
+{
+ delete __to_array
+
+ __to_array[0] = $0
+
+ __dofields (__i, __val)
+ __to_array[__i] = __val
+}
+
+function array_to_fields(__from_array,
+ __i, __val)
+{
+ for (__i = 0; ; __i++)
+ if (__i in __from_array)
+ $__i = __from_array[__i]
+ else
+ break
+}
+
+#if __have_indirect_functions
+
+function maparray(__fun, __from_array, __to_array)
+{
+ delete __to_array
+ __doarray (key, value, __from_array)
+ __to_array[key] = __call(__fun, value)
+}
+
+function group_by(__fun, __list, __to_array,
+ __item, __key)
+{
+ delete __to_array
+
+ __dolist (__item, __list) {
+ __key = __call(__fun, __item)
+ if (__key in __to_array)
+ __to_array[__key] = __list_add(__to_array[__key], __item)
+ else
+ __to_array[__key] = __list_add(__list_begin(), __item)
+ }
+
+ for (__key in __to_array)
+ __to_array[__key] = __list_end(__to_array[__key])
+}
+
+#endif
+
+#endif
diff --git a/share/cppawk/include/base.h b/share/cppawk/include/base.h
new file mode 100644
index 0000000..4012d95
--- /dev/null
+++ b/share/cppawk/include/base.h
@@ -0,0 +1,60 @@
+// cppawk: C preprocessor wrapper around awk
+// Copyright 2022 Kaz Kylheku <kaz@kylheku.com>
+//
+// BSD-2 License
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef __CPPAWK_BASE_H
+#define __CPPAWK_BASE_H
+
+#if __gawk__ && !defined __gawk_ver
+#define __gawk_ver 040000
+#endif
+
+#define __cat(a, b) a ## b
+#define __xcat(a, b) __cat(a, b)
+#define __str(x) # x
+#define __xstr(x) __str(x)
+#define __g(name) __xcat(__, __xcat(name, __LINE__))
+#define __gx(name, ext) __xcat(__, __xcat(name, __xcat(ext, __LINE__)))
+
+#define __error(...) { printf(__VA_ARGS__); print; exit 1 }
+
+#define __present(arg) ((arg) != "" || (arg) != 0)
+
+#if __egawk__
+#define __let(...) @let (__VA_ARGS__)
+#define __have_let 1
+#else
+#define __let(...)
+#endif
+
+#if __gawk__
+#define __have_switch 1
+#if __gawk_ver >= 040000 || __egawk__
+#define __have_indirect_functions 1
+#endif
+#endif
+
+#endif
diff --git a/share/cppawk/include/case-priv.h b/share/cppawk/include/case-priv.h
new file mode 100644
index 0000000..825ed1b
--- /dev/null
+++ b/share/cppawk/include/case-priv.h
@@ -0,0 +1,93 @@
+// cppawk: C preprocessor wrapper around awk
+// Copyright 2022 Kaz Kylheku <kaz@kylheku.com>
+//
+// BSD-2 License
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef __CPPAWK_CASE_PRIV_H
+#define __CPPAWK_CASE_PRIV_H
+
+#ifndef __CPPAWK_NARG_PRIV
+#include "narg-priv.h"
+#endif
+
+#ifndef __CPPAWK_BASE_H
+#include "base.h"
+#endif
+
+#if __have_switch
+
+#define __ca_first(x) case x:
+#define __ca_next(p, x) p case x:
+
+#define __mx_first(x) __of(x)
+#define __mx_next(p, x) p case x:
+
+#define __case_temps __ign
+#define __case(expr) switch (expr)
+#define __of(...) __varexpand(__ca_first, __ca_next, __VA_ARGS__) {{{
+#define __matching(...) __varexpand(__ca_first, __ca_next, __VA_ARGS__) {{{
+#define __mixed(x, y) __varexpand(__ca_first, __ca_next, __splice(x)) \
+ __varexpand(__ca_first, __ca_next, __splice(y)) {{{
+#define __cbreak break; }}}
+#define __cfall }}}
+#define __cret(val) return val; }}}
+#define __otherwise default: {{{
+
+#else
+
+#define __clause(expr) if (__pass || (expr) && (__pass = 1))
+#define __of_first(x) (__val == (x))
+#define __of_next(p, x) p || (__val == (x))
+#define __mtch_first(x) (__val ~ (x))
+#define __mtch_next(p, \
+ x) p || (__val ~ (x))
+
+#if !__have_let
+#define __case_temps __val, __once, __pass
+#else
+#define __case_temps __ign
+#endif
+
+#define __case(expr) __let (__val, __once, __pass) \
+ for ((__once = 1) && (__pass = 0) || (__val = expr); \
+ __once; \
+ __once = 0)
+#define __of(...) __clause(__varexpand(__of_first, __of_next, \
+ __VA_ARGS__)) {{{
+#define __matching(...) __clause(__varexpand(__mtch_first, mtch_next, \
+ __VA_ARGS__)) {{{
+#define __mixed(x, y) __clause(__varexpand(__of_first, __of_next, \
+ __splice(x)) || \
+ __varexpand(__mtch_first, __mtch_next, \
+ __splice(y))) {{{
+#define __cbreak break; }}}
+#define __creturn(val) return val; }}}
+#define __cfall }}}
+#define __cret(val) return val; }}}
+#define __otherwise if (__pass = 1) {{{
+
+#endif
+
+#endif
diff --git a/share/cppawk/include/case.h b/share/cppawk/include/case.h
new file mode 100644
index 0000000..d5ed331
--- /dev/null
+++ b/share/cppawk/include/case.h
@@ -0,0 +1,46 @@
+// cppawk: C preprocessor wrapper around awk
+// Copyright 2022 Kaz Kylheku <kaz@kylheku.com>
+//
+// BSD-2 License
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef __CPPAWK_CASE_H
+#define __CPPAWK_CASE_H
+
+#ifndef __CPPAWK_CASE_PRIV_H
+#include "case-priv.h"
+#endif
+
+#define case_temps __case_temps
+#define case(expr) __case(expr)
+#define of(...) __of(__VA_ARGS__)
+#define matching(...) __matching(__VA_ARGS__)
+#define mixed(...) __mixed(__VA_ARGS__)
+#define cbreak __cbreak
+#define cfall __cfall
+#define cret(val) __cret(val)
+#define then __do
+#define otherwise __otherwise
+
+#endif
diff --git a/share/cppawk/include/cons-priv.h b/share/cppawk/include/cons-priv.h
new file mode 100644
index 0000000..172f20f
--- /dev/null
+++ b/share/cppawk/include/cons-priv.h
@@ -0,0 +1,906 @@
+// cppawk: C preprocessor wrapper around awk
+// Copyright 2022 Kaz Kylheku <kaz@kylheku.com>
+//
+// BSD-2 License
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef __CPPAWK_CONS_PRIV_H
+#define __CPPAWK_CONS_PRIV_H
+
+#ifndef __CPPAWK_BASE_H
+#include "base.h"
+#endif
+
+#ifndef __CPPAWK_ITER_PRIV_H
+#include "iter-priv.h"
+#endif
+
+#ifndef __CPPAWK_CASE_PRIV_H
+#include "case-priv.h"
+#endif
+
+#ifndef __CPPAWK_NARG_PRIV_H
+#include "narg-priv.h"
+#endif
+
+#if __have_indirect_functions
+#ifndef __CPPAWK_FUN_PRIV_H
+#include "fun-priv.h"
+#endif
+#endif
+
+#define __nil ""
+
+#define __prog_first(expr) ((expr) || 1)
+#define __prog_next(prev, \
+ expr) prev && ((expr) || 1)
+#define __prog(...) (__varexpand(__prog_first, __prog_next, \
+ __VA_ARGS__))
+
+#define __progn_first(expr) (expr)
+#define __progn_next(prev, \
+ next) ((prev || 1) ? (next) : 0)
+#define __progn(...) __varexpand(__progn_first, __progn_next, \
+ __VA_ARGS__)
+
+#define __or_first(expr) (expr)
+#define __or_next(prev, \
+ next) ((__g(or) = prev) ? __g(or) : (next))
+#define __or(...) __varexpand(__or_first, __or_next, \
+ __VA_ARGS__)
+
+#define __and_first(expr) (expr)
+#define __and_next(prev, \
+ next) ((__g(and) = prev) ? next : __g(and))
+#define __and(...) __varexpand(__and_first, __and_next, \
+ __VA_ARGS__)
+
+
+#define __push(item, list) (list = __cons(item, list))
+
+#define __pop(list) (__progn(__g(ol) = (list), \
+ list = __cdr(__g(ol)), \
+ __car(__g(ol))))
+
+#define __dolist(item, list) \
+ for (__g(i) = list; \
+ !__endp(__g(i)) && ((item = __car(__g(i))) || 1); \
+ __g(i) = __cdr(__g(i)))
+
+#define __dolisti(item, index, list) \
+ for (__prog(__g(i) = list, index = 0); \
+ !__endp(__g(i)) && ((item = __car(__g(i))) || 1); \
+ __prog(__g(i) = __cdr(__g(i)), index++))
+
+#define __doconses(iter, list) \
+ for (iter = list; __consp(iter); iter = __cdr(iter))
+
+#define __list_begin() ""
+#define __list_add(stk, item) __pack(stk, item)
+#define __list_end(stk) __unpack(stk, __nil)
+#define __list_end_atom(stk, atom) __unpack(stk, atom)
+
+#define __bag_init_first(x) (x = __list_begin())
+#define __bag_init_next(p, x) (p || 1) && __bag_init_first(x)
+
+#define __bag_done_first(x) (x = __list_end(x))
+#define __bag_done_next(p, x) (p || 1) && __bag_done_first(x)
+
+#define __bags(...) for ((__g(once) = 1) && \
+ __varexpand(__bag_init_first, \
+ __bag_init_next, \
+ __VA_ARGS__); \
+ __g(once) || \
+ __varexpand(__bag_done_first, \
+ __bag_done_next, \
+ __VA_ARGS__) && 0; \
+ __g(once) = 0)
+#define __bag(bag, expr) bag = __list_add(bag, expr)
+
+#define __typecode(obj) (substr(obj, 1, 1))
+
+function __consp(__obj)
+{
+ return __typecode(__obj) == "C"
+}
+#define __consp(obj) (__typecode(obj) == "C")
+
+function __atom(__obj)
+{
+ return __typecode(__obj) != "C"
+}
+#define __atom(obj) (__typecode(obj) != "C")
+
+function __null(__obj)
+{
+ return __obj == __nil && __obj != 0
+}
+
+function __endp(__obj)
+{
+ if (__obj == __nil && __obj != 0)
+ return 1
+ if (__consp(__obj))
+ return 0
+ __error("endp: a proper list ends with nil, not %s", __obj)
+}
+
+function __bs_esc(raw)
+{
+ gsub(/[\\\042]/, "\\\\&", raw)
+ return raw
+}
+
+function __numberp(__obj)
+{
+ return __obj != "" && (__obj == 0 || __obj + 0 != 0)
+}
+#define __numberp(obj) (obj != "" && ((obj) == 0 || (obj) + 0 != 0))
+
+function __stringp(__obj)
+{
+ return __typecode(__obj) == "T"
+}
+#define __stringp(obj) (__typecode(obj) == "T")
+
+function __symbolp(__obj)
+{
+ return __obj != 0 && __typecode(__obj) ~ /^S?$/
+}
+
+function __box(__raw,
+ __check,
+ __case_temps)
+{
+ if (!__present(__raw))
+ return "U";
+
+ if (__present(__check))
+ __error("box; excess argument %s", __check)
+
+ if (__numberp(__raw))
+ return __raw;
+
+ return "T" __raw;
+}
+
+function __unbox(__obj,
+ __check,
+ __case_temps)
+{
+ if (!__present(__obj))
+ __error("unbox: missing or undefined argument")
+
+ if (__present(__check))
+ __error("unbox; excess argument %s", __check)
+
+ __case (__typecode(__obj)) {
+ __of ("T", "S")
+ __cret (substr(__obj, 2))
+ __of ("C")
+ __error("unbox: %s looks like a cons", __obj)
+ __cbreak
+ __of ("U")
+ __cret(__check)
+ __of ("")
+ __cret("nil")
+ __otherwise
+ if (!__numberp(__obj))
+ __error("unbox: %s isn't symbol, number or boxed string", __obj)
+ __cret (__obj)
+ }
+}
+
+function __box_str(__str)
+{
+ return "T" __str
+}
+#define __box_str(str) ("T" (str))
+
+function __box_sym(__name)
+{
+ return __name == "nil" ? __nil : "S" __name
+}
+
+function __cons(__a, __d)
+{
+ return "C" length(__a) "," length(__d) ":" __a __d
+}
+
+function __car(__cell,
+ __col, __com, len)
+{
+ if (__consp(__cell)) {
+ __col = match(__cell, /:/)
+ __com = match(__cell, /,/)
+ if (__col == 0 || __com == 0 || __col <= __com)
+ __error("car: %s has a malformed cons header", __cell)
+ len = substr(__cell, 2, __com - 2 + 1)
+ return substr(__cell, __col + 1, len)
+ } else if (__null(__cell)) {
+ return __nil
+ } else {
+ __error("car: %s isn't a cons", __cell)
+ }
+}
+
+function __cdr(__cell,
+ __col, __com, __alen, __dlen)
+{
+ if (__consp(__cell)) {
+ __col = match(__cell, /:/)
+ __com = match(__cell, /,/)
+ if (__col == 0 || __com == 0 || __col <= __com)
+ __error("cdr: %s has a malformed cons header", __cell)
+ __alen = substr(__cell, 2, __com - 2 + 1)
+ __dlen = substr(__cell, __com + 1, __col - __com)
+ return substr(__cell, __col + 1 + __alen, __dlen)
+ } else if (__null(__cell)) {
+ return __nil
+ } else {
+ __error("cdr: %s isn't a cons", __cell)
+ }
+}
+
+function __sexp(__obj,
+ __d, __x, __y, __case_temps)
+{
+ if (!__present(__obj))
+ __error("sexp: missing or undefined argument")
+
+ __case (__typecode(__obj)) {
+ __of ("C")
+ __d = __cdr(__obj)
+ __x = __sexp(__car(__obj))
+ if (__null(__d)) {
+ return "(" __x ")"
+ } else {
+ __y = __sexp(__d)
+ if (__typecode(__d) == "C")
+ return "(" __x " " substr(__y, 2)
+ else
+ return "(" __x " . " __y ")"
+ }
+ __cbreak
+ __of ("T")
+ __cret ("\"" __bs_esc(substr(__obj, 2)) "\"")
+ __of ("S")
+ __cret (__bs_esc(substr(__obj, 2)))
+ __of ("U")
+ __cret ("#U")
+ }
+
+ if (__numberp(__obj)) {
+ return __obj
+ } else if (__null(__obj)) {
+ return "nil"
+ } else {
+ return "\"" __bs_esc(__obj) "\""
+ }
+}
+
+function __reverse(__lst,
+ __tmp)
+{
+ __tmp = __nil
+
+ while (!__endp(__lst)) {
+ __push(__car(__lst), __tmp);
+ __lst = __cdr(__lst);
+ }
+
+ return __tmp;
+}
+
+function __values(__arr,
+ __tmp, __key, __value)
+{
+ __tmp = __list_begin()
+
+ __doarray (__key, __value, __arr)
+ __tmp = __list_add(__tmp,__value)
+
+ return __list_end(__tmp)
+}
+
+function __keys(__array,
+ __key, __tmp)
+{
+ __tmp = __list_begin()
+
+ for (__key in __array)
+ __tmp = __list_add(__tmp, __key)
+
+ return __list_end(__tmp)
+}
+
+
+function __fields(__start, __count,
+ __tmp, __end, __val)
+{
+ if (!__present(__start))
+ __start = 1
+
+ if (!__present(__count))
+ __count = NF - __start + 1
+
+ if (__count < 1)
+ return __nil
+
+ __end = __start + __count - 1
+
+ if (__end > NF)
+ __end = NF
+
+ if (__start < 1)
+ __start = 1
+
+ if (__start > __end)
+ return __nil
+
+ __tmp = __list_begin()
+
+ for (; __start <= __end; __start++)
+ __tmp = __list_add(__tmp, $(__start))
+
+ return __list_end(__tmp)
+}
+
+function __set_fields(__lst, __start,
+ __tmp, __item, __n)
+{
+ if (!__present(__start))
+ __start = 1
+
+ __dolisti (__item, __n, __lst)
+ $(__n + __start) = __item
+
+ NF = __n + __start - 1
+
+ return __n
+}
+
+function __equal(__obj1, __obj2)
+{
+ if (__obj1 == __obj2)
+ return 1;
+ return __slow_equal(__obj1, __obj2)
+}
+#define __equal(obj1, obj2) ((obj1) == (obj2) ? 1 : __slow_equal(obj1, obj2))
+
+function __slow_equal(__obj1, __obj2,
+ __tc1, __tc2, __case_temps)
+{
+ __tc1 = __typecode(__obj1)
+ __tc2 = __typecode(__obj2)
+
+ __case (__tc1 __tc2) {
+ __of ("CC")
+ __cret (__equal(__car(__obj1), __car(__obj2)) &&
+ __equal(__cdr(__obj1), __cdr(__obj2)))
+ __matching (/[UTSC][UTSC]/)
+ __cret (0);
+ }
+
+ if (__tc1 == "T")
+ return __numberp(__obj2) ? 0 : (__obj1 == __box_str(__obj2))
+
+ if (__tc2 == "T")
+ return __numberp(__obj1) ? 0 : (__box_str(__obj1) == __obj2)
+
+ if (__numberp(__obj1) && __numberp(__obj2))
+ return __obj1 + 0 == __obj2 + 0
+
+ return 0
+}
+
+function __equalize(__obj,
+ __tc, __str)
+{
+ if (!__present(__obj))
+ return ""
+
+ __tc = __typecode(__obj)
+
+ __case (__tc) {
+ __of("C")
+ __cret (__cons(__equalize(__car(__obj)),
+ __equalize(__cdr(__obj))))
+ __of("T", "S", "U", "")
+ __cret (__obj)
+ }
+
+ if (__numberp(__obj))
+ return __obj + 0
+
+ return __box_str(__obj)
+}
+
+function __pack(__stk, __item)
+{
+ return length(__item) ":" __item __stk
+}
+
+function __unpack(__stk, __out,
+ __col)
+{
+ while (__stk != "") {
+ __col = match(__stk, /:/)
+ if (__col == 0)
+ break;
+ __push(substr(__stk, __col + 1, __stk), __out)
+ __stk = substr(__stk, __col + 1 + __stk);
+ }
+
+ return __out
+}
+
+#ifndef __CPPAWK_VARG_PRIV_H
+#include "varg-priv.h"
+#endif
+
+function __list(__rest,
+ __check)
+{
+ return __arglist("list", __rest, __check)
+}
+#define __list_first(item) __cons(item, __nil)
+#define __list_next(list, item) __cons(item, list)
+#define __li(...) __varexpand(__list_first, \
+ __list_next, \
+ __revarg(__VA_ARGS__))
+
+#define __listar_first(item) item
+#define __listar(...) __varexpand(__listar_first, \
+ __list_next, \
+ __revarg(__VA_ARGS__))
+
+function __append2(__left, __right,
+ tmp)
+{
+ tmp = __reverse(__left)
+ while (!__endp(tmp))
+ __right = __cons(__pop(tmp), __right)
+ return __right
+}
+
+function __append(__rest,
+ __count, __out)
+{
+ __varg_count("append", __count, __count)
+ __out = __nil
+ __case (__count) {
+ __of (32)
+ __out = __r32
+ __cbreak
+ __of (31)
+ __out = __r31
+ __cbreak
+ __of (30)
+ __out = __r30
+ __cbreak
+ __of (29)
+ __out = __r29
+ __cbreak
+ __of (28)
+ __out = __r28
+ __cbreak
+ __of (27)
+ __out = __r27
+ __cbreak
+ __of (26)
+ __out = __r26
+ __cbreak
+ __of (25)
+ __out = __r25
+ __cbreak
+ __of (24)
+ __out = __r24
+ __cbreak
+ __of (23)
+ __out = __r23
+ __cbreak
+ __of (22)
+ __out = __r22
+ __cbreak
+ __of (21)
+ __out = __r21
+ __cbreak
+ __of (20)
+ __out = __r20
+ __cbreak
+ __of (19)
+ __out = __r19
+ __cbreak
+ __of (18)
+ __out = __r18
+ __cbreak
+ __of (17)
+ __out = __r17
+ __cbreak
+ __of (16)
+ __out = __r16
+ __cbreak
+ __of (15)
+ __out = __r15
+ __cbreak
+ __of (14)
+ __out = __r14
+ __cbreak
+ __of (13)
+ __out = __r13
+ __cbreak
+ __of (12)
+ __out = __r12
+ __cbreak
+ __of (11)
+ __out = __r11
+ __cbreak
+ __of (10)
+ __out = __r10
+ __cbreak
+ __of (9)
+ __out = __r9
+ __cbreak
+ __of (8)
+ __out = __r8
+ __cbreak
+ __of (7)
+ __out = __r7
+ __cbreak
+ __of (6)
+ __out = __r6
+ __cbreak
+ __of (5)
+ __out = __r5
+ __cbreak
+ __of (4)
+ __out = __r4
+ __cbreak
+ __of (3)
+ __out = __r3
+ __cbreak
+ __of (2)
+ __out = __r2
+ __cbreak
+ __of (1)
+ __out = __r1
+ __cbreak
+ }
+ __case (__count - 1) {
+ __of (31)
+ __out = __append2(__r31, __out)
+ __cfall
+ __of (30)
+ __out = __append2(__r30, __out)
+ __cfall
+ __of (29)
+ __out = __append2(__r29, __out)
+ __cfall
+ __of (28)
+ __out = __append2(__r28, __out)
+ __cfall
+ __of (27)
+ __out = __append2(__r27, __out)
+ __cfall
+ __of (26)
+ __out = __append2(__r26, __out)
+ __cfall
+ __of (25)
+ __out = __append2(__r25, __out)
+ __cfall
+ __of (24)
+ __out = __append2(__r24, __out)
+ __cfall
+ __of (23)
+ __out = __append2(__r23, __out)
+ __cfall
+ __of (22)
+ __out = __append2(__r22, __out)
+ __cfall
+ __of (21)
+ __out = __append2(__r21, __out)
+ __cfall
+ __of (20)
+ __out = __append2(__r20, __out)
+ __cfall
+ __of (19)
+ __out = __append2(__r19, __out)
+ __cfall
+ __of (18)
+ __out = __append2(__r18, __out)
+ __cfall
+ __of (17)
+ __out = __append2(__r17, __out)
+ __cfall
+ __of (16)
+ __out = __append2(__r16, __out)
+ __cfall
+ __of (15)
+ __out = __append2(__r15, __out)
+ __cfall
+ __of (14)
+ __out = __append2(__r14, __out)
+ __cfall
+ __of (13)
+ __out = __append2(__r13, __out)
+ __cfall
+ __of (12)
+ __out = __append2(__r12, __out)
+ __cfall
+ __of (11)
+ __out = __append2(__r11, __out)
+ __cfall
+ __of (10)
+ __out = __append2(__r10, __out)
+ __cfall
+ __of (9)
+ __out = __append2(__r9, __out)
+ __cfall
+ __of (8)
+ __out = __append2(__r8, __out)
+ __cfall
+ __of (7)
+ __out = __append2(__r7, __out)
+ __cfall
+ __of (6)
+ __out = __append2(__r6, __out)
+ __cfall
+ __of (5)
+ __out = __append2(__r5, __out)
+ __cfall
+ __of (4)
+ __out = __append2(__r4, __out)
+ __cfall
+ __of (3)
+ __out = __append2(__r3, __out)
+ __cfall
+ __of (2)
+ __out = __append2(__r2, __out)
+ __cfall
+ __of (1)
+ __out = __append2(__r1, __out)
+ __cfall
+ }
+
+ return __out
+}
+
+function __member(__item, __lst)
+{
+ while (!__endp(__lst)) {
+ if (__equal(__item, __car(__lst)))
+ return __lst;
+ __lst = __cdr(__lst)
+ }
+
+ return __nil
+}
+
+function __position(__item, __lst,
+ __pos)
+{
+ for (__pos = 0; !__endp(__lst); __pos++) {
+ if (__equal(__item, __car(__lst)))
+ return __pos;
+ __lst = __cdr(__lst)
+ }
+
+ return __nil
+}
+
+function __nth(__pos, __lst)
+{
+ for (; __pos > 0 && !__endp(__lst); __pos--)
+ __lst = __cdr(__lst)
+ return __pos == 0 ? __car(__lst) : __nil
+}
+
+function __nthcdr(__pos, __lst)
+{
+ for (; __pos > 0 && !__endp(__lst); __pos--)
+ __lst = __cdr(__lst)
+ return __lst
+}
+
+function __ldiff(__main, __tail,
+ __out, __iter)
+{
+ if (__null(__main))
+ return __nil
+
+ if (__null(__tail))
+ return __main
+
+ __out = __list_begin()
+
+ __doconses (__iter, __main) {
+ if (__iter == __tail)
+ break
+ __out = __list_add(__out, __car(__iter))
+ }
+
+ if (__atom(__iter) && __iter != __tail)
+ return __list_end_atom(__out, __iter)
+
+ return __list_end(__out)
+}
+
+function __last(__lst, __n,
+ __circbuf, __i)
+{
+ if (!__present(__n))
+ __n = 1
+ else if (__n < 0)
+ __error("last: number argument %s must be non-negative", __n)
+
+ if (__n == 0) {
+ __doconses (__iter, __lst)
+ ; // nothing
+ return __iter
+ }
+
+ delete __circbuf
+
+ __i = 0
+
+ __n++
+
+ __doconses (__iter, __lst)
+ __circbuf[__i++ % __n] = __iter
+
+ __i = (__i + 1) % __n
+
+ return (__i in __circbuf) ? __circbuf[__i] : __lst
+}
+
+function __butlast(__lst, __n,
+ __circbuf, __i, __out)
+{
+ if (!__present(__n))
+ __n = 1
+ else if (__n < 0)
+ __error("butlast: number argument %s must be non-negative", __n)
+
+ __out = __list_begin()
+
+ if (__n == 0) {
+ __doconses (__iter, __lst)
+ __out = __list_add(__out, __car(__iter))
+ return __list_end(__out)
+ }
+
+ delete __circbuf
+
+ __i = 0
+
+ __n++
+
+ __doconses (__iter, __lst) {
+ __circbuf[__i++ % __n] = __out
+ __out = __list_add(__out, __car(__iter))
+ }
+
+ __i = (__i + 1) % __n
+
+ return (__i in __circbuf) ? __list_end(__circbuf[__i]) : __nil
+}
+
+function __iota(__from, __to, __delta,
+ __out, __i, __val)
+{
+ __out = __list_begin();
+
+ if (__from < __to) {
+ if (!__present(__delta))
+ __delta = 1
+
+ if (__delta <= 0)
+ return __nil;
+
+ __i = 0
+ __val = __from
+
+ while (__val <= __to) {
+ __out = __list_add(__out, __val)
+ __i++
+ __val = __from + (__i * __delta)
+ }
+ } else if (__from > __to) {
+ if (!__present(__delta))
+ __delta = -1
+
+ if (__delta >= 0)
+ return __nil;
+
+ __i = 0
+ __val = __from
+
+ while (__val >= __to) {
+ __out = __list_add(__out, __val)
+ __i++
+ __val = __from + (__i * __delta)
+ }
+ } else {
+ return __list(__from)
+ }
+
+ return __list_end(__out)
+}
+
+function __uniq(__lst,
+ __out, __item, __seen)
+{
+ __out = __list_begin();
+
+ __dolist(__item, __lst) {
+ if (__item in __seen)
+ continue
+ __seen[__item]
+ __out = __list_add(__out, __item)
+ }
+
+ return __list_end(__out)
+}
+
+function __uniqual(__lst,
+ __out, __item, __itemeq, __seen)
+{
+ __out = __list_begin();
+
+ __dolist(__item, __lst) {
+ __itemq = __equalize(__item)
+ if (__itemq in __seen)
+ continue
+ __seen[__itemq]
+ __out = __list_add(__out, __item)
+ }
+
+ return __list_end(__out)
+}
+
+
+#if __have_indirect_functions
+
+function __mapcar(__fun, __lst,
+ __temp, __item, out)
+{
+ __temp = __list_begin()
+ __dolist(__item, __lst)
+ __temp = __list_add(__temp, __call(__fun, __item))
+ return __list_end(__temp)
+}
+
+function __mappend(__fun, __lst,
+ __temp, __item, out)
+{
+ __temp = __nil
+ __dolist(__item, __lst)
+ __temp = __append2(__temp, __call(__fun, __item))
+ return __temp
+}
+
+#endif
+
+#endif
diff --git a/share/cppawk/include/cons.h b/share/cppawk/include/cons.h
new file mode 100644
index 0000000..f120c0c
--- /dev/null
+++ b/share/cppawk/include/cons.h
@@ -0,0 +1,92 @@
+// cppawk: C preprocessor wrapper around awk
+// Copyright 2022 Kaz Kylheku <kaz@kylheku.com>
+//
+// BSD-2 License
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef __CPPAWK_CONS_H
+#define __CPPAWK_CONS_H
+
+#ifndef __CPPAWK_CONS_PRIV_H
+#include "cons-priv.h"
+#endif
+
+#define nil __nil
+#define prog(...) __prog(__VA_ARGS__)
+#define progn(...) __progn(__VA_ARGS__)
+#define or(...) __or(__VA_ARGS__)
+#define and(...) __and(__VA_ARGS__)
+#define push(item, list) __push(item, list)
+#define pop(list) __pop(list)
+#define dolist(item, list) __dolist(item, list)
+#define dolisti(item, index, list) __dolisti(item, index, list)
+#define doconses(iter, list) __doconses(iter, list)
+#define list_begin() __list_begin()
+#define list_add(stk, item) __list_add(stk, item)
+#define list_end(stk) __list_end(stk)
+#define list_end_atom(stk, atom) __list_end_atom(stk, atom)
+#define bags(...) __bags(__VA_ARGS__)
+#define bag(bag, expr) __bag(bag, expr)
+#define consp __consp
+#define atom __atom
+#define null __null
+#define endp __endp
+#define false __false
+#define true __true
+#define numberp __numberp
+#define stringp __stringp
+#define symbolp __symbolp
+#define box __box
+#define unbox __unbox
+#define box_str __box_str
+#define box_sym __box_sym
+#define cons __cons
+#define car __car
+#define cdr __cdr
+#define sexp __sexp
+#define reverse __reverse
+#define values __values
+#define keys __keys
+#define fields __fields
+#define set_fields __set_fields
+#define equal __equal
+#define equalize __equalize
+#define list __list
+#define li __li
+#define listar __listar
+#define append __append
+#define member __member
+#define position __position
+#define nth __nth
+#define nthcdr __nthcdr
+#define ldiff __ldiff
+#define last __last
+#define butlast __butlast
+#define iota __iota
+#define uniq __uniq
+#define uniqual __uniqual
+#define mapcar __mapcar
+#define mappend __mappend
+
+#endif
diff --git a/share/cppawk/include/field.h b/share/cppawk/include/field.h
new file mode 100644
index 0000000..a18000d
--- /dev/null
+++ b/share/cppawk/include/field.h
@@ -0,0 +1,88 @@
+// cppawk: C preprocessor wrapper around awk
+// Copyright 2022 Kaz Kylheku <kaz@kylheku.com>
+//
+// BSD-2 License
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef __CPPAWK_FIELD_H
+#define __CPPAWK_FIELD_H
+
+#ifndef __CPPAWK_BASE_H
+#include "base.h"
+#endif
+
+#ifndef __CPPAWK_NARG_PRIV_H
+#include "narg-priv.h"
+#endif
+
+function delf(__at, __count,
+ __i, __j)
+{
+ if (!__present(__count))
+ __count = 1
+
+ if (0 < __count && 1 <= __at && __at <= NF) {
+ __i = __at
+ __j = __at + __count
+
+ while (__j <= NF)
+ $(__i++) = $(__j++)
+
+ NF = __i - 1;
+ }
+}
+
+function __insf(__at, __count,
+ __i, __j)
+{
+ if (!__present(__count))
+ __count = 1
+
+ if (NF < __at)
+ NF = __at - 1
+
+ if (0 < __count && 1 <= __at) {
+ __i = NF + __count
+ __j = NF
+
+ NF = __i
+
+ while (__j >= __at)
+ $(__i--) = $(__j--)
+ return 1
+ }
+
+ return 0
+}
+
+#define __insf_first(arg, n, at) $(at + n - 1) = arg
+#define __insf_next(prev, arg, n, at) prev; $(at + n - 1) = arg
+
+#define insf(at, ...) { \
+ if (__insf(at, __narg(__VA_ARGS__))) { \
+ __variaexpand(__insf_first, __insf_next, at, __VA_ARGS__); \
+ } \
+}
+
+#endif
diff --git a/share/cppawk/include/fun-priv.h b/share/cppawk/include/fun-priv.h
new file mode 100644
index 0000000..0f92a44
--- /dev/null
+++ b/share/cppawk/include/fun-priv.h
@@ -0,0 +1,50 @@
+// cppawk: C preprocessor wrapper around awk
+// Copyright 2022 Kaz Kylheku <kaz@kylheku.com>
+//
+// BSD-2 License
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef __CPPAWK_FUN_PRIV_H
+#define __CPPAWK_FUN_PRIV_H
+
+#ifndef __CPPAWK_BASE_H
+#include "base.h"
+#endif
+
+#ifndef __CPPAWK_CONS_H
+#include "cons-priv.h"
+#endif
+
+#if !__have_indirect_functions
+#warning "<fun.h> requires an Awk with function indirection like newer GNU Awk"
+#endif
+
+#define __bind(fname, env) __cons(__xstr(fname), env)
+#define __fun_(fname) __xstr(fname)
+#define __call(fobj, ...) (__consp(fobj) \
+ ? __progn(__g(f) = __car(fobj), \
+ @__g(f)(__cdr(fobj), ## __VA_ARGS__)) \
+ : @fobj(__VA_ARGS__))
+
+#endif
diff --git a/share/cppawk/include/fun.h b/share/cppawk/include/fun.h
new file mode 100644
index 0000000..6600609
--- /dev/null
+++ b/share/cppawk/include/fun.h
@@ -0,0 +1,39 @@
+// cppawk: C preprocessor wrapper around awk
+// Copyright 2022 Kaz Kylheku <kaz@kylheku.com>
+//
+// BSD-2 License
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef __CPPAWK_FUN_H
+#define __CPPAWK_FUN_H
+
+#ifndef __CPPAWK_FUN_PRIV_H
+#include "fun-priv.h"
+#endif
+
+#define bind(fname, env) __bind(fname, env)
+#define fun(fname) __fun_(fname)
+#define call(...) __call(__VA_ARGS__)
+
+#endif
diff --git a/share/cppawk/include/iter-priv.h b/share/cppawk/include/iter-priv.h
new file mode 100644
index 0000000..946c874
--- /dev/null
+++ b/share/cppawk/include/iter-priv.h
@@ -0,0 +1,45 @@
+// cppawk: C preprocessor wrapper around awk
+// Copyright 2022 Kaz Kylheku <kaz@kylheku.com>
+//
+// BSD-2 License
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef __CPPAWK_ITER_PRIV_H
+#define __CPPAWK_ITER_PRIV_H
+
+#define __doarray(key, value, arr) \
+ for (key in arr) \
+ if ((value = arr[key]) || 1)
+
+#define __dostring(index, chr, str) \
+ __g(s) = str; \
+ __g(l) = length(__g(s)); \
+ for (index = 1; index <= __g(l); i++) \
+ if ((chr = substr(__g(s), index, 1)) || 1)
+
+#define __dofields(index, val) \
+ for (index = 1; index <= NF; index++) \
+ if ((val = $ index) || 1)
+
+#endif
diff --git a/share/cppawk/include/iter.h b/share/cppawk/include/iter.h
new file mode 100644
index 0000000..53bb43f
--- /dev/null
+++ b/share/cppawk/include/iter.h
@@ -0,0 +1,329 @@
+// cppawk: C preprocessor wrapper around awk
+// Copyright 2022 Kaz Kylheku <kaz@kylheku.com>
+//
+// BSD-2 License
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef __CPPAWK_ITER_H
+#define __CPPAWK_ITER_H
+
+#ifndef __CPPAWK_ITER_PRIV_H
+#include "iter-priv.h"
+#endif
+
+#ifndef __CPPAWK_BASE_H
+#include "base.h"
+#endif
+
+#ifndef __CPPAWK_NARG_PRIV_H
+#include "narg-priv.h"
+#endif
+
+#ifndef __CPPAWK_CONS_PRIV_H
+#include "cons-priv.h"
+#endif
+
+#define doarray(key, value, arr) __doarray(key, value, arr)
+#define dostring(index, chr, str) __dostring(index, chr, str)
+#define dofields(index, val) __dofields(index, val)
+
+#define loop(...) __loop_temp(__VA_ARGS__) \
+ for (__loop_init(__VA_ARGS__); \
+ (__loop_test(__VA_ARGS__) || \
+ __loop_fini(__VA_ARGS__)) && \
+ __loop_prep(__VA_ARGS__); \
+ __loop_step(__VA_ARGS__))
+
+#if __have_let
+#define __loop_temp(...) __let(__varexpand(__temp_first, __temp_next, \
+ __VA_ARGS__))
+#else
+#define __loop_temp(...)
+#endif
+
+#define __loop_init(...) __prog(__varexpand(__init_first, __init_next, \
+ __VA_ARGS__))
+#define __loop_test(...) __nd(__varexpand(__test_first, __test_next, \
+ __VA_ARGS__))
+#define __loop_prep(...) __prog(__varexpand(__prep_first, __prep_next, \
+ __VA_ARGS__))
+#define __loop_fini(...) __prog(__varexpand(__fini_first, __fini_next, \
+ __VA_ARGS__)) && 0
+#define __loop_step(...) __prog(__varexpand(__step_first, __step_next, \
+ __VA_ARGS__))
+
+#define __nd(...) __varexpand(__nd_first, __nd_next, __VA_ARGS__)
+#define __nd_first(x) (x)
+#define __nd_next(p, x) p && (x)
+
+#define loop_nest(...) __varexpand2(__cross_first, __cross_next, __VA_ARGS__)
+
+#define __cross_first(args) for (__init_ ## args; \
+ ((__test_ ## args) || \
+ (__fini_ ## args) && 0) && \
+ __prep_ ## args; \
+ __step_ ## args)
+#define __cross_next(prev, args) prev __cross_first(args)
+
+#define __temp_first(args) __temp_ ## args
+#define __temp_next(prev, args) prev __temp_ ## args
+
+#define __init_first(args) __init_ ## args
+#define __init_next(prev, args) prev, __init_ ## args
+
+#define __test_first(args) __test_ ## args
+#define __test_next(prev, args) prev, __test_ ## args
+
+#define __prep_first(args) __prep_ ## args
+#define __prep_next(prev, args) prev, __prep_ ## args
+
+#define __fini_first(args) __fini_ ## args
+#define __fini_next(prev, args) prev, __fini_ ## args
+
+#define __step_first(args) __step_ ## args
+#define __step_next(prev, args) prev, __step_ ## args
+
+#define __str_s __g(ch)
+#define __str_len __g(idx)
+#define __temp_str(idx, ch, str) __str_s, __str_len,
+#define __init_str(idx, ch, str) __str_s = (str), __str_len = length(__str_s), idx = 1
+#define __test_str(idx, ch, str) idx <= __str_len
+#define __prep_str(idx, ch, str) ch = substr(__str_s, idx, 1)
+#define __fini_str(idx, ch, str) 1
+#define __step_str(idx, ch, str) idx++
+
+#define __temp_range(idx, from, to)
+#define __init_range(idx, from, to) idx = (from)
+#define __test_range(idx, from, to) idx <= (to)
+#define __prep_range(idx, from, to) 1
+#define __fini_range(idx, from, to) 1
+#define __step_range(idx, from, to) idx++
+
+#define __temp_range_step(idx, from, to, step)
+#define __init_range_step(idx, from, to, step) idx = (from)
+#define __test_range_step(idx, from, to, step) idx <= (to)
+#define __prep_range_step(idx, from, to, step) 1
+#define __fini_range_step(idx, from, to, step) 1
+#define __step_range_step(idx, from, to, step) idx += (step)
+
+#define __temp_from(idx, from)
+#define __init_from(idx, from) idx = (from)
+#define __test_from(idx, from) 1
+#define __prep_from(idx, from) 1
+#define __fini_from(idx, from) 1
+#define __step_from(idx, from) idx++
+
+#define __temp_from_step(idx, from, step)
+#define __init_from_step(idx, from, step) idx = (from)
+#define __test_from_step(idx, from, step) 1
+#define __prep_from_step(idx, from, step) 1
+#define __fini_from_step(idx, from, step) 1
+#define __step_from_step(idx, from, step) idx += (step)
+
+#define __temp_first_then(var, first, then)
+#define __init_first_then(var, first, then) (var = (first))
+#define __test_first_then(var, first, then) 1
+#define __prep_first_then(var, first, then) 1
+#define __fini_first_then(var, first, then) 1
+#define __step_first_then(var, first, then) (var = (then))
+
+#define for_var(var, expr) first_then(var, expr, expr)
+
+#define __temp_list(iter, var, list)
+#define __init_list(iter, var, list) iter = (list)
+#define __test_list(iter, var, list) !__endp(iter)
+#define __prep_list(iter, var, list) var = __car(iter)
+#define __fini_list(iter, var, list) 0
+#define __step_list(iter, var, list) iter = __cdr(iter)
+#define __temp___list(iter, var, list)
+#define __init___list(iter, var, list) iter = (list)
+#define __test___list(iter, var, list) !__endp(iter)
+#define __prep___list(iter, var, list) var = __car(iter)
+#define __fini___list(iter, var, list) 0
+#define __step___list(iter, var, list) iter = __cdr(iter)
+
+#define __temp_fields(var) __g(var),
+#define __init_fields(var) __g(var) = 1
+#define __test_fields(var) __g(var) <= NF
+#define __prep_fields(var) var = $ __g(var)
+#define __fini_fields(var) 1
+#define __step_fields(var) __g(var)++
+#define __temp___fields(var) __g(var),
+#define __init___fields(var) __g(var) = 1
+#define __test___fields(var) __g(var) <= NF
+#define __prep___fields(var) var = $ __g(var)
+#define __fini___fields(var) 1
+#define __step___fields(var) __g(var)++
+
+
+#define __temp_keys(key, array) __g(key),
+#define __init_keys(key, array) __g(key) = __keys(array)
+#define __test_keys(key, array) !__endp(__g(key))
+#define __prep_keys(key, array) key = __car(__g(key))
+#define __fini_keys(key, array) 1
+#define __step_keys(key, array) __g(key) = __cdr(__g(key))
+#define __temp___keys(key, array) __g(key),
+#define __init___keys(key, array) __g(key) = __keys(array)
+#define __test___keys(key, array) !__endp(__g(key))
+#define __prep___keys(key, array) key = __car(__g(key))
+#define __fini___keys(key, array) 1
+#define __step___keys(key, array) __g(key) = __cdr(__g(key))
+
+#define __temp_collect(var, expr)
+#define __init_collect(var, expr) var = __list_begin()
+#define __test_collect(var, expr) 1
+#define __prep_collect(var, expr) var = __list_add(var, expr)
+#define __fini_collect(var, expr) var = __list_end(var)
+#define __step_collect(var, expr) 1
+
+#define __temp_collect_plus(var, expr)
+#define __init_collect_plus(var, expr) var = __list_begin()
+#define __test_collect_plus(var, expr) 1
+#define __prep_collect_plus(var, expr) var = __list_add(var, expr)
+#define __fini_collect_plus(var, expr) var = __list_end(__list_add(var, expr))
+#define __step_collect_plus(var, expr) 1
+
+#define __temp_summing(var, expr)
+#define __init_summing(var, expr) var = 0
+#define __test_summing(var, expr) 1
+#define __prep_summing(var, expr) var += (expr)
+#define __fini_summing(var, expr) 1
+#define __step_summing(var, expr) 1
+
+function __loop_max(a, b)
+{
+ return a > b ? a : b
+}
+
+#define __temp_maximizing(var, expr)
+#define __init_maximizing(var, expr) var = nil
+#define __test_maximizing(var, expr) 1
+#define __prep_maximizing(var, expr) var = (__null(var) \
+ ? expr \
+ : __loop_max(var, expr))
+#define __fini_maximizing(var, expr) 1
+#define __step_maximizing(var, expr) 1
+
+function __loop_min(a, b)
+{
+ return a > b ? b : a
+}
+
+#define __temp_minimizing(var, expr)
+#define __init_minimizing(var, expr) var = nil
+#define __test_minimizing(var, expr) 1
+#define __prep_minimizing(var, expr) var = (__null(var) \
+ ? expr \
+ : __loop_min(var, expr))
+#define __fini_minimizing(var, expr) 1
+#define __step_minimizing(var, expr) 1
+
+function __loop_argmax(a, arga, b, argb)
+{
+ return a > b ? arga : argb;
+}
+
+#define __ami(v) __gx(v, _max)
+#define __amx(v) __gx(v, _min)
+#define __amo(v) __gx(v, _old)
+
+#define __temp_argmax(am, arg, expr) __amx(am), __amo(am),
+#define __init_argmax(am, arg, expr) (__amx(am) = __nil) || (am = __nil)
+#define __test_argmax(am, arg, expr) 1
+#define __prep_argmax(am, arg, expr) ((__amo(am) = __amx(am)) || 1) && \
+ ((__amx(am) = \
+ (__null(__amx(am)) \
+ ? expr \
+ : __loop_max(__amx(am), \
+ expr))) || 1) && \
+ ((__amo(am) != __amx(am)) ? am = arg : 1)
+#define __fini_argmax(am, arg, expr) 1
+#define __step_argmax(am, arg, expr) 1
+
+function __loop_argmin(a, arga, b, argb)
+{
+ return a < b ? arga : argb;
+}
+
+#define __temp_argmin(am, arg, expr) __ami(am), __amo(am),
+#define __init_argmin(am, arg, expr) (__ami(am) = __nil) || (am = __nil)
+#define __test_argmin(am, arg, expr) 1
+#define __prep_argmin(am, arg, expr) ((__amo(am) = __ami(am)) || 1) && \
+ ((__ami(am) = \
+ (__null(__ami(am)) \
+ ? expr \
+ : __loop_min(__ami(am), \
+ expr))) || 1) && \
+ ((__amo(am) != __ami(am)) ? am = arg : 1)
+#define __fini_argmin(am, arg, expr) 1
+#define __step_argmin(am, arg, expr) 1
+
+#define __temp_counting(var, expr)
+#define __init_counting(var, expr) var = 0
+#define __test_counting(var, expr) 1
+#define __prep_counting(var, expr) (expr) ? var++ : 1
+#define __fini_counting(var, expr) 1
+#define __step_counting(var, expr) 1
+
+#define __temp_while(expr)
+#define __init_while(expr) 1
+#define __test_while(expr) expr
+#define __prep_while(expr) 1
+#define __fini_while(expr) 1
+#define __step_while(expr) 1
+
+#define __temp_until(expr)
+#define __init_until(expr) 1
+#define __test_until(expr) !(expr)
+#define __prep_until(expr) 1
+#define __fini_until(expr) 1
+#define __step_until(expr) 1
+
+#define __temp_parallel(...)
+#define __init_parallel(...) __prog(__varexpand3(__init_first, __init_next, \
+ __VA_ARGS__))
+#define __test_parallel(...) __nd(__varexpand3(__test_first, __test_next, \
+ __VA_ARGS__))
+#define __prep_parallel(...) (__nd(__varexpand3(__prep_first, __prep_next, \
+ __VA_ARGS__)) || 1)
+#define __fini_parallel(...) (__nd(__varexpand3(__fini_first, __fini_next, \
+ __VA_ARGS__)) && 0)
+#define __step_parallel(...) __prog(__varexpand3(__step_first, __step_next, \
+ __VA_ARGS__))
+
+#define __temp_if(test, clause)
+#define __init_if(test, clause) __init_ ## clause
+#define __test_if(test, clause) !(test) || __test_ ## clause
+#define __prep_if(test, clause) (test) && __prep_ ## clause
+#define __fini_if(test, clause) __fini_ ## clause
+#define __step_if(test, clause) (test) && __step_ ## clause
+
+#define __temp_records(file) __g(stream)
+#define __init_records(file) __g(stream) = file
+#define __test_records(file) (getline < __g(stream)) > 0
+#define __prep_records(file) 1
+#define __fini_records(file) __g(stream) != "-" ? close(__g(stream)) : 1
+#define __step_records(file) 1
+
+#endif
diff --git a/share/cppawk/include/narg-priv.h b/share/cppawk/include/narg-priv.h
new file mode 100644
index 0000000..bee5300
--- /dev/null
+++ b/share/cppawk/include/narg-priv.h
@@ -0,0 +1,367 @@
+// cppawk: C preprocessor wrapper around awk
+// Copyright 2022 Kaz Kylheku <kaz@kylheku.com>
+//
+// BSD-2 License
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef __CPPAWK_NARG_PRIV_H
+#define __CPPAWK_NARG_PRIV_H
+
+#ifndef __CPPAWK_BASE_H
+#include "base.h"
+#endif
+
+#define __bad _[<"too many args"<]
+
+#define __narg_50(B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, B12, B13, \
+ B14, B15, B16, N33, N32, N31, N30, N29, N28, N27, N26, N25, \
+ N24, N23, N22, N21, N20, N19, N18, N17, N16, N15, N14, N13, \
+ N12, N11, N10, N9, N8, N7, N6, N5, N4, N3, N2, N1, N, ...) N
+
+#define __xnarg_50(...) __narg_50(__VA_ARGS__)
+
+// The __bad entries create a 16 position red zone. We effectively have
+// space for 48 arguments, but if there are 33-48 arguments, we do not
+// return an integer count, but rather bad syntax. Beyond 48 arguments, __narg
+// starts to misbehave: it starts reproducing its 49th argument as its
+// expansion. Without the 16 position bad syntax red zone, there would be
+// and abrupt change: the macro would be good up to 32 arguments, returning the
+// 1-32 ragument count, but the 33rd argument were added, the macro would
+// misbehave badly, returning the 33rd argument, causnig a potentially
+// hard-to-find bug.
+#define __narg(...) __xnarg_50(__dummy, ## __VA_ARGS__, __bad, __bad, __bad, \
+ __bad, __bad, __bad, __bad, __bad, __bad, \
+ __bad, __bad, __bad, __bad, __bad, __bad, \
+ __bad, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, \
+ 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, \
+ 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
+
+#define __repn_1(mac1, mac2, a1) \
+ mac1(a1)
+#define __repn_2(mac1, mac2, a1, a2) \
+ mac2(mac1(a1), a2)
+#define __repn_3(mac1, mac2, a1, a2, a3) \
+ mac2(mac2(mac1(a1), a2), a3)
+#define __repn_4(mac1, mac2, a1, a2, a3, a4) \
+ mac2(mac2(mac2(mac1(a1), a2), a3), a4)
+#define __repn_5(mac1, mac2, a1, a2, a3, a4, a5) \
+ mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5)
+#define __repn_6(mac1, mac2, a1, a2, a3, a4, a5, a6) \
+ mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6)
+#define __repn_7(mac1, mac2, a1, a2, a3, a4, a5, a6, a7) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7)
+#define __repn_8(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8)
+#define __repn_9(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9)
+#define __repn_10(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10)
+#define __repn_11(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11)
+#define __repn_12(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12)
+#define __repn_13(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13)
+#define __repn_14(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14)
+#define __repn_15(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15)
+#define __repn_16(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16)
+#define __repn_17(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17)
+#define __repn_18(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18)
+#define __repn_19(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19)
+#define __repn_20(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20)
+#define __repn_21(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21)
+#define __repn_22(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22)
+#define __repn_23(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22), a23)
+#define __repn_24(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22), a23), a24)
+#define __repn_25(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22), a23), a24), a25)
+#define __repn_26(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25, a26) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22), a23), a24), a25), a26)
+#define __repn_27(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25, a26, a27) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22), a23), a24), a25), a26), a27)
+#define __repn_28(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25, a26, a27, a28) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22), a23), a24), a25), a26), a27), a28)
+#define __repn_29(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25, a26, a27, a28, a29) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22), a23), a24), a25), a26), a27), a28), a29)
+#define __repn_30(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25, a26, a27, a28, a29, a30) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22), a23), a24), a25), a26), a27), a28), a29), a30)
+#define __repn_31(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25, a26, a27, a28, a29, a30, a31) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22), a23), a24), a25), a26), a27), a28), a29), a30), a31)
+#define __repn_32(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25, a26, a27, a28, a29, a30, a31, a32) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1), a2), a3), a4), a5), a6), a7), a8), a9), a10), a11), a12), a13), a14), a15), a16), a17), a18), a19), a20), a21), a22), a23), a24), a25), a26), a27), a28), a29), a30), a31), a32)
+
+#define __repi_1(mac1, mac2, a1) \
+ mac1(a1, 1)
+#define __repi_2(mac1, mac2, a1, a2) \
+ mac2(mac1(a1, 1), a2, 2)
+#define __repi_3(mac1, mac2, a1, a2, a3) \
+ mac2(mac2(mac1(a1, 1), a2, 2), a3, 3)
+#define __repi_4(mac1, mac2, a1, a2, a3, a4) \
+ mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4)
+#define __repi_5(mac1, mac2, a1, a2, a3, a4, a5) \
+ mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5)
+#define __repi_6(mac1, mac2, a1, a2, a3, a4, a5, a6) \
+ mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6)
+#define __repi_7(mac1, mac2, a1, a2, a3, a4, a5, a6, a7) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7)
+#define __repi_8(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8)
+#define __repi_9(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9)
+#define __repi_10(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10)
+#define __repi_11(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11)
+#define __repi_12(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11), a12, 12)
+#define __repi_13(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11), a12, 12), a13, 13)
+#define __repi_14(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11), a12, 12), a13, 13), a14, 14)
+#define __repi_15(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11), a12, 12), a13, 13), a14, 14), a15, 15)
+#define __repi_16(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11), a12, 12), a13, 13), a14, 14), a15, 15), a16, 16)
+#define __repi_17(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11), a12, 12), a13, 13), a14, 14), a15, 15), a16, 16), a17, 17)
+#define __repi_18(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11), a12, 12), a13, 13), a14, 14), a15, 15), a16, 16), a17, 17), a18, 18)
+#define __repi_19(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11), a12, 12), a13, 13), a14, 14), a15, 15), a16, 16), a17, 17), a18, 18), a19, 19)
+#define __repi_20(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11), a12, 12), a13, 13), a14, 14), a15, 15), a16, 16), a17, 17), a18, 18), a19, 19), a20, 20)
+#define __repi_21(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11), a12, 12), a13, 13), a14, 14), a15, 15), a16, 16), a17, 17), a18, 18), a19, 19), a20, 20), a21, 21)
+#define __repi_22(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11), a12, 12), a13, 13), a14, 14), a15, 15), a16, 16), a17, 17), a18, 18), a19, 19), a20, 20), a21, 21), a22, 22)
+#define __repi_23(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11), a12, 12), a13, 13), a14, 14), a15, 15), a16, 16), a17, 17), a18, 18), a19, 19), a20, 20), a21, 21), a22, 22), a23, 23)
+#define __repi_24(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11), a12, 12), a13, 13), a14, 14), a15, 15), a16, 16), a17, 17), a18, 18), a19, 19), a20, 20), a21, 21), a22, 22), a23, 23), a24, 24)
+#define __repi_25(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11), a12, 12), a13, 13), a14, 14), a15, 15), a16, 16), a17, 17), a18, 18), a19, 19), a20, 20), a21, 21), a22, 22), a23, 23), a24, 24), a25, 25)
+#define __repi_26(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25, a26) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11), a12, 12), a13, 13), a14, 14), a15, 15), a16, 16), a17, 17), a18, 18), a19, 19), a20, 20), a21, 21), a22, 22), a23, 23), a24, 24), a25, 25), a26, 26)
+#define __repi_27(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25, a26, a27) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11), a12, 12), a13, 13), a14, 14), a15, 15), a16, 16), a17, 17), a18, 18), a19, 19), a20, 20), a21, 21), a22, 22), a23, 23), a24, 24), a25, 25), a26, 26), a27, 27)
+#define __repi_28(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25, a26, a27, a28) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11), a12, 12), a13, 13), a14, 14), a15, 15), a16, 16), a17, 17), a18, 18), a19, 19), a20, 20), a21, 21), a22, 22), a23, 23), a24, 24), a25, 25), a26, 26), a27, 27), a28, 28)
+#define __repi_29(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25, a26, a27, a28, a29) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11), a12, 12), a13, 13), a14, 14), a15, 15), a16, 16), a17, 17), a18, 18), a19, 19), a20, 20), a21, 21), a22, 22), a23, 23), a24, 24), a25, 25), a26, 26), a27, 27), a28, 28), a29, 29)
+#define __repi_30(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25, a26, a27, a28, a29, a30) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11), a12, 12), a13, 13), a14, 14), a15, 15), a16, 16), a17, 17), a18, 18), a19, 19), a20, 20), a21, 21), a22, 22), a23, 23), a24, 24), a25, 25), a26, 26), a27, 27), a28, 28), a29, 29), a30, 30)
+#define __repi_31(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25, a26, a27, a28, a29, a30, a31) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11), a12, 12), a13, 13), a14, 14), a15, 15), a16, 16), a17, 17), a18, 18), a19, 19), a20, 20), a21, 21), a22, 22), a23, 23), a24, 24), a25, 25), a26, 26), a27, 27), a28, 28), a29, 29), a30, 30), a31, 31)
+#define __repi_32(mac1, mac2, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25, a26, a27, a28, a29, a30, a31, a32) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1), a2, 2), a3, 3), a4, 4), a5, 5), a6, 6), a7, 7), a8, 8), a9, 9), a10, 10), a11, 11), a12, 12), a13, 13), a14, 14), a15, 15), a16, 16), a17, 17), a18, 18), a19, 19), a20, 20), a21, 21), a22, 22), a23, 23), a24, 24), a25, 25), a26, 26), a27, 27), a28, 28), a29, 29), a30, 30), a31, 31), a32, 32)
+
+#define __repia_1(mac1, mac2, a, a1) \
+ mac1(a1, 1, a)
+#define __repia_2(mac1, mac2, a, a1, a2) \
+ mac2(mac1(a1, 1, a), a2, 2, a)
+#define __repia_3(mac1, mac2, a, a1, a2, a3) \
+ mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a)
+#define __repia_4(mac1, mac2, a, a1, a2, a3, a4) \
+ mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a)
+#define __repia_5(mac1, mac2, a, a1, a2, a3, a4, a5) \
+ mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a)
+#define __repia_6(mac1, mac2, a, a1, a2, a3, a4, a5, a6) \
+ mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a)
+#define __repia_7(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a)
+#define __repia_8(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a)
+#define __repia_9(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a)
+#define __repia_10(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a)
+#define __repia_11(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a)
+#define __repia_12(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a), a12, 12, a)
+#define __repia_13(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a), a12, 12, a), a13, 13, a)
+#define __repia_14(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a), a12, 12, a), a13, 13, a), a14, 14, a)
+#define __repia_15(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a), a12, 12, a), a13, 13, a), a14, 14, a), a15, 15, a)
+#define __repia_16(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a), a12, 12, a), a13, 13, a), a14, 14, a), a15, 15, a), a16, 16, a)
+#define __repia_17(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a), a12, 12, a), a13, 13, a), a14, 14, a), a15, 15, a), a16, 16, a), a17, 17, a)
+#define __repia_18(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a), a12, 12, a), a13, 13, a), a14, 14, a), a15, 15, a), a16, 16, a), a17, 17, a), a18, 18, a)
+#define __repia_19(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a), a12, 12, a), a13, 13, a), a14, 14, a), a15, 15, a), a16, 16, a), a17, 17, a), a18, 18, a), a19, 19, a)
+#define __repia_20(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a), a12, 12, a), a13, 13, a), a14, 14, a), a15, 15, a), a16, 16, a), a17, 17, a), a18, 18, a), a19, 19, a), a20, 20, a)
+#define __repia_21(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a), a12, 12, a), a13, 13, a), a14, 14, a), a15, 15, a), a16, 16, a), a17, 17, a), a18, 18, a), a19, 19, a), a20, 20, a), a21, 21, a)
+#define __repia_22(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a), a12, 12, a), a13, 13, a), a14, 14, a), a15, 15, a), a16, 16, a), a17, 17, a), a18, 18, a), a19, 19, a), a20, 20, a), a21, 21, a), a22, 22, a)
+#define __repia_23(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a), a12, 12, a), a13, 13, a), a14, 14, a), a15, 15, a), a16, 16, a), a17, 17, a), a18, 18, a), a19, 19, a), a20, 20, a), a21, 21, a), a22, 22, a), a23, 23, a)
+#define __repia_24(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a), a12, 12, a), a13, 13, a), a14, 14, a), a15, 15, a), a16, 16, a), a17, 17, a), a18, 18, a), a19, 19, a), a20, 20, a), a21, 21, a), a22, 22, a), a23, 23, a), a24, 24, a)
+#define __repia_25(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a), a12, 12, a), a13, 13, a), a14, 14, a), a15, 15, a), a16, 16, a), a17, 17, a), a18, 18, a), a19, 19, a), a20, 20, a), a21, 21, a), a22, 22, a), a23, 23, a), a24, 24, a), a25, 25, a)
+#define __repia_26(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25, a26) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a), a12, 12, a), a13, 13, a), a14, 14, a), a15, 15, a), a16, 16, a), a17, 17, a), a18, 18, a), a19, 19, a), a20, 20, a), a21, 21, a), a22, 22, a), a23, 23, a), a24, 24, a), a25, 25, a), a26, 26, a)
+#define __repia_27(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25, a26, a27) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a), a12, 12, a), a13, 13, a), a14, 14, a), a15, 15, a), a16, 16, a), a17, 17, a), a18, 18, a), a19, 19, a), a20, 20, a), a21, 21, a), a22, 22, a), a23, 23, a), a24, 24, a), a25, 25, a), a26, 26, a), a27, 27, a)
+#define __repia_28(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25, a26, a27, a28) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a), a12, 12, a), a13, 13, a), a14, 14, a), a15, 15, a), a16, 16, a), a17, 17, a), a18, 18, a), a19, 19, a), a20, 20, a), a21, 21, a), a22, 22, a), a23, 23, a), a24, 24, a), a25, 25, a), a26, 26, a), a27, 27, a), a28, 28, a)
+#define __repia_29(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25, a26, a27, a28, a29) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a), a12, 12, a), a13, 13, a), a14, 14, a), a15, 15, a), a16, 16, a), a17, 17, a), a18, 18, a), a19, 19, a), a20, 20, a), a21, 21, a), a22, 22, a), a23, 23, a), a24, 24, a), a25, 25, a), a26, 26, a), a27, 27, a), a28, 28, a), a29, 29, a)
+#define __repia_30(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25, a26, a27, a28, a29, a30) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a), a12, 12, a), a13, 13, a), a14, 14, a), a15, 15, a), a16, 16, a), a17, 17, a), a18, 18, a), a19, 19, a), a20, 20, a), a21, 21, a), a22, 22, a), a23, 23, a), a24, 24, a), a25, 25, a), a26, 26, a), a27, 27, a), a28, 28, a), a29, 29, a), a30, 30, a)
+#define __repia_31(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25, a26, a27, a28, a29, a30, a31) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a), a12, 12, a), a13, 13, a), a14, 14, a), a15, 15, a), a16, 16, a), a17, 17, a), a18, 18, a), a19, 19, a), a20, 20, a), a21, 21, a), a22, 22, a), a23, 23, a), a24, 24, a), a25, 25, a), a26, 26, a), a27, 27, a), a28, 28, a), a29, 29, a), a30, 30, a), a31, 31, a)
+#define __repia_32(mac1, mac2, a, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, \
+ a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, \
+ a24, a25, a26, a27, a28, a29, a30, a31, a32) \
+ mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac2(mac1(a1, 1, a), a2, 2, a), a3, 3, a), a4, 4, a), a5, 5, a), a6, 6, a), a7, 7, a), a8, 8, a), a9, 9, a), a10, 10, a), a11, 11, a), a12, 12, a), a13, 13, a), a14, 14, a), a15, 15, a), a16, 16, a), a17, 17, a), a18, 18, a), a19, 19, a), a20, 20, a), a21, 21, a), a22, 22, a), a23, 23, a), a24, 24, a), a25, 25, a), a26, 26, a), a27, 27, a), a28, 28, a), a29, 29, a), a30, 30, a), a31, 31, a), a32, 32, a)
+
+#define __varexpand(mac1, mac2, ...) \
+ __xcat(__repn_, __narg(__VA_ARGS__)) (mac1, mac2, __VA_ARGS__)
+
+#define __varexpand2(mac1, mac2, ...) \
+ __xcat(__repn_, __narg(__VA_ARGS__)) (mac1, mac2, __VA_ARGS__)
+
+#define __varexpand3(mac1, mac2, ...) \
+ __xcat(__repn_, __narg(__VA_ARGS__)) (mac1, mac2, __VA_ARGS__)
+
+#define __rev_first(arg) arg
+#define __rev_next(args, arg) arg, args
+#define __revarg(...) __varexpand(__rev_first, __rev_next, __VA_ARGS__)
+
+#define __va_args(...) __VA_ARGS__
+#define __splice(args) __va_args args
+
+#define __variexpand(mac1, mac2, ...) \
+ __xcat(__repi_, __narg(__VA_ARGS__)) (mac1, mac2, __VA_ARGS__)
+
+#define __variaexpand(mac1, mac2, a, ...) \
+ __xcat(__repia_, __narg(__VA_ARGS__)) (mac1, mac2, a, __VA_ARGS__)
+
+#endif
diff --git a/share/cppawk/include/narg.h b/share/cppawk/include/narg.h
new file mode 100644
index 0000000..b757f41
--- /dev/null
+++ b/share/cppawk/include/narg.h
@@ -0,0 +1,44 @@
+// cppawk: C preprocessor wrapper around awk
+// Copyright 2022 Kaz Kylheku <kaz@kylheku.com>
+//
+// BSD-2 License
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef CPPAWK_NARG_H
+#define CPPAWK_NARG_H
+
+#ifndef __CPPAWK_NARG_PRIV_H
+#include "narg-priv.h"
+#endif
+
+#define narg(...) __narg(__VA_ARGS__)
+#define varexpand(first, rest, ...) __varexpand(first, rest, __VA_ARGS__)
+#define variexpand(first, rest, ...) __variexpand(first, rest, __VA_ARGS__)
+#define variaexpand(first, rest, \
+ arg, ...) __variaexpand(first, rest, arg, \
+ __VA_ARGS__)
+#define revarg(...) __revarg(__VA_ARGS__)
+#define splice(args) __splice(args)
+
+#endif
diff --git a/share/cppawk/include/varg-priv.h b/share/cppawk/include/varg-priv.h
new file mode 100644
index 0000000..d71b500
--- /dev/null
+++ b/share/cppawk/include/varg-priv.h
@@ -0,0 +1,392 @@
+// cppawk: C preprocessor wrapper around awk
+// Copyright 2022 Kaz Kylheku <kaz@kylheku.com>
+//
+// BSD-2 License
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef __CPPAWK_VARG_PRIV_H
+#define __CPPAWK_VARG_PRIV_H
+
+#ifndef __CPPAWK_BASE_H
+#include "base.h"
+#endif
+
+#ifndef __CPPAWK_CASE_PRIV_H
+#include "case-priv.h"
+#endif
+
+#define __rest \
+ __r1, __r2, __r3, __r4, __r5, __r6, __r7, __r8, __r9, __r10, __r11, \
+ __r12, __r13, __r14, __r15, __r16, __r17, __r18, __r19, __r20, __r21, \
+ __r22, __r23, __r24, __r25, __r26, __r27, __r28, __r29, __r30, __r31, __r32
+
+#define __varg_count(name, check, count) \
+ if (__present(check)) \
+ __error(name ": too many arguments"); \
+ count = 0; \
+ if (__present(__r16)) { \
+ if (__present(__r24)) { \
+ if (__present(__r28)) { \
+ if (__present(__r30)) { \
+ if (__present(__r31)) { \
+ if (__present(__r32)) \
+ count = 32; \
+ else \
+ count = 31; \
+ } else { \
+ count = 30; \
+ } \
+ } else { /* !__present(__r30) */ \
+ if (__present(__r29)) \
+ count = 29; \
+ else \
+ count = 28; \
+ } \
+ } else { /* !__present(__r28) */ \
+ if (__present(__r26)) { \
+ if (__present(__r27)) \
+ count = 27; \
+ else \
+ count = 26; \
+ } else { /* !__present(__r26) */ \
+ if (__present(__r25)) \
+ count = 25; \
+ else \
+ count = 24; \
+ } \
+ } \
+ } else { /* !__present(__r24) */ \
+ if (__present(__r20)) { \
+ if (__present(__r22)) { \
+ if (__present(__r23)) \
+ count = 23; \
+ else \
+ count = 22; \
+ } else { /* !__present(__r22) */ \
+ if (__present(__r21)) \
+ count = 21; \
+ else \
+ count = 20; \
+ } \
+ } else { /* !__present(__r20) */ \
+ if (__present(__r18)) { \
+ if (__present(__r19)) \
+ count = 19; \
+ else \
+ count = 18; \
+ } else { /* !__present(__r18) */ \
+ if (__present(__r17)) \
+ count = 17; \
+ else \
+ count = 16; \
+ } \
+ } \
+ } \
+ } else { /*!__present(__r16) */ \
+ if (__present(__r8)) { \
+ if (__present(__r12)) { \
+ if (__present(__r14)) { \
+ if (__present(__r15)) { \
+ count = 15; \
+ } else { \
+ count = 14; \
+ } \
+ } else { /* !__present(__r14) */ \
+ if (__present(__r13)) \
+ count = 13; \
+ else \
+ count = 12; \
+ } \
+ } else { /* !__present(__r12) */ \
+ if (__present(__r10)) { \
+ if (__present(__r11)) \
+ count = 11; \
+ else \
+ count = 10; \
+ } else { /* !__present(__r10) */ \
+ if (__present(__r9)) \
+ count = 9; \
+ else \
+ count = 8; \
+ } \
+ } \
+ } else { /* !__present(__r8) */ \
+ if (__present(__r4)) { \
+ if (__present(__r6)) { \
+ if (__present(__r7)) \
+ count = 7; \
+ else \
+ count = 6; \
+ } else { /* !__present(__r6) */ \
+ if (__present(__r5)) \
+ count = 5; \
+ else \
+ count = 4; \
+ } \
+ } else { /* !__present(__r4) */ \
+ if (__present(__r2)) { \
+ if (__present(__r3)) \
+ count = 3; \
+ else \
+ count = 2; \
+ } else { /* !__present(__r2) */ \
+ if (__present(__r1)) \
+ count = 1; \
+ } \
+ } \
+ } \
+ }
+
+#define __varg_list(name, check, count, out) \
+ __varg_count(name, check, count); \
+ out = __nil; \
+ __case (count) { \
+ __of (32) \
+ out = __cons(__r32, out); \
+ __cfall; \
+ __of (31) \
+ out = __cons(__r31, out); \
+ __cfall; \
+ __of (30) \
+ out = __cons(__r30, out); \
+ __cfall; \
+ __of (29) \
+ out = __cons(__r29, out); \
+ __cfall; \
+ __of (28) \
+ out = __cons(__r28, out); \
+ __cfall; \
+ __of (27) \
+ out = __cons(__r27, out); \
+ __cfall; \
+ __of (26) \
+ out = __cons(__r26, out); \
+ __cfall; \
+ __of (25) \
+ out = __cons(__r25, out); \
+ __cfall; \
+ __of (24) \
+ out = __cons(__r24, out); \
+ __cfall; \
+ __of (23) \
+ out = __cons(__r23, out); \
+ __cfall; \
+ __of (22) \
+ out = __cons(__r22, out); \
+ __cfall; \
+ __of (21) \
+ out = __cons(__r21, out); \
+ __cfall; \
+ __of (20) \
+ out = __cons(__r20, out); \
+ __cfall; \
+ __of (19) \
+ out = __cons(__r19, out); \
+ __cfall; \
+ __of (18) \
+ out = __cons(__r18, out); \
+ __cfall; \
+ __of (17) \
+ out = __cons(__r17, out); \
+ __cfall; \
+ __of (16) \
+ out = __cons(__r16, out); \
+ __cfall; \
+ __of (15) \
+ out = __cons(__r15, out); \
+ __cfall; \
+ __of (14) \
+ out = __cons(__r14, out); \
+ __cfall; \
+ __of (13) \
+ out = __cons(__r13, out); \
+ __cfall; \
+ __of (12) \
+ out = __cons(__r12, out); \
+ __cfall; \
+ __of (11) \
+ out = __cons(__r11, out); \
+ __cfall; \
+ __of (10) \
+ out = __cons(__r10, out); \
+ __cfall; \
+ __of (9) \
+ out = __cons(__r9, out); \
+ __cfall; \
+ __of (8) \
+ out = __cons(__r8, out); \
+ __cfall; \
+ __of (7) \
+ out = __cons(__r7, out); \
+ __cfall; \
+ __of (6) \
+ out = __cons(__r6, out); \
+ __cfall; \
+ __of (5) \
+ out = __cons(__r5, out); \
+ __cfall; \
+ __of (4) \
+ out = __cons(__r4, out); \
+ __cfall; \
+ __of (3) \
+ out = __cons(__r3, out); \
+ __cfall; \
+ __of (2) \
+ out = __cons(__r2, out); \
+ __cfall; \
+ __of (1) \
+ out = __cons(__r1, out); \
+ __cfall; \
+ }
+
+#define __varg_array(name, check, count, out) \
+ __varg_count(name, check, count); \
+ delete out; \
+ __case (count) { \
+ __of (32) \
+ out[32] = __r32; \
+ __cfall; \
+ __of (31) \
+ out[31] = __r31; \
+ __cfall; \
+ __of (30) \
+ out[30] = __r30; \
+ __cfall; \
+ __of (29) \
+ out[29] = __r29; \
+ __cfall; \
+ __of (28) \
+ out[28] = __r28; \
+ __cfall; \
+ __of (27) \
+ out[27] = __r27; \
+ __cfall; \
+ __of (26) \
+ out[26] = __r26; \
+ __cfall; \
+ __of (25) \
+ out[25] = __r25; \
+ __cfall; \
+ __of (24) \
+ out[24] = __r24; \
+ __cfall; \
+ __of (23) \
+ out[23] = __r23; \
+ __cfall; \
+ __of (22) \
+ out[22] = __r22; \
+ __cfall; \
+ __of (21) \
+ out[21] = __r21; \
+ __cfall; \
+ __of (20) \
+ out[20] = __r20; \
+ __cfall; \
+ __of (19) \
+ out[19] = __r19; \
+ __cfall; \
+ __of (18) \
+ out[18] = __r18; \
+ __cfall; \
+ __of (17) \
+ out[17] = __r17; \
+ __cfall; \
+ __of (16) \
+ out[16] = __r16; \
+ __cfall; \
+ __of (15) \
+ out[15] = __r15; \
+ __cfall; \
+ __of (14) \
+ out[14] = __r14; \
+ __cfall; \
+ __of (13) \
+ out[13] = __r13; \
+ __cfall; \
+ __of (12) \
+ out[12] = __r12; \
+ __cfall; \
+ __of (11) \
+ out[11] = __r11; \
+ __cfall; \
+ __of (10) \
+ out[10] = __r10; \
+ __cfall; \
+ __of (9) \
+ out[9] = __r9; \
+ __cfall; \
+ __of (8) \
+ out[8] = __r8; \
+ __cfall; \
+ __of (7) \
+ out[7] = __r7; \
+ __cfall; \
+ __of (6) \
+ out[6] = __r6; \
+ __cfall; \
+ __of (5) \
+ out[5] = __r5; \
+ __cfall; \
+ __of (4) \
+ out[4] = __r4; \
+ __cfall; \
+ __of (3) \
+ out[3] = __r3; \
+ __cfall; \
+ __of (2) \
+ out[2] = __r2; \
+ __cfall; \
+ __of (1) \
+ out[1] = __r1; \
+ __cfall; \
+ }
+
+#ifndef __CPPAWK_CONS_PRIV_H
+#include "cons-priv.h"
+#endif
+
+function __argcount(__name, __rest,
+ __narg, // check argument; doubles as local count
+ __case_temps)
+{
+ __varg_count(__name, __narg, __narg)
+ return __narg;
+}
+
+function __arglist(__name, __rest,
+ __narg, // check argument; doubles as local count
+ __out, __case_temps)
+{
+ __varg_list(__name, __narg, __narg, __out)
+ return __out;
+}
+
+function __argarray(__name, __to_array, __rest,
+ __narg, // check argument; doubles as local count
+ __case_temps)
+{
+ __varg_array(__name, __narg, __narg, __to_array)
+}
+
+#endif
diff --git a/share/cppawk/include/varg.h b/share/cppawk/include/varg.h
new file mode 100644
index 0000000..c0ff036
--- /dev/null
+++ b/share/cppawk/include/varg.h
@@ -0,0 +1,46 @@
+// cppawk: C preprocessor wrapper around awk
+// Copyright 2022 Kaz Kylheku <kaz@kylheku.com>
+//
+// BSD-2 License
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef __CPPAWK_VARG_H
+#define __CPPAWK_VARG_H
+
+#ifndef __CPPAWK_BASE_H
+#include "base.h"
+#endif
+
+#ifndef __CPPAWK_VARG_PRIV_H
+#include "varg-priv.h"
+#endif
+
+#define restargs __rest
+#define arg(n) __r ## n
+#define present(arg) __present(arg)
+#define argcount __argcount
+#define arglist __arglist
+#define argarray __argarray
+
+#endif