Don't use %f in HTTP interface (Closes:#584)
authorClément Stenac <zorglub@videolan.org>
Sat, 18 Mar 2006 10:14:40 +0000 (10:14 +0000)
committerClément Stenac <zorglub@videolan.org>
Sat, 18 Mar 2006 10:14:40 +0000 (10:14 +0000)
modules/control/http/macro.c
modules/control/http/rpn.c

index d6743fd..46b3f2f 100644 (file)
@@ -687,6 +687,7 @@ void E_(MacroDo)( httpd_file_sys_t *p_args,
             int     i;
             float   f;
             char    *psz;
             int     i;
             float   f;
             char    *psz;
+            lldiv_t div;
 
             if( *m->param1  == '\0' )
             {
 
             if( *m->param1  == '\0' )
             {
@@ -701,7 +702,9 @@ void E_(MacroDo)( httpd_file_sys_t *p_args,
                     break;
                 case MVLC_FLOAT:
                     f = config_GetFloat( p_intf, m->param1 );
                     break;
                 case MVLC_FLOAT:
                     f = config_GetFloat( p_intf, m->param1 );
-                    sprintf( value, "%f", f );
+                    div = lldiv( f * 1000000 , 1000000 );
+                    sprintf( value, I64Fd".%06u", div.quot,
+                            (unsigned int)div.rem );
                     break;
                 case MVLC_STRING:
                     psz = config_GetPsz( p_intf, m->param1 );
                     break;
                 case MVLC_STRING:
                     psz = config_GetPsz( p_intf, m->param1 );
index a8f1a10..5d80561 100644 (file)
@@ -694,7 +694,9 @@ void E_(EvaluateRPN)( intf_thread_t *p_intf, mvar_t  *vars,
                 case VLC_VAR_FLOAT:
                 {
                     char psz_value[20];
                 case VLC_VAR_FLOAT:
                 {
                     char psz_value[20];
-                    snprintf( psz_value, sizeof(psz_value), "%f", val.f_float );
+                    lldiv_t value = lldiv( val.f_float * 1000000, 1000000 );
+                    snprintf( psz_value, sizeof(psz_value), I64Fd".%06u",
+                                    value.quot, (unsigned int)value.rem );
                     E_(SSPush)( st, psz_value );
                     break;
                 }
                     E_(SSPush)( st, psz_value );
                     break;
                 }
@@ -788,8 +790,10 @@ void E_(EvaluateRPN)( intf_thread_t *p_intf, mvar_t  *vars,
             case VLC_VAR_FLOAT:
             {
                 char psz_string[20];
             case VLC_VAR_FLOAT:
             {
                 char psz_string[20];
-                snprintf( psz_string, sizeof(psz_string), "%f",
-                          config_GetFloat( p_intf, psz_variable ) );
+                lldiv_t value = lldiv( config_GetFloat( p_intf, psz_variable )
+                                       * 1000000, 1000000 );
+                snprintf( psz_string, sizeof(psz_string), I64Fd".%06u",
+                          value.quot, (unsigned int)value.rem );
                 E_(SSPush)( st, psz_string );
                 break;
             }
                 E_(SSPush)( st, psz_string );
                 break;
             }