Skip to content

Commit a258571

Browse files
john-caigitster
authored andcommitted
name-rev.c: use strbuf_getline instead of limited size buffer
Using a buffer limited to 2048 is unnecessarily limiting. Switch to using a string buffer to read in stdin for annotation. Signed-off-by: "John Cai" <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 34ae3b7 commit a258571

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

builtin/name-rev.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -623,14 +623,13 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
623623
name_tips();
624624

625625
if (annotate_stdin) {
626-
char buffer[2048];
626+
struct strbuf sb = STRBUF_INIT;
627627

628-
while (!feof(stdin)) {
629-
char *p = fgets(buffer, sizeof(buffer), stdin);
630-
if (!p)
631-
break;
632-
name_rev_line(p, &data);
628+
while (strbuf_getline(&sb, stdin) != EOF) {
629+
strbuf_addch(&sb, '\n');
630+
name_rev_line(sb.buf, &data);
633631
}
632+
strbuf_release(&sb);
634633
} else if (all) {
635634
int i, max;
636635

0 commit comments

Comments
 (0)