Use alphabteical order for getopt

This commit is contained in:
Grégory Soutadé 2016-08-12 18:13:31 +02:00
parent bfdb3b4161
commit 9ebfb9f7cf

38
gget.c
View File

@ -512,23 +512,8 @@ int main(int argc, char** argv)
int continuous_mode=0; int continuous_mode=0;
int exists; int exists;
while ((opt = getopt(argc, argv, "hn:l:o:u:qm:")) != -1) { while ((opt = getopt(argc, argv, "hl:m:n:o:qu:")) != -1) {
switch (opt) { switch (opt) {
case 'n':
nb_threads = strtoul(optarg, &endptr, 0);
if (*endptr)
{
usage(argv[0]);
return 1;
}
if (nb_threads == 0)
nb_threads = DEFAULT_NB_THREADS;
else if (nb_threads > MAX_NB_THREADS)
{
printf("Max numberb of threads is %d\n", MAX_NB_THREADS);
nb_threads = MAX_NB_THREADS;
}
break;
case 'l': case 'l':
max_speed = strtoul(optarg, &endptr, 0); max_speed = strtoul(optarg, &endptr, 0);
if (*endptr) if (*endptr)
@ -570,15 +555,30 @@ int main(int argc, char** argv)
} }
max_chunk_size *= multiplier; max_chunk_size *= multiplier;
break; break;
case 'n':
nb_threads = strtoul(optarg, &endptr, 0);
if (*endptr)
{
usage(argv[0]);
return 1;
}
if (nb_threads == 0)
nb_threads = DEFAULT_NB_THREADS;
else if (nb_threads > MAX_NB_THREADS)
{
printf("Max numberb of threads is %d\n", MAX_NB_THREADS);
nb_threads = MAX_NB_THREADS;
}
break;
case 'o': case 'o':
out_filename = strdup(optarg); out_filename = strdup(optarg);
break; break;
case 'u':
user_agent = strdup(optarg);
break;
case 'q': case 'q':
quiet = 1; quiet = 1;
break; break;
case 'u':
user_agent = strdup(optarg);
break;
default: default:
case 'h': case 'h':
usage(argv[0]); usage(argv[0]);