On 2011-03-21 20.24, Ted Unangst wrote:
> On Mon, Mar 21, 2011 at 7:04 AM, Benny Lofgren <bl-li...@lofgren.biz> wrote:
>> Realized I was sloppy with KNF. This diff is hopefully neater looking.
> 
> I like this, but 5 seconds is not enough.  I would have chosen at
> least an hour, for poorly synced NFS systems, if not a whole day.

New diff below with 24 hours grace period. You are right about NFS, that
scenario never even entered my mind... It makes perfect sense to me to
allow for around a day of time diff in that kind of environment.

> 
> Also // comments aren't really in vogue.  Just leave the comment out.
> 

Thanks, I got that from several other people as well. :-)  I skipped the
comment as you suggested and will keep it in mind in the future.


Regards,
/Benny

----8<--------8<--------8<--------8<--------8<---- (cut)
Index: print.c
===================================================================
RCS file: /cvs/src/bin/ls/print.c,v
retrieving revision 1.27
diff -u -r1.27 print.c
--- print.c     12 Sep 2010 20:16:29 -0000      1.27
+++ print.c     21 Mar 2011 20:37:41 -0000
@@ -235,6 +235,7 @@
 {
        int i;
        char *longstring;
+       time_t now = time(NULL);

        longstring = ctime(&ftime);
        for (i = 4; i < 11; ++i)
@@ -244,7 +245,7 @@
        if (f_sectime)
                for (i = 11; i < 24; i++)
                        (void)putchar(longstring[i]);
-       else if (ftime + SIXMONTHS > time(NULL))
+       else if (ftime > now - SIXMONTHS && ftime < now + SECSPERDAY)
                for (i = 11; i < 16; ++i)
                        (void)putchar(longstring[i]);
        else {
----8<--------8<--------8<--------8<--------8<---- (cut)

-- 
internetlabbet.se     / work:   +46 8 551 124 80      / "Words must
Benny Lvfgren        /  mobile: +46 70 718 11 90     /   be weighed,
                    /   fax:    +46 8 551 124 89    /    not counted."
                   /    email:  benny -at- internetlabbet.se

Reply via email to