On Wed, Aug 01, 2007 at 12:08:16PM -0700, Colin Kuskie wrote:
> The attached patch marks the 3rd argument of substr as
> optional so the 2 argument version of substr will work.
>
> .sub 'substr'
> .param string x
> - .param int start
> - .param int len
> + .param int start
> + .param int len :optional
> +
> + unless len goto end_of_string
Close. What this actually does is cause a len of 0 to
mean grab to the end of the string (which is arguably incorrect,
since a len of 0 should probably return a zero-length string).
PIR has an :opt_flag that allows us to know if a particular
argument has been supplied by the caller, thus we probably
want something like:
.sub 'substr'
.param string x
.param int start
.param int len :optional
.param int has_len :opt_flag
unless has_len goto end_of_string
# ...
Try it that way and resubmit the patch. And thanks!
Pm