bug#7325: new test failure due to non-portability of printf formats like %05.3s

2010-11-05 Thread Jim Meyering
Jim Meyering wrote:
> Paul Eggert wrote:
>> On 11/04/10 00:56, Jim Meyering wrote:
>>
>>> However, what about Eric's example?
>>>
>>>   $ src/stat-p -c '_%-0 010.4:X_' k  # yours
>>>   _234   _
>>>   $ src/stat-j -c '_%-0 010.4:X_' k  # mine
>>>   _0234  _
>>
>> That's simply an issue of whether the value is considered to be signed
>> or unsigned, and can be fixed by the patch at the end of this message.
>>
>> However, let me take a step back a minute.  Do users really want all
>> this functionality?  Personally, what I'd like to see is a single
>> format like this:
>>
>>%.3X
>>
>> that prints out the entire seconds since the Epoch, truncated
>> to millseconds.  That's simpler than what we require now:
>>
>>%X.%.3:X
>>
>> The changelogs suggest that we used to do things the simpler way,
>> but changed on Oct. 21.  I don't recall this being discussed: I
>
> It was due to portability concerns, since with coreutils-8.6,
> %X, %Y, etc. expanded to floating point values, and that broke
> backwards compatibility:
>
>   http://thread.gmane.org/gmane.comp.gnu.coreutils.general/161/focus=366
>
> However, enabling floating point output only when there is a ".PREC"
> part of the format sounds like a fine compromise.
> Sure, old scripts that used %.3X (expecting no ".") would break,
> but I doubt any such uses exist, since that notation did nothing useful.
>
> A patch would be most welcome.

Hi Paul,
Please let us know whether you are working on this.





bug#7331: Date command bug

2010-11-05 Thread Bob Proulx
Raymond Pete wrote:
> Thanks for the info Bob :-) I figured I missed something here.
> I see running my jobs just after midnight is probably not best.

I like running those types of calculations either at 12 noon or using
UTC.  Then the DST issues are avoided.

I also like using the 'date -R' format since it is RFC standard (used
in email and news) and unambiguous about timezones.  Otherwise I like
using "%F %T %z" for being compact, unambiguous, and sorts nicely.

I will go ahead and close the bug with this email then.

> Appreciate all the work you guys do!

The team enjoys hearing those nice words.  :-)

Bob





bug#7325: new test failure due to non-portability of printf formats like %05.3s

2010-11-05 Thread Paul Eggert
On 11/05/2010 11:34 AM, Jim Meyering wrote:

> Please let us know whether you are working on this.

