ratpoison-devel
[Top][All Lists]
Advanced

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

Re: [RP] cleaning up cmd_clock


From: Jonathan Walther
Subject: Re: [RP] cleaning up cmd_clock
Date: Fri, 13 Apr 2001 11:45:40 -0700 (PDT)

-----BEGIN PGP SIGNED MESSAGE-----

Ok, this patch fixes that.  I took out the error check for time()
for a very good reason:  look at how we invoke it.  The only possible
error condition for time() is if the pointer you pass it is out of the
area you can access; because of how we allocate it we will not get that
error.  Also, no matter what value you throw at it, ctime() knows what
to do.  All our bases are covered.

On Fri, 13 Apr 2001, shawn wrote:
> >Now you can see the date as well as time, and all the ugly
> >constants are gone.  It looks a lot cleaner too.  Patch here:
> Applied. The only problem is that newline at the end...

Index: src/actions.c
===================================================================
RCS file: /cvsroot/ratpoison/ratpoison/src/actions.c,v
retrieving revision 1.54
diff -b -U3 -r1.54 actions.c
- --- src/actions.c     2001/04/13 09:24:05     1.54
+++ src/actions.c       2001/04/13 19:01:44
@@ -701,21 +701,16 @@
 
 /* Show the current time on the bar. Thanks to Martin Samuelsson
    <address@hidden> for the patch. Thanks to Jonathan Walther
- -   <address@hidden> for making it pretty. */
+   <address@hidden> for making it pretty. */
 void
 cmd_clock (void *data)
 {
+  char *msg;
   time_t timep;
  
- -  timep = time(NULL);
- -  if(timep == ((time_t)-1))
- -    {
- -      PRINT_ERROR ("time() failed\n")
- -      return;
- -    }
+  message (msg = strndup(ctime((time(&timep), &timep)), 24));
 
- -  /* FIXME: There's an annoying newline at the end */
- -  message (ctime(&timep));
+  free(msg);
 }
 
 

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: noconv

iQCVAwUBOtdJVMK9HT/YfGeBAQEq7AP+L+cbK0oIryAuyCxSfFlxoTQKkYS64BXT
nlbU1zklTyzUINjSCYH3brVVqqRpZBUsqUx3TnKOlL7P1/lk1cmw8w4mtc0AY7fS
iALJOyVfb73xvtVzlfy/q92dX1ZhFbLn41qLS9XUMtEutmMTcGakGYy48h3lhfr1
wMweyJ0j1/I=
=ZGtr
-----END PGP SIGNATURE-----




reply via email to

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