bug-coreutils
[Top][All Lists]
Advanced

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

Re: "pr -D FORMAT" fixes, to match "date +FORMAT"


From: Jim Meyering
Subject: Re: "pr -D FORMAT" fixes, to match "date +FORMAT"
Date: Sun, 20 Mar 2005 23:22:09 +0100

Paul Eggert <address@hidden> wrote:
...
>    if (tm == NULL)
>      {
> -      buf = xmalloc (INT_BUFSIZE_BOUND (long int));
> -      sprintf (buf, "%ld", (long int) st.st_mtime);
> +      buf = xmalloc (INT_BUFSIZE_BOUND (long int)
> +                  + MAX (10, INT_BUFSIZE_BOUND (int)));
> +      sprintf (buf, "%ld.9d", (long int) s, ns);

I've just corrected this:

It looks non-trivial to exercise this one.  Of course, it's easy to
exercise in a debugger, but do you know how to create a file with
e.g. 64-bit st_mtime so that makes localtime fails?  I tried using a
very large value on Solaris 5.9, but utime fails with EOVERFLOW (which
isn't mentioned in Solaris man pages as one of the ways utime may fail).
utimes works the same way.

2005-03-20  Jim Meyering  <address@hidden>

        * src/pr.c (init_header): Add missing `%' in new format string.
        (init_header): Use zero-filled `.%09d' format, not space-filled `.%9d'.

Index: src/pr.c
===================================================================
RCS file: /fetish/cu/src/pr.c,v
retrieving revision 1.132
retrieving revision 1.134
diff -u -p -r1.132 -r1.134
--- src/pr.c    20 Mar 2005 18:40:40 -0000      1.132
+++ src/pr.c    20 Mar 2005 19:53:30 -0000      1.134
@@ -1693,7 +1693,7 @@ init_header (char *filename, int desc)
     {
       buf = xmalloc (INT_BUFSIZE_BOUND (long int)
                     + MAX (10, INT_BUFSIZE_BOUND (int)));
-      sprintf (buf, "%ld.9d", (long int) s, ns);
+      sprintf (buf, "%ld.%09d", (long int) s, ns);
     }
   else
     {




reply via email to

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