[vlc-devel] commit: msecstotimestr: fix negative numbers handling ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat Feb 20 18:44:11 CET 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Feb 20 19:42:01 2010 +0200| [6d951bda65d9048a15368b67381c1d3d6c5e4430] | committer: Rémi Denis-Courmont 

msecstotimestr: fix negative numbers handling

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

 src/misc/mtime.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/misc/mtime.c b/src/misc/mtime.c
index e6f9da6..b85c7ef 100644
--- a/src/misc/mtime.c
+++ b/src/misc/mtime.c
@@ -127,6 +127,13 @@ char *mstrtime( char *psz_buffer, mtime_t date )
  */
 char *secstotimestr( char *psz_buffer, int32_t i_seconds )
 {
+    if( unlikely(i_seconds < 0) )
+    {
+        secstotimestr( psz_buffer + 1, -i_seconds );
+        *psz_buffer = '-';
+        return psz_buffer;
+    }
+
     div_t d;
 
     d = div( i_seconds, 60 );
@@ -137,8 +144,8 @@ char *secstotimestr( char *psz_buffer, int32_t i_seconds )
         snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%u:%02u:%02u",
                  d.quot, d.rem, i_seconds );
     else
-         snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%02u:%02u",
-                   d.rem, i_seconds );
+        snprintf( psz_buffer, MSTRTIME_MAX_SIZE, "%02u:%02u",
+                  d.rem, i_seconds );
     return psz_buffer;
 }
 




More information about the vlc-devel mailing list