[vlc-commits] zvbi: strip leading/end whitespaces from text subtitles

Ilkka Ollakka git at videolan.org
Tue Nov 12 17:00:18 CET 2013


vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Tue Nov 12 15:32:14 2013 +0200| [d3d8a8c097168cde4d2dc33bf9681436dd936851] | committer: Ilkka Ollakka

zvbi: strip leading/end whitespaces from text subtitles

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d3d8a8c097168cde4d2dc33bf9681436dd936851
---

 bindings/python      |    2 +-
 modules/codec/zvbi.c |   19 +++++++++++++++----
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/bindings/python b/bindings/python
index 391f638..e4ce04b 160000
--- a/bindings/python
+++ b/bindings/python
@@ -1 +1 @@
-Subproject commit 391f6383e9568209c3242468c4179645708bdc39
+Subproject commit e4ce04bca758d81550894dc88351d96526723278
diff --git a/modules/codec/zvbi.c b/modules/codec/zvbi.c
index ffc06cb..7f18f08 100644
--- a/modules/codec/zvbi.c
+++ b/modules/codec/zvbi.c
@@ -42,6 +42,8 @@
 # include "config.h"
 #endif
 
+#include <ctype.h>
+
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <assert.h>
@@ -414,15 +416,24 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
     if( p_sys->b_text )
     {
         unsigned int i_textsize = 7000;
-        int i_total;
+        int i_total,offset;
         char p_text[i_textsize+1];
 
         i_total = vbi_print_page_region( &p_page, p_text, i_textsize,
                         "UTF-8", 0, 0, 0, i_first_row, p_page.columns, i_num_rows );
-        p_text[i_total] = '\0';
-        p_spu->p_region->psz_text = strdup( p_text );
+
+        for( offset=1; offset<i_total && isspace( p_text[i_total-offset ] ); offset++)
+           p_text[i_total-offset] = '\0';
+
+        i_total -= offset;
+
+        offset=0;
+        while( offset < i_total && isspace( p_text[offset] ) )
+           offset++;
+
+        p_spu->p_region->psz_text = strdup( &p_text[offset] );
 #ifdef ZVBI_DEBUG
-        msg_Info( p_dec, "page %x-%x(%d)\n%s", p_page.pgno, p_page.subno, i_total, p_text );
+        msg_Info( p_dec, "page %x-%x(%d)\n\"%s\"", p_page.pgno, p_page.subno, i_total, &p_text[offset] );
 #endif
     }
     else



More information about the vlc-commits mailing list