From b8ae43dd24dcc81779c87d81244ab539f9107fa2 Mon Sep 17 00:00:00 2001 From: Claes Nästén Date: Mon, 6 Dec 2021 07:43:44 +0100 Subject: fix: skip libutil on SunOS libutil is not available on Solaris variants, even on Solaris 11 where forkpty is available. --- src/nvim/CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 185d55daed..bb16459a7f 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -468,9 +468,11 @@ list(APPEND NVIM_LINK_LIBRARIES if(UNIX) list(APPEND NVIM_LINK_LIBRARIES - m - util - ) + m) + if (NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS") + list(APPEND NVIM_LINK_LIBRARIES + util) + endif() endif() set(NVIM_EXEC_LINK_LIBRARIES ${NVIM_LINK_LIBRARIES} ${LUA_PREFERRED_LIBRARIES}) -- cgit From 8fdf1b265d982b80bfa8e6d98374514ece20a03e Mon Sep 17 00:00:00 2001 From: Claes Nästén Date: Mon, 6 Dec 2021 07:44:44 +0100 Subject: fix: define NAME_MAX from _XOPEN_NAME_MAX On SunOS NAME_MAX is not defined, _XOPEN_NAME_MAX is so fall back to defining NAME_MAX from _XOPEN_NAME_MAX. --- src/nvim/os/os_defs.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/nvim/os/os_defs.h b/src/nvim/os/os_defs.h index 8049b3b80e..dce4b0c187 100644 --- a/src/nvim/os/os_defs.h +++ b/src/nvim/os/os_defs.h @@ -13,6 +13,10 @@ # include "nvim/os/unix_defs.h" #endif +#if !defined(NAME_MAX) && defined(_XOPEN_NAME_MAX) +#define NAME_MAX _XOPEN_NAME_MAX +#endif + #define BASENAMELEN (NAME_MAX - 5) // Use the system path length if it makes sense. -- cgit From 8f1fdbc54a873abc7375c785b2b6ee5440910de2 Mon Sep 17 00:00:00 2001 From: Claes Nästén Date: Mon, 6 Dec 2021 07:49:15 +0100 Subject: fix: add STRNLEN compatability macro Older SunOS systems come without strnlen, add STRNLEN macro in line with the other str* compat macros. --- src/nvim/api/private/helpers.c | 2 +- src/nvim/message.c | 2 +- src/nvim/strings.c | 12 ++++++++++++ src/nvim/vim.h | 5 +++++ 4 files changed, 19 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index d470def277..9b407eab8b 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -513,7 +513,7 @@ String cbuf_to_string(const char *buf, size_t size) String cstrn_to_string(const char *str, size_t maxsize) FUNC_ATTR_NONNULL_ALL { - return cbuf_to_string(str, strnlen(str, maxsize)); + return cbuf_to_string(str, STRNLEN(str, maxsize)); } /// Creates a String using the given C string. Unlike diff --git a/src/nvim/message.c b/src/nvim/message.c index 6fcd4cef8a..d698cfbeda 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -2056,7 +2056,7 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr, int recurs msg_ext_last_attr = attr; } // Concat pieces with the same highlight - size_t len = strnlen((char *)str, maxlen); // -V781 + size_t len = STRNLEN(str, maxlen); // -V781 ga_concat_len(&msg_ext_last_chunk, (char *)str, len); msg_ext_cur_len += len; return; diff --git a/src/nvim/strings.c b/src/nvim/strings.c index c58e052ae9..27f93fe4ce 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -394,6 +394,18 @@ void del_trailing_spaces(char_u *ptr) } } +#if !defined(HAVE_STRNLEN) +size_t xstrnlen(const char *s, size_t n) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE +{ + const char *end = memchr(s, '\0', n); + if (end == NULL) { + return n; + } + return end - s; +} +#endif + #if (!defined(HAVE_STRCASECMP) && !defined(HAVE_STRICMP)) /* * Compare two strings, ignoring case, using current locale. diff --git a/src/nvim/vim.h b/src/nvim/vim.h index e3539c1a57..2f8ddd1e88 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -215,6 +215,11 @@ enum { FOLD_TEXT_LEN = 51, }; //!< buffer size for get_foldtext() // (vim_strchr() is now in strings.c) #define STRLEN(s) strlen((char *)(s)) +#ifdef HAVE_STRNLEN +# define STRNLEN(s, n) strnlen((char *)(s), (size_t)(n)) +#else +# define STRNLEN(s, n) xstrnlen((char *)(s), (size_t)(n)) +#endif #define STRCPY(d, s) strcpy((char *)(d), (char *)(s)) #define STRNCPY(d, s, n) strncpy((char *)(d), (char *)(s), (size_t)(n)) #define STRLCPY(d, s, n) xstrlcpy((char *)(d), (char *)(s), (size_t)(n)) -- cgit From 435dd04bdb7b385fe63bdd6985cda3380663e959 Mon Sep 17 00:00:00 2001 From: Claes Nästén Date: Mon, 6 Dec 2021 07:51:42 +0100 Subject: fix: don't include pty.h on SunOS --- src/nvim/os/pty_process_unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/os/pty_process_unix.c b/src/nvim/os/pty_process_unix.c index 24ecf5c24f..abbb410293 100644 --- a/src/nvim/os/pty_process_unix.c +++ b/src/nvim/os/pty_process_unix.c @@ -15,7 +15,7 @@ # include #elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) # include -#else +#elif !defined(__sun) # include #endif -- cgit From 05f9f63f2478841f9fa6261c68663797fa9d43f6 Mon Sep 17 00:00:00 2001 From: Claes Nästén Date: Mon, 6 Dec 2021 07:53:14 +0100 Subject: fix: don't use cfsetspeed, use i and o variants cfsetspeed is not available on SunOS, use cfsetispeed and cfsetospeed instead. --- src/nvim/os/pty_process_unix.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/os/pty_process_unix.c b/src/nvim/os/pty_process_unix.c index abbb410293..450bc75ffb 100644 --- a/src/nvim/os/pty_process_unix.c +++ b/src/nvim/os/pty_process_unix.c @@ -198,7 +198,9 @@ static void init_termios(struct termios *termios) FUNC_ATTR_NONNULL_ALL termios->c_cflag = CS8|CREAD; termios->c_lflag = ISIG|ICANON|IEXTEN|ECHO|ECHOE|ECHOK; - cfsetspeed(termios, 38400); + // not using cfsetspeed, not available on all platforms + cfsetispeed(termios, 38400); + cfsetospeed(termios, 38400); #ifdef IUTF8 termios->c_iflag |= IUTF8; -- cgit