ref: 8dfc09d5e2ca3e9dfa06d251ec58fbd1d6b5d6dd
parent: 19032af10bf5b22ec31b327cbd3a590c6788e64c
author: robs <robs>
date: Sat Nov 18 11:41:47 EST 2006
Fix rounding error when reading command-line time parameters. ../Changelog Allow command-line time parameters of < 1 sec to omit the leading 0.
--- a/src/util.c
+++ b/src/util.c
@@ -356,7 +356,7 @@
int st_parsesamples(st_rate_t rate, char *str, st_size_t *samples, char def)
{
int found_samples = 0, found_time = 0;
- int time;
+ int time = 0;
long long_samples;
float frac = 0;
@@ -371,7 +371,7 @@
while(1)
{
- if (sscanf(str, "%d", &time) != 1)
+ if (str[0] != '.' && sscanf(str, "%d", &time) != 1)
return ST_EOF;
*samples += time;
@@ -393,7 +393,7 @@
}
*samples *= rate;
- *samples += (rate * frac);
+ *samples += (rate * frac) + 0.5;
return ST_SUCCESS;
}
if (found_samples || (def == 's' && !found_time))