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=-0.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,RDNS_NONE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: from authenticated user by zero.zsh.org with local id 1kikUj-000NZM-Bf; Fri, 27 Nov 2020 20:37:29 +0000 Authentication-Results: zsh.org; iprev=pass (out4-smtp.messagingengine.com) smtp.remote-ip=66.111.4.28; dkim=pass header.d=daniel.shahaf.name header.s=fm2 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from out4-smtp.messagingengine.com ([66.111.4.28]:49615) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1kikUJ-000NKW-Uw; Fri, 27 Nov 2020 20:37:05 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id C95405C010A for ; Fri, 27 Nov 2020 15:37:01 -0500 (EST) Received: from imap37 ([10.202.2.87]) by compute3.internal (MEProxy); Fri, 27 Nov 2020 15:37:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=mime-version:message-id:in-reply-to :references:date:from:to:subject:content-type :content-transfer-encoding; s=fm2; bh=WjFNWPGpnoDy9gk1hkAHbXTNYj AulKmOmAtTPX1O16M=; b=ihNS4SH1jt3NnjKHFwlX7xVxFuN52ut8Jellgtsm1N woI0o+M9GGV+Ot1fuRCnWNCgIIkGhglcZh5DFV0uALt8zYRDOoGFpl5CrYEdmkB8 3ElXdSZDa7aClmsLEI8SresAretHAZzni0f9DIYFTd6nGAHCM3QMlul0kiF5Odxs K/7FPQ+iwhmEFaXNsjZjJs7EogI9QKCGpCOmb7V98Xn8jShAFqh/2FDuXVtbqn2t KHpdbvdi9GbKyDF1SRM5mX3gVd6mZP4RKt9WcwW2kyxJrFKVxKszHOxVlWYuNQoW m5K32sUCvnTH3PFFQITs4ZrIxQiQm1tQMBb1X1tsQ5vg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=WjFNWPGpnoDy9gk1hkAHbXTNYjAulKmOmAtTPX1O1 6M=; b=F8IYX3/QcqmO1NcJ0aEzSaxiC9bIj0UYgo83rDiF4BRPkxFDtvCdPDHdL bbe80HC3QqK9JAmq1qiGRaXTv7C2iQNdkSF/nij3PvzQEFt32kmPt3vB1fHwMKmz IRDttZXaqW+6kYykKQDuAs36NWUC6kQkHTiEnLtw10840jtKnrnHMlD6HDYrEH0s T9SSKcFusy3Muy8C5JGqswyOGrbSKN3ANyLFNKBeJYk6vKa77wJ318upZ3o+mk/N hmvtnDNIeTEOPYi8isLibcGRpl0xJAZwW1H1UnjacDE2RD387aJ5k3aYRcFAnfcr yfSrBJZRKlEh0K7IYnRXjLElkqh7w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudehgedgudegudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgfgse htqhertderreejnecuhfhrohhmpedfffgrnhhivghlucfuhhgrhhgrfhdfuceougdrshes uggrnhhivghlrdhshhgrhhgrfhdrnhgrmhgvqeenucggtffrrghtthgvrhhnpeefhfekfe evieelleehiefftdekudejledvhfdtjedtgeegvdeuffefleehhfdvgfenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurdhssegurghnihgvlh drshhhrghhrghfrdhnrghmvg X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 85FF1190006D; Fri, 27 Nov 2020 15:37:00 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.0-622-g4a97c0b-fm-20201115.001-g4a97c0b3 Mime-Version: 1.0 Message-Id: <808eb7ef-fe44-474a-ba85-6144b95b16c2@www.fastmail.com> In-Reply-To: <20201127201342.t4uthqbfwuhzgevz@chazelas.org> References: <20201123214942.hi2rx7n3jk25ucmd@chazelas.org> <74327-1606347813.918593@HxCz.NV4p.AwzH> <20201126205819.dbncs24ppnw3pdny@chazelas.org> <20201127163949.GD26720@tarpaulin.shahaf.local2> <20201127201342.t4uthqbfwuhzgevz@chazelas.org> Date: Fri, 27 Nov 2020 20:36:40 +0000 From: "Daniel Shahaf" To: zsh-workers@zsh.org Subject: =?UTF-8?Q?Re:_[PATCHv2_2/2]_[long]_improvements_to_limit/ulimit_API_and_?= =?UTF-8?Q?doc_(the_rest)?= Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Seq: 47671 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: Stephane Chazelas wrote on Fri, 27 Nov 2020 20:13 +00:00: > 2020-11-27 16:39:49 +0000, Daniel Shahaf: > [...] > > Please specify in the docstring the types, values, and meanings of t= he > > formal parameters. >=20 > I've tried to address that in this v3 patch. Specifying the type > (as in char*, int...) seems redundant though and not generally > done in other functions, so I've left it out for now. Of course, DRY; but still, notice how one of the ints is actually a boolean, so the formal type information doesn't convey everything. > +++ b/Src/Builtins/rlimits.c > @@ -255,38 +267,214 @@ printrlim(rlim_t val, const char *unit) > +/* > + * Parse a string into the corresponding value based on the limit typ= e > + * > + * ZLIMTYPE_UNKNOWN / ZLIMTYPE_NUMBER: > + * decimal integer without sign only: raw value > + * > + * ZLIMTYPE_TIME / ZLIMTYPE_MICROSECONDS: > + * only gives seconds or microseconds depending on type= > + * or: > + * [[hour:]min:]sec[.usec] > + * or: > + * with h (hour), m (min), s (sec), ms, us suffix. > + * > + * ZLIMTYPE_MEMORY: > + * without suffix interpreted as KiB by "limit" (except= for > + * RLIMIT_MSGQUEUE, see below) and based on resinfo.unit by "ulim= it". > + * > + * K/M/G/T/P/E suffix and same with iB suffix use 1024 factor > + * KB/MB/GB... use 1000 factor. > + * > + * B for bytes (avoids that mess about default units). > + * > + * All suffixes are case insensitive. > + * > + * Arguments: > + * - s: string to parse > + * - lim: resource being limited (from which will derive the type a= nd unit) > + * - ulimit: to specify whether we're being called by ulimit or not= . > + * For ulimit, suffix-less limits are multiplied by the l= imit's > + * unit. Suggest to add the word "boolean" to the description of this parameter. Since you've already gone and described it in prose, I'd consider to also rename it to something like =C2=ABmultiply_suffixless_limits_by_implied_unit_p=C2=BB (trailing _p fo= r "predicate", i.e., signifies the variable is a boolean), to avoid caller= =E2=80=93callee coupling. > + * - err: (return value) error to be returned if any. If a non-NULL= value is > + * stored there, zstrtorlimt failed and the return value is= > + * irrelevant (though will be 0). You don't actually say anywhere what the return value will be when there= _isn't_ an error. Cheers, Daniel P.S. As I said elsethread, feel free to stick this patch on a short- lived topic branch, if that's easier to you than posting revisions= to a mailing list. > + */ > + > /**/ > static rlim_t > -zstrtorlimt(const char *s, char **t, int base) > +zstrtorlimt(const char *s, int lim, int ulimit, char **err) > {