A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/neovim/neovim/commit/8f1fdbc54a873abc7375c785b2b6ee5440910de2 below:

add STRNLEN compatability macro · neovim/neovim@8f1fdbc · GitHub

File tree Expand file treeCollapse file tree 6 files changed

+21

-2

lines changed

Filter options

Expand file treeCollapse file tree 6 files changed

+21

-2

lines changed Original file line number Diff line number Diff line change

@@ -45,6 +45,7 @@ check_function_exists(readlink HAVE_READLINK)

45 45

check_function_exists(setpgid HAVE_SETPGID)

46 46

check_function_exists(setsid HAVE_SETSID)

47 47

check_function_exists(sigaction HAVE_SIGACTION)

48 +

check_function_exists(strnlen HAVE_STRNLEN)

48 49

check_function_exists(strcasecmp HAVE_STRCASECMP)

49 50

check_function_exists(strncasecmp HAVE_STRNCASECMP)

50 51

check_function_exists(strptime HAVE_STRPTIME)

Original file line number Diff line number Diff line change

@@ -30,6 +30,7 @@

30 30

#cmakedefine HAVE_SETPGID

31 31

#cmakedefine HAVE_SETSID

32 32

#cmakedefine HAVE_SIGACTION

33 +

#cmakedefine HAVE_STRNLEN

33 34

#cmakedefine HAVE_STRCASECMP

34 35

#cmakedefine HAVE_STRINGS_H

35 36

#cmakedefine HAVE_STRNCASECMP

Original file line number Diff line number Diff line change

@@ -513,7 +513,7 @@ String cbuf_to_string(const char *buf, size_t size)

513 513

String cstrn_to_string(const char *str, size_t maxsize)

514 514

FUNC_ATTR_NONNULL_ALL

515 515

{

516 -

return cbuf_to_string(str, strnlen(str, maxsize));

516 +

return cbuf_to_string(str, STRNLEN(str, maxsize));

517 517

}

518 518 519 519

/// Creates a String using the given C string. Unlike

Original file line number Diff line number Diff line change

@@ -2056,7 +2056,7 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr, int recurs

2056 2056

msg_ext_last_attr = attr;

2057 2057

}

2058 2058

// Concat pieces with the same highlight

2059 -

size_t len = strnlen((char *)str, maxlen); // -V781

2059 +

size_t len = STRNLEN(str, maxlen); // -V781

2060 2060

ga_concat_len(&msg_ext_last_chunk, (char *)str, len);

2061 2061

msg_ext_cur_len += len;

2062 2062

return;

Original file line number Diff line number Diff line change

@@ -394,6 +394,18 @@ void del_trailing_spaces(char_u *ptr)

394 394

}

395 395

}

396 396 397 +

#if !defined(HAVE_STRNLEN)

398 +

size_t xstrnlen(const char *s, size_t n)

399 +

FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE

400 +

{

401 +

const char *end = memchr(s, '\0', n);

402 +

if (end == NULL) {

403 +

return n;

404 +

}

405 +

return end - s;

406 +

}

407 +

#endif

408 + 397 409

#if (!defined(HAVE_STRCASECMP) && !defined(HAVE_STRICMP))

398 410

/*

399 411

* Compare two strings, ignoring case, using current locale.

Original file line number Diff line number Diff line change

@@ -215,6 +215,11 @@ enum { FOLD_TEXT_LEN = 51, }; //!< buffer size for get_foldtext()

215 215

// (vim_strchr() is now in strings.c)

216 216 217 217

#define STRLEN(s) strlen((char *)(s))

218 +

#ifdef HAVE_STRNLEN

219 +

# define STRNLEN(s, n) strnlen((char *)(s), (size_t)(n))

220 +

#else

221 +

# define STRNLEN(s, n) xstrnlen((char *)(s), (size_t)(n))

222 +

#endif

218 223

#define STRCPY(d, s) strcpy((char *)(d), (char *)(s))

219 224

#define STRNCPY(d, s, n) strncpy((char *)(d), (char *)(s), (size_t)(n))

220 225

#define STRLCPY(d, s, n) xstrlcpy((char *)(d), (char *)(s), (size_t)(n))

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4