mysql2sqlite icon indicating copy to clipboard operation
mysql2sqlite copied to clipboard

work around mawk's lack of repetition support

Open frrad opened this issue 6 years ago • 2 comments

mawk does not support brace expressions for repetition. See: https://github.com/ThomasDickey/original-mawk/issues/25

This change works around the problem by just repeating the match group the desired number of times.

You can see the fix in action on the tests in my branch here https://github.com/frrad/mysql2sqlite/pull/3/files.

I also think that it's perfectly justifiable to not support mawk since this is pretty gross. If you decide to go this road though it might be nice to call it out in the README which currently says that mawk "should work"

frrad avatar Aug 20 '19 07:08 frrad

Thanks for spotting it - I would call it a regression and we shall probably add a unit test for this case (though this unit test shall be conditional to not require each contributor to have mawk installed, but instead issue a warning, that mawk unit tests could not be executed leading to potential issues - type mawk >/dev/null 2>&1 && do_the_mawk_unit_tests...).

Feel free to wait a bit (until I've reviewed the other pulls of yours regarding unit tests :wink:) and then add this mawk warning to unit tests.

Just a though - would it be more readable to construct the regex programatically using a loop in BEGIN{} instead of copy-paste? I'm afraid it wouldn't, but I'm curious what you think.

dumblob avatar Aug 20 '19 10:08 dumblob

I think that's actually much nicer (though still not amazing). I've made the change. Commit tested here.

frrad avatar Aug 21 '19 04:08 frrad