From: Johnathan Nightingale Date: Tue, 13 Jul 2010 23:53:45 +0000 (-0400) Subject: Gerfried's warnings about multiple frequency specs X-Git-Tag: upstream/1.3~1^2~4 X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=b5344de14f213a4f2d72c8b118e86eb6e2a017f0;p=pkg%2Fbeep.git Gerfried's warnings about multiple frequency specs --- diff --git a/beep.c b/beep.c index a0da2d3..80fc1ed 100644 --- a/beep.c +++ b/beep.c @@ -159,6 +159,9 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { (argfreq <= 0)) usage_bail(argv[0]); else + if (result->freq != 0) + fprintf(stderr, "WARNING: multiple -f values given, only last " + "one is used.\n"); result->freq = argfreq; break; case 'l' : /* length */ @@ -201,8 +204,10 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { exit(0); break; case 'n' : /* also --new - create another beep */ + if (result->freq == 0) + result->freq = DEFAULT_FREQ; result->next = (beep_parms_t *)malloc(sizeof(beep_parms_t)); - result->next->freq = DEFAULT_FREQ; + result->next->freq = 0; result->next->length = DEFAULT_LENGTH; result->next->reps = DEFAULT_REPS; result->next->delay = DEFAULT_DELAY; @@ -220,6 +225,8 @@ void parse_command_line(int argc, char **argv, beep_parms_t *result) { usage_bail(argv[0]); } } + if (result->freq == 0) + result->freq = DEFAULT_FREQ; } void play_beep(beep_parms_t parms) { @@ -260,7 +267,7 @@ int main(int argc, char **argv) { char sin[4096], *ptr; beep_parms_t *parms = (beep_parms_t *)malloc(sizeof(beep_parms_t)); - parms->freq = DEFAULT_FREQ; + parms->freq = 0; parms->length = DEFAULT_LENGTH; parms->reps = DEFAULT_REPS; parms->delay = DEFAULT_DELAY;