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

Re: broken parsing with $((`:`))



On Wed, 15 Apr 2015 08:13:48 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Apr 15, 10:03am, Peter Stephenson wrote:
> } 
> } Yes, indeed --- there's a funny internal special case for empty strings
> } that I never quite get my head around.
> } 
> } -    if (!*s) {
> } +    if (!*s || *s == Nularg) {
> 
> I wonder if (a) there are other overlooked cases like this and (b) if it
> would be useful to have a #define macro for (c == '\0' || c == Nularg).
> A quick grep doesn't find existing cases of that test other than this
> new one, but of course if the Nularg part were forgotten, it wouldn't.

Just looked and the typical tests for Nularg are:

- We get it as a single character so just ignore it because there's a '\0'
  next which the following code will handle normally;

- We look for Nularg in a string and skip over the character because
  ditto (we could have made the math.c cases follow this form);

- In a few cases we explicitly check to see if there was a '\0'
  after the Nularg --- possibly me being cautious because I don't really
  know what's going on; I think that's actually unnecessary because
  Nularg means the whole string is empty.

(- Not directly relevant but in prompt.c we look to see if there's a
Nularg we can backup over, which is probably really cool.)

pws



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