@b4n to be honest, I prefer my version. I find it easier to grasp because it's split into 3 strv-related utility functions that have well defined and separated functionality (the functions should be useful on their own). I don't so how your code is really any shorter (and neither is worryingly long, each is well below 200 LOCs with 20-30 of them being comments). And it's more efficient. I'm surprised, as you usually seem care about efficiency? Efficiency is normally not a big deal for me, but I care if the more efficient version is already written (or if the change is trivial and/or obvious but that doesn't apply here).
So I would rather fix the bugs you mention and proceed with my version. What do you think?