]> granicus.if.org Git - vim/commitdiff
patch 8.1.2084: Amiga: cannot get the user name v8.1.2084
authorBram Moolenaar <Bram@vim.org>
Fri, 27 Sep 2019 11:38:56 +0000 (13:38 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 27 Sep 2019 11:38:56 +0000 (13:38 +0200)
Problem:    Amiga: cannot get the user name.
Solution:   Use getpwuid() if available. (Ola Söder, closes #4985)

src/os_amiga.c
src/os_amiga.h
src/version.c

index dfc805374ff5271f828b3e4d3b4bd0f9b162fd61..aff24c5674ee97dce9a4ff3ff09b6dbca10fca7e 100644 (file)
@@ -664,7 +664,15 @@ mch_can_restore_icon(void)
     int
 mch_get_user_name(char_u *s, int len)
 {
-    /* TODO: Implement this. */
+#if defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__)
+    struct passwd   *pwd = getpwuid(getuid());
+
+    if (pwd != NULL && pwd->pw_name && len > 0)
+    {
+        vim_strncpy(s, (char_u *)pwd->pw_name, len - 1);
+        return OK;
+    }
+#endif
     *s = NUL;
     return FAIL;
 }
index 6f951fb96b861157a15079972917bbb0111df55f..71841ac6a550a1164a01a161751a5bc0fd8dd325 100644 (file)
@@ -90,6 +90,7 @@ typedef long off_t;
 # include <unistd.h>
 # include <limits.h>
 # include <errno.h>
+# include <pwd.h>
 # include <dirent.h>
 #endif
 
index 98ddcca846b13d4074f0b2b528e19f7bd3f655fd..6c17851ecee4d7d1630f90442f1f646868f2312e 100644 (file)
@@ -757,6 +757,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2084,
 /**/
     2083,
 /**/