0
0
mirror of https://github.com/vim/vim.git synced 2025-10-18 07:54:29 -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:
Ola Söder
2025-09-29 20:19:36 +00:00
committed by Christian Brabandt
parent b3966d6a8e
commit decc9dd6a2
3 changed files with 31 additions and 0 deletions

View File

@@ -1768,3 +1768,31 @@ mch_setenv(char *var, char *value, int x UNUSED)
return 0; // success return 0; // success
return -1; // failure 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
View File

@@ -43,4 +43,5 @@ int mch_has_exp_wildcard(char_u *p);
int mch_has_wildcard(char_u *p); int mch_has_wildcard(char_u *p);
char_u *mch_getenv(char_u *var); char_u *mch_getenv(char_u *var);
int mch_setenv(char *var, char *value, int x); int mch_setenv(char *var, char *value, int x);
int mch_get_random(char_u *buf, int len);
/* vim: set ft=c : */ /* vim: set ft=c : */

View File

@@ -729,6 +729,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1811,
/**/ /**/
1810, 1810,
/**/ /**/