On Wed, May 18, 2011 at 05:14:21PM -0700, Junio C Hamano wrote:
+ if (from_stdin) {
+ struct strbuf sb = STRBUF_INIT;
+ while (strbuf_getwholeline(&sb, stdin, '\n') != EOF) {
+ int len = sb.len;
+ if (len && sb.buf[len - 1] == '\n')
+ sb.buf[--len] = '\0';
+ retval |= remove_one_note(t, sb.buf, flag);
+ }
+ }
Wouldn't strbuf_rtrim (or even strbuf_trim) be useful here?
Manipulating only a copy of the len parameter while changing the strbuf
itself raised warning flags, though it is correct as-is because you
never actually use sb.len.
Using strbuf_trim is shorter, easier to read, and will helpfully eat any
extraneous whitespace, too.
-Peff