Re: patch to allow negative string offsets in {}
| From: | cshmoove at bellsouth dot net | Date: | Sat, 30 Jul 2005 15:21:06 +0000 |
| Subject: | Re: patch to allow negative string offsets in {} | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-17468@lists.php.net to get a copy of this message | ||
val,
you dont clamp at the lower bound. suppose offset == -LONG_MAX
l0t3k
"val khokhlov" <val@vk.kiev.ua> wrote in message
news:446750995.20050730134023@vk.kiev.ua...
> Hello,
>
> a small patch that allows using negative value for offset in
> $string{offset}
> $string = "test";
> $string{-1} -> last 't'
> $string{-2} -> 's' and so on...
>
> ================<<
> --- zend_execute.c Mon Jul 18 11:20:19 2005
> +++ /home/val/src/php/php5.1/php-src/Zend/zend_execute.c Sat Jul 30
> 13:33:57 2005
> @@ -1097,6 +1097,7 @@
> result->str_offset.str = container;
> PZVAL_LOCK(container);
> result->str_offset.offset =
> dim->value.lval;
> + if (dim->value.lval < 0)
> result->str_offset.offset += container->value.str.len;
> result->var.ptr_ptr = NULL;
> if (type == BP_VAR_R || type ==
> BP_VAR_IS) {
> AI_USE_PTR(result->var);
>
> ================<<
>
> --
> Best regards,
> val mailto:val@vk.kiev.ua