History

cmdutils: remove unnecessary OPT_DUMMY implementation

The -i INPUT option can be implemented more cleanly by using a function option, which can easily be done now that the parse_arg_function passed to parse_options has a standard signature.

Stefano Sabatini committed 15 years ago

Commit b4af3cf1 parent 96f931a3 files · +14 −17Browse files

Unified · Split

3 files
  1. cmdutils.c +0 −2
  2. cmdutils.h +0 −1
  3. ffplay.c +14 −14
cmdutils.c+0−2
@@ -273,8 +273,6 @@ unknown_opt: · 272 unmodified lines
273273 *po->u.int64_arg = parse_number_or_die(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX);
274274 } else if (po->flags & OPT_FLOAT) {
275275 *po->u.float_arg = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY);
276− } else if (po->flags & OPT_DUMMY) {
277− /* Do nothing for this option */
278276 } else {
279277 if (po->u.func_arg(opt, arg) < 0) {
280278 fprintf(stderr, "%s: failed to set value '%s' for option '%s'\n", argv[0], arg, opt);
cmdutils.h+0−1
@@ -128,7 +128,6 @@ typedef struct { · 127 unmodified lines
128128 #define OPT_INT64 0x0400
129129 #define OPT_EXIT 0x0800
130130 #define OPT_DATA 0x1000
131−#define OPT_DUMMY 0x2000
132131 union {
133132 int *int_arg;
134133 char **str_arg;
ffplay.c+14−14
@@ -2916,6 +2916,19 @@ static int opt_show_mode(const char *opt, const char *arg) · 2915 unmodified lines
29162916 return 0;
29172917 }
29182918
2919+static int opt_input_file(const char *opt, const char *filename)
2920+{
2921+ if (input_filename) {
2922+ fprintf(stderr, "Argument '%s' provided as input filename, but '%s' was already specified.\n",
2923+ filename, input_filename);
2924+ exit(1);
2925+ }
2926+ if (!strcmp(filename, "-"))
2927+ filename = "pipe:";
2928+ input_filename = filename;
2929+ return 0;
2930+}
2931+
29192932 static const OptionDef options[] = {
29202933 #include "cmdutils_common_opts.h"
29212934 { "x", HAS_ARG, {(void*)opt_width}, "force displayed width", "width" },
@@ -2961,7 +2974,7 @@ static const OptionDef options[] = { · 39 unmodified lines
29612974 { "rdftspeed", OPT_INT | HAS_ARG| OPT_AUDIO | OPT_EXPERT, {(void*)&rdftspeed}, "rdft speed", "msecs" },
29622975 { "showmode", HAS_ARG, {(void*)opt_show_mode}, "select show mode (0 = video, 1 = waves, 2 = RDFT)", "mode" },
29632976 { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
2964− { "i", OPT_DUMMY, {NULL}, "ffmpeg compatibility dummy option", ""},
2977+ { "i", HAS_ARG, {(void *)opt_input_file}, "read specified file", "input_file"},
29652978 { NULL, },
29662979 };
29672980
@@ -3006,19 +3019,6 @@ static void show_help(void) · 38 unmodified lines
30063019 );
30073020 }
30083021
3009−static int opt_input_file(const char *opt, const char *filename)
3010−{
3011− if (input_filename) {
3012− fprintf(stderr, "Argument '%s' provided as input filename, but '%s' was already specified.\n",
3013− filename, input_filename);
3014− exit(1);
3015− }
3016− if (!strcmp(filename, "-"))
3017− filename = "pipe:";
3018− input_filename = filename;
3019− return 0;
3020−}
3021−
30223022 /* Called from the main */
30233023 int main(int argc, char **argv)
30243024 {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t