From: Junio C Hamano Date: Mon, 9 Mar 2009 01:22:44 +0000 (-0700) Subject: grep: cast printf %.*s "precision" argument explicitly to int X-Git-Tag: v1.6.3-rc0~144^2~1 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=747a322bcc4df5f9a371890ffe728741456704c7;p=git.git 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 --- diff --git a/grep.c b/grep.c index cace1c8bc..be99b3416 100644 --- a/grep.c +++ b/grep.c @@ -490,9 +490,9 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol, *eol = '\0'; while (next_match(opt, bol, eol, ctx, &match, eflags)) { printf("%.*s%s%.*s%s", - match.rm_so, bol, + (int)match.rm_so, bol, opt->color_match, - match.rm_eo - match.rm_so, bol + match.rm_so, + (int)(match.rm_eo - match.rm_so), bol + match.rm_so, GIT_COLOR_RESET); bol += match.rm_eo; rest -= match.rm_eo;