[net.sources] A Usenet article generator 4.3 FIX

trainor@ucla-cs.UUCP (02/19/87)

>Well, I compiled and run it, but at the end of producing its amusing
>output, it constantly gives "Segmentation fault - core dumped". This
>is on a VAX running 4.3BSD.

Same here.  It's just a sloppy pointer thing...  The DIFFs follow.
Also, the roll(n) function was returning large integers, outside the
range.  Please note that the low-order bits of most rand() functions
are junk!!!!  If you have random(), use it.

	Douglas

141c141
< 		srand ((unsigned) atoi (optarg));
---
> 		srand (atoi (optarg));
377c377
<     return (int) (n * (double) rand() / 32768.);
---
>     return ((((rand()>>8)&0x7fff)*n)/0x7fff);
403c403
< 	if (tp == NULL)
---
> 	if (p->scnod == (struct node *) NULL || tp == (char *) NULL)
ARPA:  trainor@locus.ucla.edu
UUCP:  ..!{sch-loki,silogic,randvax,ihnp4,sdcrdcf,trwspp,ucbvax}!ucla-cs!trainor
SNAKE: trainor@eric.sidewinder.snake

jbuck@epimass.UUCP (02/20/87)

In article <4544@curly.ucla-cs.UCLA.EDU< trainor@CS.UCLA.EDU (Vulture of Light) writes:
<<Well, I compiled and run it, but at the end of producing its amusing
<<output, it constantly gives "Segmentation fault - core dumped". This
<<is on a VAX running 4.3BSD.
<
<Same here.  It's just a sloppy pointer thing...  The DIFFs follow.

Blush.  Well, it passed lint when I posted it.

<Also, the roll(n) function was returning large integers, outside the
<range.  Please note that the low-order bits of most rand() functions
<are junk!!!!  If you have random(), use it.

I agree.  Though in fairness, my system doesn't have random(), and
my documentation mentioned that roll(n) was likely to need change.
-- 
- Joe Buck 	{hplabs,ihnp4,sun,ames}!oliveb!epimass!jbuck
  Entropic Processing, Inc., Cupertino, California