From 5ba1582dda65479e99565b74a0238c23c41ce838 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Sun, 25 Oct 2009 20:18:24 +0000 Subject: [PATCH] From Jim Young via bug 4162: This patch limits the number of fractional digits used to calculate the fractional component of editcap's -t and -w options. Specifically this patch truncates the fractional component (if any) of the -t and -w options to 6 and 9 respectively. svn path=/trunk/; revision=30698 --- editcap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/editcap.c b/editcap.c index 5937cbac37..2cbf2387f0 100644 --- a/editcap.c +++ b/editcap.c @@ -336,6 +336,11 @@ set_time_adjustment(char *optarg) /* now collect the partial seconds, if any */ if (*frac != '\0') { /* chars left, so get fractional part */ val = strtol(&(frac[1]), &end, 10); + /* if more than 6 fractional digits truncate to 6 */ + if((end - &(frac[1])) > 6) { + frac[7] = 't'; /* 't' for truncate */ + val = strtol(&(frac[1]), &end, 10); + } if (*frac != '.' || end == NULL || end == frac || val < 0 || val > ONE_MILLION || val == LONG_MIN || val == LONG_MAX) { fprintf(stderr, "editcap: \"%s\" isn't a valid time adjustment\n", @@ -401,6 +406,11 @@ set_rel_time(char *optarg) /* now collect the partial seconds, if any */ if (*frac != '\0') { /* chars left, so get fractional part */ val = strtol(&(frac[1]), &end, 10); + /* if more than 9 fractional digits truncate to 9 */ + if((end - &(frac[1])) > 9) { + frac[10] = 't'; /* 't' for truncate */ + val = strtol(&(frac[1]), &end, 10); + } if (*frac != '.' || end == NULL || end == frac || val < 0 || val > ONE_BILLION || val == LONG_MIN || val == LONG_MAX) { fprintf(stderr, "3: editcap: \"%s\" isn't a valid rel time value\n",