make mksh compatible to the AT&T ksh spec which says, according to
twkm (from #ksh on freenode), that $RANDOM is always an unsigned 15-bit decimal integer. (RANDOM << 15 | RANDOM) thusly yields 30 bit, which is still more than 36^5, so we can use it on the baselife CD to speed things up
This commit is contained in:
parent
8adc4a2c56
commit
c2e79abc08
4
check.t
4
check.t
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.74 2006/11/12 10:44:41 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.75 2006/11/19 16:43:41 tg Exp $
|
||||||
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
||||||
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
||||||
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
||||||
@ -7,7 +7,7 @@
|
|||||||
# http://www.research.att.com/~gsf/public/ifs.sh
|
# http://www.research.att.com/~gsf/public/ifs.sh
|
||||||
|
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)MIRBSD KSH R29 2006/11/12
|
@(#)MIRBSD KSH R29 2006/11/19
|
||||||
description:
|
description:
|
||||||
Check version of shell.
|
Check version of shell.
|
||||||
category: pdksh
|
category: pdksh
|
||||||
|
11
mksh.1
11
mksh.1
@ -1,7 +1,7 @@
|
|||||||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.67 2006/11/16 13:05:39 tg Exp $
|
.\" $MirOS: src/bin/mksh/mksh.1,v 1.68 2006/11/19 16:43:42 tg Exp $
|
||||||
.\" $OpenBSD: ksh.1,v 1.116 2006/07/26 10:13:25 jmc Exp $
|
.\" $OpenBSD: ksh.1,v 1.116 2006/07/26 10:13:25 jmc Exp $
|
||||||
.\"
|
.\"
|
||||||
.Dd November 12, 2006
|
.Dd November 19, 2006
|
||||||
.Dt MKSH 1
|
.Dt MKSH 1
|
||||||
.Os MirBSD
|
.Os MirBSD
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -1550,14 +1550,13 @@ Every time
|
|||||||
is referenced, it is assigned a pseudo-random number first.
|
is referenced, it is assigned a pseudo-random number first.
|
||||||
By default, if available,
|
By default, if available,
|
||||||
.Xr arc4random 3
|
.Xr arc4random 3
|
||||||
is used to produce unsigned 31\-bit values (0\-2147483647)
|
is used to produce unsigned 15\-bit values (0\-32767)
|
||||||
whose quality depends on the operating environment.
|
whose quality depends on the operating environment.
|
||||||
If
|
If
|
||||||
.Ev RANDOM
|
.Ev RANDOM
|
||||||
is assigned a value, it is used as the seed to
|
is assigned a value, it is used as the seed to
|
||||||
.Xr srand 3
|
.Xr srand 3
|
||||||
and subsequent references yield a semi-predictable sequence
|
and subsequent references yield a semi-predictable sequence from
|
||||||
of unsigned 15\-bit results (0\-32767) employing
|
|
||||||
.Xr rand 3 .
|
.Xr rand 3 .
|
||||||
.It Ev REPLY
|
.It Ev REPLY
|
||||||
Default parameter for the
|
Default parameter for the
|
||||||
@ -5190,7 +5189,6 @@ Shell database.
|
|||||||
Privileged shell profile.
|
Privileged shell profile.
|
||||||
.El
|
.El
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr arc4random 1 ,
|
|
||||||
.Xr awk 1 ,
|
.Xr awk 1 ,
|
||||||
.Xr ed 1 ,
|
.Xr ed 1 ,
|
||||||
.Xr getopt 1 ,
|
.Xr getopt 1 ,
|
||||||
@ -5206,6 +5204,7 @@ Privileged shell profile.
|
|||||||
.Xr open 2 ,
|
.Xr open 2 ,
|
||||||
.Xr pipe 2 ,
|
.Xr pipe 2 ,
|
||||||
.Xr wait 2 ,
|
.Xr wait 2 ,
|
||||||
|
.Xr arc4random 3 ,
|
||||||
.Xr getopt 3 ,
|
.Xr getopt 3 ,
|
||||||
.Xr nl_langinfo 3 ,
|
.Xr nl_langinfo 3 ,
|
||||||
.Xr rand 3 ,
|
.Xr rand 3 ,
|
||||||
|
4
sh.h
4
sh.h
@ -8,8 +8,8 @@
|
|||||||
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
|
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
|
||||||
/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
|
/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
|
||||||
|
|
||||||
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.84 2006/11/16 13:35:00 tg Exp $"
|
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.85 2006/11/19 16:43:43 tg Exp $"
|
||||||
#define MKSH_VERSION "R29 2006/11/12"
|
#define MKSH_VERSION "R29 2006/11/19"
|
||||||
|
|
||||||
#if HAVE_SYS_PARAM_H
|
#if HAVE_SYS_PARAM_H
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
12
var.c
12
var.c
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.32 2006/11/12 14:58:16 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.33 2006/11/19 16:43:43 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Variables
|
* Variables
|
||||||
@ -853,7 +853,7 @@ makenv(void)
|
|||||||
* we return values from rand() instead of arc4random()
|
* we return values from rand() instead of arc4random()
|
||||||
*/
|
*/
|
||||||
#if HAVE_ARC4RANDOM
|
#if HAVE_ARC4RANDOM
|
||||||
int use_rand = 0;
|
static int use_rand = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -919,13 +919,11 @@ getspec(struct tbl *vp)
|
|||||||
case V_RANDOM:
|
case V_RANDOM:
|
||||||
vp->flag &= ~SPECIAL;
|
vp->flag &= ~SPECIAL;
|
||||||
#if HAVE_ARC4RANDOM
|
#if HAVE_ARC4RANDOM
|
||||||
if (use_rand)
|
if (!use_rand)
|
||||||
#endif
|
setint(vp, arc4random() & 0x7FFF);
|
||||||
setint(vp, (long) (rand() & 0x7FFF));
|
|
||||||
#if HAVE_ARC4RANDOM
|
|
||||||
else
|
else
|
||||||
setint(vp, arc4random() & 0x7FFFFFFF);
|
|
||||||
#endif
|
#endif
|
||||||
|
setint(vp, rand() & 0x7FFF);
|
||||||
vp->flag |= SPECIAL;
|
vp->flag |= SPECIAL;
|
||||||
break;
|
break;
|
||||||
case V_HISTSIZE:
|
case V_HISTSIZE:
|
||||||
|
Loading…
Reference in New Issue
Block a user