summaryrefslogtreecommitdiffstats
path: root/src/os_unix.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:05:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:05:19 +0000
commita4e9136f68a40b1cb0eb6df5a5f06603224a87f4 (patch)
treeba32e0d0069ad6adfd6b32d05161a03eea5e4c7c /src/os_unix.c
parentReleasing progress-linux version 2:9.1.0496-1~progress7.99u1. (diff)
downloadvim-a4e9136f68a40b1cb0eb6df5a5f06603224a87f4.tar.xz
vim-a4e9136f68a40b1cb0eb6df5a5f06603224a87f4.zip
Merging upstream version 2:9.1.0698.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/os_unix.c42
1 files changed, 38 insertions, 4 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index d155142..e77a4b2 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -2699,6 +2699,9 @@ mch_FullName(
if ((force || !mch_isFullName(fname))
&& ((p = vim_strrchr(fname, '/')) == NULL || p != fname))
{
+ if (p == NULL && STRCMP(fname, "..") == 0)
+ // Handle ".." without path separators.
+ p = fname + 2;
/*
* If the file name has a path, change to that directory for a moment,
* and then get the directory (and get back to where we were).
@@ -2707,7 +2710,7 @@ mch_FullName(
if (p != NULL)
{
if (STRCMP(p, "/..") == 0)
- // for "/path/dir/.." include the "/.."
+ // For "/path/dir/.." include the "/..".
p += 3;
#ifdef HAVE_FCHDIR
@@ -7498,9 +7501,9 @@ gpm_open(void)
{
Gpm_Close(); // We don't want to talk to xterm via gpm
- // Gpm_Close fails to properly restore the WINCH and TSTP handlers,
- // leading to Vim ignoring resize signals. We have to re-initialize
- // these handlers again here.
+ // Gpm_Close fails to properly restore the WINCH and TSTP handlers,
+ // leading to Vim ignoring resize signals. We have to re-initialize
+ // these handlers again here.
# ifdef SIGWINCH
mch_signal(SIGWINCH, sig_winch);
# endif
@@ -7722,6 +7725,37 @@ sig_sysmouse SIGDEFARG(sigarg)
}
#endif // FEAT_SYSMOUSE
+/*
+ * Fill the buffer 'buf' with 'len' random bytes.
+ * Returns FAIL if the OS PRNG is not available or something went wrong.
+ */
+ int
+mch_get_random(char_u *buf, int len)
+{
+ static int dev_urandom_state = NOTDONE;
+
+ if (dev_urandom_state == FAIL)
+ return FAIL;
+
+ int fd = open("/dev/urandom", O_RDONLY);
+
+ // Attempt reading /dev/urandom.
+ if (fd == -1)
+ dev_urandom_state = FAIL;
+ else if (read(fd, buf, len) == len)
+ {
+ dev_urandom_state = OK;
+ close(fd);
+ }
+ else
+ {
+ dev_urandom_state = FAIL;
+ close(fd);
+ }
+
+ return dev_urandom_state;
+}
+
#if defined(FEAT_LIBCALL) || defined(PROTO)
typedef char_u * (*STRPROCSTR)(char_u *);
typedef char_u * (*INTPROCSTR)(int);