1: $cppawk ' #include BEGIN { print narg(x), narg(x, y), narg(x, y, z), narg(x, y, z, w) }' : 1 2 3 4 -- 2: $cppawk ' #include BEGIN { print narg(a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a) }' : 32 -- 3: $cppawk ' #include BEGIN { print narg(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1) }' : ERR -- 4: $cppawk ' #include #define first(x) x #define rest(prev, x) prev : x #define colonize(...) [varexpand(first, rest, __VA_ARGS__)] #define str(x) #x #define xstr(x) str(x) #define scolonize(...) xstr(colonize(__VA_ARGS__)) BEGIN { print scolonize(1), scolonize(1,2), scolonize(1, 2, 3) }' : [1] [1 : 2] [1 : 2 : 3] -- 5: $cppawk ' #include #define str(x) #x #define xstr(x) str(x) #define srev(...) xstr((revarg(__VA_ARGS__))) BEGIN { print srev(1), srev(1,2), srev(1, 2, 3) }' : (1) (2, 1) (3, 2, 1) -- 5: $cppawk ' #include #define first(x) x #define rest(prev, x) prev : x #define colonize(...) [varexpand(first, rest, __VA_ARGS__)] #define str(x) #x #define xstr(x) str(x) #define scolonize(...) xstr(colonize(__VA_ARGS__)) #define scol(x, rest) scolonize(x, splice(rest)) BEGIN { print scol(1, (2, 3)) }' : [1 : 2 : 3] -- 6: x=2 args=1 revargs=1 while [ $x -lt 33 ] ; do args="$args, $x" revargs="$x $revargs" [ "$($cppawk "#include BEGIN { print revarg($args) }")" = "$revargs" ] || exit 1 x=$((x + 1)) done echo okay : okay -- 7: $cppawk ' #include #define first(x, i) x ## i #define rest(prev, x, i) prev : x ## i #define colonize(...) [variexpand(first, rest, __VA_ARGS__)] #define str(x) #x #define xstr(x) str(x) #define scolonize(...) xstr(colonize(__VA_ARGS__)) BEGIN { print scolonize(a), scolonize(a, b), scolonize(a, b, c) }' : [a1] [a1 : b2] [a1 : b2 : c3] -- 7: $cppawk ' #include #define first(x, i, a) a-x ## i #define rest(prev, x, i, a) prev : a-x ## i #define colonize(a, ...) [variaexpand(first, rest, a, __VA_ARGS__)] #define str(x) #x #define xstr(x) str(x) #define scolonize(...) xstr(colonize(__VA_ARGS__)) BEGIN { print scolonize(m, a), scolonize(n, a, b), scolonize(p, a, b, c) }' : [m-a1] [n-a1 : n-b2] [p-a1 : p-b2 : p-c3]