summaryrefslogtreecommitdiff
path: root/playlist.c
diff options
context:
space:
mode:
authorGravatar Igor Murzov <igor@gplsoft.org>2009-12-26 17:55:04 +0300
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-12-27 15:13:54 +0100
commit94dd735f3c45b43ca00eaba4f22ef8440259e142 (patch)
tree121bcaf28cb2db7224e669982f1f209aba369954 /playlist.c
parent3218e5d52cd775861499db85258c0d8910cbd513 (diff)
allow more than two digits in minutes field in pl_cue_parse_time()
Diffstat (limited to 'playlist.c')
-rw-r--r--playlist.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/playlist.c b/playlist.c
index f39cddca..36a47b55 100644
--- a/playlist.c
+++ b/playlist.c
@@ -127,17 +127,21 @@ pl_get_value_from_cue (const char *p, int sz, char *out) {
static float
pl_cue_parse_time (const char *p) {
- int len = strnlen(p, 9);
- // should be in 'mm:ss:ff' format, so only len = 8 is acceptable
- if (len != 8) {
+ char *endptr;
+ long mins = strtol(p, &endptr, 10);
+ if (endptr - p < 2 || *endptr != ':') {
return -1;
}
- if (p[2] != ':' || p[5] != ':') {
+ p = endptr + 1;
+ long sec = strtol(p, &endptr, 10);
+ if (endptr - p != 2 || *endptr != ':') {
+ return -1;
+ }
+ p = endptr + 1;
+ long frm = strtol(p, &endptr, 10);
+ if (endptr - p != 2 || *endptr != '\0') {
return -1;
}
- int mins = atoi (p);
- int sec = atoi (p + 3);
- int frm = atoi (p + 5);
return mins * 60.f + sec + frm / 75.f;
}