Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preg_match_all and flags #144

Closed
tamaranga opened this issue Feb 2, 2014 · 7 comments
Closed

preg_match_all and flags #144

tamaranga opened this issue Feb 2, 2014 · 7 comments

Comments

@tamaranga
Copy link
Contributor

public function testMatchAll(flags)
{
    var text, matches;
    let text = "test1,test2";
    preg_match_all("/(test[0-9]+)/", text, matches, flags);
    return matches;
}

Results of calling are currently the same, but must be different:

this->testMatchAll(PREG_PATTERN_ORDER);
this->testMatchAll(PREG_SET_ORDER);

In case of "PREG_PATTERN_ORDER" must be:

Array
(
    [0] => Array
        (
            [0] => test1
            [1] => test2
        )

    [1] => Array
        (
            [0] => test1
            [1] => test2
        )

)

And in case of "PREG_SET_ORDER" must be:

Array
(
    [0] => Array
        (
            [0] => test1
            [1] => test1
        )

    [1] => Array
        (
            [0] => test2
            [1] => test2
        )

)
@phalcon
Copy link

phalcon commented Feb 3, 2014

@racklin could you take a look please?

racklin added a commit to racklin/zephir that referenced this issue Feb 6, 2014
Signed-off-by: Rack Lin <racklin@gmail.com>
@racklin
Copy link
Contributor

racklin commented Feb 6, 2014

@tamaranga Hi, I can't reproduce this issue.
could you using my commit branch and regenerate c code.

The PREG_PATTERN_ORDER must be 1, and PREG_SET_ORDER must be 2 in ext/test/pregmatch.c

commit: racklin@138aa52
branch: https://github.com/racklin/zephir/tree/bugfix/144

@tamaranga
Copy link
Contributor Author

@racklin, hi
c code generated by branch: https://github.com/racklin/zephir/tree/bugfix/144:

    zval *m1, *m2, *_0;

    ZEPHIR_MM_GROW();

    ZEPHIR_INIT_VAR(_0);
    ZVAL_LONG(_0, 1);
    ZEPHIR_INIT_VAR(m1);
    zephir_call_method_p1(m1, this_ptr, "testmatchall", _0);
    ZEPHIR_INIT_BNVAR(_0);
    ZVAL_LONG(_0, 2);
    ZEPHIR_INIT_VAR(m2);
    zephir_call_method_p1(m2, this_ptr, "testmatchall", _0);
    zephir_call_func_p1_noret("print_r", m1);
    zephir_call_func_p1_noret("print_r", m2);
    ZEPHIR_MM_RESTORE();

As we can see flags are correct: (PREG_PATTERN_ORDER = 1, PREG_SET_ORDER = 2)

But testMatchAllInZep returns:

Array ( 
  [0] => Array ( [0] => test1 [1] => test2 ) 
  [1] => Array ( [0] => test1 [1] => test2 ) 
) 
Array ( 
  [0] => Array ( [0] => test1 [1] => test2 ) 
  [1] => Array ( [0] => test1 [1] => test2 ) 
)

So results are the same, but must be different.

@racklin
Copy link
Contributor

racklin commented Feb 7, 2014

@tamaranga hmm.... strangely.
My OUTPUT is different.

Array
(
    [0] => Array
        (
            [0] => test1
            [1] => test2
        )

    [1] => Array
        (
            [0] => test1
            [1] => test2
        )

)
Array
(
    [0] => Array
        (
            [0] => test1
            [1] => test1
        )

    [1] => Array
        (
            [0] => test2
            [1] => test2
        )

)

Could you tell me which pcre and php version you are using???

@tamaranga
Copy link
Contributor Author

@racklin
php 5.3.15
pcre 8.02 2010-03-19 (phpinfo)

Interesting that in "php" preg_match_all returns correct results.
Maybe i have wrong pcre version, whitch is used by zephir (if different), i do not know where to see this one.

@nkt
Copy link
Contributor

nkt commented Mar 28, 2014

As I know, @phalcon removed preg_match optimiser for now.
@phalcon am I right?

@phalcon
Copy link

phalcon commented Mar 28, 2014

It wasn't working well, so I disabled temporarily, need some more time to track the problem down.

steffengy pushed a commit to steffengy/zephir that referenced this issue Apr 15, 2015
steffengy pushed a commit to steffengy/zephir that referenced this issue Apr 15, 2015
steffengy pushed a commit to steffengy/zephir that referenced this issue Apr 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants