From 3de05c07c13c2f0b2b13261fe47c4d69a8976434 Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Wed, 9 Oct 2013 21:40:55 +0000 Subject: [PATCH] Only build and use the compat.c bsd_setenv/bsd_putenv/bsd_unsetenv on systems that don't provide the POSIX setenv(). This fixes building plugins that link to compat.c on OS X (shared libraries on OS X don't have direct access to environ). It also reduces the binary size on platforms which provide setenv(), which these days is most of them. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@382 13b04d17-f746-0410-82c6-800466cd88b0 --- Changelog | 2 ++ configure | 5 +++-- include/defs.h.in | 3 +++ include/ircaux.h | 3 +++ source/commands.c | 2 +- source/compat.c | 2 +- 6 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Changelog b/Changelog index ae1b6b3..905f3c8 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,7 @@ [Changes 1.2c01] +* Use system setenv() in preference to compat bsd_setenv(). (caf) + * Allow selection of alternate hashing methods with $crypt(). (caf) * Improve the initial seeding of the randm() fallback RNG. (caf) diff --git a/configure b/configure index d01f8f4..a95a44f 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 273 . +# From configure.in Revision: 381 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59. # @@ -7162,7 +7162,8 @@ done -for ac_func in socket gethostname gettimeofday strtoul strlcpy strlcat stpcpy vsnprintf snprintf setsid strerror uname getrusage sysconf getpgid killpg getlogin realpath fchdir getpass fpathconf getpwent setvbuf select mkstemp memmove scandir + +for ac_func in socket gethostname gettimeofday strtoul strlcpy strlcat stpcpy vsnprintf snprintf setsid strerror uname getrusage sysconf getpgid killpg getlogin realpath fchdir getpass fpathconf getpwent setvbuf select mkstemp memmove scandir setenv do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 diff --git a/include/defs.h.in b/include/defs.h.in index 22a2b30..baec8ee 100644 --- a/include/defs.h.in +++ b/include/defs.h.in @@ -195,6 +195,9 @@ /* Define to 1 if you have the `select' function. */ #undef HAVE_SELECT +/* Define to 1 if you have the `setenv' function. */ +#undef HAVE_SETENV + /* Define to 1 if you have the `setsid' function. */ #undef HAVE_SETSID diff --git a/include/ircaux.h b/include/ircaux.h index e887577..98282bd 100644 --- a/include/ircaux.h +++ b/include/ircaux.h @@ -263,10 +263,13 @@ char *ulongcomma (unsigned long); unsigned long strtoul (const char *, char **, int); #endif +#ifndef HAVE_SETENV char * bsd_getenv (const char *); int bsd_putenv (const char *); int bsd_setenv (const char *, const char *, int); void bsd_unsetenv (const char *); +#define setenv bsd_setenv +#endif #ifndef HAVE_INET_ATON int inet_aton (const char *, struct in_addr *); diff --git a/source/commands.c b/source/commands.c index b032f57..cc88953 100644 --- a/source/commands.c +++ b/source/commands.c @@ -3078,7 +3078,7 @@ BUILT_IN_COMMAND(setenvcmd) char *env_var; if ((env_var = next_arg(args, &args)) != NULL) - bsd_setenv(env_var, args, 1); + setenv(env_var, args, 1); else say("Usage: SETENV "); } diff --git a/source/compat.c b/source/compat.c index b88add2..a5aa741 100644 --- a/source/compat.c +++ b/source/compat.c @@ -1000,7 +1000,7 @@ int scandir (const char *name, /* --- end of scandir.c --- */ /* --- start of env.c --- */ -#if 1 +#ifndef HAVE_SETENV /* * Copyright (c) 1987, 1988, 1993 * The Regents of the University of California. All rights reserved.