Skip to content

Commit

Permalink
Allow to have 4, 5 or 6 decimal places instead of only 4 & 6.
Browse files Browse the repository at this point in the history
  • Loading branch information
hartkopp committed May 11, 2010
1 parent 84e6b37 commit c8247c8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions asc2log.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ void calc_tv(struct timeval *tv, struct timeval *read_tv,
if (dplace == 4) /* shift values having only 4 decimal places */
read_tv->tv_usec *= 100; /* and need for 6 */

if (dplace == 5) /* shift values having only 5 decimal places */
read_tv->tv_usec *= 10; /* and need for 6 */

if (timestamps == 'a') { /* absolute */

tv->tv_sec = date_tv->tv_sec + read_tv->tv_sec;
Expand Down Expand Up @@ -172,7 +175,7 @@ int main(int argc, char **argv)
static struct timeval tv; /* current frame timestamp */
static struct timeval read_tv; /* frame timestamp from ASC file */
static struct timeval date_tv; /* date of the ASC file */
static int dplace; /* decimal place 4 or 6 or uninitialized */
static int dplace; /* decimal place 4, 5 or 6 or uninitialized */
static char base; /* 'd'ec or 'h'ex */
static char timestamps; /* 'a'bsolute or 'r'elative */

Expand Down Expand Up @@ -262,8 +265,8 @@ int main(int argc, char **argv)
dplace = strlen(tmp2);
if (verbose)
printf("decimal place %d, e.g. '%s'\n", dplace, tmp2);
if ((dplace != 4) && (dplace != 6)) {
printf("invalid dplace %d (must be 4 or 6)!\n", dplace);
if (dplace < 4 || dplace > 6) {
printf("invalid dplace %d (must be 4, 5 or 6)!\n", dplace);
return 1;
}
} else
Expand Down

0 comments on commit c8247c8

Please sign in to comment.