Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Deliver yesterday, code today, think tomorrow.


devel / comp.lang.awk / Re: one-liner for auto-detection of awk variant

SubjectAuthor
* one-liner for auto-detection of awk variantKpop 2GM
`* Re: one-liner for auto-detection of awk variantKpop 2GM
 `- Re: one-liner for auto-detection of awk variantJanis Papanagnou

1
one-liner for auto-detection of awk variant

<ad827e0b-8e86-48df-9605-76d692f90422n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1113&group=comp.lang.awk#1113

  copy link   Newsgroups: comp.lang.awk
X-Received: by 2002:adf:d219:0:b0:1e3:3e71:8a6 with SMTP id j25-20020adfd219000000b001e33e7108a6mr20192542wrh.35.1645558965171;
Tue, 22 Feb 2022 11:42:45 -0800 (PST)
X-Received: by 2002:a0d:f041:0:b0:2d6:250d:4e46 with SMTP id
z62-20020a0df041000000b002d6250d4e46mr25882641ywe.171.1645558964705; Tue, 22
Feb 2022 11:42:44 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.128.88.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.awk
Date: Tue, 22 Feb 2022 11:42:44 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=2603:7000:3c3d:41c0:0:0:0:3c3;
posting-account=n74spgoAAAAZZyBGGjbj9G0N4Q659lEi
NNTP-Posting-Host: 2603:7000:3c3d:41c0:0:0:0:3c3
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ad827e0b-8e86-48df-9605-76d692f90422n@googlegroups.com>
Subject: one-liner for auto-detection of awk variant
From: jason.cy.kwan@gmail.com (Kpop 2GM)
Injection-Date: Tue, 22 Feb 2022 19:42:45 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Kpop 2GM - Tue, 22 Feb 2022 19:42 UTC

hey Janis,

i managed to come up with this intentionally crafted line that managed to spit out 7 different responses, including 4 different responses from gawk, which helps to auto-detect which awk-variant or invocation flags were used, and to tailor your program's/function's behavior, if necessary (e.g. gawk -P posix mode cannot directly calculate length(array), requiring workarounds to yield a count). It's not perfect, as multiple gawk invocation flags still yield "+nan", but it shouldn't be too hard to do a secondary test from that point on.

% ${awk_variant} 'BEGIN { print \
\
-log((log(-0)*log(-0))^-log(0^length("\0")))/(-"0xABCD")^-(1-("<"<"\x3C")) }'

gawk511 -e : +nan
gawk -c : +nan
gawk -t : +nan
--------------------------------------
gawk -M : -nan
--------------------------------------
gawk -n : +inf
gawk -P : -inf
--------------------------------------
mawk1.3.4 : inf
mawk1.9.9.6 : nan
--------------------------------------
nawk20200816 : 0

Hope someone finds utility in this.
The 4Chan Teller

Re: one-liner for auto-detection of awk variant

<ba6a26d6-5516-49b2-8376-1015a56c20d8n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1116&group=comp.lang.awk#1116

  copy link   Newsgroups: comp.lang.awk
X-Received: by 2002:a05:600c:8a9:b0:380:da47:a911 with SMTP id l41-20020a05600c08a900b00380da47a911mr5675996wmp.102.1645611754189;
Wed, 23 Feb 2022 02:22:34 -0800 (PST)
X-Received: by 2002:a81:4d54:0:b0:2d7:c17e:2511 with SMTP id
a81-20020a814d54000000b002d7c17e2511mr4201069ywb.215.1645611753489; Wed, 23
Feb 2022 02:22:33 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.128.87.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.awk
Date: Wed, 23 Feb 2022 02:22:33 -0800 (PST)
In-Reply-To: <ad827e0b-8e86-48df-9605-76d692f90422n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2603:7000:3c3d:41c0:0:0:0:3c3;
posting-account=n74spgoAAAAZZyBGGjbj9G0N4Q659lEi
NNTP-Posting-Host: 2603:7000:3c3d:41c0:0:0:0:3c3
References: <ad827e0b-8e86-48df-9605-76d692f90422n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ba6a26d6-5516-49b2-8376-1015a56c20d8n@googlegroups.com>
Subject: Re: one-liner for auto-detection of awk variant
From: jason.cy.kwan@gmail.com (Kpop 2GM)
Injection-Date: Wed, 23 Feb 2022 10:22:34 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Kpop 2GM - Wed, 23 Feb 2022 10:22 UTC

