diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2016-11-19 02:49:15 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2016-11-19 02:50:59 -0800 |
commit | 575bdb1bc65d0aa73df127ec1bf70ab6ec3db174 (patch) | |
tree | 8d0cb596c9c2654f2c0d6055978b17ec6f4e6116 | |
parent | 928af46ede5d5bd3b564466042531d57b0e506bf (diff) | |
download | grep-575bdb1bc65d0aa73df127ec1bf70ab6ec3db174.tar.gz |
grep: simplify by using PRIuMAX
* configure.ac (HAVE_PRINTF_C99_SIZES): Remove; no longer needed.
* src/grep.c (print_offset): Simplify (Bug#24451).
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | src/grep.c | 26 |
2 files changed, 1 insertions, 31 deletions
diff --git a/configure.ac b/configure.ac index 0dd4d849..8a20317e 100644 --- a/configure.ac +++ b/configure.ac @@ -206,12 +206,6 @@ fi gl_FUNC_PCRE -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 - case $host_os in mingw*) suffix=w32 ;; *) suffix=posix ;; @@ -1084,32 +1084,8 @@ print_sep (char sep) static void print_offset (uintmax_t pos, const char *color) { -#if !HAVE_PRINTF_C99_SIZES - /* Do not rely on printf to print pos, since uintmax_t may be longer - than long, and long long is not portable. */ - - int min_width = offset_width; - char buf[sizeof pos * CHAR_BIT]; - char *p = buf + sizeof buf; - - do - { - *--p = '0' + pos % 10; - --min_width; - } - while ((pos /= 10) != 0); - - /* Do this to maximize the probability of alignment across lines. */ - while (--min_width >= 0) - *--p = ' '; -#endif /* !HAVE_PRINTF_C99_SIZES */ - pr_sgr_start_if (color); -#if HAVE_PRINTF_C99_SIZES - printf_errno ("%*ju", offset_width, pos); -#else - fwrite_errno (p, 1, buf + sizeof buf - p); -#endif + printf_errno ("%*"PRIuMAX, offset_width, pos); pr_sgr_end_if (color); } |