Merge pull request #16547 from pekdon/sunos

Portability improvements, first steps at getting neovim on x86_64 SunOS
This commit is contained in:
James McCoy 2021-12-09 21:09:22 -05:00 committed by GitHub
commit 0cf546508d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 34 additions and 7 deletions

View File

@ -45,6 +45,7 @@ check_function_exists(readlink HAVE_READLINK)
check_function_exists(setpgid HAVE_SETPGID) check_function_exists(setpgid HAVE_SETPGID)
check_function_exists(setsid HAVE_SETSID) check_function_exists(setsid HAVE_SETSID)
check_function_exists(sigaction HAVE_SIGACTION) check_function_exists(sigaction HAVE_SIGACTION)
check_function_exists(strnlen HAVE_STRNLEN)
check_function_exists(strcasecmp HAVE_STRCASECMP) check_function_exists(strcasecmp HAVE_STRCASECMP)
check_function_exists(strncasecmp HAVE_STRNCASECMP) check_function_exists(strncasecmp HAVE_STRNCASECMP)
check_function_exists(strptime HAVE_STRPTIME) check_function_exists(strptime HAVE_STRPTIME)

View File

@ -30,6 +30,7 @@
#cmakedefine HAVE_SETPGID #cmakedefine HAVE_SETPGID
#cmakedefine HAVE_SETSID #cmakedefine HAVE_SETSID
#cmakedefine HAVE_SIGACTION #cmakedefine HAVE_SIGACTION
#cmakedefine HAVE_STRNLEN
#cmakedefine HAVE_STRCASECMP #cmakedefine HAVE_STRCASECMP
#cmakedefine HAVE_STRINGS_H #cmakedefine HAVE_STRINGS_H
#cmakedefine HAVE_STRNCASECMP #cmakedefine HAVE_STRNCASECMP

View File

@ -468,9 +468,11 @@ list(APPEND NVIM_LINK_LIBRARIES
if(UNIX) if(UNIX)
list(APPEND NVIM_LINK_LIBRARIES list(APPEND NVIM_LINK_LIBRARIES
m m)
util if (NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS")
) list(APPEND NVIM_LINK_LIBRARIES
util)
endif()
endif() endif()
set(NVIM_EXEC_LINK_LIBRARIES ${NVIM_LINK_LIBRARIES} ${LUA_PREFERRED_LIBRARIES}) set(NVIM_EXEC_LINK_LIBRARIES ${NVIM_LINK_LIBRARIES} ${LUA_PREFERRED_LIBRARIES})

View File

@ -513,7 +513,7 @@ String cbuf_to_string(const char *buf, size_t size)
String cstrn_to_string(const char *str, size_t maxsize) String cstrn_to_string(const char *str, size_t maxsize)
FUNC_ATTR_NONNULL_ALL 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 /// Creates a String using the given C string. Unlike

View File

@ -2054,7 +2054,7 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr, int recurs
msg_ext_last_attr = attr; msg_ext_last_attr = attr;
} }
// Concat pieces with the same highlight // 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); ga_concat_len(&msg_ext_last_chunk, (char *)str, len);
msg_ext_cur_len += len; msg_ext_cur_len += len;
return; return;

View File

@ -13,6 +13,10 @@
# include "nvim/os/unix_defs.h" # include "nvim/os/unix_defs.h"
#endif #endif
#if !defined(NAME_MAX) && defined(_XOPEN_NAME_MAX)
#define NAME_MAX _XOPEN_NAME_MAX
#endif
#define BASENAMELEN (NAME_MAX - 5) #define BASENAMELEN (NAME_MAX - 5)
// Use the system path length if it makes sense. // Use the system path length if it makes sense.

View File

@ -15,7 +15,7 @@
# include <libutil.h> # include <libutil.h>
#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) #elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
# include <util.h> # include <util.h>
#else #elif !defined(__sun)
# include <pty.h> # include <pty.h>
#endif #endif
@ -198,7 +198,9 @@ static void init_termios(struct termios *termios) FUNC_ATTR_NONNULL_ALL
termios->c_cflag = CS8|CREAD; termios->c_cflag = CS8|CREAD;
termios->c_lflag = ISIG|ICANON|IEXTEN|ECHO|ECHOE|ECHOK; 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 #ifdef IUTF8
termios->c_iflag |= IUTF8; termios->c_iflag |= IUTF8;

View File

@ -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)) #if (!defined(HAVE_STRCASECMP) && !defined(HAVE_STRICMP))
/* /*
* Compare two strings, ignoring case, using current locale. * Compare two strings, ignoring case, using current locale.

View File

@ -215,6 +215,11 @@ enum { FOLD_TEXT_LEN = 51, }; //!< buffer size for get_foldtext()
// (vim_strchr() is now in strings.c) // (vim_strchr() is now in strings.c)
#define STRLEN(s) strlen((char *)(s)) #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 STRCPY(d, s) strcpy((char *)(d), (char *)(s))
#define STRNCPY(d, s, n) strncpy((char *)(d), (char *)(s), (size_t)(n)) #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)) #define STRLCPY(d, s, n) xstrlcpy((char *)(d), (char *)(s), (size_t)(n))