From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=DATE_IN_PAST_06_12, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 30330 invoked from network); 27 Apr 2023 09:36:05 -0000 Received: from 9front.inri.net (168.235.81.73) by inbox.vuxu.org with ESMTPUTF8; 27 Apr 2023 09:36:05 -0000 Received: from mail-lf1-f50.google.com ([209.85.167.50]) by 9front; Thu Apr 27 05:34:26 -0400 2023 Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-4eff055d4d3so5686239e87.3 for <9front@9front.org>; Thu, 27 Apr 2023 02:34:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682588064; x=1685180064; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=vmQvj81tob24rBFW9aIjhJbCNhydo5uHcRrx1VkYnHI=; b=dbnIfSnRwI9gJJcpBz1uOnNHTjwhdQNMM2ezCRF/Q0GBKYWZJXUJHG8vXlTINXCQzm ovE3tadhFkgWHh2rK8fBU2zfHQN3Jc7qPn39/vrz4StbtK357MZl8OuGIgkf8YoIEzVG WGYVFhWBcJlv1EC4zeB6qqZc5/IJKByCqVIeVWl33T2WtY2UQvZNUvfmdvM4kciubzC6 SwrUyFGNtVCgAOYzLAahzYMTAUXLVp6Qm4KlC1QXbdCdthQzbHi5QcBS97sxtGOs6IFA 9KJCfw+lnpJAupkBYEDRY2L//IoJEkRsRWFIUvDnCsuOdSF+oDkHHbHXS+riYRZ5hYaq mVAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682588064; x=1685180064; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vmQvj81tob24rBFW9aIjhJbCNhydo5uHcRrx1VkYnHI=; b=ZTiHv98IaFunUMqsoRgfqciNR7Re4PEH/1WrjCBaFoJjqWiw6RvZ04sfC2xyTaFbxJ g46JQnxINYTPQ4RT8nf72FZYF0TKnTvEfgc9OH8SomuJb25I+ZqCawEjVvE4Ji/R22kW EBIGz8RKTvvz9IX7VTxKXNWxPw/mw4OUhntF7TCQ7QlW8qt6Ab4J6fZdlalEXpkOfuUa sgGat1yt9qDmPxkuEgn7u3sWfWRBIr9sOu+wiRID40NpFntT8HZXnkwjbsqMeySD6EWL JPNeEdWCUS/HhuoCtQoGNO789wIFWDz3Ks9VW7BAupmLuyTPmwRoLHGUAg3CsJJpF2y2 xtLg== X-Gm-Message-State: AC+VfDw0+73D+Eqr96hna7k8sIlSl0oPzcudHNblRQElnzVJhQCapw7B 0lCdPcuxnUVRi/W8MY085tPO44ItiQE39SEMroueZRQ5Eg== X-Google-Smtp-Source: ACHHUZ4VTmJnY093Aw2MRZ0GM0hfX/1+8XSFywOuyoK1k+odbmSrqzFzXrizfm5OL0UVPMnI1TZUxPhbuQEpGrHE8cM= X-Received: by 2002:a17:907:320a:b0:959:6fb2:1c35 with SMTP id xg10-20020a170907320a00b009596fb21c35mr13110ejb.60.1682561149552; Wed, 26 Apr 2023 19:05:49 -0700 (PDT) MIME-Version: 1.0 References: <7BAAF1BDE05AF95E8E1167B980AD0CDA@eigenstate.org> In-Reply-To: <7BAAF1BDE05AF95E8E1167B980AD0CDA@eigenstate.org> From: Yury Chumak Date: Thu, 27 Apr 2023 05:05:13 +0300 Message-ID: To: 9front@9front.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: transactional self-healing cloud proxy realtime-java backend Subject: Re: [9front] Bug in rc Reply-To: 9front@9front.org Precedence: bulk Hitting limit is a half decision. In general, a strange decision is to implement such non-limiting constructions using recursion. By the way, in my real code there is a limit of 141 'case'-blocks, but there are complex 'case' conditions in the blocks - apparently they are additionally expanded.. So the test example is ideal at maximum, but really the limit can be reached faster. =D1=87=D1=82, 27 =D0=B0=D0=BF=D1=80. 2023=E2=80=AF=D0=B3. =D0=B2 03:46, : > > Quoth Yury Chumak : > > Hello all.. > > > > Noticed that rc returns error 'stack overflow' if code consists > > 'switch' construction with big amount of 'case' blocks. Steps to > > reproduce: > > > > 1.Generate test script by next code: > > #!/bin/rc > > echo '#!/bin/rc' >test.rc > > echo 'switch($*){' >>test.rc > > for(i in `{seq 1 250}){ > > echo ' case ' $i>>test.rc > > echo ' echo number ' $i>>test.rc > > } > > echo ' case *' >>test.rc > > echo ' echo number none'>>test.rc > > echo '}'>>test.rc > > > > 2. Run result script: > > % chmod +x test.rc > > % test.rc > > ./test.rc:497: token 248: yacc stack overflow > > > > The 'switch' construction works normaly with number 'case' block less t= han 247. > > In comparison linux's bash has no limitation to number elements in > > 'case' block (at least 500k tested). > > > > Yes, the grammar for this is right recursive, > which means the full stack is collected before > it's reduced: > > body: cmd > | cmdsan body {$$=3Dtree2(';', $1, $2);} > > You can play around with refactoring it to be > left recursive, or maybe bringing in the C rewrite > of the parser from plan9port (ideally with tests). > > But I'm not sure why it matters; you can hit a > limit with a huge switch, but it doesn't seem > like a limit for practical code. > --=20 Sphynkx