janstarke / rexgen

API Documentation
https://github.com/janstarke/rexgen/blob/master/doc/api.md
GNU General Public License v2.0
52 stars 21 forks source link

Resume does not work right on a just created iterator. #30

Closed jfoug closed 7 years ago

jfoug commented 8 years ago

If the iterator has just been created but next() had not been called, then when it was restored, every child iterator was bumped by 1 value.

So if \0[0-9][0-9] was the regex, we were seeing the last value be:

x63 then save then restore and first word after restore was x74 when the proper word would have been x73. So x73, x83, x93, x04, x14, x24, x34, x44, x54, x64 were never being generated.

The bug is not storing/restoring the 'state' value (enum) within the iterator. So if the iterator does not have the next() called, it has all of the state values in the resetted state, which is almost certainly not right.

jfoug commented 8 years ago

Corrected here: https://github.com/jfoug/rexgen/commit/43eb0b4a8119530dea5d8a37a4b86071e79f32d8

Placed in pull-request #29