• cppawk now mentioned in GNU Awk manual.

    From Kaz Kylheku@864-117-4973@kylheku.com to comp.lang.awk on Sat Jun 10 05:54:56 2023
    From Newsgroup: comp.lang.awk

    Cool!

    https://www.kylheku.com/cgit/cppawk/about/

    cppawk preprocesses your Awk code with the C preprocessor
    and executes it or optionally captures it.

    This has benefits:

    - modularization: making a big Awk program out of include
    files.
    - #include nicely searches relative to the directory
    of the file in which the #include appears. Bye-bye AWKPATH.

    - #define constants, efficiently propagated where you want them.

    - macros for inlining code; avoid call overhead.

    - syntactic macros! including ones that come with cppawk
    - cppawk provides a case macro which translates to GNU Awk
    switch syntax or to portable Awk.
    - cppawk provides a loop macro with numerous useful clauses.
    - parallel and cross-product iteration.
    - cppawk has some macros for dealing with

    - conditional code. E.g. #if ... we are targeting this awk,
    do this, #else do that.
    - parametrize your code and conditionally generate;
    #if THIS_FEATURE ... #endif

    cppawk is rigorously developed, covered by 149 test cases.
    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Kpop 2GM@jason.cy.kwan@gmail.com to comp.lang.awk on Thu Jul 6 15:29:50 2023
    From Newsgroup: comp.lang.awk

    here's an easy way to do (some form of) var-arg without any special preprocessor :

    BEGIN {
    . . CONVFMT = OFMT = "%.250g"
    . . srand() srand()
    }

    ($++NF = _______(__ARGV__[$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11,
    . . . . . . . . . . . . . . . . . . . . . . . . $12, $13, $14, $15, $16, $17] = FNR "_" NR "_" NF "_" (1 + int(3^3^3 *
    rand()))))^_ {
    . . print
    }


    function _______(__, ___, _, ____, _____, ________, _________,
    __________, ___________)
    {
    . . for (_ in __ARGV__) {
    . . . . if ((_____ = __ARGV__[_]) == __) {
    . . . . . . delete __ARGV__[_]
    . . . . . . break
    . . . . }
    . . }
    . . print __ = +___[_ ^= (_____ = split(_, ___, SUBSEP)) < _____]
    . . ___________ = (++_^_^_ * _)^(_ + (__________ = _ * _ * _--))
    . . * __________--
    . . while (_++ < _____) {
    . . . . print __ = (____ = ( (________ = ___[_]) * __) < ___________) \
    . . . . ? ____ : (length(________) <= __________) ? int((________ = \
    . . . . +________) * substr(__ = __ "", !!_, _________ = length(__) \
    . . . . - __________) + (____ = int((__ = substr(__, ++_________) * \
    . . . . ________) / (_________ = (!!_ !_)^__________)))) sprintf("%.*d",
    . . . . __________, __ - _________ * ____) : (________ * substr(__,
    . . . . !!_, ________ = match(__, "[^0][0]*$"))) substr(__, ++________)
    . . }
    . . return __
    }

    when I fed in

    echo ' 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 '

    as the input, then run the output through gnu-factor, it looks like :

    2: 2
    6: 2 3
    30: 2 3 5
    210: 2 3 5 7
    2310: 2 3 5 7 11
    30030: 2 3 5 7 11 13
    510510: 2 3 5 7 11 13 17
    9699690: 2 3 5 7 11 13 17 19
    223092870: 2 3 5 7 11 13 17 19 23
    6469693230: 2 3 5 7 11 13 17 19 23 29
    200560490130: 2 3 5 7 11 13 17 19 23 29 31
    7420738134810: 2 3 5 7 11 13 17 19 23 29 31 37
    304250263527210: 2 3 5 7 11 13 17 19 23 29 31 37 41
    13082761331670030: 2 3 5 7 11 13 17 19 23 29 31 37 41 43
    614889782588491410: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 32589158477190044730: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 1922760350154212639070: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59

    worked in gawk 5.2.2, mawk 1.3.4, mawk2 - 1.9.9.6, and nawk 20200816
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From gazelle@gazelle@shell.xmission.com (Kenny McCormack) to comp.lang.awk on Thu Jul 6 23:15:54 2023
    From Newsgroup: comp.lang.awk

    In article <7ffd2ac7-7c32-4fac-9cb1-a0c8c4371ae2n@googlegroups.com>,
    Kpop 2GM <jason.cy.kwan@gmail.com> wrote:
    here's an easy way to do (some form of) var-arg without any special preprocessor :

    BEGIN {
    . . CONVFMT = OFMT = "%.250g"
    . . srand() srand()
    }

    Thank you for sharing.
    --
    The randomly chosen signature file that would have appeared here is more than 4 lines long. As such, it violates one or more Usenet RFCs. In order to remain in compliance with said RFCs, the actual sig can be found at the following URL:
    http://user.xmission.com/~gazelle/Sigs/Snicker
    --- Synchronet 3.20a-Linux NewsLink 1.114