]> git.sesse.net Git - vlc/blobdiff - src/libvlc.c
Check that hotkeys are sorted properly (debug-only self-test)
[vlc] / src / libvlc.c
index e35062f299376c532bee9babcb094210c4b50703..c3087573effd011e093f40c29cfd77f338dd53a8 100644 (file)
@@ -817,13 +817,22 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
         struct hotkey *p_keys =
             malloc( (libvlc_actions_count + 1) * sizeof (*p_keys) );
 
-       /* Initialize from configuration */
+        /* Initialize from configuration */
         for( size_t i = 0; i < libvlc_actions_count; i++ )
         {
             p_keys[i].psz_action = libvlc_actions[i].name;
             p_keys[i].i_key = config_GetInt( p_libvlc,
                                              libvlc_actions[i].name );
             p_keys[i].i_action = libvlc_actions[i].value;
+#ifndef NDEBUG
+            if (i > 0
+             && strcmp(libvlc_actions[i-1].name, libvlc_actions[i].name) >= 0)
+            {
+                msg_Err(p_libvlc, "%s and %s are not ordered properly",
+                        libvlc_actions[i-1].name, libvlc_actions[i].name);
+                abort();
+            }
+#endif
         }
         p_keys[libvlc_actions_count].psz_action = NULL;
         p_keys[libvlc_actions_count].i_key = 0;
@@ -1921,6 +1930,9 @@ static void ListModules( libvlc_int_t *p_this, bool b_verbose )
 #ifdef WIN32
     ShowConsole( true );
     b_color = false; // don't put color control codes in a .txt file
+#else
+    if( !isatty( 1 ) )
+        b_color = false;
 #endif
 
     /* List all modules */
@@ -1929,45 +1941,41 @@ static void ListModules( libvlc_int_t *p_this, bool b_verbose )
     /* Enumerate each module */
     for (size_t j = 0; (p_parser = list[j]) != NULL; j++)
     {
-        if( !( p_parser->psz_capability &&
-            !strcmp( p_parser->psz_capability, "services probe" ) ) )
-        {
-            if( b_color )
-                utf8_fprintf( stdout, GREEN"  %-22s "WHITE"%s\n"GRAY,
-                              p_parser->psz_object_name,
-                              _( p_parser->psz_longname ) );
-            else
-                utf8_fprintf( stdout, "  %-22s %s\n",
-                              p_parser->psz_object_name,
-                              _( p_parser->psz_longname ) );
+        if( b_color )
+            utf8_fprintf( stdout, GREEN"  %-22s "WHITE"%s\n"GRAY,
+                          p_parser->psz_object_name,
+                          _( p_parser->psz_longname ) );
+        else
+            utf8_fprintf( stdout, "  %-22s %s\n",
+                          p_parser->psz_object_name,
+                          _( p_parser->psz_longname ) );
 
-            if( b_verbose )
+        if( b_verbose )
+        {
+            char *const *pp_shortcut = p_parser->pp_shortcuts;
+            while( *pp_shortcut )
             {
-                char *const *pp_shortcut = p_parser->pp_shortcuts;
-                while( *pp_shortcut )
-                {
-                    if( strcmp( *pp_shortcut, p_parser->psz_object_name ) )
-                    {
-                        if( b_color )
-                            utf8_fprintf( stdout, CYAN"   s %s\n"GRAY,
-                                          *pp_shortcut );
-                        else
-                            utf8_fprintf( stdout, "   s %s\n",
-                                          *pp_shortcut );
-                    }
-                    pp_shortcut++;
-                }
-                if( p_parser->psz_capability )
+                if( strcmp( *pp_shortcut, p_parser->psz_object_name ) )
                 {
                     if( b_color )
-                        utf8_fprintf( stdout, MAGENTA"   c %s (%d)\n"GRAY,
-                                      p_parser->psz_capability,
-                                      p_parser->i_score );
+                        utf8_fprintf( stdout, CYAN"   s %s\n"GRAY,
+                                      *pp_shortcut );
                     else
-                        utf8_fprintf( stdout, "   c %s (%d)\n",
-                                      p_parser->psz_capability,
-                                      p_parser->i_score );
+                        utf8_fprintf( stdout, "   s %s\n",
+                                      *pp_shortcut );
                 }
+                pp_shortcut++;
+            }
+            if( p_parser->psz_capability )
+            {
+                if( b_color )
+                    utf8_fprintf( stdout, MAGENTA"   c %s (%d)\n"GRAY,
+                                  p_parser->psz_capability,
+                                  p_parser->i_score );
+                else
+                    utf8_fprintf( stdout, "   c %s (%d)\n",
+                                  p_parser->psz_capability,
+                                  p_parser->i_score );
             }
         }
     }