]> git.sesse.net Git - vlc/commitdiff
* Fix a problem with empty subtitles with Subviewer subs
authorDerk-Jan Hartman <hartman@videolan.org>
Mon, 16 Aug 2004 00:45:24 +0000 (00:45 +0000)
committerDerk-Jan Hartman <hartman@videolan.org>
Mon, 16 Aug 2004 00:45:24 +0000 (00:45 +0000)
* fixed a line ending replace problem with subviewer subs
* single char subtitle lines should now work subviewer and subrip

modules/demux/subtitle.c

index 20572f5e4243444674664e2475d160e41ce3dffd..3746d8285cd47e2ca8e4cb837aa5df62de603cbb 100644 (file)
@@ -855,7 +855,7 @@ static int  ParseSubRip( demux_t *p_demux, subtitle_t *p_subtitle )
                 }
 
                 i_len = strlen( s );
-                if( i_len <= 1 )
+                if( i_len <= 0 )
                 {
                     /* empty line -> end of this subtitle */
                     buffer_text[__MAX( i_buffer_text - 1, 0 )] = '\0';
@@ -949,7 +949,7 @@ static int  ParseSubViewer( demux_t *p_demux, subtitle_t *p_subtitle )
                 }
 
                 i_len = strlen( s );
-                if( i_len <= 1 )
+                if( i_len <= 0 )
                 {
                     /* empty line -> end of this subtitle */
                     buffer_text[__MAX( i_buffer_text - 1, 0 )] = '\0';
@@ -957,14 +957,15 @@ static int  ParseSubViewer( demux_t *p_demux, subtitle_t *p_subtitle )
                     p_subtitle->i_stop = i_stop;
 
                     /* replace [br] by \n */
-                    for( i = 0; i < strlen( buffer_text ) - 3; i++ )
+                    for( i = 0; i < i_buffer_text - 3; i++ )
                     {
                         if( buffer_text[i] == '[' && buffer_text[i+1] == 'b' &&
                             buffer_text[i+2] == 'r' && buffer_text[i+3] == ']' )
                         {
                             char *temp = buffer_text + i + 1;
                             buffer_text[i] = '\n';
-                            memmove( temp, temp+3, strlen( temp-3 ));
+                            memmove( temp, temp+3, strlen( temp ) -3 );
+                            temp[strlen( temp )-3] = '\0';
                         }
                     }
                     p_subtitle->psz_text = strdup( buffer_text );