[vlc-devel] commit: Accept partial matches with -p <module name> (aka --module ...) ( Antoine Cellerier )

git version control git at videolan.org
Tue Sep 2 01:29:04 CEST 2008


vlc | branch: master | Antoine Cellerier <dionoea at videolan.org> | Tue Sep  2 01:29:38 2008 +0200| [884122a7d6cb1d1b48dc9bf52ce89c114462997a] | committer: Antoine Cellerier 

Accept partial matches with -p <module name> (aka --module ...)
Old behavior is still available by prefixing the module name with an
equal sign. For example "vlc -p ts --advanced" returns help on the mux_ts,
vod_rtsp, ts and dvb (aka atsc) modules while "vlc -p '=ts' --advanced"
returns help on the mux_ts (aka ts) and ts modules.

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

 src/libvlc-module.c |    3 ++-
 src/libvlc.c        |   22 +++++++++++++---------
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index 5bf3336..bc432b0 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -2508,7 +2508,8 @@ vlc_module_begin();
     N_("print a list of available modules with extra detail")
 #define MODULE_TEXT \
     N_("print help on a specific module (can be combined with --advanced " \
-       "and --help-verbose)")
+       "and --help-verbose). Prefix the module name with = for strict" \
+       "matches.")
 #define IGNORE_CONFIG_TEXT \
     N_("no configuration option will be loaded nor saved to config file")
 #define SAVE_CONFIG_TEXT \
diff --git a/src/libvlc.c b/src/libvlc.c
index fd8f1d6..ca2dd48 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -152,7 +152,7 @@ static void SetLanguage   ( char const * );
 static inline int LoadMessages (void);
 static int  GetFilenames  ( libvlc_int_t *, int, const char *[] );
 static void Help          ( libvlc_int_t *, char const *psz_help_name );
-static void Usage         ( libvlc_int_t *, char const *psz_module_name );
+static void Usage         ( libvlc_int_t *, char const *psz_search );
 static void ListModules   ( libvlc_int_t *, bool );
 static void Version       ( void );
 
@@ -1297,8 +1297,8 @@ static void Help( libvlc_int_t *p_this, char const *psz_help_name )
     if( psz_help_name && !strcmp( psz_help_name, "help" ) )
     {
         utf8_fprintf( stdout, vlc_usage, p_this->psz_object_name );
-        Usage( p_this, "help" );
-        Usage( p_this, "main" );
+        Usage( p_this, "=help" );
+        Usage( p_this, "=main" );
         print_help_on_full_help();
     }
     else if( psz_help_name && !strcmp( psz_help_name, "longhelp" ) )
@@ -1355,7 +1355,7 @@ static void print_help_section( module_config_t *p_item, bool b_color, bool b_de
     }
 }
 
-static void Usage( libvlc_int_t *p_this, char const *psz_module_name )
+static void Usage( libvlc_int_t *p_this, char const *psz_search )
 {
 #define FORMAT_STRING "  %s --%s%s%s%s%s%s%s "
     /* short option ------'    | | | | | | |
@@ -1398,6 +1398,8 @@ static void Usage( libvlc_int_t *p_this, char const *psz_module_name )
     bool b_found       = false;
     int  i_only_advanced = 0; /* Number of modules ignored because they
                                * only have advanced options */
+    bool b_strict = psz_search && *psz_search == '=';
+    if( b_strict ) psz_search++;
 
     memset( psz_spaces_text, ' ', PADDING_SPACES+LINE_START );
     psz_spaces_text[PADDING_SPACES+LINE_START] = '\0';
@@ -1424,7 +1426,7 @@ static void Usage( libvlc_int_t *p_this, char const *psz_module_name )
 
     /* Ugly hack to make sure that the help options always come first
      * (part 1) */
-    if( !psz_module_name )
+    if( !psz_search )
         Usage( p_this, "help" );
 
     /* Enumerate the config for each module */
@@ -1436,13 +1438,15 @@ static void Usage( libvlc_int_t *p_this, char const *psz_module_name )
         module_config_t *p_section = NULL;
         module_config_t *p_end = p_parser->p_config + p_parser->confsize;
 
-        if( psz_module_name && strcmp( psz_module_name,
-                                       p_parser->psz_object_name ) )
+        if( psz_search &&
+            ( b_strict ? strcmp( psz_search, p_parser->psz_object_name )
+                       : !strstr( p_parser->psz_object_name, psz_search ) ) )
         {
             char *const *pp_shortcut = p_parser->pp_shortcuts;
             while( *pp_shortcut )
             {
-                if( !strcmp( psz_module_name, *pp_shortcut ) )
+                if( b_strict ? !strcmp( psz_search, *pp_shortcut )
+                             : strstr( *pp_shortcut, psz_search ) )
                     break;
                 pp_shortcut ++;
             }
@@ -1459,7 +1463,7 @@ static void Usage( libvlc_int_t *p_this, char const *psz_module_name )
         b_help_module = !strcmp( "help", p_parser->psz_object_name );
         /* Ugly hack to make sure that the help options always come first
          * (part 2) */
-        if( !psz_module_name && b_help_module )
+        if( !psz_search && b_help_module )
             continue;
 
         /* Ignore modules with only advanced config options if requested */




More information about the vlc-devel mailing list