Re: [PHP4BETA] some ?'s about reg.c

From: Date: Sat, 15 May 1999 13:53:45 +0000
Subject: Re: [PHP4BETA] some ?'s about reg.c
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-865@lists.php.net to get a copy of this message
> Can someone explain to me what the following piece of code from reg.c does? I > figured the rest of it out, but I don't know when subs[0].rm_so would be > equal to subs[0].rm_eo. > > Line 408 in reg.c: > if (subs[0].rm_so == subs[0].rm_eo) { > if (subs[0].rm_so + pos >= string_len) > break; > new_l = strlen (buf) + 1; > if (new_l + 1 > buf_len) { > buf_len = 1 + buf_len + 2 * new_l; > nbuf = emalloc(buf_len * > sizeof(char)); > strcpy(nbuf, buf); > efree(buf); > buf = nbuf; > } > pos += subs[0].rm_eo + 1; > buf [new_l-1] = string [pos-1]; > buf [new_l] = '\0'; > } else { > pos += subs[0].rm_eo; > } I think Jaakko wrote that code. <Jaakko.Hyvatti@iki.fi> But basically when rm_so is equal to rm_eo it indicates that you have an empty substring. From regex/regex.3: An empty substring is denoted by equal offsets, both indicating the character following the empty substring. -Rasmus -- PHP 4 Beta

« previous php.version4 (#865) next »