From: Junio C Hamano Date: Wed, 13 Jan 2016 23:44:29 GMT Subject: Re: What's cooking in git.git (Jan 2016, #02; Mon, 11) Message-ID: In-Reply-To: <20160113232255.GA17937@sigill.intra.peff.net> Jeff King 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.