@matheusbsbs / matheus-bagliano / commits / 747a322bcc
Fork 0

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>

Junio C Hamano committed Mar 8, 2009 at 18:22 UTC 747a322bcc4df5f9a371890ffe728741456704c7
1 file changed +2 -2
grep.c
+2 -2
@@ -490,9 +490,9 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol,
490 *eol = '\0';
491 while (next_match(opt, bol, eol, ctx, &match, eflags)) {
492 printf("%.*s%s%.*s%s",
493 - match.rm_so, bol,
493 + (int)match.rm_so, bol,
494 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,
496 GIT_COLOR_RESET);
497 bol += match.rm_eo;
498 rest -= match.rm_eo;