mscdex / node-pcre

A pcre binding for node.js
MIT License
39 stars 9 forks source link

Incorrect group offsets returned #4

Closed stoarca closed 11 years ago

stoarca commented 11 years ago

To my knowledge, if an array is returned by PCRE.exec, it must be of even length. I'm encountering some weird behavior when dealing with nested groups. Test case:

PCRE.exec('((t))+', 't', 0) // returns [0, 1, 0, 0, 1], which has odd length

This seems like a bug. If not, what do the offsets in the array mean?

stoarca commented 11 years ago

I think the error is at https://github.com/mscdex/node-pcre/blob/master/src/binding.cc#L545 and https://github.com/mscdex/node-pcre/blob/master/src/binding.cc#L551

i is being incremented by only 1 instead of 2. I haven't tested to see if this is the actual problem.

alexgorbatchev commented 11 years ago

@mscdex could you chip in on this please?

mscdex commented 11 years ago

Should be fixed in 0dc7fd9d5.

alexgorbatchev commented 11 years ago

Thnx a ton!

mscdex commented 11 years ago

Actually fixed in 8549a2ff3. I'll be writing tests soon :-)