Use a more sensible default of 1 or -1 when only the start and

end values are specified.

PR:		bin/68981
Submitted by:	Stefan `Sec` Zehl
MFC after:	2 weeks
This commit is contained in:
Diomidis Spinellis 2006-11-06 15:11:50 +00:00
parent 850cb5f8db
commit 7d71f06cb4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=164043
2 changed files with 9 additions and 2 deletions

View File

@ -115,7 +115,7 @@ conflict, the lower value is used.
If fewer than three are specified, defaults are assigned
left to right, except for
.Ar s ,
which assumes its default unless both
which assumes a default of 1 or -1 if both
.Ar begin
and
.Ar end
@ -171,6 +171,10 @@ a function in APL.
.Ex -std
.Sh EXAMPLES
The command
.Dl jot - 1 10
.Pp
prints the integers from 1 to 10,
while the command
.Dl jot 21 -1 1.00
.Pp
prints 21 evenly spaced numbers increasing from -1 to 1.

View File

@ -193,10 +193,13 @@ main(int argc, char **argv)
case HAVE_ENDER | HAVE_STEP:
case HAVE_BEGIN:
case HAVE_BEGIN | HAVE_STEP:
case HAVE_BEGIN | HAVE_ENDER:
reps = REPS_DEF;
mask |= HAVE_REPS;
break;
case HAVE_BEGIN | HAVE_ENDER:
s = ender > begin ? 1 : -1;
mask |= HAVE_STEP;
break;
case HAVE_BEGIN | HAVE_ENDER | HAVE_STEP:
if (randomize)
reps = REPS_DEF;