Commit 85aac6d9 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

help: simplify output function calls

parent 67910630
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include <wctype.h> #include <wctype.h>
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_charset.h>
#include <vlc_modules.h> #include <vlc_modules.h>
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include "modules/modules.h" #include "modules/modules.h"
...@@ -37,6 +36,7 @@ ...@@ -37,6 +36,7 @@
#include "libvlc.h" #include "libvlc.h"
#if defined( _WIN32 ) && !VLC_WINSTORE_APP #if defined( _WIN32 ) && !VLC_WINSTORE_APP
# include <vlc_charset.h>
static void ShowConsole (void); static void ShowConsole (void);
static void PauseConsole (void); static void PauseConsole (void);
# define wcwidth(cp) (cp, 1) /* LOL */ # define wcwidth(cp) (cp, 1) /* LOL */
...@@ -152,8 +152,8 @@ bool config_PrintHelp (vlc_object_t *obj) ...@@ -152,8 +152,8 @@ bool config_PrintHelp (vlc_object_t *obj)
*****************************************************************************/ *****************************************************************************/
static inline void print_help_on_full_help( void ) static inline void print_help_on_full_help( void )
{ {
utf8_fprintf( stdout, "\n" ); putchar('\n');
utf8_fprintf( stdout, "%s\n", _("To get exhaustive help, use '-H'.") ); puts(_("To get exhaustive help, use '-H'."));
} }
static const char vlc_usage[] = N_( static const char vlc_usage[] = N_(
...@@ -196,19 +196,19 @@ static void Help (vlc_object_t *p_this, char const *psz_help_name) ...@@ -196,19 +196,19 @@ static void Help (vlc_object_t *p_this, char const *psz_help_name)
if( psz_help_name && !strcmp( psz_help_name, "help" ) ) if( psz_help_name && !strcmp( psz_help_name, "help" ) )
{ {
utf8_fprintf( stdout, _(vlc_usage), "vlc" ); printf(_(vlc_usage), "vlc");
Usage( p_this, "=main" ); Usage( p_this, "=main" );
print_help_on_full_help(); print_help_on_full_help();
} }
else if( psz_help_name && !strcmp( psz_help_name, "longhelp" ) ) else if( psz_help_name && !strcmp( psz_help_name, "longhelp" ) )
{ {
utf8_fprintf( stdout, _(vlc_usage), "vlc" ); printf(_(vlc_usage), "vlc");
Usage( p_this, NULL ); Usage( p_this, NULL );
print_help_on_full_help(); print_help_on_full_help();
} }
else if( psz_help_name && !strcmp( psz_help_name, "full-help" ) ) else if( psz_help_name && !strcmp( psz_help_name, "full-help" ) )
{ {
utf8_fprintf( stdout, _(vlc_usage), "vlc" ); printf(_(vlc_usage), "vlc");
Usage( p_this, NULL ); Usage( p_this, NULL );
} }
else if( psz_help_name ) else if( psz_help_name )
...@@ -281,7 +281,7 @@ static void print_desc(const char *str, unsigned margin, bool color) ...@@ -281,7 +281,7 @@ static void print_desc(const char *str, unsigned margin, bool color)
{ {
if (!newline) if (!newline)
{ {
fputc(' ', stdout); /* insert space */ putchar(' '); /* insert space */
charwidth = 1; charwidth = 1;
} }
fwrite(word, 1, wordlen, stdout); /* write complete word */ fwrite(word, 1, wordlen, stdout); /* write complete word */
...@@ -313,7 +313,7 @@ static void print_desc(const char *str, unsigned margin, bool color) ...@@ -313,7 +313,7 @@ static void print_desc(const char *str, unsigned margin, bool color)
} }
if (!newline) if (!newline)
fputc(' ', stdout); putchar(' ');
printf(color ? "%s\n"GRAY : "%s\n", word); printf(color ? "%s\n"GRAY : "%s\n", word);
} }
...@@ -459,7 +459,7 @@ static void print_item(const module_t *m, const module_config_t *item, ...@@ -459,7 +459,7 @@ static void print_item(const module_t *m, const module_config_t *item,
offset -= strlen(item->psz_name) + vlc_swidth(prefix); offset -= strlen(item->psz_name) + vlc_swidth(prefix);
if (offset < 0) if (offset < 0)
{ {
fputc('\n', stdout); putchar('\n');
offset = PADDING_SPACES + LINE_START; offset = PADDING_SPACES + LINE_START;
} }
printf("%*s", offset, ""); printf("%*s", offset, "");
...@@ -612,14 +612,12 @@ static void Usage (vlc_object_t *p_this, char const *psz_search) ...@@ -612,14 +612,12 @@ static void Usage (vlc_object_t *p_this, char const *psz_search)
*****************************************************************************/ *****************************************************************************/
static void ListModules (vlc_object_t *p_this, bool b_verbose) static void ListModules (vlc_object_t *p_this, bool b_verbose)
{ {
bool b_color = var_InheritBool( p_this, "color" ); bool color = false;
ShowConsole(); ShowConsole();
#ifdef _WIN32 #ifndef _WIN32
b_color = false; // don't put color control codes in a .txt file if (isatty(STDOUT_FILENO))
#else color = var_InheritBool(p_this, "color");
if( !isatty( 1 ) )
b_color = false;
#endif #endif
/* List all modules */ /* List all modules */
...@@ -631,39 +629,19 @@ static void ListModules (vlc_object_t *p_this, bool b_verbose) ...@@ -631,39 +629,19 @@ static void ListModules (vlc_object_t *p_this, bool b_verbose)
{ {
module_t *p_parser = list[j]; module_t *p_parser = list[j];
const char *objname = module_get_object (p_parser); const char *objname = module_get_object (p_parser);
if( b_color ) printf(color ? GREEN" %-22s "WHITE"%s\n"GRAY : " %-22s %s\n",
utf8_fprintf( stdout, GREEN" %-22s "WHITE"%s\n"GRAY, objname, objname, module_gettext(p_parser, p_parser->psz_longname));
module_gettext( p_parser, p_parser->psz_longname ) );
else
utf8_fprintf( stdout, " %-22s %s\n", objname,
module_gettext( p_parser, p_parser->psz_longname ) );
if( b_verbose ) if( b_verbose )
{ {
char *const *pp_shortcuts = p_parser->pp_shortcuts; char *const *pp_shortcuts = p_parser->pp_shortcuts;
for( unsigned i = 0; i < p_parser->i_shortcuts; i++ ) for( unsigned i = 0; i < p_parser->i_shortcuts; i++ )
{
if( strcmp( pp_shortcuts[i], objname ) ) if( strcmp( pp_shortcuts[i], objname ) )
{ printf(color ? CYAN" s %s\n"GRAY : " s %s\n",
if( b_color ) pp_shortcuts[i]);
utf8_fprintf( stdout, CYAN" s %s\n"GRAY, if (p_parser->psz_capability != NULL)
pp_shortcuts[i] ); printf(color ? MAGENTA" c %s (%d)\n"GRAY : " c %s (%d)\n",
else p_parser->psz_capability, p_parser->i_score);
utf8_fprintf( stdout, " s %s\n",
pp_shortcuts[i] );
}
}
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 );
}
} }
} }
module_list_free (list); module_list_free (list);
...@@ -678,12 +656,11 @@ static void ListModules (vlc_object_t *p_this, bool b_verbose) ...@@ -678,12 +656,11 @@ static void ListModules (vlc_object_t *p_this, bool b_verbose)
static void Version( void ) static void Version( void )
{ {
ShowConsole(); ShowConsole();
utf8_fprintf( stdout, _("VLC version %s (%s)\n"), VERSION_MESSAGE, printf(_("VLC version %s (%s)\n"), VERSION_MESSAGE, psz_vlc_changeset);
psz_vlc_changeset ); printf(_("Compiled by %s on %s (%s)\n"), VLC_CompileBy(),
utf8_fprintf( stdout, _("Compiled by %s on %s (%s)\n"), VLC_CompileHost(), __DATE__" "__TIME__ );
VLC_CompileBy(), VLC_CompileHost(), __DATE__" "__TIME__ ); printf(_("Compiler: %s\n"), VLC_Compiler());
utf8_fprintf( stdout, _("Compiler: %s\n"), VLC_Compiler() ); fputs(LICENSE_MSG, stdout);
utf8_fprintf( stdout, "%s", LICENSE_MSG );
PauseConsole(); PauseConsole();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment