Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: 3.1.5-pws-3: (subscripts) Re: Problem with associative arrays



Bart Schaefer wrote:

> 
> On Dec 16,  3:31pm, Sven Wischnowsky wrote:
> } Subject: Problem with associative arrays
> }
> } And this time it's for real:
> } 
> }   % typeset -A a
> }   % a[x*]=foo
> }   zsh: bad math expression: unbalanced stack
> }   % echo $a[x*]
> }   foo
> }   %
> } 
> } The problem is that isident() uses mathevalarg() to skip (!) over the
> } contents of a subscript (unless the subscript contains flags).
> 
> isident() seems to be rather inconsistent about strict checking of the
> text inside the [ ].  Below is the most obvious fix (#ifdef'd for now).

...minus one `s', it seems:

  % typeset -A a
  % a[--foo--]=bar
  zsh: not an identifier: a[--foo--]

Bye
 Sven

*** os/params.c	Thu Dec 17 12:20:23 1998
--- Src/params.c	Thu Dec 17 12:49:07 1998
***************
*** 663,669 ****
      /* Require balanced [ ] pairs */
      for (s = ss; *(s += strcspn(++ss, "[]")) && s > ss; ss = s)
  	;
!     return (*ss == ']' && !s[1]);
  #endif
  }
  
--- 663,669 ----
      /* Require balanced [ ] pairs */
      for (s = ss; *(s += strcspn(++ss, "[]")) && s > ss; ss = s)
  	;
!     return (*ss == ']' && !ss[1]);
  #endif
  }
  

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author