patch 9.1.1811: Amiga: Initialization of random buffer can be improved

Commit: 
https://github.com/vim/vim/commit/decc9dd6a2f9434326ee17b9d0b8089ebb227635
Author: Ola Söder <[email protected]>
Date:   Mon Sep 29 20:19:36 2025 +0000

    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 <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/os_amiga.c b/src/os_amiga.c
index d09974f94..aa50779ec 100644
--- a/src/os_amiga.c
+++ b/src/os_amiga.c
@@ -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;
+}
diff --git a/src/proto/os_amiga.pro b/src/proto/os_amiga.pro
old mode 100644
new mode 100755
index abebae154..86d14903d
--- a/src/proto/os_amiga.pro
+++ b/src/proto/os_amiga.pro
@@ -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 : */
diff --git a/src/version.c b/src/version.c
index b82a01a92..5c74bc0e1 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1811,
 /**/
     1810,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1v3KVX-001q8M-A5%40256bit.org.

Raspunde prin e-mail lui