fix bug where flac would crash if not given a value after some options

This commit is contained in:
Josh Coalson 2002-01-26 23:17:17 +00:00
parent 1152f9fe26
commit 90cf0b22ce
1 changed files with 62 additions and 24 deletions

View File

@ -89,10 +89,12 @@ int main(int argc, char *argv[])
else if(0 == strcmp(argv[i], "-s-")) else if(0 == strcmp(argv[i], "-s-"))
verbose = true; verbose = true;
else if(0 == strcmp(argv[i], "-S")) { else if(0 == strcmp(argv[i], "-S")) {
if(++i >= argc)
return long_usage("ERROR: must specify a value with -S\n");
if(num_requested_seek_points < 0) if(num_requested_seek_points < 0)
num_requested_seek_points = 0; num_requested_seek_points = 0;
num_requested_seek_points++; num_requested_seek_points++;
strcat(requested_seek_points, argv[++i]); strcat(requested_seek_points, argv[i]);
strcat(requested_seek_points, "<"); strcat(requested_seek_points, "<");
} }
else if(0 == strcmp(argv[i], "-S-")) { else if(0 == strcmp(argv[i], "-S-")) {
@ -103,14 +105,20 @@ int main(int argc, char *argv[])
delete_input = true; delete_input = true;
else if(0 == strcmp(argv[i], "--delete-input-file-")) else if(0 == strcmp(argv[i], "--delete-input-file-"))
delete_input = false; delete_input = false;
else if(0 == strcmp(argv[i], "--output-prefix")) else if(0 == strcmp(argv[i], "--output-prefix")) {
output_prefix = argv[++i]; if(++i >= argc)
return long_usage("ERROR: must specify a value with --output-prefix\n");
output_prefix = argv[i];
}
else if(0 == strcmp(argv[i], "--sector-align")) else if(0 == strcmp(argv[i], "--sector-align"))
sector_align = true; sector_align = true;
else if(0 == strcmp(argv[i], "--sector-align-")) else if(0 == strcmp(argv[i], "--sector-align-"))
sector_align = false; sector_align = false;
else if(0 == strcmp(argv[i], "--skip")) else if(0 == strcmp(argv[i], "--skip")) {
skip = (FLAC__uint64)atoi(argv[++i]); /* @@@ takes a pretty damn big file to overflow atoi() here, but it could happen */ if(++i >= argc)
return long_usage("ERROR: must specify a value with --skip\n");
skip = (FLAC__uint64)atoi(argv[i]); /* @@@ takes a pretty damn big file to overflow atoi() here, but it could happen */
}
else if(0 == strcmp(argv[i], "--lax")) else if(0 == strcmp(argv[i], "--lax"))
lax = true; lax = true;
else if(0 == strcmp(argv[i], "--lax-")) else if(0 == strcmp(argv[i], "--lax-"))
@ -121,8 +129,11 @@ int main(int argc, char *argv[])
else if(0 == strcmp(argv[i], "--ogg-")) else if(0 == strcmp(argv[i], "--ogg-"))
use_ogg = false; use_ogg = false;
#endif #endif
else if(0 == strcmp(argv[i], "-b")) else if(0 == strcmp(argv[i], "-b")) {
blocksize = atoi(argv[++i]); if(++i >= argc)
return long_usage("ERROR: must specify a value with -b\n");
blocksize = atoi(argv[i]);
}
else if(0 == strcmp(argv[i], "-e")) else if(0 == strcmp(argv[i], "-e"))
do_exhaustive_model_search = true; do_exhaustive_model_search = true;
else if(0 == strcmp(argv[i], "-e-")) else if(0 == strcmp(argv[i], "-e-"))
@ -131,8 +142,11 @@ int main(int argc, char *argv[])
do_escape_coding = true; do_escape_coding = true;
else if(0 == strcmp(argv[i], "-E-")) else if(0 == strcmp(argv[i], "-E-"))
do_escape_coding = false; do_escape_coding = false;
else if(0 == strcmp(argv[i], "-l")) else if(0 == strcmp(argv[i], "-l")) {
max_lpc_order = atoi(argv[++i]); if(++i >= argc)
return long_usage("ERROR: must specify a value with -l\n");
max_lpc_order = atoi(argv[i]);
}
else if(0 == strcmp(argv[i], "-m")) { else if(0 == strcmp(argv[i], "-m")) {
do_mid_side = true; do_mid_side = true;
loose_mid_side = false; loose_mid_side = false;
@ -143,18 +157,30 @@ int main(int argc, char *argv[])
loose_mid_side = do_mid_side = true; loose_mid_side = do_mid_side = true;
else if(0 == strcmp(argv[i], "-M-")) else if(0 == strcmp(argv[i], "-M-"))
loose_mid_side = do_mid_side = false; loose_mid_side = do_mid_side = false;
else if(0 == strcmp(argv[i], "-o")) else if(0 == strcmp(argv[i], "-o")) {
cmdline_forced_outfilename = argv[++i]; if(++i >= argc)
return long_usage("ERROR: must specify a value with -o\n");
cmdline_forced_outfilename = argv[i];
}
else if(0 == strcmp(argv[i], "-p")) else if(0 == strcmp(argv[i], "-p"))
do_qlp_coeff_prec_search = true; do_qlp_coeff_prec_search = true;
else if(0 == strcmp(argv[i], "-p-")) else if(0 == strcmp(argv[i], "-p-"))
do_qlp_coeff_prec_search = false; do_qlp_coeff_prec_search = false;
else if(0 == strcmp(argv[i], "-P")) else if(0 == strcmp(argv[i], "-P")) {
padding = atoi(argv[++i]); if(++i >= argc)
else if(0 == strcmp(argv[i], "-q")) return long_usage("ERROR: must specify a value with -P\n");
qlp_coeff_precision = atoi(argv[++i]); padding = atoi(argv[i]);
}
else if(0 == strcmp(argv[i], "-q")) {
if(++i >= argc)
return long_usage("ERROR: must specify a value with -q\n");
qlp_coeff_precision = atoi(argv[i]);
}
else if(0 == strcmp(argv[i], "-r")) { else if(0 == strcmp(argv[i], "-r")) {
char *p = strchr(argv[++i], ','); char *p;
if(++i >= argc)
return long_usage("ERROR: must specify a value with -r\n");
p = strchr(argv[i], ',');
if(0 == p) { if(0 == p) {
min_residual_partition_order = 0; min_residual_partition_order = 0;
max_residual_partition_order = atoi(argv[i]); max_residual_partition_order = atoi(argv[i]);
@ -164,8 +190,11 @@ int main(int argc, char *argv[])
max_residual_partition_order = atoi(++p); max_residual_partition_order = atoi(++p);
} }
} }
else if(0 == strcmp(argv[i], "-R")) else if(0 == strcmp(argv[i], "-R")) {
rice_parameter_search_dist = atoi(argv[++i]); if(++i >= argc)
return long_usage("ERROR: must specify a value with -R\n");
rice_parameter_search_dist = atoi(argv[i]);
}
else if(0 == strcmp(argv[i], "-V")) else if(0 == strcmp(argv[i], "-V"))
verify = true; verify = true;
else if(0 == strcmp(argv[i], "-V-")) else if(0 == strcmp(argv[i], "-V-"))
@ -174,12 +203,21 @@ int main(int argc, char *argv[])
format_is_big_endian = true; format_is_big_endian = true;
else if(0 == strcmp(argv[i], "-fl")) else if(0 == strcmp(argv[i], "-fl"))
format_is_big_endian = false; format_is_big_endian = false;
else if(0 == strcmp(argv[i], "-fc")) else if(0 == strcmp(argv[i], "-fc")) {
format_channels = atoi(argv[++i]); if(++i >= argc)
else if(0 == strcmp(argv[i], "-fp")) return long_usage("ERROR: must specify a value with -fc\n");
format_bps = atoi(argv[++i]); format_channels = atoi(argv[i]);
else if(0 == strcmp(argv[i], "-fs")) }
format_sample_rate = atoi(argv[++i]); else if(0 == strcmp(argv[i], "-fp")) {
if(++i >= argc)
return long_usage("ERROR: must specify a value with -fp\n");
format_bps = atoi(argv[i]);
}
else if(0 == strcmp(argv[i], "-fs")) {
if(++i >= argc)
return long_usage("ERROR: must specify a value with -fs\n");
format_sample_rate = atoi(argv[i]);
}
else if(0 == strcmp(argv[i], "-fu")) else if(0 == strcmp(argv[i], "-fu"))
format_is_unsigned_samples = true; format_is_unsigned_samples = true;
else if(0 == strcmp(argv[i], "-fr")) else if(0 == strcmp(argv[i], "-fr"))