mirror of
https://github.com/rtlsdrblog/rtl-sdr-blog.git
synced 2024-12-26 02:48:31 +01:00
rtl_fm/rtl_power: Improve scanning range parsing
This commit is contained in:
parent
b2ee24eff5
commit
f2a9a81c4b
13
src/rtl_fm.c
13
src/rtl_fm.c
@ -926,8 +926,21 @@ void frequency_range(struct controller_state *s, char *arg)
|
|||||||
int i;
|
int i;
|
||||||
start = arg;
|
start = arg;
|
||||||
stop = strchr(start, ':') + 1;
|
stop = strchr(start, ':') + 1;
|
||||||
|
if (stop == (char *)1) { // no stop or step given
|
||||||
|
s->freqs[s->freq_len] = (uint32_t) atofs(start);
|
||||||
|
s->freq_len++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
stop[-1] = '\0';
|
stop[-1] = '\0';
|
||||||
step = strchr(stop, ':') + 1;
|
step = strchr(stop, ':') + 1;
|
||||||
|
if (step == (char *)1) { // no step given
|
||||||
|
s->freqs[s->freq_len] = (uint32_t) atofs(start);
|
||||||
|
s->freq_len++;
|
||||||
|
s->freqs[s->freq_len] = (uint32_t) atofs(stop);
|
||||||
|
s->freq_len++;
|
||||||
|
stop[-1] = ':';
|
||||||
|
return;
|
||||||
|
}
|
||||||
step[-1] = '\0';
|
step[-1] = '\0';
|
||||||
for(i=(int)atofs(start); i<=(int)atofs(stop); i+=(int)atofs(step))
|
for(i=(int)atofs(start); i<=(int)atofs(stop); i+=(int)atofs(step))
|
||||||
{
|
{
|
||||||
|
@ -437,8 +437,16 @@ void frequency_range(char *arg, double crop)
|
|||||||
/* hacky string parsing */
|
/* hacky string parsing */
|
||||||
start = arg;
|
start = arg;
|
||||||
stop = strchr(start, ':') + 1;
|
stop = strchr(start, ':') + 1;
|
||||||
|
if (stop == (char *)1) {
|
||||||
|
fprintf(stderr, "Bad frequency range specification: %s\n", arg);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
stop[-1] = '\0';
|
stop[-1] = '\0';
|
||||||
step = strchr(stop, ':') + 1;
|
step = strchr(stop, ':') + 1;
|
||||||
|
if (step == (char *)1) {
|
||||||
|
fprintf(stderr, "Bad frequency range specification: %s\n", arg);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
step[-1] = '\0';
|
step[-1] = '\0';
|
||||||
lower = (int)atofs(start);
|
lower = (int)atofs(start);
|
||||||
upper = (int)atofs(stop);
|
upper = (int)atofs(stop);
|
||||||
|
Loading…
Reference in New Issue
Block a user