[vlc-devel] commit: Don't rely on scanf when parsing floats from files ( Rémi Denis-Courmont )

git version control git at videolan.org
Wed May 21 21:11:47 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rem at videolan.org> | Wed May 21 22:07:22 2008 +0300| [a2c338bb861ca781457ae23c8a36215a6ce82ea6]

Don't rely on scanf when parsing floats from files

(well, you _can_ but you'd need to use uselocale() then)

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

 modules/demux/subtitle.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/modules/demux/subtitle.c b/modules/demux/subtitle.c
index f65575f..d1e142f 100644
--- a/modules/demux/subtitle.c
+++ b/modules/demux/subtitle.c
@@ -1468,8 +1468,10 @@ static int ParseMPSub( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
             free( psz_temp );
         }
         /* Data Lines */
-        if( sscanf (s, "%f %f", &f1, &f2 ) == 2 )
+        f1 = us_strtod( s, &psz_temp );
+        if( *psz_temp )
         {
+            f2 = us_strtod( psz_temp, NULL );
             mpsub_total += f1 * mpsub_factor;
             p_subtitle->i_start = (int64_t)(10000.0 * mpsub_total);
             mpsub_total += f2 * mpsub_factor;




More information about the vlc-devel mailing list