diff --git a/sh.h b/sh.h index f34f256..bf65be9 100644 --- a/sh.h +++ b/sh.h @@ -152,7 +152,7 @@ #endif #ifdef EXTERN -__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.547 2012/04/14 14:07:47 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.548 2012/04/14 14:35:12 tg Exp $"); #endif #define MKSH_VERSION "R40 2012/04/07" @@ -1888,6 +1888,7 @@ size_t array_ref_len(const char *); char *arrayname(const char *); mksh_uari_t set_array(const char *, bool, const char **); uint32_t hash(const void *); +mksh_ari_t rndget(void); void rndset(long); enum Test_op { diff --git a/var.c b/var.c index a7cd348..fcaf6e5 100644 --- a/var.c +++ b/var.c @@ -27,7 +27,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/var.c,v 1.145 2012/04/07 11:19:53 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/var.c,v 1.146 2012/04/14 14:35:13 tg Exp $"); /*- * Variables @@ -1094,11 +1094,7 @@ getspec(struct tbl *vp) return; break; case V_RANDOM: - /* - * this is the same Linear Congruential PRNG as Borland - * C/C++ allegedly uses in its built-in rand() function - */ - i = ((lcg_state = 22695477 * lcg_state + 1) >> 16) & 0x7FFF; + i = rndget(); break; case V_HISTSIZE: i = histsize; @@ -1479,6 +1475,16 @@ hash(const void *s) return (h); } +mksh_ari_t +rndget(void) +{ + /* + * this is the same Linear Congruential PRNG as Borland + * C/C++ allegedly uses in its built-in rand() function + */ + return (((lcg_state = 22695477 * lcg_state + 1) >> 16) & 0x7FFF); +} + void rndset(long v) {