[vlc-commits] commit: Do not use obsolescent ctime(_r) ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Sat Sep 4 07:12:30 CEST 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Sep  4 08:09:54 2010 +0300| [f6cecfc93bd3b0fe10141d2f928b2a1da9ff4e19] | committer: Rémi Denis-Courmont 

Do not use obsolescent ctime(_r)

Use strftime() and localtime_r() instead.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f6cecfc93bd3b0fe10141d2f928b2a1da9ff4e19
---

 modules/control/http/mvar.c |   11 ++++-------
 src/input/vlmshell.c        |   13 ++++---------
 2 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/modules/control/http/mvar.c b/modules/control/http/mvar.c
index 9465019..33ba6dc 100644
--- a/modules/control/http/mvar.c
+++ b/modules/control/http/mvar.c
@@ -570,7 +570,7 @@ mvar_t *mvar_FileSetNew( intf_thread_t *p_intf, char *name,
         else
 #endif
         {
-            char psz_buf[26];
+            char psz_buf[20];
             char psz_tmp[strlen( psz_dir ) + 1 + strlen( psz_name ) + 1];
 
             sprintf( psz_tmp, "%s"DIR_SEP"%s", psz_dir, psz_name );
@@ -596,13 +596,10 @@ mvar_t *mvar_FileSetNew( intf_thread_t *p_intf, char *name,
             mvar_AppendNewVar( f, "size", psz_buf );
 
             /* FIXME memory leak FIXME */
-#   ifdef HAVE_CTIME_R
-            ctime_r( &stat_info.st_mtime, psz_buf );
+            struct tm tm;
+            strftime( psz_buf, sizeof( psz_buf ), "%F %H:%M:%S",
+                      localtime_r( &stat_info.st_mtime, &tm ) );
             mvar_AppendNewVar( f, "date", psz_buf );
-#   else
-            mvar_AppendNewVar( f, "date", ctime( &stat_info.st_mtime ) );
-#   endif
-
 #else
             mvar_AppendNewVar( f, "type", "unknown" );
             mvar_AppendNewVar( f, "size", "unknown" );
diff --git a/src/input/vlmshell.c b/src/input/vlmshell.c
index d84e38f..fba0774 100644
--- a/src/input/vlmshell.c
+++ b/src/input/vlmshell.c
@@ -1530,18 +1530,13 @@ static vlm_message_t *vlm_Show( vlm_t *vlm, vlm_media_sys_t *media,
             if( i_next_date > i_time )
             {
                 time_t i_date = (time_t) (i_next_date / 1000000) ;
+                struct tm tm;
+                char psz_date[32];
 
-#if !defined( UNDER_CE )
-#ifdef HAVE_CTIME_R
-                char psz_date[500];
-                ctime_r( &i_date, psz_date );
-#else
-                char *psz_date = ctime( &i_date );
-#endif
-
+                strftime( psz_date, sizeof(psz_date), "%F %H:%M:%S (%a)",
+                          localtime_r( &i_date, &tm ) );
                 vlm_MessageAdd( msg_schedule,
                                 vlm_MessageNew( "next launch", "%s", psz_date ) );
-#endif
             }
         }
 



More information about the vlc-commits mailing list