So my question is this: is this block at the end some sort of anti-pattern, and is it something that's going to come back to bite me in the future?
Not necessarily.It depends on whether line
can contain end-of-line markers.
If line
can contain an EOL character that marks the end of the CSV record for you,then you could move the logic from the last switch
into case EOL:
for the state-specific handling as appropriate,and stop further processing.Or you want to support multi-line CSV records (newline characters embedded within quotes), then you could continue processing the next line.
If the full length of line
is expected to be the complete CSV record,then it's fine to not terminate it with an explicit EOL and handle it in the extra switch
as you did.