From: "Jun. T" <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: Re: (LC_ALL=C; set -x 128 129; printf "%s\n" ${(#)@} | hexdump -C)
Date: Sat, 9 Sep 2023 01:30:36 +0900 [thread overview]
Message-ID: <64346084-434A-4A42-AD56-44809DA2E54C@kba.biglobe.ne.jp> (raw)
In-Reply-To: <899459233.232418.1694104433053@mail.virginmedia.com>
> 2023/09/08 1:33, Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
>
> Looks like these are the only calls to substevalchar(), so perhaps
> the changes could be made internal to that.
I changed paramsubst() just because we can assume errflag=0 at the
start of the block (and would make the things simpler.).
But, anyway, my previous patch was not complete.
Either with or without my previous patch (in any locale):
% echo ${(#X):-@}
zsh: bad math expression: illegal character: @
This is OK. But:
% printf "%s\n" ${(#):-@} | hexdump -C
00000000 22 0a 22 |"."|
00000003
The quote removal is done in remnulargs() ( at subst.c:169).
So it seems that if noerrs is set (without (X) flag) then we should not
quit from prefork() at line 146. This means, I guess, substevalchar()
should not return NULL if noerrs is set. But if we want to continue
even if we have a bad math expression, only thing we can do is just
to return "" instead of NULL. The patch below (hopefuly) does this.
Any comment is welcome.
diff --git a/Src/subst.c b/Src/subst.c
index 14947ae36..d68159227 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -1489,11 +1489,18 @@ subst_parse_str(char **sp, int single, int err)
static char *
substevalchar(char *ptr)
{
- zlong ires = mathevali(ptr);
+ zlong ires;
int len = 0;
+ int saved_errflag = errflag;
- if (errflag)
- return NULL;
+ errflag = 0;
+ ires = mathevali(ptr);
+
+ if (errflag) { /* not a valid numerical expression */
+ errflag |= saved_errflag;
+ return noerrs ? dupstring(""): NULL;
+ }
+ errflag |= saved_errflag;
#ifdef MULTIBYTE_SUPPORT
if (isset(MULTIBYTE) && ires > 127) {
/* '\\' + 'U' + 8 bytes of character + '\0' */
next prev parent reply other threads:[~2023-09-08 16:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-30 7:27 Stephane Chazelas
2023-08-30 19:45 ` Bart Schaefer
2023-08-31 17:38 ` Jun. T
2023-09-07 14:26 ` Jun. T
2023-09-07 16:33 ` Peter Stephenson
2023-09-08 16:30 ` Jun. T [this message]
2023-09-11 8:57 ` Peter Stephenson
2023-09-11 12:11 ` Jun. T
2023-09-13 9:59 ` Jun T
2023-09-21 9:26 ` Jun T
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=64346084-434A-4A42-AD56-44809DA2E54C@kba.biglobe.ne.jp \
--to=takimoto-j@kba.biglobe.ne.jp \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).