> > Otto Moerbeek wrote: > > > On Mon, Dec 07, 2015 at 01:36:22AM -0500, Michael McConville wrote: > > > > This isn't a grave issue, but I came across it while exploring integer > > > > overflow and think it's worth sharing. > > > > > > > > grep represents line numbers with an int, which predictably overflows > > > > for inputs with >= 2^31 newlines. This is easy to demonstrate using the > > > > -n option and a debugging printf. > > > > > > > > The below diff fixes this, and tunes up a for loop while I'm in there. > > > > > > how does this fix work on 32-bit platforms? Better use offset_t. > > > > Good catch, thanks. > > > > Does this look better? Or is PRId64 preferred for off_t? > > Neither is correct, off_t should be cast to intmax_t first and then %jd > be used.
That is incorrect advice for the OpenBSD world.
