Jeff King [off-list ref] writes:
I think you'll end up with some of the callers being a bit uglier. I.e.,
where we say:
strbuf_getline(&buf, in, delim);
and "delim" is set elsewhere. These will become:
if (delim == '\n') /* or maybe even "if (nul_terminate)" */
strbuf_getline_lf(&buf, in);
else
strbuf_getline_nul(&buf, in);
My plan is to use a function pointer to switch between them. A code
like the above in practice look more like
(1) there is a config/option parser that sets line_terminator that
is typically a file-scope global.
if (z_option)
line_terminator = '\0';
else
line_terminator = '\n';
(2) the callsite calls getline with it
strbuf_getline(..., line_terminator);
So we can introduce a file-scope global, (*getline_fn)(), and then
tweak (1) by removing line_terminator and replacing the assignment
with an assignment to getline_fn.