Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
68f6af6e
Commit
68f6af6e
authored
Feb 28, 2010
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
getopt: remove optional argument support
parent
2b1c487c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
56 deletions
+25
-56
src/config/cmdline.c
src/config/cmdline.c
+3
-4
src/config/getopt.c
src/config/getopt.c
+19
-40
src/config/vlc_getopt.h
src/config/vlc_getopt.h
+3
-12
No files found.
src/config/cmdline.c
View file @
68f6af6e
...
@@ -141,8 +141,7 @@ int config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc,
...
@@ -141,8 +141,7 @@ int config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc,
p_longopts
[
i_index
].
name
=
strdup
(
p_item
->
psz_name
);
p_longopts
[
i_index
].
name
=
strdup
(
p_item
->
psz_name
);
if
(
p_longopts
[
i_index
].
name
==
NULL
)
continue
;
if
(
p_longopts
[
i_index
].
name
==
NULL
)
continue
;
p_longopts
[
i_index
].
has_arg
=
p_longopts
[
i_index
].
has_arg
=
(
p_item
->
i_type
==
CONFIG_ITEM_BOOL
)
?
no_argument
:
(
p_item
->
i_type
!=
CONFIG_ITEM_BOOL
);
required_argument
;
p_longopts
[
i_index
].
flag
=
&
flag
;
p_longopts
[
i_index
].
flag
=
&
flag
;
p_longopts
[
i_index
].
val
=
0
;
p_longopts
[
i_index
].
val
=
0
;
i_index
++
;
i_index
++
;
...
@@ -157,7 +156,7 @@ int config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc,
...
@@ -157,7 +156,7 @@ int config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc,
strcat
(
psz_name
,
p_item
->
psz_name
);
strcat
(
psz_name
,
p_item
->
psz_name
);
p_longopts
[
i_index
].
name
=
psz_name
;
p_longopts
[
i_index
].
name
=
psz_name
;
p_longopts
[
i_index
].
has_arg
=
no_argument
;
p_longopts
[
i_index
].
has_arg
=
false
;
p_longopts
[
i_index
].
flag
=
&
flag
;
p_longopts
[
i_index
].
flag
=
&
flag
;
p_longopts
[
i_index
].
val
=
1
;
p_longopts
[
i_index
].
val
=
1
;
i_index
++
;
i_index
++
;
...
@@ -168,7 +167,7 @@ int config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc,
...
@@ -168,7 +167,7 @@ int config_LoadCmdLine( vlc_object_t *p_this, int *pi_argc,
strcat
(
psz_name
,
p_item
->
psz_name
);
strcat
(
psz_name
,
p_item
->
psz_name
);
p_longopts
[
i_index
].
name
=
psz_name
;
p_longopts
[
i_index
].
name
=
psz_name
;
p_longopts
[
i_index
].
has_arg
=
no_argument
;
p_longopts
[
i_index
].
has_arg
=
false
;
p_longopts
[
i_index
].
flag
=
&
flag
;
p_longopts
[
i_index
].
flag
=
&
flag
;
p_longopts
[
i_index
].
val
=
1
;
p_longopts
[
i_index
].
val
=
1
;
i_index
++
;
i_index
++
;
...
...
src/config/getopt.c
View file @
68f6af6e
...
@@ -267,9 +267,7 @@ static const char *
...
@@ -267,9 +267,7 @@ static const char *
If a char in OPTSTRING is followed by a colon, that means it wants an arg,
If a char in OPTSTRING is followed by a colon, that means it wants an arg,
so the following text in the same ARGV-element, or the text of the following
so the following text in the same ARGV-element, or the text of the following
ARGV-element, is returned in `optarg'. Two colons mean an option that
ARGV-element, is returned in `optarg'.
wants an optional arg; if there is text in the current ARGV-element,
it is returned in `optarg', otherwise `optarg' is set to zero.
If OPTSTRING starts with `-' or `+', it requests different methods of
If OPTSTRING starts with `-' or `+', it requests different methods of
handling the non-option ARGV-elements.
handling the non-option ARGV-elements.
...
@@ -447,8 +445,6 @@ int
...
@@ -447,8 +445,6 @@ int
optind
++
;
optind
++
;
if
(
*
nameend
)
if
(
*
nameend
)
{
{
/* Don't test has_arg with >, because some C compilers don't
allow it to be used on enums. */
if
(
pfound
->
has_arg
)
if
(
pfound
->
has_arg
)
optarg
=
nameend
+
1
;
optarg
=
nameend
+
1
;
else
else
...
@@ -459,7 +455,7 @@ int
...
@@ -459,7 +455,7 @@ int
return
'?'
;
return
'?'
;
}
}
}
}
else
if
(
pfound
->
has_arg
==
1
)
else
if
(
pfound
->
has_arg
)
{
{
if
(
optind
<
argc
)
if
(
optind
<
argc
)
optarg
=
argv
[
optind
++
];
optarg
=
argv
[
optind
++
];
...
@@ -575,8 +571,6 @@ int
...
@@ -575,8 +571,6 @@ int
option_index
=
indfound
;
option_index
=
indfound
;
if
(
*
nameend
)
if
(
*
nameend
)
{
{
/* Don't test has_arg with >, because some C compilers don't
allow it to be used on enums. */
if
(
pfound
->
has_arg
)
if
(
pfound
->
has_arg
)
optarg
=
nameend
+
1
;
optarg
=
nameend
+
1
;
else
else
...
@@ -585,7 +579,7 @@ int
...
@@ -585,7 +579,7 @@ int
return
'?'
;
return
'?'
;
}
}
}
}
else
if
(
pfound
->
has_arg
==
1
)
else
if
(
pfound
->
has_arg
)
{
{
if
(
optind
<
argc
)
if
(
optind
<
argc
)
optarg
=
argv
[
optind
++
];
optarg
=
argv
[
optind
++
];
...
@@ -609,20 +603,6 @@ int
...
@@ -609,20 +603,6 @@ int
return
'W'
;
/* Let the application handle it. */
return
'W'
;
/* Let the application handle it. */
}
}
if
(
temp
[
1
]
==
':'
)
if
(
temp
[
1
]
==
':'
)
{
if
(
temp
[
2
]
==
':'
)
{
/* This is an option that accepts an argument optionally. */
if
(
*
nextchar
!=
'\0'
)
{
optarg
=
nextchar
;
optind
++
;
}
else
optarg
=
NULL
;
nextchar
=
NULL
;
}
else
{
{
/* This is an option that requires an argument. */
/* This is an option that requires an argument. */
if
(
*
nextchar
!=
'\0'
)
if
(
*
nextchar
!=
'\0'
)
...
@@ -646,7 +626,6 @@ int
...
@@ -646,7 +626,6 @@ int
optarg
=
argv
[
optind
++
];
optarg
=
argv
[
optind
++
];
nextchar
=
NULL
;
nextchar
=
NULL
;
}
}
}
return
c
;
return
c
;
}
}
}
}
src/config/vlc_getopt.h
View file @
68f6af6e
...
@@ -54,9 +54,8 @@
...
@@ -54,9 +54,8 @@
zero.
zero.
The field `has_arg' is:
The field `has_arg' is:
no_argument (or 0) if the option does not take an argument,
false if the option does not take an argument,
required_argument (or 1) if the option requires an argument,
true if the option requires an argument.
optional_argument (or 2) if the option takes an optional argument.
If the field `flag' is not NULL, it points to a variable that is set
If the field `flag' is not NULL, it points to a variable that is set
to the value given in the field `val' when the option is found, but
to the value given in the field `val' when the option is found, but
...
@@ -72,19 +71,11 @@
...
@@ -72,19 +71,11 @@
struct
option
struct
option
{
{
const
char
*
name
;
const
char
*
name
;
/* has_arg can't be an enum because some compilers complain about
bool
has_arg
;
type mismatches in all the code that assumes it is an int. */
int
has_arg
;
int
*
flag
;
int
*
flag
;
int
val
;
int
val
;
};
};
/* Names for the values of the `has_arg' field of `struct option'. */
#define no_argument 0
#define required_argument 1
#define optional_argument 2
extern
int
vlc_getopt_long
(
int
argc
,
char
*
const
*
argv
,
const
char
*
shortopts
,
extern
int
vlc_getopt_long
(
int
argc
,
char
*
const
*
argv
,
const
char
*
shortopts
,
const
struct
option
*
longopts
,
int
*
longind
);
const
struct
option
*
longopts
,
int
*
longind
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment