Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Old 'cd ......' function broken.
- X-seq: zsh-workers 2189
- From: Zoltan Hidvegi <hzoli@xxxxxxxxxx>
- To: pws@xxxxxx (Peter Stephenson)
- Subject: Re: Old 'cd ......' function broken.
- Date: Wed, 2 Oct 1996 23:56:04 +0200 (MET DST)
- Cc: peta@xxxxxxxxxxxxx, zsh-workers@xxxxxxxxxxxxxxx
- In-reply-to: <199610011522.RAA02255@xxxxxxxxxx> from Peter Stephenson at "Oct 1, 96 05:22:00 pm"
> peta@xxxxxxxxxxxxx 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;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author