From ca9aa7596094c4af094edb7eb63648570d53c100 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 6 Nov 2010 13:57:08 -0700 Subject: stat: do not rely on undefined behavior in printf formats * src/stat.c (digits, printf_flags): New static vars. (make_format): New function. (out_string, out_int, out_uint, out_uint_o, out_uint_x): (out_minus_zero): Use it to avoid undefined behavior when invoking printf. (print_it): Check for invalid conversion specifications such as %..X and %1-X, which would otherwise rely on undefined behavior when invoking printf. * tests/misc/stat-nanoseconds: Check that the "I" printf flag doesn't mess up in the C locale, as it formerly did on non-GNU hosts. --- tests/misc/stat-nanoseconds | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/misc/stat-nanoseconds b/tests/misc/stat-nanoseconds index 0f41eb045..cd2159644 100755 --- a/tests/misc/stat-nanoseconds +++ b/tests/misc/stat-nanoseconds @@ -39,6 +39,7 @@ test "$(stat -c %13.6X k)" = ' 67413.023456' || fail=1 test "$(stat -c %013.6X k)" = 067413.023456 || fail=1 test "$(stat -c %-13.6X k)" = '67413.023456 ' || fail=1 test "$(stat -c %18.10X k)" = ' 67413.0234567890' || fail=1 +test "$(stat -c %I18.10X k)" = ' 67413.0234567890' || fail=1 test "$(stat -c %018.10X k)" = 0067413.0234567890 || fail=1 test "$(stat -c %-18.10X k)" = '67413.0234567890 ' || fail=1 -- cgit v1.2.3-70-g09d2