Fix parsing of time specification with trailing spaces (#1118)
This commit is contained in:
parent
9d32825cd9
commit
b32ffeec35
3 changed files with 11 additions and 3 deletions
|
@ -75,7 +75,7 @@ void am_analyze(am_analyze_t *a, int16_t *am_buf, unsigned n_samples, int debug_
|
|||
a->signal_pulse_counter++;
|
||||
if (a->signal_pulse_counter >= PULSE_DATA_SIZE) {
|
||||
a->signal_pulse_counter = 0;
|
||||
fprintf(stderr, "To many pulses detected, probably bad input data or input parameters\n");
|
||||
fprintf(stderr, "Too many pulses detected, probably bad input data or input parameters\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ int atoi_time(const char *str, const char *error_hint)
|
|||
double val = 0.0;
|
||||
unsigned colons = 0;
|
||||
|
||||
while (*endptr) {
|
||||
do {
|
||||
double num = strtod(str, &endptr);
|
||||
|
||||
if (str == endptr) {
|
||||
|
@ -179,6 +179,7 @@ int atoi_time(const char *str, const char *error_hint)
|
|||
val += num;
|
||||
break;
|
||||
}
|
||||
// intentional fallthrough
|
||||
case ':':
|
||||
++colons;
|
||||
if (colons == 1)
|
||||
|
@ -218,8 +219,13 @@ int atoi_time(const char *str, const char *error_hint)
|
|||
fprintf(stderr, "%sunknown time suffix (%s)\n", error_hint, endptr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// chew up any remaining whitespace
|
||||
while (*endptr == ' ' || *endptr == '\t')
|
||||
++endptr;
|
||||
str = endptr;
|
||||
}
|
||||
|
||||
} while (*endptr);
|
||||
|
||||
if (val > INT_MAX || val < INT_MIN) {
|
||||
fprintf(stderr, "%stime argument too big (%f)\n", error_hint, val);
|
||||
|
|
|
@ -26,6 +26,8 @@ static int style_check(char *path)
|
|||
{
|
||||
FILE *fp = fopen(path, "r");
|
||||
assert(fp);
|
||||
if(!fp)
|
||||
exit(EXIT_FAILURE);
|
||||
|
||||
int read_errors = 0;
|
||||
int long_errors = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue