summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2010-11-06 13:57:08 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2010-11-06 18:09:44 -0700
commitca9aa7596094c4af094edb7eb63648570d53c100 (patch)
treedb5f45604c3bbdcf1b0cb2e68fdcd804a682bc2a /tests
parent6c058b2dabe2e577d56e8c2c82cec550ff82f085 (diff)
downloadcoreutils-ca9aa7596094c4af094edb7eb63648570d53c100.tar.xz
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.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/misc/stat-nanoseconds1
1 files changed, 1 insertions, 0 deletions
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