[MPlayer-cvslog] r33601 - trunk/sub/vobsub.c

cboesch subversion at mplayerhq.hu
Sun Jun 12 12:55:24 CEST 2011


Author: cboesch
Date: Sun Jun 12 12:55:24 2011
New Revision: 33601

Log:
vobsub: simplify timestamp parsing.

Modified:
   trunk/sub/vobsub.c

Modified: trunk/sub/vobsub.c
==============================================================================
--- trunk/sub/vobsub.c	Sun Jun 12 12:41:49 2011	(r33600)
+++ trunk/sub/vobsub.c	Sun Jun 12 12:55:24 2011	(r33601)
@@ -693,55 +693,11 @@ static int vobsub_parse_id(vobsub_t *vob
 
 static int vobsub_parse_timestamp(vobsub_t *vob, const char *line)
 {
-    // timestamp: HH:MM:SS.mmm, filepos: 0nnnnnnnnn
-    const char *p;
     int h, m, s, ms;
     off_t filepos;
-    while (isspace(*line))
-        ++line;
-    p = line;
-    while (isdigit(*p))
-        ++p;
-    if (p - line != 2)
-        return -1;
-    h = atoi(line);
-    if (*p != ':')
-        return -1;
-    line = ++p;
-    while (isdigit(*p))
-        ++p;
-    if (p - line != 2)
-        return -1;
-    m = atoi(line);
-    if (*p != ':')
-        return -1;
-    line = ++p;
-    while (isdigit(*p))
-        ++p;
-    if (p - line != 2)
-        return -1;
-    s = atoi(line);
-    if (*p != ':')
-        return -1;
-    line = ++p;
-    while (isdigit(*p))
-        ++p;
-    if (p - line != 3)
-        return -1;
-    ms = atoi(line);
-    if (*p != ',')
-        return -1;
-    line = p + 1;
-    while (isspace(*line))
-        ++line;
-    if (strncmp("filepos:", line, 8))
-        return -1;
-    line += 8;
-    while (isspace(*line))
-        ++line;
-    if (! isxdigit(*line))
+    if (sscanf(line, " %02d:%02d:%02d:%03d, filepos: %09lx",
+               &h, &m, &s, &ms, &filepos) != 5)
         return -1;
-    filepos = strtol(line, NULL, 16);
     return vobsub_add_timestamp(vob, filepos, vob->delay + ms + 1000 * (s + 60 * (m + 60 * h)));
 }
 


More information about the MPlayer-cvslog mailing list