zsh-workers
 help / color / mirror / code / Atom feed
* Singleton arrays treated as scalars
@ 1999-04-16  7:18 Bart Schaefer
  1999-04-16  7:52 ` Geoff Wing
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 1999-04-16  7:18 UTC (permalink / raw)
  To: zsh-workers

I wrote:
} On Apr 15,  2:08pm, Sven Wischnowsky wrote:
} } Subject: Re: BUG: zsh-3.1.5-pws-14: parameter expansion not working proper
} }
} } Now, we could make the multsub() save (and at the end restore) the
} } value of, say `static int mult_isarr'. It then sets it to zero and
} } calls paramsubst() (via prefork(), as usual). At the end of
} } paramsubst() we set `mult_isarr = isarr'.
} 
} I actually tried this last night -- although I had paramsubst() set the
} static to 0 on the way in; multsub() just saved and restored it -- and
} it worked for some cases but not others, so I decided I was missing a
} subtlety somewhere and threw it out.

I tried this again and got much better results for two-or-more element
arrays, but singleton arrays were still getting subscripted as scalars.
Investigation led me to this fragment of paramsubst():

        if (isarr > 0 && !plan9 && (!aval || !aval[0])) {
            val = dupstring("");
            isarr = 0;
        } else if (isarr && aval && aval[0] && !aval[1]) {
            val = aval[0];
            isarr = 0;
        }

Well, look at that.  If we have a singleton array, make it into a scalar.
This doesn't have anything to do with multsub() at all!

Does anybody remember why this code is here?  What part of the world is
going to come crashing down if that "else if" clause gets deleted?

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Singleton arrays treated as scalars
  1999-04-16  7:18 Singleton arrays treated as scalars Bart Schaefer
@ 1999-04-16  7:52 ` Geoff Wing
  0 siblings, 0 replies; 3+ messages in thread
From: Geoff Wing @ 1999-04-16  7:52 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer <schaefer@brasslantern.com> typed:
:I tried this again and got much better results for two-or-more element
:arrays, but singleton arrays were still getting subscripted as scalars.
:Investigation led me to this fragment of paramsubst():
:
:        if (isarr > 0 && !plan9 && (!aval || !aval[0])) {
:            val = dupstring("");
:            isarr = 0;
:        } else if (isarr && aval && aval[0] && !aval[1]) {
:            val = aval[0];
:            isarr = 0;
:        }
:
:Well, look at that.  If we have a singleton array, make it into a scalar.
:This doesn't have anything to do with multsub() at all!
:
:Does anybody remember why this code is here?  What part of the world is
:going to come crashing down if that "else if" clause gets deleted?

It's a pf artifact.  Looking in 2.00.03 sees it there in a slightly
different incantation but logically the same.
-- 
Geoff Wing   <gcw@pobox.com>            Mobile : (Australia) 0412 162 441
Work URL: http://www.primenet.com.au/   Ego URL: http://pobox.com/~gcw/


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Singleton arrays treated as scalars
@ 1999-04-16  7:38 Sven Wischnowsky
  0 siblings, 0 replies; 3+ messages in thread
From: Sven Wischnowsky @ 1999-04-16  7:38 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> I tried this again and got much better results for two-or-more element
> arrays, but singleton arrays were still getting subscripted as scalars.
> Investigation led me to this fragment of paramsubst():
> 
>         if (isarr > 0 && !plan9 && (!aval || !aval[0])) {
>             val = dupstring("");
>             isarr = 0;
>         } else if (isarr && aval && aval[0] && !aval[1]) {
>             val = aval[0];
>             isarr = 0;
>         }
> 
> Well, look at that.  If we have a singleton array, make it into a scalar.
> This doesn't have anything to do with multsub() at all!
> 
> Does anybody remember why this code is here?  What part of the world is
> going to come crashing down if that "else if" clause gets deleted?

When buildin the patch I just sent, I stumbled over this, too. And no, 
I have no idea whence this came or what would happen, if...

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-04-16  7:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-04-16  7:18 Singleton arrays treated as scalars Bart Schaefer
1999-04-16  7:52 ` Geoff Wing
1999-04-16  7:38 Sven Wischnowsky

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).