finally succeeded in creating a grand unified detector function.

Now it could detect 14 unique combinations of awk-variants and invocation flags, including 11 different ways of calling gawk, and return a 2-digit value that maps to the data dictionary listed beneath it.

The detection methodology is entirely based on inherent behavior of each awk combo, instead of relying on external variables or system settings that could be tricked via manual override. It also has built-in cleansing for the local variables in case values were passed during the function call.

Unicode detection is based on UTF-8 encoding of U+06D2, a code point that has been part of the Unicode spec since version 1.1 in 1993. On top of obvious ones like ASCII, C, and POSIX, it works when locale is UTF-8 encoding of any language.

UCS2, UTF-7, UTF-16/32 either endian, EBCDIC ARMSCII, ISCII, ISO8859-anything, CP-anything, or the legacy multi-byte ones like Big5, GB-anything, EUC-JP/KR/CN, Shift-JIS etc, most likely would lead to erroneous detection, since it was only designed with UTF-8 in mind.

Feel free to use it as is or modify it in any shape or form to customize to your needs. While UTF-8 capability detection is in place, and designed to be compliant with published specs, it does not include any copyrighted material or intellectual property pertaining to Unicode Consortium.

The 4Chan Teller

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

command is ::: $awk0 'BEGIN {
print awk_var_tester()

} function awk_var_tester(_, __, ___, ____, _____, ______) {
return \
(substr(______ = "\\%" (___ = _ < "") index((__ *= __ ^= __ = ___ += ++___) ___, ___) sprintf("%c_%%c", __ * (___ ^ ___++ - +-___--) - _ ^ (! __)), __ * __, ! __) substr((______ = ((((_ = (substr(___, __, (sub("..$", (______) "&", ______)) - (sub("_", "", ______)))) substr(______ = sprintf(______, (____ = (_____ = ____ = substr(__, ___) ^ ++___ * __ ^ --___) + (___ + --__) * (__++ - ___) - ___) % (__ ^ ___), (_____ += (__ - ___ ^ ___) ^ ___ + ___) % (__ ^ ___), ____, _____), index(______, "_") + (___ < __)) substr(sub("_.+$", "", ______), __, ! __)) ~ substr(______, __ ~ __, ___ ^ ___)) + (_ ~ ("[^" (______) "]")) * ___ + (_ ~ ("[^" (_) "]")) * (___ ^ ___) + (sprintf("%i", __ ^ __ ^ ___ ^ (-! ! __)) % ___) * (__ + __ + __ + __) + (sprintf("%c", -___) == sprintf("%c", ! ___)) * (__ + __) + ("<" < "\x3C") * (__ * __ * ___) + (length(_) % ___) * __ + ((__ ^ __ - ! ! __) % ___) * (__ / ___) + ("0x" (___) (! _ ! _)) + 0x101) % (int((_ = (! ! _ ! _) ^ ++___) / --___) -+-++__)) % (_ / ___)) + --__ * (______ < -___ + __) + (______ + ___ == __ ? -___ : ______ ~ ((__ - ___) "$") ? __ * (___ + ___) - ___ : ! ___) + _, ++___)) } '

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gawk -e .. |- 06 gawk -ne … |- 01 gawk -nMbe |- 93
gawk -be . |- 90 gawk -nbe .|- 85 mawk1 — ... |- 29

gawk -ce . |- 49 gawk -Me .|- 76 mawk2 — ….|- 21
gawk -cbe |- 33 gawk -Mbe |- 98 nawk — ……. |- 12
gawk -Pe . |- 39 gawk -nMe |- 09
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Re: one-liner for auto-detection of awk variant

