[66331] trunk/base
jmr at macports.org
jmr at macports.org
Fri Apr 9 05:07:55 PDT 2010
Revision: 66331
http://trac.macports.org/changeset/66331
Author: jmr at macports.org
Date: 2010-04-09 05:07:54 -0700 (Fri, 09 Apr 2010)
Log Message:
-----------
cope with the absence of strlcpy and sysctlbyname (#22716)
Modified Paths:
--------------
trunk/base/configure
trunk/base/configure.ac
trunk/base/src/config.h.in
trunk/base/src/macports1.0/sysctl.c
trunk/base/src/pextlib1.0/tracelib.c
Modified: trunk/base/configure
===================================================================
--- trunk/base/configure 2010-04-09 10:55:03 UTC (rev 66330)
+++ trunk/base/configure 2010-04-09 12:07:54 UTC (rev 66331)
@@ -8232,7 +8232,7 @@
fi
for ac_header in limits.h paths.h sys/file.h crt_externs.h fcntl.h sys/fcntl.h sys/cdefs.h err.h sys/socket.h \
- readline/readline.h readline/history.h pwd.h sys/paths.h utime.h
+ sys/sysctl.h readline/readline.h readline/history.h pwd.h sys/paths.h utime.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -8250,7 +8250,7 @@
INCLUDES="-I.. -I. $INCLUDES"
# Checks for library functions.
-for ac_func in bzero memset fgetln lockf flock setmode strcasecmp strncasecmp strlcpy copyfile clearenv
+for ac_func in bzero memset fgetln lockf flock setmode strcasecmp strncasecmp strlcpy 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 2010-04-09 10:55:03 UTC (rev 66330)
+++ trunk/base/configure.ac 2010-04-09 12:07:54 UTC (rev 66331)
@@ -194,12 +194,12 @@
AC_HEADER_DIRENT
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([limits.h paths.h sys/file.h crt_externs.h fcntl.h sys/fcntl.h sys/cdefs.h err.h sys/socket.h \
- readline/readline.h readline/history.h pwd.h sys/paths.h utime.h])
+ sys/sysctl.h readline/readline.h readline/history.h pwd.h sys/paths.h utime.h])
INCLUDES="-I.. -I. $INCLUDES"
# Checks for library functions.
-AC_CHECK_FUNCS([bzero memset fgetln lockf flock setmode strcasecmp strncasecmp strlcpy copyfile clearenv])
+AC_CHECK_FUNCS([bzero memset fgetln lockf flock setmode strcasecmp strncasecmp strlcpy 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 2010-04-09 10:55:03 UTC (rev 66330)
+++ trunk/base/src/config.h.in 2010-04-09 12:07:54 UTC (rev 66331)
@@ -152,6 +152,9 @@
/* Define to 1 if you have the `strncasecmp' function. */
#undef HAVE_STRNCASECMP
+/* Define to 1 if you have the `sysctlbyname' function. */
+#undef HAVE_SYSCTLBYNAME
+
/* Define to 1 if you have the <sys/cdefs.h> header file. */
#undef HAVE_SYS_CDEFS_H
@@ -178,6 +181,9 @@
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
+/* Define to 1 if you have the <sys/sysctl.h> header file. */
+#undef HAVE_SYS_SYSCTL_H
+
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
Modified: trunk/base/src/macports1.0/sysctl.c
===================================================================
--- trunk/base/src/macports1.0/sysctl.c 2010-04-09 10:55:03 UTC (rev 66330)
+++ trunk/base/src/macports1.0/sysctl.c 2010-04-09 12:07:54 UTC (rev 66331)
@@ -39,7 +39,10 @@
#include <string.h>
#include <errno.h>
#include <sys/types.h>
+
+#if HAVE_SYS_SYSCTL_H
#include <sys/sysctl.h>
+#endif
#include "sysctl.h"
@@ -48,6 +51,7 @@
*/
int SysctlCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
{
+#if HAVE_SYSCTLBYNAME
const char error_message[] = "sysctl failed: ";
Tcl_Obj *tcl_result;
int res;
@@ -84,4 +88,8 @@
Tcl_SetObjResult(interp, tcl_result);
return TCL_OK;
+#else
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("sysctl not available", -1));
+ return TCL_ERROR;
+#endif
}
Modified: trunk/base/src/pextlib1.0/tracelib.c
===================================================================
--- trunk/base/src/pextlib1.0/tracelib.c 2010-04-09 10:55:03 UTC (rev 66330)
+++ trunk/base/src/pextlib1.0/tracelib.c 2010-04-09 12:07:54 UTC (rev 66331)
@@ -30,7 +30,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#if HAVE_CONFIG_H
#include <config.h>
+#endif
+
#include <string.h>
#include <sys/time.h>
#include <sys/resource.h>
@@ -47,6 +50,26 @@
#include <limits.h>
#include "tracelib.h"
+#ifndef HAVE_STRLCPY
+/* Define strlcpy if it's not available. */
+size_t strlcpy(char* dst, const char* src, size_t size);
+size_t strlcpy(char* dst, const char* src, size_t size)
+{
+ size_t result = strlen(src);
+ if (size > 0)
+ {
+ size_t copylen = size - 1;
+ if (copylen > result)
+ {
+ copylen = result;
+ }
+ memcpy(dst, src, copylen);
+ dst[copylen] = 0;
+ }
+ return result;
+}
+#endif
+
static char * name;
static char * sandbox;
static char * filemap, * filemap_end;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20100409/16253597/attachment.html>
More information about the macports-changes
mailing list