From 5c50e08983ff276dc472d00baba7a835dbda6cc5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 31 Jan 2012 11:10:18 +0100 Subject: replace: use libbsd for strlcat/strlcpy when available. --- lib/replace/wscript | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'lib/replace') diff --git a/lib/replace/wscript b/lib/replace/wscript index e4fc72b50e..e85d33cf61 100644 --- a/lib/replace/wscript +++ b/lib/replace/wscript @@ -163,12 +163,18 @@ def configure(conf): conf.CHECK_FUNCS('pipe strftime srandom random srand rand usleep setbuffer') conf.CHECK_FUNCS('lstat getpgrp utime utimes seteuid setreuid setresuid setegid') conf.CHECK_FUNCS('setregid setresgid chroot strerror vsyslog setlinebuf mktime') - conf.CHECK_FUNCS('ftruncate chsize rename waitpid wait4 strlcpy strlcat') + conf.CHECK_FUNCS('ftruncate chsize rename waitpid wait4') conf.CHECK_FUNCS('initgroups pread pwrite strndup strcasestr') conf.CHECK_FUNCS('strtok_r mkdtemp dup2 dprintf vdprintf isatty chown lchown') conf.CHECK_FUNCS('link readlink symlink realpath snprintf vsnprintf') conf.CHECK_FUNCS('asprintf vasprintf setenv unsetenv strnlen strtoull __strtoull') conf.CHECK_FUNCS('strtouq strtoll __strtoll strtoq') + + # libbsd on some platforms provides strlcpy and strlcat + if not conf.CHECK_FUNCS('strlcpy strlcat'): + conf.CHECK_FUNCS_IN('strlcpy strlcat', 'bsd', headers='bsd/string.h', + checklibc=True) + #Some OS (ie. freebsd) return EINVAL if the convertion could not be done, it's not what we expect #Let's detect those cases if conf.CONFIG_SET('HAVE_STRTOLL'): @@ -206,19 +212,19 @@ def configure(conf): if conf.CHECK_FUNCS_IN('clock_gettime', 'rt', checklibc=True): for c in ['CLOCK_MONOTONIC', 'CLOCK_PROCESS_CPUTIME_ID', 'CLOCK_REALTIME']: conf.CHECK_CODE(''' - #if TIME_WITH_SYS_TIME - # include - # include - #else - # if HAVE_SYS_TIME_H - # include - # else - # include - # endif - #endif - clockid_t clk = %s''' % c, - 'HAVE_%s' % c, - msg='Checking whether the clock_gettime clock ID %s is available' % c) + #if TIME_WITH_SYS_TIME + # include + # include + #else + # if HAVE_SYS_TIME_H + # include + # else + # include + # endif + #endif + clockid_t clk = %s''' % c, + 'HAVE_%s' % c, + msg='Checking whether the clock_gettime clock ID %s is available' % c) conf.CHECK_TYPE('struct timespec', headers='sys/time.h time.h') @@ -436,7 +442,7 @@ def build(bld): # at the moment: # hide_symbols=bld.BUILTIN_LIBRARY('replace'), private_library=True, - deps='crypt dl nsl socket rt') + deps='crypt dl nsl socket rt bsd') bld.SAMBA_SUBSYSTEM('replace-test', source='''test/testsuite.c test/strptime.c -- cgit