Shells, features and interaction
Joseph S. D. Yao
jsdy at hadron.UUCP
Thu Nov 28 16:15:18 AEST 1985
In article <3387 at brl-tgr.ARPA> gwyn at brl-tgr.ARPA (Doug Gwyn <gwyn>) writes:
>I hope to post a public domain implementation of "seq" (which
>Rob called "loop" in his example) soon. Stay tuned.
You mean this?
/* #include <local.h> */
/*********************************************************************\
**
** loop -- do a quick FORTRAN-style (ech) numeric loop
**
** Syntax:
** loop [ start [ end [ incr ] ] ]
**
** Copyright and Disclaimers:
** Who cares? It's past midnight. Have a ball.
**
** Description:
** This is a program that really counts.
**
#ifdef SCCS
** Last modified %G% %U%. Last retrieved %H% %T%.
**
# else
** $Log:$
#endif SCCS
** Author:
** Joseph S. D. Yao
** Engineering and Information Systems Division
** Hadron, Inc.
** 9990 Lee Highway
** Fairfax VA 22030
** (703) 359-6163
**
** Routines:
** main(argc, argv, envp)
**
\*********************************************************************/
#ifndef lint
# ifdef SCCS
static char SCCS_id[] = "%W%";
# else
static char RCS_id[] =
"@(#)$Header:$";
# endif SCCS
#endif lint
main(argc, argv, envp)
int argc;
char **argv;
char **envp;
{
register int var, end, incr;
#ifdef lint
argv = envp;
#endif lint
var = end = incr = 1;
/* Arg 1: start value for var. */
if (--argc > 0)
var = atoi(*++argv);
/* Arg 2: end value for var. */
if (--argc > 0)
end = atoi(*++argv);
/* Arg 3: increment for var. */
if (--argc > 0)
incr = atoi(*++argv);
/* A zero increment could take a while. */
if (incr == 0)
incr = 1;
/*
** Different tests are used if incr < 0 or > 0.
** This coding is for speed, not program size.
*/
if (incr < 0) {
while (var >= end) {
printf("%d\n", var);
var += incr;
}
} else {
while (var <= end) {
printf("%d\n", var);
var += incr;
}
}
return(0);
}
--
Joe Yao hadron!jsdy at seismo.{CSS.GOV,ARPA,UUCP}
More information about the Comp.unix
mailing list