aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os/users.c
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-01-25 18:31:31 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-01-25 18:31:31 +0000
commit9243becbedbb6a1592208051f8fa2b090dcc5e7d (patch)
tree607c2a862ec3f4399b8766383f6f8e04c4aa43b4 /src/nvim/os/users.c
parent9e40b6e9e1bc67f2d856adb837ee64dd0e25b717 (diff)
parent3c48d3c83fc21dbc0841f9210f04bdb073d73cd1 (diff)
downloadrneovim-usermarks.tar.gz
rneovim-usermarks.tar.bz2
rneovim-usermarks.zip
Merge remote-tracking branch 'upstream/master' into usermarksusermarks
Diffstat (limited to 'src/nvim/os/users.c')
-rw-r--r--src/nvim/os/users.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/nvim/os/users.c b/src/nvim/os/users.c
index bd34e917b2..ef2986246b 100644
--- a/src/nvim/os/users.c
+++ b/src/nvim/os/users.c
@@ -3,6 +3,9 @@
// users.c -- operating system user information
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
#include <uv.h>
#include "auto/config.h"
@@ -10,11 +13,12 @@
#include "nvim/garray.h"
#include "nvim/memory.h"
#include "nvim/os/os.h"
-#include "nvim/strings.h"
+#include "nvim/types.h"
+#include "nvim/vim.h"
#ifdef HAVE_PWD_H
# include <pwd.h>
#endif
-#ifdef WIN32
+#ifdef MSWIN
# include <lm.h>
#endif
@@ -56,7 +60,7 @@ int os_get_usernames(garray_T *users)
}
endpwent();
}
-#elif defined(WIN32)
+#elif defined(MSWIN)
{
DWORD nusers = 0, ntotal = 0, i;
PUSER_INFO_0 uinfo;
@@ -93,7 +97,7 @@ int os_get_usernames(garray_T *users)
for (i = 0; i < users->ga_len; i++) {
char *local_user = ((char **)users->ga_data)[i];
- if (STRCMP(local_user, user_env) == 0) {
+ if (strcmp(local_user, user_env) == 0) {
break;
}
}
@@ -142,7 +146,7 @@ int os_get_uname(uv_uid_t uid, char *s, size_t len)
if ((pw = getpwuid(uid)) != NULL // NOLINT(runtime/threadsafe_fn)
&& pw->pw_name != NULL && *(pw->pw_name) != NUL) {
- STRLCPY(s, pw->pw_name, len);
+ xstrlcpy(s, pw->pw_name, len);
return OK;
}
#endif
@@ -208,17 +212,17 @@ char *get_users(expand_T *xp, int idx)
/// @return 0 if name does not match any user name.
/// 1 if name partially matches the beginning of a user name.
/// 2 is name fully matches a user name.
-int match_user(char_u *name)
+int match_user(char *name)
{
- int n = (int)STRLEN(name);
+ int n = (int)strlen(name);
int result = 0;
init_users();
for (int i = 0; i < ga_users.ga_len; i++) {
- if (STRCMP(((char_u **)ga_users.ga_data)[i], name) == 0) {
+ if (strcmp(((char **)ga_users.ga_data)[i], name) == 0) {
return 2; // full match
}
- if (STRNCMP(((char_u **)ga_users.ga_data)[i], name, n) == 0) {
+ if (strncmp(((char **)ga_users.ga_data)[i], name, (size_t)n) == 0) {
result = 1; // partial match
}
}