changeset 33905:c0cb8c5e7fdb

Fix reading of aqr/subrip09 subtitles. NULL return would indicate EOF, thus the "clear subtitle" entries would cause sub file parsing to stop. In addition the wrong sub end times would be used with CONFIG_SORTSUB.
author reimar
date Mon, 15 Aug 2011 20:19:39 +0000
parents 9184861c8bcd
children 3c172a874b4b
files sub/subreader.c
diffstat 1 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/sub/subreader.c	Mon Aug 15 20:05:09 2011 +0000
+++ b/sub/subreader.c	Mon Aug 15 20:19:39 2011 +0000
@@ -790,6 +790,7 @@
 static subtitle *sub_read_line_aqt(stream_t *st,subtitle *current, int utf16) {
     char line[LINE_LEN+1];
 
+retry:
     while (1) {
     // try to locate next subtitle
         if (!stream_read_line (st, line, LINE_LEN, utf16))
@@ -799,6 +800,7 @@
     }
 
 #ifdef CONFIG_SORTSUB
+    if (!previous_sub_end)
     previous_sub_end = (current->start) ? current->start - 1 : 0;
 #else
     if (previous_aqt_sub != NULL)
@@ -821,13 +823,11 @@
         return ERR;
 
     if (!strlen(current->text[0]) && !strlen(current->text[1])) {
-#ifdef CONFIG_SORTSUB
-	previous_sub_end = 0;
-#else
+#ifndef CONFIG_SORTSUB
 	// void subtitle -> end of previous marked and exit
 	previous_aqt_sub = NULL;
 #endif
-	return NULL;
+	goto retry;
 	}
 
     return current;
@@ -842,6 +842,7 @@
     int a1,a2,a3;
     int len;
 
+retry:
     while (1) {
     // try to locate next subtitle
         if (!stream_read_line (st, line, LINE_LEN, utf16))
@@ -853,6 +854,7 @@
     current->start = a1*360000+a2*6000+a3*100;
 
 #ifdef CONFIG_SORTSUB
+    if (!previous_sub_end)
     previous_sub_end = (current->start) ? current->start - 1 : 0;
 #else
     if (previous_subrip09_sub != NULL)
@@ -870,13 +872,11 @@
         return ERR;
 
     if (!strlen(current->text[0]) && current->lines <= 1) {
-#ifdef CONFIG_SORTSUB
-	previous_sub_end = 0;
-#else
+#ifndef CONFIG_SORTSUB
 	// void subtitle -> end of previous marked and exit
 	previous_subrip09_sub = NULL;
 #endif
-	return NULL;
+	goto retry;
 	}
 
     return current;