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

Re: ${(s::)VAR} vs "${(s::)VAR}"



On Apr 27,  9:38pm, Peter Stephenson wrote:
}
} This comes from the function wordcount() in utils.c, which is called in
} a couple of functions used for splitting words, none of which has any
} comments apart from a few speculations from me dating from 2003.  The
} function takes a mysterious argument mul which presumably has got
} something to do with doing something multiple times.

"mul" takes values -1, 0, 1.  The only time it's less than zero is when
called from spacesplit() with allownull == 0.  So it must have to do
with handling multiple consecutive appearances of the separator.

}  	for (; (c = findsep(&s, sep, 0)) >= 0; s += sl)
} -	    if ((c && *(s + sl)) || mul)
} +	    if ((c || mul) && *(s + sl))
}  		r++;

Does it matter that the changed line dereferences s+sl in cases where
the original line does not?



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