Skip to content

Commit

Permalink
Define strlcpy only on platforms where it's not available
Browse files Browse the repository at this point in the history
Signed-off-by: David Heidelberg <david@ixit.cz>
  • Loading branch information
okias committed Jan 17, 2024
1 parent e7dd973 commit 3889f17
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,8 @@ endif()
include(CheckCSourceCompiles)
include(CheckSymbolExists)

check_symbol_exists(strlcpy "string.h" HAVE_STRLCPY)

set(CMAKE_REQUIRED_INCLUDES ${LUA_INCLUDE_DIR})
if(USE_LUAJIT)
set(CMAKE_REQUIRED_LIBRARIES ${LUA_LIBRARY})
Expand Down
14 changes: 0 additions & 14 deletions src/porting.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define strtok_r(x, y, z) mystrtok_r(x, y, z)
#endif

// strlcpy is missing from glibc. thanks a lot, drepper.
// strlcpy is also missing from AIX and HP-UX because they aim to be weird.
// We can't simply alias strlcpy to MSVC's strcpy_s, since strcpy_s by
// default raises an assertion error and aborts the program if the buffer is
// too small.
#if defined(__FreeBSD__) || defined(__NetBSD__) || \
defined(__OpenBSD__) || defined(__DragonFly__) || \
defined(__APPLE__) || \
defined(__sun) || defined(sun) || \
defined(__QNX__) || defined(__QNXNTO__)
#define HAVE_STRLCPY
#endif

// So we need to define our own.
#ifndef HAVE_STRLCPY
#define strlcpy(d, s, n) mystrlcpy(d, s, n)
#endif
Expand Down

0 comments on commit 3889f17

Please sign in to comment.