PATCH: untokenize string sent to matheval for (#) flag

Mikael Magnusson <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel
Message-ID <[email protected]>
Fixes 49409.
---

Before:
echo ${(X#):-2#1011010}
zsh:1: bad math expression: illegal character: ^?

After:
echo ${(X#):-2#1011010}
Z

I don't think matheval ever does anything useful with tokenized strings so this
shouldn't cause any problems, right?

 Src/subst.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Src/subst.c b/Src/subst.c
index 1776d5e164..9c7ba6c453 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -1494,6 +1494,8 @@ substevalchar(char *ptr)
     int saved_errflag = errflag;
 
     errflag = 0;
+    ptr = dupstring(ptr);
+    untokenize(ptr);
     ires = mathevali(ptr);
 
     if (errflag) {  /* not a valid numerical expression */
-- 
2.38.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.