The attached patch makes two modifications to editcap:
- makes a leading zero in the argument to -t optional. the original
code required -t 0.5 or -t -0.5, with this patch -t .5 and -t -.5
are accepted as well
- includes the -t option in in the summary portion of of the editcap
usage message
cheers,
--Scott
--
Scott Renfro <scott@xxxxxxxxxx> +1 650 862 4206
Index: editcap.c
===================================================================
RCS file: /cvsroot/ethereal/editcap.c,v
retrieving revision 1.16
diff -u -r1.16 editcap.c
--- editcap.c 2001/07/12 08:16:44 1.16
+++ editcap.c 2001/07/13 07:18:33
@@ -216,21 +216,38 @@
if (!optarg)
return;
- /* first collect the whole seconds */
- val = strtol(optarg, &frac, 10);
- if (frac == NULL || frac == optarg || val == LONG_MIN || val == LONG_MAX) {
- fprintf(stderr, "editcap: \"%s\" is not a valid time adjustment\n",
- optarg);
- exit(1);
- }
- if (val < 0) {
- time_adj.is_negative = 1;
- val = -val;
+ /* skip leading whitespace */
+ while (*optarg == ' ' || *optarg == '\t') {
+ optarg++;
}
+
+ /* check for a negative adjustment */
+ if (*optarg == '-') {
+ time_adj.is_negative = 1;
+ optarg++;
+ }
+
+ /* collect whole number of seconds, if any */
+ if (*optarg == '.') { /* only fractional (i.e., .5 is ok) */
+ val = 0;
+ frac = optarg;
+ } else {
+ val = strtol(optarg, &frac, 10);
+ if (frac == NULL || frac == optarg || val == LONG_MIN || val == LONG_MAX) {
+ fprintf(stderr, "editcap: \"%s\" is not a valid time adjustment\n",
+ optarg);
+ exit(1);
+ }
+ if (val < 0) { /* implies '--' since we caught '-' above */
+ fprintf(stderr, "editcap: \"%s\" is not a valid time adjustment\n",
+ optarg);
+ exit(1);
+ }
+ }
time_adj.tv.tv_sec = val;
/* now collect the partial seconds, if any */
- if (*frac != '\0') { /* have more to string, so more to */
+ if (*frac != '\0') { /* chars left, so get fractional part */
val = strtol(&(frac[1]), &end, 10);
if (*frac != '.' || end == NULL || end == frac
|| val < 0 || val > ONE_MILLION || val == LONG_MIN || val == LONG_MAX) {
@@ -261,7 +278,8 @@
const char *string;
fprintf(stderr, "Usage: editcap [-r] [-h] [-v] [-T <encap type>] [-F <capture type>]\n");
- fprintf(stderr, " [-s <snaplen>] <infile> <outfile> [ <record#>[-<record#>] ... ]\n");
+ fprintf(stderr, " [-s <snaplen>] [-t <time adjustment\n");
+ fprintf(stderr, " <infile> <outfile> [ <record#>[-<record#>] ... ]\n");
fprintf(stderr, " where\t-r specifies that the records specified should be kept, not deleted, \n");
fprintf(stderr, " default is to delete\n");
fprintf(stderr, " \t-v specifies verbose operation, default is silent\n");