Thread (98 messages) flat view 98 messages, 5 authors, 2016-06-15

Re: [PATCH v2 02/17] check-attr, check-ignore, checkout-index: read paths with strbuf_getline_crlf()

From: Johannes Schindelin <hidden>
Date: 2016-06-15 23:07:37

Possibly related (same subject, not in this thread)

Hi Junio,

On Mon, 4 Jan 2016, Johannes Schindelin wrote:
 	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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help