diff options
author | Diomidis Spinellis <dds@FreeBSD.org> | 2006-11-06 08:47:41 +0000 |
---|---|---|
committer | Diomidis Spinellis <dds@FreeBSD.org> | 2006-11-06 08:47:41 +0000 |
commit | d737ec1ad49e1d8c904cfdfd63edd46e22e00776 (patch) | |
tree | 2bbe779e0a32729bbb984215640a67aba30b7c70 /usr.bin/jot/jot.c | |
parent | 2c75d9c7bad1588b035c1c967a8519847d9bd4eb (diff) | |
download | src-d737ec1ad49e1d8c904cfdfd63edd46e22e00776.tar.gz src-d737ec1ad49e1d8c904cfdfd63edd46e22e00776.zip |
Merge code in common cases.
Verified by: New regression tests in tools/regression/usr.bin/jot
MFC after: 2 weeks
Notes
Notes:
svn path=/head/; revision=164023
Diffstat (limited to 'usr.bin/jot/jot.c')
-rw-r--r-- | usr.bin/jot/jot.c | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/usr.bin/jot/jot.c b/usr.bin/jot/jot.c index 9fd5619e859a..c2b001bcaf59 100644 --- a/usr.bin/jot/jot.c +++ b/usr.bin/jot/jot.c @@ -184,52 +184,29 @@ main(int argc, char **argv) while (mask) /* 4 bit mask has 1's where last 4 args were given */ switch (mask) { /* fill in the 0's by default or computation */ case HAVE_STEP: - reps = REPS_DEF; - mask = HAVE_REPS | HAVE_STEP; - break; case HAVE_ENDER: - reps = REPS_DEF; - mask = HAVE_REPS | HAVE_ENDER; - break; case HAVE_ENDER | HAVE_STEP: - reps = REPS_DEF; - mask = HAVE_REPS | HAVE_ENDER | HAVE_STEP; - break; case HAVE_BEGIN: - reps = REPS_DEF; - mask = HAVE_REPS | HAVE_BEGIN; - break; case HAVE_BEGIN | HAVE_STEP: - reps = REPS_DEF; - mask = HAVE_REPS | HAVE_BEGIN | HAVE_STEP; - break; case HAVE_BEGIN | HAVE_ENDER: reps = REPS_DEF; - mask = HAVE_REPS | HAVE_BEGIN | HAVE_ENDER; + mask |= HAVE_REPS; break; case HAVE_BEGIN | HAVE_ENDER | HAVE_STEP: - if (randomize) { + if (randomize) reps = REPS_DEF; - mask = 0; - break; - } - if (s == 0.0) { + else if (s == 0.0) reps = 0; - mask = 0; - break; - } - reps = (ender - begin + s) / s; + else + reps = (ender - begin + s) / s; if (reps <= 0) errx(1, "impossible stepsize"); mask = 0; break; case HAVE_REPS: - begin = BEGIN_DEF; - mask = HAVE_REPS | HAVE_BEGIN; - break; case HAVE_REPS | HAVE_STEP: begin = BEGIN_DEF; - mask = HAVE_REPS | HAVE_BEGIN | HAVE_STEP; + mask |= HAVE_BEGIN; break; case HAVE_REPS | HAVE_ENDER: s = (randomize ? time(NULL) : STEP_DEF); |