About v21:
Patch applies with some offset, make check ok, psql tap tests ok.
I also did some interactive tests which behaved as I was expecting.
I'm ok with this patch. I think that the very simple automaton code
structure achieved is worth the very few code duplications. It is also
significantly shorter than the nested if/switch variants, and it does
exactly what Tom and Robert wished with respect to errors, so I think that
this is a good compromise.
A tiny detail about "default". I would have added a comment when it is
expected to be dead code (else, elif), and I would have put the list of
matching states explicitely otherwise (if, endif) otherwise the reader has
to remember what the other states are. Probably it is me being really too
peckish, if at all possible:-)
I've turned the patch as ready, again.
--
Fabien.