mirror of
https://github.com/vim/vim.git
synced 2025-10-17 07:44:28 -04:00
patch 9.1.1811: Amiga: Initialization of random buffer can be improved
Problem: Amiga: Initialization of random buffer can be improved Solution: Use RANDOM device when available (Ola Söder) closes: #18419 Signed-off-by: Ola Söder <rolfkopman@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
b3966d6a8e
commit
decc9dd6a2
@@ -1768,3 +1768,31 @@ mch_setenv(char *var, char *value, int x UNUSED)
|
||||
return 0; // success
|
||||
return -1; // failure
|
||||
}
|
||||
|
||||
/*
|
||||
* Fill the buffer 'buf' with 'len' random bytes.
|
||||
* Returns FAIL if RANDOM: is not available or something went wrong.
|
||||
*/
|
||||
int
|
||||
mch_get_random(char_u *buf, int len)
|
||||
{
|
||||
struct Process *proc = (struct Process *) FindTask(0L);
|
||||
APTR win = proc->pr_WindowPtr;
|
||||
|
||||
// Don't show requester if RANDOM: doesn't exist
|
||||
proc->pr_WindowPtr = (APTR) -1L;
|
||||
|
||||
BPTR fh = Open("RANDOM:", MODE_OLDFILE);
|
||||
|
||||
proc->pr_WindowPtr = win;
|
||||
|
||||
int status;
|
||||
|
||||
if (!fh || Read(fh, buf, len) != len)
|
||||
status = FAIL;
|
||||
else
|
||||
status = OK;
|
||||
|
||||
Close(fh);
|
||||
return status;
|
||||
}
|
||||
|
1
src/proto/os_amiga.pro
Normal file → Executable file
1
src/proto/os_amiga.pro
Normal file → Executable file
@@ -43,4 +43,5 @@ int mch_has_exp_wildcard(char_u *p);
|
||||
int mch_has_wildcard(char_u *p);
|
||||
char_u *mch_getenv(char_u *var);
|
||||
int mch_setenv(char *var, char *value, int x);
|
||||
int mch_get_random(char_u *buf, int len);
|
||||
/* vim: set ft=c : */
|
||||
|
@@ -729,6 +729,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1811,
|
||||
/**/
|
||||
1810,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user