From: RĂ©mi Denis-Courmont Date: Wed, 3 Jan 2007 22:19:44 +0000 (+0000) Subject: Some cleanup. Use strlen(). X-Git-Tag: 0.9.0-test0~8903 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=7fb3ea1b63173ac5d4c9c771b6bf1fa9e73ad66c;p=vlc Some cleanup. Use strlen(). --- diff --git a/src/misc/modules.c b/src/misc/modules.c index b22a48209b..701463cff6 100644 --- a/src/misc/modules.c +++ b/src/misc/modules.c @@ -503,54 +503,33 @@ module_t * __module_Need( vlc_object_t *p_this, const char *psz_capability, if( i_shortcuts > 0 ) { vlc_bool_t b_trash; - int i_dummy, i_short = i_shortcuts; - char *psz_name = psz_shortcuts; + const char *psz_name = psz_shortcuts; /* Let's drop modules with a <= 0 score (unless they are * explicitly requested) */ b_trash = p_module->i_score <= 0; - while( i_short > 0 ) + for( unsigned i_short = i_shortcuts; i_short > 0; i_short-- ) { - for( i_dummy = 0; p_module->pp_shortcuts[i_dummy]; i_dummy++ ) + for( unsigned i = 0; p_module->pp_shortcuts[i]; i++ ) { - if( !strcasecmp( psz_name, - p_module->pp_shortcuts[i_dummy] ) ) + if( !strcasecmp( psz_name, p_module->pp_shortcuts[i] ) ) { /* Found it */ - b_trash = VLC_FALSE; i_shortcut_bonus = i_short * 10000; - break; + goto found_shortcut; } } - if( i_shortcut_bonus ) - { - /* We found it... remember ? */ - break; - } - /* Go to the next shortcut... This is so lame! */ - while( *psz_name ) - { - psz_name++; - } - psz_name++; - i_short--; + psz_name += strlen( psz_name ) + 1; } /* If we are in "strict" mode and we couldn't * find the module in the list of provided shortcuts, * then kick the bastard out of here!!! */ - if( i_short == 0 && b_strict ) - { - b_trash = VLC_TRUE; - } - - if( b_trash ) - { + if( b_strict ) continue; - } } /* If we didn't require a shortcut, trash <= 0 scored plugins */ else if( p_module->i_score <= 0 ) @@ -558,6 +537,8 @@ module_t * __module_Need( vlc_object_t *p_this, const char *psz_capability, continue; } +found_shortcut: + /* Special case: test if we requested a particular intf plugin */ if( !i_shortcuts && p_module->psz_program && !strcmp( psz_capability, "interface" ) @@ -636,8 +617,10 @@ module_t * __module_Need( vlc_object_t *p_this, const char *psz_capability, { #ifdef HAVE_DYNAMIC_PLUGINS /* Make sure the module is loaded in mem */ - module_t *p_module = p_tmp->p_module->b_submodule ? - (module_t *)p_tmp->p_module->p_parent : p_tmp->p_module; + module_t *p_module = p_tmp->p_module; + if( p_module->b_submodule ) + p_module = (module_t *)p_module->p_parent; + if( !p_module->b_builtin && !p_module->b_loaded ) { module_t *p_new_module =