From 09b7f775fb4db8129eabac5bd328576872eacf41 Mon Sep 17 00:00:00 2001 From: Gildas Bazin Date: Tue, 26 Mar 2002 22:02:32 +0000 Subject: [PATCH] * changed the behaviour of the config file: - now all the config options are saved. config options which have no default value are also saved in the config file but as an empty string. - config_LoadConfigFile will ignore empty config options, which also means we cannot pass an empty string as a config option. (this shouldn't matter anyway) --- src/misc/configuration.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/misc/configuration.c b/src/misc/configuration.c index 94a8293104..8ef4c982b2 100644 --- a/src/misc/configuration.c +++ b/src/misc/configuration.c @@ -2,7 +2,7 @@ * configuration.c management of the modules configuration ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: configuration.c,v 1.8 2002/03/21 07:11:57 gbazin Exp $ + * $Id: configuration.c,v 1.9 2002/03/26 22:02:32 gbazin Exp $ * * Authors: Gildas Bazin * @@ -373,6 +373,8 @@ int config_LoadConfigFile( const char *psz_module_name ) { case MODULE_CONFIG_ITEM_BOOL: case MODULE_CONFIG_ITEM_INTEGER: + if( !*psz_option_value ) + break; /* ignore empty option */ p_module->p_config[i].i_value = atoi( psz_option_value); intf_WarnMsg( 7, "config: found <%s> option %s=%i", @@ -382,6 +384,9 @@ int config_LoadConfigFile( const char *psz_module_name ) break; default: + if( !*psz_option_value ) + break; /* ignore empty option */ + vlc_mutex_lock( p_module->p_config[i].p_lock ); /* free old string */ @@ -593,20 +598,19 @@ int config_SaveConfigFile( const char *psz_module_name ) case MODULE_CONFIG_ITEM_BOOL: case MODULE_CONFIG_ITEM_INTEGER: if( p_module->p_config[i].psz_text ) - fprintf( file, "# %s\n", p_module->p_config[i].psz_text ); + fprintf( file, "# %s %s\n", p_module->p_config[i].psz_text, + MODULE_CONFIG_ITEM_BOOL?"":"" ); fprintf( file, "%s=%i\n", p_module->p_config[i].psz_name, p_module->p_config[i].i_value ); break; default: - if( p_module->p_config[i].psz_value ) - { - if( p_module->p_config[i].psz_text ) - fprintf( file, "# %s\n", - p_module->p_config[i].psz_text ); - fprintf( file, "%s=%s\n", p_module->p_config[i].psz_name, - p_module->p_config[i].psz_value ); - } + if( p_module->p_config[i].psz_text ) + fprintf( file, "# %s \n", + p_module->p_config[i].psz_text ); + fprintf( file, "%s=%s\n", p_module->p_config[i].psz_name, + p_module->p_config[i].psz_value? + p_module->p_config[i].psz_value:"" ); } } -- 2.39.2