[108069] trunk/base
jmr at macports.org
jmr at macports.org
Thu Jul 11 22:28:37 PDT 2013
Revision: 108069
https://trac.macports.org/changeset/108069
Author: jmr at macports.org
Date: 2013-07-11 22:28:37 -0700 (Thu, 11 Jul 2013)
Log Message:
-----------
check for strlcat and provide an implementation when not present in the OS
Modified Paths:
--------------
trunk/base/configure
trunk/base/configure.ac
trunk/base/src/config.h.in
trunk/base/src/darwintracelib1.0/darwintrace.c
trunk/base/src/pextlib1.0/Makefile
trunk/base/src/pextlib1.0/tracelib.c
Added Paths:
-----------
trunk/base/src/pextlib1.0/strlcat.c
trunk/base/src/pextlib1.0/strlcat.h
Modified: trunk/base/configure
===================================================================
--- trunk/base/configure 2013-07-12 04:52:49 UTC (rev 108068)
+++ trunk/base/configure 2013-07-12 05:28:37 UTC (rev 108069)
@@ -8799,7 +8799,7 @@
INCLUDES="-I.. -I. $INCLUDES"
# Checks for library functions.
-for ac_func in bzero memset fgetln lockf flock setmode strcasecmp strncasecmp strlcpy copyfile clearenv sysctlbyname
+for ac_func in bzero memset fgetln lockf flock setmode strcasecmp strncasecmp strlcpy strlcat copyfile clearenv sysctlbyname
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
Modified: trunk/base/configure.ac
===================================================================
--- trunk/base/configure.ac 2013-07-12 04:52:49 UTC (rev 108068)
+++ trunk/base/configure.ac 2013-07-12 05:28:37 UTC (rev 108069)
@@ -243,7 +243,7 @@
INCLUDES="-I.. -I. $INCLUDES"
# Checks for library functions.
-AC_CHECK_FUNCS([bzero memset fgetln lockf flock setmode strcasecmp strncasecmp strlcpy copyfile clearenv sysctlbyname])
+AC_CHECK_FUNCS([bzero memset fgetln lockf flock setmode strcasecmp strncasecmp strlcpy strlcat copyfile clearenv sysctlbyname])
MP_CHECK_READLINK_IS_P1003_1A
# Check for md5 implementation
Modified: trunk/base/src/config.h.in
===================================================================
--- trunk/base/src/config.h.in 2013-07-12 04:52:49 UTC (rev 108068)
+++ trunk/base/src/config.h.in 2013-07-12 05:28:37 UTC (rev 108069)
@@ -173,6 +173,9 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
+/* Define to 1 if you have the `strlcat' function. */
+#undef HAVE_STRLCAT
+
/* Define to 1 if you have the `strlcpy' function. */
#undef HAVE_STRLCPY
Modified: trunk/base/src/darwintracelib1.0/darwintrace.c
===================================================================
--- trunk/base/src/darwintracelib1.0/darwintrace.c 2013-07-12 04:52:49 UTC (rev 108068)
+++ trunk/base/src/darwintracelib1.0/darwintrace.c 2013-07-12 05:28:37 UTC (rev 108069)
@@ -96,6 +96,8 @@
}
#endif
+#include "../pextlib1.0/strlcat.c"
+
/* global variables (only checked when setup is first called)
* DARWINTRACE_LOG
* path to the log file (no logging happens if it's unset).
Modified: trunk/base/src/pextlib1.0/Makefile
===================================================================
--- trunk/base/src/pextlib1.0/Makefile 2013-07-12 04:52:49 UTC (rev 108068)
+++ trunk/base/src/pextlib1.0/Makefile 2013-07-12 05:28:37 UTC (rev 108069)
@@ -2,7 +2,7 @@
Pextlib.o strsed.o fgetln.o md5cmd.o setmode.o xinstall.o \
fs-traverse.o strcasecmp.o vercomp.o filemap.o base32cmd.o \
sha1cmd.o curl.o rmd160cmd.o sha256cmd.o readline.o uid.o \
- tracelib.o tty.o readdir.o pipe.o flock.o \
+ tracelib.o tty.o readdir.o pipe.o flock.o strlcat.o \
system.o mktemp.o realpath.o ../registry2.0/registry${SHLIB_SUFFIX}
SHLIB_NAME= Pextlib${SHLIB_SUFFIX}
INSTALLDIR= ${DESTDIR}${datadir}/macports/Tcl/pextlib1.0
Added: trunk/base/src/pextlib1.0/strlcat.c
===================================================================
--- trunk/base/src/pextlib1.0/strlcat.c (rev 0)
+++ trunk/base/src/pextlib1.0/strlcat.c 2013-07-12 05:28:37 UTC (rev 108069)
@@ -0,0 +1,36 @@
+/* $Id$
+**
+** Replacement for a missing strlcat.
+**
+** Written by Russ Allbery <rra at stanford.edu>
+** This work is hereby placed in the public domain by its author.
+**
+** Provides the same functionality as the *BSD function strlcat, originally
+** developed by Todd Miller and Theo de Raadt. strlcat works similarly to
+** strncat, except simpler. The result is always nul-terminated even if the
+** source string is longer than the space remaining in the destination
+** string, and the total space required is returned. The third argument is
+** the total space available in the destination buffer, not just the amount
+** of space remaining.
+*/
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifndef HAVE_STRLCAT
+size_t
+strlcat(char *dst, const char *src, size_t size)
+{
+ size_t used, length, copy;
+
+ used = strlen(dst);
+ length = strlen(src);
+ if (size > 0 && used < size - 1) {
+ copy = (length >= size - used) ? size - used - 1 : length;
+ memcpy(dst + used, src, copy);
+ dst[used + copy] = '\0';
+ }
+ return used + length;
+}
+#endif
Property changes on: trunk/base/src/pextlib1.0/strlcat.c
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added: trunk/base/src/pextlib1.0/strlcat.h
===================================================================
--- trunk/base/src/pextlib1.0/strlcat.h (rev 0)
+++ trunk/base/src/pextlib1.0/strlcat.h 2013-07-12 05:28:37 UTC (rev 108069)
@@ -0,0 +1,6 @@
+/* $Id$ */
+#ifdef HAVE_STRLCAT
+#include <string.h>
+#else
+size_t strlcat(char *dst, const char *src, size_t size);
+#endif
Property changes on: trunk/base/src/pextlib1.0/strlcat.h
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Modified: trunk/base/src/pextlib1.0/tracelib.c
===================================================================
--- trunk/base/src/pextlib1.0/tracelib.c 2013-07-12 04:52:49 UTC (rev 108068)
+++ trunk/base/src/pextlib1.0/tracelib.c 2013-07-12 05:28:37 UTC (rev 108069)
@@ -59,6 +59,8 @@
#include "tracelib.h"
+#include "strlcat.h"
+
#ifndef HAVE_STRLCPY
/* Define strlcpy if it's not available. */
size_t strlcpy(char *dst, const char *src, size_t size);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20130711/f73f1745/attachment-0001.html>
More information about the macports-changes
mailing list