Re: CVS update: php3/functions
| From: | Jim Winstead | Date: | Wed, 26 May 1999 20:00:57 +0000 |
| Subject: | Re: CVS update: php3/functions | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-6028@lists.php.net to get a copy of this message | ||
I don't know if this is related to your earlier query about having
an empty first array entry if the regex you are splitting on occurs
at the beginning of the string, but that behavior is very much
correct -- it is analogous to explode(":", ":second:third:fourth")
where the first field is simply empty.
Sorry for not chiming in sooner, but I deleted the original message
and hadn't had time to go dig it up again.
Jim
On May 26, andrey wrote:
> Date: Wednesday May 26, 1999 @ 14:47
> Author: andrey
>
> Update of /repository/php3/functions
> In directory php:/tmp/cvs-serv8726/functions
>
> Modified Files:
> reg.c
> Log Message:
> Fixed a couple of split() bugs.
>
> Index: php3/functions/reg.c
> diff -u php3/functions/reg.c:1.99 php3/functions/reg.c:1.100
> --- php3/functions/reg.c:1.99 Mon Apr 5 17:46:27 1999
> +++ php3/functions/reg.c Wed May 26 14:47:26 1999
> @@ -28,7 +28,7 @@
> | Jaakko Hyvätti <jaakko@hyvatti.iki.fi> |
> +----------------------------------------------------------------------+
> */
> -/* $Id: reg.c,v 1.99 1999/04/05 21:46:27 sas Exp $ */
> +/* $Id: reg.c,v 1.100 1999/05/26 18:47:26 andrey Exp $ */
> #ifdef THREAD_SAFE
> #include "tls.h"
> #endif
> @@ -543,7 +543,7 @@
> }
>
> /* churn through str, generating array entries as we go */
> - while ((count == -1 || count > 1) && !(err = regexec(&re, strp, 1, subs, 0)))
> {
> + while ((count == -1 || count > 0) && !(err = regexec(&re, strp, 1, subs, 0)))
> {
> if (subs[0].rm_so == 0 && subs[0].rm_eo) {
> /* match is at start of string, return empty string */
> add_next_index_stringl(return_value, empty_string, 0, 1);
> @@ -584,9 +584,10 @@
> }
>
> /* otherwise we just have one last element to add to the array */
> - size = endp - strp;
> -
> - add_next_index_stringl(return_value, strp, size, 1);
> + if (count == -1) {
> + size = endp - strp;
> + add_next_index_stringl(return_value, strp, size, 1);
> + }
>
> _php3_regfree(&re);
>
>
> --
> PHP Development Mailing List http://www.php.net/
> To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
> For help: php-dev-help@lists.php.net
>
>
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net