Yes I am.  (So hard that I wasn't reading my email.  :-)
Please expect a patch soon, but it won't be tiny.





bug#7325: new test failure due to non-portability of printf formats like %05.3s

2010-11-05 Thread Paul Eggert
On 11/04/2010 11:34 PM, Jim Meyering wrote:
> Pádraig Brady wrote:
>> I still slightly prefer just using %.X as
>> it's backwards compat with older coreutils (excluding 8.6).
> 
> So do I.

I built that and tried it out, and found another problem that has been
annoying me for years in other programs: 'stat' prints out unnecessary
trailing zeros for time stamps, when the file system resolution is
coarser than nanosecond resolution.  So I figured I'd fix that too,
for 'stat' (other programs can be fixed later).  With this fix, %.X
outputs the time stamp but omits trailing zeros if it can infer that
the file system would always put zeros there.  If you want a specific
number of zeros, you can use something like %.3X or %.9X (or %.100X :-).

>From d37bad3d644a98887402b5398b7280701a7b7559 Mon Sep 17 00:00:00 2001
From: Paul Eggert 
Date: Fri, 5 Nov 2010 19:35:12 -0700
Subject: [PATCH] stat: use e.g. %.3X instead of %X.%3:X for sub-second precision

* NEWS: Document this.
* doc/coreutils.texi (stat invocation): Likewise.
* gl/lib/fstimeprec.c, gl/lib/fstimeprec.h, gl/modules/fstimeprec:
* gl/modules/fstimeprec-tests, gl/tests/test-fstimeprec.c:
New files.
* bootstrap.conf (gnulib_modules): Add fstimeprec.
* src/stat.c: Include fstimeprec.h.  Don't include xstrtol.h.
(decimal_point, decimal_point_len): New static vars.
(main): Initialize them.
(epoch_sec, out_ns): Remove.
(out_int, out_uint): Now returns whatever printf returned.
(out_minus_zero, out_epoch_secs): New functions.
(print_stat): Use out_epoch_sec instead of out_ns and epoch_sec.
(print_stat, print_it, usage): Remove the %:X-style formats.
* tests/misc/stat-nanoseconds: Set TZ=UTC0 to avoid problems
with weird time zones.  Use a time stamp near the Epoch so that we
don't have to worry about leap seconds.  Redo test cases to match
new behavior.
* tests/touch/60-seconds: Change %Y.%:Y to %.9Y, to adjust to
new behavior.
---
 NEWS|   10 +--
 bootstrap.conf  |1 +
 doc/coreutils.texi  |   37 
 gl/lib/fstimeprec.c |  178 +++
 gl/lib/fstimeprec.h |   22 +
 gl/modules/fstimeprec   |   24 +
 gl/modules/fstimeprec-tests |   10 ++
 gl/tests/test-fstimeprec.c  |   74 +++
 src/stat.c  |  218 ++-
 tests/misc/stat-nanoseconds |   25 +++--
 tests/touch/60-seconds  |2 +-
 11 files changed, 480 insertions(+), 121 deletions(-)
 create mode 100644 gl/lib/fstimeprec.c
 create mode 100644 gl/lib/fstimeprec.h
 create mode 100644 gl/modules/fstimeprec
 create mode 100644 gl/modules/fstimeprec-tests
 create mode 100644 gl/tests/test-fstimeprec.c

diff --git a/NEWS b/NEWS
index 3b9bea2..1e5a8db 100644
--- a/NEWS
+++ b/NEWS
@@ -20,16 +20,12 @@ GNU coreutils NEWS-*- 
outline -*-
   stat's %X, %Y, and %Z directives once again print only the integer
   part of seconds since the epoch.  This reverts a change from
   coreutils-8.6, that was deemed unnecessarily disruptive.  To obtain
-  the nanoseconds portion corresponding to %X, you may now use %:X.
-  I.e., to print the floating point number of seconds using maximum
-  precision, use this format string: %X.%:X.  Likewise for %Y, %Z and %W.
+  a full resolution time stamp for %X, use %.X; if you want (say) just
+  3 fractional digits, use %.3X.  Likewise for %Y and %Z.
 
   stat's new %W format directive would print floating point seconds.
   However, with the above change to %X, %Y and %Z, we've made %W work
-  the same way:  %W now expands to seconds since the epoch (or 0 when
-  not supported), and %:W expands to the nanoseconds portion, or to
-  0 if not supported.
-
+  the same way as the others.
 
 * Noteworthy changes in release 8.6 (2010-10-15) [stable]
 
diff --git a/bootstrap.conf b/bootstrap.conf
index 18ef914..5a6ebae 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -85,6 +85,7 @@ gnulib_modules="
   freopen
   freopen-safer
   fseeko
+  fstimeprec
   fsusage
   fsync
   ftello
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index be5999f..8dfb069 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -10707,37 +10707,36 @@ The valid @var{format} directives for files with 
@option{--format} and
 @item %U - User name of owner
 @item %w - Time of file birth, or @samp{-} if unknown
 @item %W - Time of file birth as seconds since Epoch, or @samp{0}
-...@item %:W - Time of file birth: nanoseconds remainder, or @samp{0}
 @item %x - Time of last access
 @item %X - Time of last access as seconds since Epoch
-...@item %:X - Time of last access: nanoseconds remainder
 @item %y - Time of last modification
 @item %Y - Time of last modification as seconds since Epoch
-...@item %:Y - Time of last modification: nanoseconds remainder
 @item %z - Time of last change
 @item %Z - Time of last change as seconds since Epoch
-...@item %:Z - Time of last change: nanoseconds remainder
 @end itemize
 
-Note