From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 343972426D for ; Sun, 25 Feb 2024 08:30:37 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1708846237; b=Ys0Rf3MURyzSDtvIjwCyTj+btMeQLGH+e6YVU5NE9gxTGpSzsGdxPmZj1hhdPdVXBdMh/kb3Pe 9PDVAJxF+UiBz6Qz4cE4HyE+hN8jqhd93W7Ru8EsZZm+iTCrqHBqtSB8mCW80Hitb+ePl6IAvn isurL6eboy1LYXbAwZs1dbqHK36oCfYK5C/HmxaqF0iHZmxIv1RbbZ65BgeQt5Gt6yHBQMwaM0 5Zc0NsY2yV9TyRpUBNzrUnUVn2iIArlkGSmH86Nh6PmNSPRm0nGAx6V24adW02EuDk+3M1rvai lRguEVilVvNeagH3MJOiw5dJlyr/G4jDiOtZ7q+JXbbmmA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay1-d.mail.gandi.net) smtp.remote-ip=217.70.183.193; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1708846237; bh=ZLztR7WTo5lz0uryQy3XgxyP9SmHK3JQSc65YKlJHvA=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:DKIM-Signature; b=cDF8NhR5BWX1VjJUIXkGDbOveKw9DdEiYwzl1ptkVAJgc3oameboFfxsNRxJdwwpf8x3ZlZrqb Crcs6Sanj8O+WwQWaLGI5NvakDPeeeXQvRqn8IsNw4RinekaEwQ2eYe5g00KtW+VoGxCPnF3eP qY2BqlNN2eRWo7AIVviY7TpGxwreW70x5xaUPDZgw1w1xcfuEFBH9qacfF1s7fjKHmBfoptLye KMMId0n35iSt+z51304P4YSFA1w22OFyqc2+NRGLkqZ486FXyy9HCLfPkdg3YWei0VV7cCY5Pe uWnYEeNcXUEbldWMMeCPPjor3Xpl+zutvGlMp5p8UtAC4A==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=VSZeOZjhG6ogPpueqSlfzM827tT4Z+yCgDQ2AvvOWhE=; b=JNz/DGFdluxCs34SgGL+QtcMJv +kROBZNdnZqWY6ZAjqW+TXAoHaeBX+s7MhLPLPEgnioZb1up/WIxbkzBh7EPlV2LRRo9RpnpZaxlj JeeVxfrPfadlcxyYDywq2+W2ydvln10zOMcVfi10FIyPWx65xSfwRO0oxu/lq0Y5P6tBL3WgF32ao qqW7Cz+F3Sk1yl3IctBZJ30nj8VQRE7dOR6PDPOb3VQEKks6q3NrA8WbRbyHhVHNDbZIgGKYhS4PT L43zfuMtK0+N+pQPaT0/TJ9fqfJI6vy87bPetCHHMhf4ioVlbksNJcbr12MEbJWyLrKI0nP2fZZET LPfdtWbQ==; Received: by zero.zsh.org with local id 1re8y5-0008fV-Fm; Sun, 25 Feb 2024 07:30:37 +0000 Authentication-Results: zsh.org; iprev=pass (relay1-d.mail.gandi.net) smtp.remote-ip=217.70.183.193; dmarc=none header.from=chazelas.org; arc=none Received: from relay1-d.mail.gandi.net ([217.70.183.193]:36523) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1re8xV-0008JZ-UI; Sun, 25 Feb 2024 07:30:03 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 15B0D240004; Sun, 25 Feb 2024 07:29:57 +0000 (UTC) Date: Sun, 25 Feb 2024 07:29:51 +0000 From: Stephane Chazelas To: Bart Schaefer Cc: zsh workers Subject: Re: Metafication in error messages (Was: [PATCH] unmetafy Re: $var not expanded in ${x?$var}) Message-ID: <20240225072951.sxzdzoydvgqxctdj@chazelas.org> Mail-Followup-To: Bart Schaefer , zsh workers References: <20240222072313.7woy5vxvt4fbxyhj@chazelas.org> <20240222075528.eruaoosiuhmcrdsy@chazelas.org> <20240223192717.tczrbc63fei7d4m2@chazelas.org> <20240224094722.hnullrzrb6gsswnm@chazelas.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-GND-Sasl: stephane@chazelas.org X-Seq: 52601 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: 2024-02-24 22:05:26 -0800, Bart Schaefer: > On Sat, Feb 24, 2024 at 6:17 PM Bart Schaefer wrote: > > > > The actual tradeoff to make %l do the raw output is: > > + fix the width calculation in math.c, then use %s * > > + add one call to metafy() in parse.c, to use %s instead of %l ** > > + add one call to unmetafy() in subst.c, to use %l instead of %s > > - remove metalen(), zhalloc(), memcpy(), and nicezputs() from utils.c > > + add one call to fwrite() in place of the above > > Stephane, if you really still think it preferable to add %S (thus > moving the unmetafy() from subst.c to utils.c) then I think we should > just do away with %l entirely. Either way we're ending up with a > branch in zerrmsg() that's used for exactly one special case. I don't have a strong opinion on it. Either way, the internal documentation should make it clear the metafy and nicezputs expectations. Like: %s expects metafied string, prints it nicezputs'ed %l expects non-metafied string and byte length, prints it raw. it's the caller's responsibility to make sure the string is not truncated in the middle of a character. Note that there's truncating in between the bytes of a character and there's truncating between the characters of a grapheme cluster like decomposed Hangul syllables (or $'Ste\u301phane'). I don't think we'd want to try and address that. Other option could be to have %s, %S and %*s %*S and let nicezputs do the truncation and ellipsis in %*s case which might be a cleaner interface if (likely) more cumbersome to implement. -- Stephane