Re: What's cooking in git.git (Jan 2016, #02; Mon, 11)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeff King <peff@xxxxxxxx> 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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]