[vlc-devel] [PATCH] Explain how to open a file starting with a dash from the command line
Sveinung Kvilhaugsvik
sveinung84 at users.sourceforge.net
Sun Feb 22 21:05:28 CET 2009
When a user tries to open a file that has a name starting with '-' from the
command line VLC will treat it as an option. Since the name of the file
probably isn't a valid option it will give an error message about
options. It can be confusing for a user to be told about options when he
tried to open a file. This patch will make VLC show to the user how to open
the file the correct way in addition to the information about options it
gives today.
---
src/config/cmdline.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/src/config/cmdline.c b/src/config/cmdline.c
index c9fa3ce..d1bee9a 100644
--- a/src/config/cmdline.c
+++ b/src/config/cmdline.c
@@ -55,7 +55,7 @@ int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc,
const char *ppsz_argv[],
bool b_ignore_errors )
{
- int i_cmd, i_index, i_opts, i_shortopts, flag, i_verbose = 0;
+ int i_cmd, i_example, i_index, i_opts, i_shortopts, flag, i_verbose = 0;
module_t *p_parser;
struct option *p_longopts;
const char **argv_copy = NULL;
@@ -378,6 +378,15 @@ int __config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc,
{
fprintf( stderr, "`%s'\n", ppsz_argv[optind-1] );
}
+
+ if ((!(optopt)) || (ppsz_argv[optind-1][0] == '-')) {
+ i_example = optind - 1;
+ } else {
+ i_example = optind;
+ }
+ fprintf( stderr, "To play a file named '%s' try 'vlc -- %s'\n",
+ ppsz_argv[i_example], ppsz_argv[i_example] );
+
fputs( "Try `vlc --help' for more information.\n", stderr );
for( i_index = 0; p_longopts[i_index].name; i_index++ )
--
1.5.6.3
More information about the vlc-devel
mailing list