grep-devel
[Top][All Lists]
Advanced

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

Re: [Grep-devel] [PATCH] grep: use 'j' printf length modifier for [u]int


From: Jim Meyering
Subject: Re: [Grep-devel] [PATCH] grep: use 'j' printf length modifier for [u]intmax_t
Date: Thu, 20 Oct 2016 09:36:28 -0700

On Wed, Oct 19, 2016 at 9:30 PM, Zev Weiss <address@hidden> wrote:
...
>> gl_PRINTF_SIZES_C99
>> if test "$gl_cv_func_printf_sizes_c99" = yes; then
>>  AC_DEFINE([HAVE_PRINTF_C99_SIZES], [1],
>>    [Define to 1 if printf formats %j, %z, %t and %L work.])
>> fi
>>
>> Zev, do you want to add that to your patch, #ifdef your new one-liner,
>> with the rest in an #else block and test that?
>>
>> Then, we can think about removing the #else block at our leisure.
>
>
> Okay, something like the attached then?

Thank you.
That looks perfect.

> I have to say I'm a bit unsure about what this version will actually do
> though.  I'm certainly far from an expert on gnulib and its associated
> autoconf tooling, but from my reading of printf.m4 it appears it only
> conditionally tests for printf("%j") support (predicated on
> HAVE_STDINT_H_WITH_UINTMAX || HAVE_INTTYPES_H_WITH_UINTMAX).  On a system
> sufficiently old that neither of those macros is defined, couldn't we still
> end up compiling the new %j code even if the runtime libc doesn't support
> it?

Yes, indeed.
Good catch. I've just fixed that in gnulib with this commit:

http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=aec038e314bbf51c871eedef8b2fd8cad783cf3f

> Also: my initial patch was actually part of an effort to pick any
> low-hanging fruit I could find in simplifying grep's output code as
> preparatory work for adding output buffering to my multithreading patch set
> (which I am continuing to maintain/develop).  That in combination with the
> fact that I don't have access to a pre-C99 system to test things like this
> on means I actually might lean slightly toward keeping it as-is in
> preference to maintaining the existing code in an #ifdef block, but it's not
> a strong preference either way, so if the general consensus is toward using
> printf when possible that's OK with me.

I hope that within a year or so we will have enough evidence that it
is ok to remove that pre-C99-supporting code in grep.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]