From: Zoltan Hidvegi <hzoli@cs.elte.hu>
To: pws@ifh.de (Peter Stephenson)
Cc: peta@cim.mcgill.ca, zsh-workers@math.gatech.edu
Subject: Re: Old 'cd ......' function broken.
Date: Wed, 2 Oct 1996 23:56:04 +0200 (MET DST) [thread overview]
Message-ID: <199610022156.XAA00979@hzoli.ppp.cs.elte.hu> (raw)
In-Reply-To: <199610011522.RAA02255@sgi.ifh.de> from Peter Stephenson at "Oct 1, 96 05:22:00 pm"
> peta@cim.mcgill.ca wrote:
> > I got this from the zsh mailing list a while ago. It used to work
> > but no more (zsh-3.0.0). It doesnt like ${(r:(${#1}-1)*3-1::../:)b}
>
> It looks like the expression after the first : isn't being interpreted
> as a mathematical expression for evaluation any more. Somebody will
> know if this is a feature, otherwise it's a bug. You can get away
> with:
The expression is interpreted as a mathematical expression but it does not
expanded before arithmetic evaluation. The patch below fixes that.
Zoltan
rcsdiff -qc -kk -r2.50 -r2.51 subst.c
*** Src/subst.c
--- Src/subst.c 1996/10/02 21:51:13 2.51
***************
*** 654,659 ****
--- 654,687 ----
return s;
}
+ /**/
+ int
+ get_intarg(char **s)
+ {
+ char *t = get_strarg(*s + 1);
+ char *p, sav;
+ long ret;
+
+ if (!*t)
+ return -1;
+ sav = *t;
+ *t = '\0';
+ p = dupstring(*s + 2);
+ *s = t;
+ *t = sav;
+ if (parsestr(p))
+ return -1;
+ singsub(&p);
+ if (errflag)
+ return -1;
+ ret = matheval(p);
+ if (errflag)
+ return -1;
+ if (ret < 0)
+ ret = -ret;
+ return ret < 0 ? -ret : ret;
+ }
+
/* parameter substitution */
#define isstring(c) ((c) == '$' || (char)(c) == String || (char)(c) == Qstring)
***************
*** 708,714 ****
inbrace = 1;
s++;
if (*s == '(' || *s == Inpar) {
! char *t, sav, *d;
int tt = 0;
long num;
int escapes = 0;
--- 736,742 ----
inbrace = 1;
s++;
if (*s == '(' || *s == Inpar) {
! char *t, sav;
int tt = 0;
long num;
int escapes = 0;
***************
*** 751,768 ****
substr = 1;
break;
case 'I':
! flnum = 0;
! t = get_strarg(++s);
! if (*t) {
! sav = *t;
! *t = '\0';
! d = dupstring(s + 1);
! untokenize(d);
! if ((flnum = mathevalarg(s + 1, &d)) < 0)
! flnum = -flnum;
! *t = sav;
! s = t;
! } else
goto flagerr;
break;
--- 779,786 ----
substr = 1;
break;
case 'I':
! flnum = get_intarg(&s);
! if (flnum < 0)
goto flagerr;
break;
***************
*** 828,854 ****
tt = 1;
/* fall through */
case 'r':
! t = get_strarg(++s);
! if (!*t)
goto flagerr;
- sav = *t;
- *t = '\0';
- d = dupstring(s + 1);
- untokenize(d);
- if ((num = mathevalarg(d, &d)) < 0)
- num = -num;
if (tt)
prenum = num;
else
postnum = num;
! *t = sav;
! sav = *s;
! s = t + 1;
! if (*s != sav) {
! s--;
! break;
! }
! t = get_strarg(s);
if (!*t)
goto flagerr;
sav = *t;
--- 846,859 ----
tt = 1;
/* fall through */
case 'r':
! num = get_intarg(&s);
! if (num < 0)
goto flagerr;
if (tt)
prenum = num;
else
postnum = num;
! t = get_strarg(++s);
if (!*t)
goto flagerr;
sav = *t;
***************
*** 1608,1625 ****
(*ptr)++;
break;
case 'F':
! rec = -1;
(*ptr)++;
- ptr1 = get_strarg(ptr2 = *ptr);
- if ((sav = *ptr1))
- *ptr1 = '\0';
- ptr2 = dupstring(ptr2 + 1);
- if (sav)
- *ptr1 = sav;
- untokenize(ptr2);
- rec = mathevalarg(ptr2, &ptr2);
- *ptr = ptr1 + 1;
- c = '\0';
break;
default:
*ptr = lptr;
--- 1613,1620 ----
(*ptr)++;
break;
case 'F':
! rec = get_intarg(ptr);
(*ptr)++;
break;
default:
*ptr = lptr;
prev parent reply other threads:[~1996-10-02 23:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <199610011450.KAA15883@Pontryagin.McRCIM.McGill.EDU>
1996-10-01 15:22 ` Peter Stephenson
1996-10-02 21:56 ` Zoltan Hidvegi [this message]
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=199610022156.XAA00979@hzoli.ppp.cs.elte.hu \
--to=hzoli@cs.elte.hu \
--cc=peta@cim.mcgill.ca \
--cc=pws@ifh.de \
--cc=zsh-workers@math.gatech.edu \
/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).