Re: [PATCH v2 02/17] check-attr, check-ignore, checkout-index: read paths with strbuf_getline_crlf()
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jan 4, 2016, 12:27 UTC
- Message-ID
- <alpine.DEB.2.20.1601041305020.14434@virtualbox>
- In-Reply-To
- <alpine.DEB.2.20.1601041258280.14434@virtualbox>
Hi Junio,
On Mon, 4 Jan 2016, Johannes Schindelin wrote:
Show 10 quoted lines
> strbuf_init(&buf, 0);
> strbuf_init(&nbuf, 0);
> - while (strbuf_getline(&buf, stdin, line_termination) != EOF) {
> - if (line_termination && buf.buf[0] == '"') {
> + while ((nul_term_line
> + ? strbuf_getline(&buf, stdin, '\0')
> + : strbuf_getline_crlf(&buf, stdin)) != EOF) {
> + if (!nul_term_line && buf.buf[0] == '"') {
> strbuf_reset(&nbuf);
> if (unquote_c_style(&nbuf, buf.buf, NULL))FWIW this is an example of that "abuse" I referred to earlier: the call to strbuf_getline(..., '\0') is actually *not* interested in a line at all. So I guess I would suggest to change the name "strbuf_getline" to "strbuf_getdelim" first, and then re-introduce a different "strbuf_getline" which is actually your "strbuf_getline_crlf". Because let's face it, if we are really reading a line of text, CR/LF should be handled automatically.
Ciao, Dscho