<sv5bi3$kh0$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1118&group=comp.lang.awk#1118

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.awk
Subject: Re: one-liner for auto-detection of awk variant
Date: Wed, 23 Feb 2022 14:07:15 +0100
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <sv5bi3$kh0$1@dont-email.me>
References: <ad827e0b-8e86-48df-9605-76d692f90422n@googlegroups.com>
<ba6a26d6-5516-49b2-8376-1015a56c20d8n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: base64
Injection-Date: Wed, 23 Feb 2022 13:07:15 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="974f37684cedd984e125bd993430089c";
logging-data="21024"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19lpkyNkB7bM+Ui3/TqnjzX"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:JB1QDoG+1hV+sv2eTXpeErRaYvw=
In-Reply-To: <ba6a26d6-5516-49b2-8376-1015a56c20d8n@googlegroups.com>
 by: Janis Papanagnou - Wed, 23 Feb 2022 13:07 UTC

Amazing! :-)
On 23.02.2022 11:22, Kpop 2GM wrote:
> finally succeeded in creating a grand unified detector function.
>
> Now it could detect 14 unique combinations of awk-variants and
> invocation flags, including 11 different ways of calling gawk, and
> return a 2-digit value that maps to the data dictionary listed
> beneath it.
>
> The detection methodology is entirely based on inherent behavior of
> each awk combo, instead of relying on external variables or system
> settings that could be tricked via manual override. It also has
> built-in cleansing for the local variables in case values were passed
> during the function call.
>
> [...]
>
> The 4Chan Teller
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> command is ::: $awk0 'BEGIN {
> print awk_var_tester()
>
> } function awk_var_tester(_, __, ___, ____, _____, ______) {
> return \
> (substr(______ = "\\%" (___ = _ < "") index((__ *= __ ^= __ = ___ += ++___) ___, ___) sprintf("%c_%%c", __ * (___ ^ ___++ - +-___--) - _ ^ (! __)), __ * __, ! __) substr((______ = ((((_ = (substr(___, __, (sub("..$", (______) "&", ______)) - (sub("_", "", ______)))) substr(______ = sprintf(______, (____ = (_____ = ____ = substr(__, ___) ^ ++___ * __ ^ --___) + (___ + --__) * (__++ - ___) - ___) % (__ ^ ___), (_____ += (__ - ___ ^ ___) ^ ___ + ___) % (__ ^ ___), ____, _____), index(______, "_") + (___ < __)) substr(sub("_.+$", "", ______), __, ! __)) ~ substr(______, __ ~ __, ___ ^ ___)) + (_ ~ ("[^" (______) "]")) * ___ + (_ ~ ("[^" (_) "]")) * (___ ^ ___) + (sprintf("%i", __ ^ __ ^ ___ ^ (-! ! __)) % ___) * (__ + __ + __ + __) + (sprintf("%c", -___) == sprintf("%c", ! ___)) * (__ + __) + ("<" < "\x3C") * (__ * __ * ___) + (length(_) % ___) * __ + ((__ ^ __ - ! ! __) % ___) * (__ / ___) + ("0x" (___) (! _ ! _)) + 0x101) % (int((_ = (! ! _ ! _) ^ ++___) / --___) -+-++__)) % (_ / ___)) + --__ * (______ < -___ + __) + (______ + ___ == __ ? -___ : ______ ~ ((__ - ___) "$") ? __ * (___ + ___) - ___ : ! ___) + _, ++___)) } '
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> gawk -e .. |- 06 gawk -ne … |- 01 gawk -nMbe |- 93
> gawk -be . |- 90 gawk -nbe .|- 85 mawk1 — ... |- 29
>
> gawk -ce . |- 49 gawk -Me .|- 76 mawk2 — ….|- 21
> gawk -cbe |- 33 gawk -Mbe |- 98 nawk — ……. |- 12
> gawk -Pe . |- 39 gawk -nMe |- 09
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor