Skip to content

Commit 747a322

Browse files
committed
grep: cast printf %.*s "precision" argument explicitly to int
On some systems, regoff_t that is the type of rm_so/rm_eo members are wider than int; %.*s precision specifier expects an int, so use an explicit cast. A breakage reported on Darwin by Brian Gernhardt should be fixed with this patch. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent a94982e commit 747a322

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

grep.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,9 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol,
490490
*eol = '\0';
491491
while (next_match(opt, bol, eol, ctx, &match, eflags)) {
492492
printf("%.*s%s%.*s%s",
493-
match.rm_so, bol,
493+
(int)match.rm_so, bol,
494494
opt->color_match,
495-
match.rm_eo - match.rm_so, bol + match.rm_so,
495+
(int)(match.rm_eo - match.rm_so), bol + match.rm_so,
496496
GIT_COLOR_RESET);
497497
bol += match.rm_eo;
498498
rest -= match.rm_eo;

0 commit comments

Comments
 (0)