Re: [PATCH v2 0/7] grep.c: teach --column to 'git-grep(1)'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 21, 2018 at 07:53:02AM -0400, Jeff King wrote:

> > @@ -1429,7 +1447,7 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol,
> >  	 */
> >  	if (opt->columnnum && cno) {
> >  		char buf[32];
> > -		xsnprintf(buf, sizeof(buf), "%d", cno);
> > +		xsnprintf(buf, sizeof(buf), "%zu", cno);
> 
> Unfortunately %z isn't portable. You have to use:
> 
>   xsnprintf(buf, sizeof(buf), "%"PRIuMAX, (uintmax_t)cno);

To clarify: yes, it is in C99. But traditionally we have not required
that.

This might be a candidate for another "weather balloon" patch to see if
anybody complains, though. The last time time we dealt with this in a
major way was over 7 years ago in 28bd70d811 (unbreak and eliminate
NO_C99_FORMAT, 2011-03-16).

I know Johannes switched out some "%lu" for PRIuMAX as recently as last
August[1], but I think that is more about the Windows size_t not matching
"unsigned long", and the decision to use PRIuMAX was to match the
existing codebase. AFAIK %zu is available on Windows.

-Peff

[1] https://public-inbox.org/git/alpine.DEB.2.21.1.1708100011391.11175@virtualbox/



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux