peter@baylor.UUCP (Peter da Silva) (08/19/85)
> cc -E prog.c | cb | cat -s
ANOTHER FLAG FOR CAT!?!?!? How many places have cat -s?
--
Peter (Made in Australia) da Silva
UUCP: ...!shell!neuro1!{hyd-ptd,baylor,datafac}!peter
MCI: PDASILVA; CIS: 70216,1076
rlk@chinet.UUCP (Richard L. Klappal) (08/22/85)
In article <471@baylor.UUCP> peter@baylor.UUCP (Peter da Silva) writes: >> cc -E prog.c | cb | cat -s > >ANOTHER FLAG FOR CAT!?!?!? How many places have cat -s? >-- > Peter (Made in Australia) da Silva The Fortune 32:16 has it. Means force single spacing on output (kinda like uniq) to get rid of excessive blank lines. PS: Peter: Could you post the MSDOS version of cb. (if legal to do so). I friend uses the Idiot/Barely Moron with Lattice, and would appreciate having cb. (+vi + ... UN*X :-)). Richard Klappal UUCP: ..!ihnp4!chinet!uklpl!rlk | "Money is truthful. If a man MCIMail: rklappal | speaks of his honor, make him Compuserve: 74106,1021 | pay cash." USPS: 1 S 299 Danby Street | Villa Park IL 60181 | Lazarus Long TEL: (312) 620-4988 | (aka R. Heinlein) -------------------------------------------------------------------------
root@bu-cs.UUCP (Barry Shein) (08/24/85)
Not really a bite, but I remember when I was first learning C I was quite bewildered by the fact that you couldn't really declare your own 'argv', that is, you couldn't declare an array of pointers to fixed length buffers except perhaps by: char *myargv[] = { "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", etc I mean, argv seemed kinda holy to me, disturbing. -Barry Shein, Boston University P.S. I know argv is var length, but that would be even harder to declare!
peters@cubsvax.UUCP (Peter S. Shenkin) (08/26/85)
I've had several bugs involving code hidden in macro definitions which have
been very difficult to find. One I recall offhand went something like this:
/* OPEN MOUTH *****************************************************************/
#define Coords(I) (complicated.structure.redirection[I].x, \
complicated.structure.redirection[I].y, \
complicated.structure.redirection[I].z )
main()
{
...
subr(Coords(i)); /* BITE */
...
}
/***************************************************************************/
subr(x,y,z)
float x,y,z;
{...}
/* SWALLOW ******************************************************************/
Problem is, when expanded, the call to subr looks like
subr((exp1,exp2,exp3));
The comma operator is applied, and subr() gets only exp1 !!! The interesting
thing is that if anyone had asked me, whether (something), ((something)),
and (((something))) mean the same in C, I would have said "Yes," without
thinking. Obviously, I would have been wrong.
Peter S. Shenkin philabs!cubsvax!peters Columbia Univ. Biology
dave@lsuc.UUCP (David Sherman) (08/30/85)
> >ANOTHER FLAG FOR CAT!?!?!? How many places have cat -s? > > The Fortune 32:16 has it. Means force single spacing on output > (kinda like uniq) to get rid of excessive blank lines. For those with BSD systems, or (as in our case) systems with some BSD utilities, the ssp(1) program does this. (It's used by man(1) for output to a terminal.) Dave Sherman The Law Society of Upper Canada Toronto -- { ihnp4!utzoo pesnta utcs hcr decvax!utcsri } !lsuc!dave
guy@sun.uucp (Guy Harris) (08/31/85)
> Not really a bite, but I remember when I was first learning C > I was quite bewildered by the fact that you couldn't really > declare your own 'argv', that is, you couldn't declare an > array of pointers to fixed length buffers except perhaps by: > > char *myargv[] = { > "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", > "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", > > etc > > I mean, argv seemed kinda holy to me, disturbing. If you want an array of pointers to fixed-length buffers, you can declare it as long as the number of such pointers can be determined at the time you write the code. char bufs[3][20]; char *bufps[3] = { bufs[0], bufs[1], bufs[2], }; If the number can't be fixed when you write the code, you can set up "bufps" at run time. Also note that "argv" isn't a pointer to an array of pointers to fixed-length buffers, it's a pointer to an array of pointers to strings, which you *can* declare. > P.S. I know argv is var length, but that would be even harder to declare! The secret is that "argv" (or, more correctly, what "argv" points to) *isn't* declared. Pointers need not point to things which have been declared; "malloc" returns pointers to objects fabricated on the fly. If you have "n" arguments ("n" is a variable here), just do register char **argv; argv = (char **)malloc(n * sizeof(char *)); And you can fill them in. Guy Harris
peter@graffiti.UUCP (Peter da Silva) (09/03/85)
> > Not really a bite, but I remember when I was first learning C > > I was quite bewildered by the fact that you couldn't really > > declare your own 'argv', that is, you couldn't declare an > > array of pointers to fixed length buffers except perhaps by: > > > > char *myargv[] = { > > "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", > > "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", > > What are you talking about? char *myargv[5] = { "/bin/sh", "sh", "-c", "echo 'well it worked'", NULL }; What's so holy about this?