]> git.sesse.net Git - vlc/blobdiff - src/config/chain.c
Change the "intf-show" variable into a toggle.
[vlc] / src / config / chain.c
index 88ad2831a075bb03b96aaf5122f455d571e078ad..80b86f4228cc5f9dc8f91957342b64c016cecd87 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <vlc_common.h>
 #include "libvlc.h"
+#include <vlc_charset.h>
 
 #include "vlc_interface.h"
 
@@ -185,7 +186,7 @@ char *config_ChainCreate( char **ppsz_name, config_chain_t **pp_cfg,
 
     if( !psz_chain )
         return NULL;
-    psz_chain += strspn( psz_chain, " \t" );
+    SKIPSPACE( psz_chain );
 
     /* Look for parameter (a {...} or :...) or end of name (space or nul) */
     len = strcspn( psz_chain, "{: \t" );
@@ -193,14 +194,14 @@ char *config_ChainCreate( char **ppsz_name, config_chain_t **pp_cfg,
     psz_chain += len;
 
     /* Parse the parameters */
-    psz_chain += strspn( psz_chain, " \t" );
+    SKIPSPACE( psz_chain );
     if( *psz_chain == '{' )
     {
         /* Parse all name=value[,] elements */
         do
         {
             psz_chain++; /* skip previous delimiter */
-            psz_chain += strspn( psz_chain, " \t" );
+            SKIPSPACE( psz_chain );
 
             /* Look for the end of the name (,={}_space_) */
             len = strcspn( psz_chain, "=,{} \t" );
@@ -220,17 +221,17 @@ char *config_ChainCreate( char **ppsz_name, config_chain_t **pp_cfg,
             pp_next = &p_cfg->p_next;
 
             /* Extract the option value */
-            psz_chain += strspn( psz_chain, " \t" );
+            SKIPSPACE( psz_chain );
             if( strchr( "={", *psz_chain ) )
             {
                 p_cfg->psz_value = ChainGetValue( &psz_chain );
-                psz_chain += strspn( psz_chain, " \t" );
+                SKIPSPACE( psz_chain );
             }
         }
         while( !memchr( "}", *psz_chain, 2 ) );
 
         if( *psz_chain ) psz_chain++; /* skip '}' */;
-        psz_chain += strspn( psz_chain, " \t" );
+        SKIPSPACE( psz_chain );
     }
 
     if( *psz_chain == ':' )
@@ -255,8 +256,9 @@ void config_ChainDestroy( config_chain_t *p_cfg )
     }
 }
 
-void __config_ChainParse( vlc_object_t *p_this, const char *psz_prefix,
-                          const char *const *ppsz_options, config_chain_t *cfg )
+#undef config_ChainParse
+void config_ChainParse( vlc_object_t *p_this, const char *psz_prefix,
+                        const char *const *ppsz_options, config_chain_t *cfg )
 {
     if( psz_prefix == NULL ) psz_prefix = "";
     size_t plen = 1 + strlen( psz_prefix );
@@ -340,13 +342,6 @@ void __config_ChainParse( vlc_object_t *p_this, const char *psz_prefix,
                  * modules so i'll do it later */
                 continue;
             }
-            if( p_conf->psz_oldname
-             && !strcmp( p_conf->psz_oldname, name ) )
-            {
-                 psz_name = p_conf->psz_name;
-                 msg_Warn( p_this, "Option %s is obsolete. Use %s instead.",
-                           name, psz_name );
-            }
         }
         /* </Check if the option is deprecated> */
 
@@ -359,8 +354,6 @@ void __config_ChainParse( vlc_object_t *p_this, const char *psz_prefix,
             continue;
         }
 
-        i_type &= CONFIG_ITEM;
-
         if( i_type != VLC_VAR_BOOL && cfg->psz_value == NULL )
         {
             msg_Warn( p_this, "missing value for option %s", cfg->psz_name );
@@ -382,10 +375,9 @@ void __config_ChainParse( vlc_object_t *p_this, const char *psz_prefix,
                                     NULL, 0 );
                 break;
             case VLC_VAR_FLOAT:
-                val.f_float = atof( cfg->psz_value ? cfg->psz_value : "0" );
+                val.f_float = us_atof( cfg->psz_value ? cfg->psz_value : "0" );
                 break;
             case VLC_VAR_STRING:
-            case VLC_VAR_MODULE:
                 val.psz_string = cfg->psz_value;
                 break;
             default:
@@ -416,7 +408,8 @@ config_chain_t *config_ChainDuplicate( const config_chain_t *p_src )
 {
     config_chain_t *p_dst = NULL;
     config_chain_t **pp_last = &p_dst;
-    while( p_src )
+
+    for( ; p_src != NULL; p_src = p_src->p_next )
     {
         config_chain_t *p = malloc( sizeof(*p) );
         if( !p )
@@ -449,32 +442,23 @@ char *config_StringUnescape( char *psz_string )
     return psz_string;
 }
 
-char *config_StringEscape( const char *psz_string )
+char *config_StringEscape( const char *str )
 {
-    char *psz_return;
-    char *psz_dst;
-    int i_escape;
+    size_t length = 0;
 
-    if( !psz_string )
+    if( str == NULL )
         return NULL;
 
-    i_escape = 0;
-    for( const char *p = psz_string; *p; p++ )
-    {
-        if( IsEscapeNeeded( *p ) )
-            i_escape++;
-    }
+    for( const char *p = str; *p; p++ )
+        length += IsEscapeNeeded( *p ) ? 2 : 1;
 
-    psz_return = psz_dst = malloc( strlen( psz_string ) + i_escape + 1 );
-    for( const char *p = psz_string; *p; p++ )
+    char *ret = xmalloc( length + 1 ), *dst = ret;
+    for( const char *p = str; *p; p++ )
     {
         if( IsEscapeNeeded( *p ) )
-            *psz_dst++ = '\\';
-        *psz_dst++ = *p;
+            *dst++ = '\\';
+        *dst++ = *p;
     }
-    *psz_dst = '\0';
-
-    return psz_return;
+    *dst = '\0';;
+    return ret;
 }
-
-