I think srand($0) should seed to whatever the content of $0 is, and srand
w/o argument should enable arc4random(). See the diff below.
$ echo 1|./obj/awk '{srand ; print rand}'
0.353398
$ echo 1|./obj/awk '{srand($0) ; print rand}'
0.840188
$ echo 1|./obj/awk '{srand($1) ; print rand}'
0.840188
$ echo 1|./obj/awk '{srand(1) ; print rand}'
0.840188
ok? Anyone with a large collection of awk scripts want to test?
sounds reasonable. fwiw, the behaviour you introduced mimics gawk. the
diff reads ok, except for a minor nit; please see below.
@@ -35,7 +35,7 @@ THIS SOFTWARE.
#include "awk.h"
#include "ytab.h"
-#define tempfree(x) if (istemp(x)) tfree(x); else
+#define tempfree(x) do {if (istemp(x)) tfree(x);} while (0)
/*
#undef tempfree
this could use some spaces and parentheses:
do { if (istemp((x)) tfree((x)); } while (0)
the rest of the diff, as i've already stated, looks fine to me.
-p.