[vlc-devel] [PATCH 3/3] demux/ttml: Convert_time: refactor redundant call to sscanf

Filip Roséen filip at atch.se
Wed Jul 27 07:42:03 CEST 2016


Given that the only difference between "%d:%d:%d,%d" and "%d:%d:%d.%d"
is the delimiter used between s1 and d1, a common format has replaced
the two that will accept both.

---
 modules/demux/ttml.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/modules/demux/ttml.c b/modules/demux/ttml.c
index c6e0616..0113923 100644
--- a/modules/demux/ttml.c
+++ b/modules/demux/ttml.c
@@ -165,8 +165,7 @@ static int Convert_time( int64_t *timing_value, const char *s )
     int d1 = 0;
 
     if ( sscanf( s, "%d.%ds", &s1, &d1) == 2 ||
-         sscanf( s, "%d:%d:%d,%d", &h1, &m1, &s1, &d1 ) == 4 ||
-         sscanf( s, "%d:%d:%d.%d", &h1, &m1, &s1, &d1 ) == 4 ||
+         sscanf( s, "%d:%d:%d%*[,.]%d", &h1, &m1, &s1, &d1 ) == 4 ||
          sscanf( s, "%d:%d:%d", &h1, &m1, &s1) == 3 )
     {
         (*timing_value) = ( (int64_t)h1 * 3600 * 1000 +
-- 
2.9.0



More information about the vlc-devel mailing list