Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't re-define strlcpy/strlcat with >=glibc-2.38 #646

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ if cc.has_function('close_range', prefix: '#define _GNU_SOURCE\n#include <unistd
add_project_arguments('-DHAVE_CLOSE_RANGE_CLOEXEC', language: 'c')
endif

if cc.has_function('strlcpy', prefix: '#define _GNU_SOURCE\n#include <string.h>')
add_project_arguments('-DHAVE_STRLCPY', language: 'c')
endif

incdir = include_directories('src/shared')
einfo_incdir = include_directories('src/libeinfo')
rc_incdir = include_directories('src/librc')
Expand Down
5 changes: 1 addition & 4 deletions src/libeinfo/libeinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ static const char *const color_terms[] = {
};
#endif

/* strlcat and strlcpy are nice, shame glibc does not define them */
#ifdef __GLIBC__
# if !defined (__UCLIBC__) && !defined (__dietlibc__)
#ifndef HAVE_STRLCPY
static size_t
strlcat(char *dst, const char *src, size_t size)
{
Expand Down Expand Up @@ -176,7 +174,6 @@ strlcat(char *dst, const char *src, size_t size)

return dst_n + (s - src);
}
# endif
#endif

static bool
Expand Down
4 changes: 1 addition & 3 deletions src/shared/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@

#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))

#ifdef __GLIBC__
# if !defined (__UCLIBC__) && !defined (__dietlibc__)
#ifndef HAVE_STRLCPY
# define strlcpy(dst, src, size) snprintf(dst, size, "%s", src)
# endif
#endif

#ifndef timespecsub
Expand Down
Loading