From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id ff42df18 for ; Wed, 8 Jan 2020 21:34:13 +0000 (UTC) Received: (qmail 19465 invoked by alias); 8 Jan 2020 21:34:08 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45267 Received: (qmail 5622 invoked by uid 1010); 8 Jan 2020 21:34:08 -0000 X-Qmail-Scanner-Diagnostics: from out5-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25684. spamassassin: 3.4.2. Clear:RC:0(66.111.4.29):SA:0(-2.6/5.0):. Processed in 2.869383 secs); 08 Jan 2020 21:34:08 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrvdehkedgudeglecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgfgse htqhertderreejnecuhfhrohhmpedfffgrnhhivghlucfuhhgrhhgrfhdfuceougdrshes uggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgvqeenucfrrghrrghmpehmrghilhhfrhhomh epugdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgvnecuvehluhhsthgvrhfuihii vgeptd X-ME-Proxy: X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.7-731-g1812a7f-fmstable-20200106v2 Mime-Version: 1.0 Message-Id: In-Reply-To: <82F8CDE0-C95C-4D31-ABFC-EBB3C97799F3@kba.biglobe.ne.jp> References: <82F8CDE0-C95C-4D31-ABFC-EBB3C97799F3@kba.biglobe.ne.jp> Date: Wed, 08 Jan 2020 21:33:10 +0000 From: "Daniel Shahaf" To: "Jun T" , zsh-workers@zsh.org Subject: Re: [PATCH] find RLIM_NLIMITS correctly on Cygwin Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Jun T wrote on Wed, 08 Jan 2020 10:39 +00:00: > On Cygwin, has lines like: >=20 > #define RLIMIT_NLIMITS 7 /* upper bound of RLIMIT_* defines */ > #define RLIM_NLIMITS RLIMIT_NLIMITS >=20 > but rlimits.awk fails to find the value of RLIM_NLIMITS > (and sets ZSH_NLIMITS to zero). I don't object to the patch, but we should think about actually using a C preprocessor to parse header files, otherwise we'd just be playing whack-a-mole as OS's use more features of C syntax in their header files= . Actually, looking at the generated $builddir/Src/Builtins/rlimits.h file= , couldn't we move the entire thing into Src/Builtins/rlimits.c? Instead = of =C2=ABrecs[lim]=C2=BB we could have =C2=ABrecs(lim)=C2=BB, using the fol= lowing function: static inline const char *recs(int lim) { if (lim =3D=3D RLIMIT_AIO_MEM) return "aiomemorylocked"; if (lim =3D=3D RLIMIT_AIO_OPS) return "aiooperations"; =E2=8B=AE } And then another such function for =C2=ABlimtype=C2=BB, replace the =C2=AB= for(i =3D 0; i < ZSH_NLIMITS; i++)=C2=BB loops by looping on all RLIMIT_* macros that are= #define'd by the OS, and good riddance to the awk script=E2=80=A6 Cheers, Daniel >=20 > diff --git a/Src/Builtins/rlimits.awk b/Src/Builtins/rlimits.awk > index e9c576c66..4cf960314 100644 > --- a/Src/Builtins/rlimits.awk > +++ b/Src/Builtins/rlimits.awk > @@ -79,6 +79,12 @@ BEGIN {limidx =3D 0} > split(limtail, tmp) > nlimits =3D tmp[2] > } > +# for Cygwin > +/^[\t ]*#[\t ]*define[\t ]*RLIM_NLIMITS[\t ]*RLIMIT_NLIMITS/ { > + if (!nlimits && limrev["NLIMITS"]) { > + nlimits =3D limrev["NLIMITS"] > + } > +} > =20 > END { > if (limrev["MEMLOCK"] !=3D "") { >=20 >=20 >