about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2001-06-26 06:01:47 +0000
committerBart Schaefer <barts@users.sourceforge.net>2001-06-26 06:01:47 +0000
commit563fbed02c1fc4bdf43f261548a2c3f47a426ed2 (patch)
treed07b3c171b0f1ec71ddcb8db027d752edc60feca
parentcbf446701561ca5c14a7ca23ae51ac59b984a1ea (diff)
downloadzsh-563fbed02c1fc4bdf43f261548a2c3f47a426ed2.tar.gz
zsh-563fbed02c1fc4bdf43f261548a2c3f47a426ed2.tar.xz
zsh-563fbed02c1fc4bdf43f261548a2c3f47a426ed2.zip
More merges: 14973,14976, and some whitespace.
-rw-r--r--ChangeLog10
-rw-r--r--Src/Modules/zftp.c208
-rw-r--r--Src/prompt.c12
-rw-r--r--acconfig.h34
-rw-r--r--aczsh.m4173
-rw-r--r--zshconfig.ac49
6 files changed, 348 insertions, 138 deletions
diff --git a/ChangeLog b/ChangeLog
index 9eac614a3..b37e7d4fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -39,6 +39,16 @@
 	* 14988 with mod suggested in 14989: Src/exec.c: avoid names of
 	saved special parameters being trashed.
 
+2001-06-19  Bart Schaefer  <schaefer@zsh.org>
+
+	* 14976: aczsh.m4: Add socklen_t to possible SOCKLEN_T types.
+
+2001-06-19  Andrej Borsenkow  <bor@zsh.org>
+
+	* 14973: acconfig.h, aczsh.m4, zshconfig.ac, Src/Modules/zftp.c:
+	fix for reported problems on AIX 4.x. Still no feedback if it
+	finally works (or even compiles)
+
 2001-06-18  Bart Schaefer  <schaefer@zsh.org>
 
 	* 14965: Src/Zle/computil.c: Silence compiler warnings.
diff --git a/Src/Modules/zftp.c b/Src/Modules/zftp.c
index 64565c9e1..46ba71cbc 100644
--- a/Src/Modules/zftp.c
+++ b/Src/Modules/zftp.c
@@ -50,15 +50,36 @@ union zftp_sockaddr;
 struct zftp_session;
 typedef struct zftp_session *Zftp_session;
 
-#include "zftp.mdh"
-#include "zftp.pro"
+/*
+ * We need to include the zsh headers later to avoid clashes with
+ * the definitions on some systems, however we need the configuration
+ * file to decide whether we can include netinet/in_systm.h, which
+ * doesn't exist on cygwin.
+ */
+#include "../../config.h"
 
+#include <sys/types.h>
 #include <sys/socket.h>
 #include <netdb.h>
-#include <netinet/in_systm.h>
+/*
+ * For some reason, configure doesn't always detect netinet/in_systm.h.
+ * On some systems, including linux, this seems to be because gcc is
+ * throwing up a warning message about the redefinition of
+ * __USE_LARGEFILE.  This means the problem is somewhere in the
+ * header files where we can't get at it.  For now, revert to
+ * not including this file only on systems where we know it's missing.
+ * Currently this is just cygwin.
+ */
+#ifndef __CYGWIN__
+# include <netinet/in_systm.h>
+#endif
 #include <netinet/in.h>
 #include <netinet/ip.h>
 #include <arpa/inet.h>
+
+#include "zftp.mdh"
+#include "zftp.pro"
+
 /* it's a TELNET based protocol, but don't think I like doing this */
 #include <arpa/telnet.h>
 
@@ -90,6 +111,10 @@ union zftp_sockaddr {
 #endif
 };
 
+#ifdef USE_LOCAL_H_ERRNO
+int h_errno;
+#endif
+
 /* We use the RFC 2553 interfaces.  If the functions don't exist in the library,
    simulate them. */
 
@@ -101,12 +126,12 @@ union zftp_sockaddr {
 # define INET6_ADDRSTRLEN 46
 #endif
 
-/**/  
+/**/
 #ifndef HAVE_INET_NTOP
 
-/**/    
+/**/
 static char const *
-inet_ntop(int af, void const *cp, char *buf, size_t len)
+zsh_inet_ntop(int af, void const *cp, char *buf, size_t len)
 {       
         if(af != AF_INET) {
                 errno = EAFNOSUPPORT;
@@ -120,7 +145,11 @@ inet_ntop(int af, void const *cp, char *buf, size_t len)
         return buf;
 }
 
-/**/  
+#else /* !HAVE_INET_NTOP */
+
+# define zsh_inet_ntop inet_ntop
+
+/**/
 #endif /* !HAVE_INET_NTOP */
 
 /**/
@@ -134,38 +163,68 @@ inet_ntop(int af, void const *cp, char *buf, size_t len)
 #  endif
 
 /**/
-static int inet_aton(char const *src, struct in_addr *dst)
+static int zsh_inet_aton(char const *src, struct in_addr *dst)
 {
     return (dst->s_addr = inet_addr(src)) != INADDR_NONE;
 }
 
+#else /* !HAVE_INET_ATON */
+
+# define zsh_inet_aton inet_aton
+
 /**/
 # endif /* !HAVE_INET_ATON */
 
 /**/
 static int
-inet_pton(int af, char const *src, void *dst)
+zsh_inet_pton(int af, char const *src, void *dst)
 {
         if(af != AF_INET) {
                 errno = EAFNOSUPPORT;
                 return -1;
         }
-        return !!inet_aton(src, dst);
+        return !!zsh_inet_aton(src, dst);
 }
 
+#else /* !HAVE_INET_PTON */
+
+# define zsh_inet_pton inet_pton
+
 /**/
 #endif /* !HAVE_INET_PTON */
 
 /**/
 #ifndef HAVE_GETIPNODEBYNAME
 
+/**/
+# ifndef HAVE_GETHOSTBYNAME2
+
+/**/
+static struct hostent *
+zsh_gethostbyname2(char const *name, int af)
+{
+	if(af != AF_INET) {
+		h_errno = NO_RECOVERY;
+		return NULL;
+	}
+	return gethostbyname(name);
+}
+
+#else /* !HAVE_GETHOSTBYNAME2 */
+
+# define zsh_gethostbyname2 gethostbyname2
+
+/**/
+# endif /* !HAVE_GETHOSTBYNAME2 */
+
+
 /* note: this is not a complete implementation.  If ignores the flags,
    and does not provide the memory allocation of the standard interface.
    Each returned structure will overwrite the previous one. */
 
 /**/
 static struct hostent *
-getipnodebyname(char const *name, int af, int flags, int *errorp)
+zsh_getipnodebyname(char const *name, int af, int flags, int *errorp)
 {
 	static struct hostent ahe;
 	static char nbuf[16];
@@ -176,8 +235,8 @@ getipnodebyname(char const *name, int af, int flags, int *errorp)
 	static char pbuf[INET_ADDRSTRLEN];
 # endif
 	struct hostent *he;
-	if(inet_pton(af, name, nbuf) == 1) {
-		inet_ntop(af, nbuf, pbuf, sizeof(pbuf));
+	if(zsh_inet_pton(af, name, nbuf) == 1) {
+		zsh_inet_ntop(af, nbuf, pbuf, sizeof(pbuf));
 		ahe.h_name = pbuf;
 		ahe.h_aliases = addrlist+1;
 		ahe.h_addrtype = af;
@@ -185,35 +244,21 @@ getipnodebyname(char const *name, int af, int flags, int *errorp)
 		ahe.h_addr_list = addrlist;
 		return &ahe;
 	}
-	he = gethostbyname2(name, af);
+	he = zsh_gethostbyname2(name, af);
 	if(!he)
 		*errorp = h_errno;
 	return he;
 }
-
-/**/
-# ifndef HAVE_GETHOSTBYNAME2
-
-/**/
-static struct hostent *
-gethostbyname2(char const *name, int af)
-{
-	if(af != AF_INET) {
-		h_errno = NO_RECOVERY;
-		return NULL;
-	}
-	return gethostbyname(name);
-}
-
-/**/
-# endif /* !HAVE_GETHOSTBYNAME2 */
-
 /**/
 static void
 freehostent(struct hostent *ptr)
 {
 }
 
+#else /* !HAVE_GETIPNODEBYNAME */
+
+# define zsh_getipnodebyname getipnodebyname
+
 /**/
 #endif /* !HAVE_GETIPNODEBYNAME */
 
@@ -838,8 +883,6 @@ zfgetmsg(void)
 
     if (zfsess->cfd == -1)
 	return 6;
-    if (!(verbose = getsparam("ZFTP_VERBOSE")))
-	verbose = "";
     zsfree(lastmsg);
     lastmsg = NULL;
 
@@ -865,6 +908,9 @@ zfgetmsg(void)
     zfsetparam("ZFTP_CODE", ztrdup(lastcodestr), ZFPM_READONLY);
     stopit = (*ptr++ != '-');
 
+    queue_signals();
+    if (!(verbose = getsparam("ZFTP_VERBOSE")))
+	verbose = "";
     if (strchr(verbose, lastcodestr[0])) {
 	/* print the whole thing verbatim */
 	printing = 1;
@@ -874,6 +920,7 @@ zfgetmsg(void)
 	printing = 2;
 	fputs(ptr, stderr);
     }
+    unqueue_signals();
     if (printing)
 	fputc('\n', stderr);
 
@@ -1144,7 +1191,7 @@ zfopendata(char *name, union zftp_sockaddr *zdsockp, int *is_passivep)
 	if(zdsockp->a.sa_family == AF_INET6) {
 	    /* see RFC 2428 for explanation */
 	    strcpy(portcmd, "EPRT |2|");
-	    inet_ntop(AF_INET6, &zdsockp->in6.sin6_addr,
+	    zsh_inet_ntop(AF_INET6, &zdsockp->in6.sin6_addr,
 		portcmd+8, INET6_ADDRSTRLEN);
 	    sprintf(strchr(portcmd, 0), "|%u|\r\n",
 		(unsigned)ntohs(zdsockp->in6.sin6_port));
@@ -1195,7 +1242,8 @@ zfclosedata(void)
 static int
 zfgetdata(char *name, char *rest, char *cmd, int getsize)
 {
-    int len, newfd, is_passive;
+    SOCKLEN_T len;
+    int newfd, is_passive;
     union zftp_sockaddr zdsock;
 
     if (zfopendata(name, &zdsock, &is_passive))
@@ -1301,8 +1349,7 @@ zfgetdata(char *name, char *rest, char *cmd, int getsize)
 #endif
 #if defined(F_SETFD) && defined(FD_CLOEXEC)
 	/* If the shell execs a program, we don't want this fd left open. */
-	len = FD_CLOEXEC;
-	fcntl(zfsess->dfd, F_SETFD, &len);
+	fcntl(zfsess->dfd, F_SETFD, FD_CLOEXEC);
 #endif
 
     return 0;
@@ -1830,7 +1877,8 @@ zftp_open(char *name, char **args, int flags)
     struct servent *zservp;
     struct hostent *zhostp = NULL;
     char **addrp, *fname;
-    int err, len, tmout;
+    int err, tmout;
+    SOCKLEN_T len;
     int herrno, af, salen;
 
     if (!*args) {
@@ -1870,10 +1918,12 @@ zftp_open(char *name, char **args, int flags)
     if (setjmp(zfalrmbuf)) {
 	char *hname;
 	alarm(0);
+	queue_signals();
 	if ((hname = getsparam("ZFTP_HOST")) && *hname) 
 	    zwarnnam(name, "timeout connecting to %s", hname, 0);
 	else
 	    zwarnnam(name, "timeout on host name lookup", NULL, 0);
+	unqueue_signals();
 	zfclose(0);
 	return 1;
     }
@@ -1889,7 +1939,7 @@ zftp_open(char *name, char **args, int flags)
 # define FAILED() do { } while(0)
 #endif
     {
-    	zhostp = getipnodebyname(args[0], af, 0, &herrno);
+    	zhostp = zsh_getipnodebyname(args[0], af, 0, &herrno);
 	if (!zhostp || errflag) {
 	    /* should use herror() here if available, but maybe
 	     * needs configure test. on AIX it's present but not
@@ -1971,7 +2021,7 @@ zftp_open(char *name, char **args, int flags)
 	char pbuf[INET_ADDRSTRLEN];
 #endif
 	addrp--;
-	inet_ntop(af, *addrp, pbuf, sizeof(pbuf));
+	zsh_inet_ntop(af, *addrp, pbuf, sizeof(pbuf));
 	zfsetparam("ZFTP_IP", ztrdup(pbuf), ZFPM_READONLY);
     }
     freehostent(zhostp);
@@ -1986,8 +2036,7 @@ zftp_open(char *name, char **args, int flags)
 
 #if defined(F_SETFD) && defined(FD_CLOEXEC)
     /* If the shell execs a program, we don't want this fd left open. */
-    len = FD_CLOEXEC;
-    fcntl(zfsess->cfd, F_SETFD, &len);
+    fcntl(zfsess->cfd, F_SETFD, FD_CLOEXEC);
 #endif
 
     len = sizeof(zfsess->sock);
@@ -2055,8 +2104,7 @@ zftp_open(char *name, char **args, int flags)
 	DPUTS(zfstatfd == -1, "zfstatfd not created");
 #if defined(F_SETFD) && defined(FD_CLOEXEC)
 	/* If the shell execs a program, we don't want this fd left open. */
-	len = FD_CLOEXEC;
-	fcntl(zfstatfd, F_SETFD, &len);
+	fcntl(zfstatfd, F_SETFD, FD_CLOEXEC);
 #endif
 	unlink(fname);
     }
@@ -2824,7 +2872,7 @@ zfclose(int leaveparams)
 	if (!zfnopen) {
 	    /* Write the final status in case this is a subshell */
 	    lseek(zfstatfd, zfsessno*sizeof(int), 0);
-	    write(zfstatfd, zfstatusp+zfsessno, sizeof(int));
+	    write(zfstatfd, (char *)zfstatusp+zfsessno, sizeof(int));
 
 	    close(zfstatfd);
 	    zfstatfd = -1;
@@ -2911,10 +2959,12 @@ savesession()
     for (ps = zfparams, pd = zfsess->params; *ps; ps++, pd++) {
 	if (*pd)
 	    zsfree(*pd);
+	queue_signals();
 	if ((val = getsparam(*ps)))
 	    *pd = ztrdup(val);
 	else
 	    *pd = NULL;
+	unqueue_signals();
     }
     *pd = NULL;
 }
@@ -3101,7 +3151,7 @@ bin_zftp(char *name, char **args, char *ops, int func)
 	/* Get the status in case it was set by a forked process */
 	int oldstatus = zfstatusp[zfsessno];
 	lseek(zfstatfd, 0, 0);
-	read(zfstatfd, zfstatusp, sizeof(int)*zfsesscnt);
+	read(zfstatfd, (char *)zfstatusp, sizeof(int)*zfsesscnt);
 	if (zfsess->cfd != -1 && (zfstatusp[zfsessno] & ZFST_CLOS)) {
 	    /* got closed in subshell without us knowing */
 	    zcfinish = 2;
@@ -3144,6 +3194,7 @@ bin_zftp(char *name, char **args, char *ops, int func)
 	return 1;
     }
 
+    queue_signals();
     if ((prefs = getsparam("ZFTP_PREFS"))) {
 	zfprefs = 0;
 	for (ptr = prefs; *ptr; ptr++) {
@@ -3174,6 +3225,7 @@ bin_zftp(char *name, char **args, char *ops, int func)
 	    }
 	}
     }
+    unqueue_signals();
 
     ret = (*zptr->fun)(fullname, args, zptr->flags);
 
@@ -3190,11 +3242,44 @@ bin_zftp(char *name, char **args, char *ops, int func)
 	 * but only for the active session.
 	 */
 	lseek(zfstatfd, zfsessno*sizeof(int), 0);
-	write(zfstatfd, zfstatusp+zfsessno, sizeof(int));
+	write(zfstatfd, (char *)zfstatusp+zfsessno, sizeof(int));
     }
     return ret;
 }
 
+static void
+zftp_cleanup(void)
+{
+    /*
+     * There are various parameters hanging around, but they're
+     * all non-special so are entirely non-life-threatening.
+     */
+    LinkNode nptr;
+    Zftp_session cursess = zfsess;
+    for (zfsessno = 0, nptr = firstnode(zfsessions); nptr;
+	 zfsessno++, incnode(nptr)) {
+	zfsess = (Zftp_session)nptr->dat;
+	zfclosedata();
+	/*
+	 * When closing the current session, do the usual unsetting,
+	 * otherwise don't.
+	 */
+	zfclose(zfsess != cursess);
+    }
+    zsfree(lastmsg);
+    zfunsetparam("ZFTP_SESSION");
+    freelinklist(zfsessions, (FreeFunc) freesession);
+    zfree(zfstatusp, sizeof(int)*zfsesscnt);
+    deletebuiltins("zftp", bintab, sizeof(bintab)/sizeof(*bintab));
+}
+
+static int
+zftpexithook(Hookdef d, void *dummy)
+{
+    zftp_cleanup();
+    return 0;
+}
+
 /* The load/unload routines required by the zsh library interface */
 
 /**/
@@ -3209,7 +3294,7 @@ int
 boot_(Module m)
 {
     int ret;
-    if ((ret = addbuiltins(m->nam, bintab,
+    if ((ret = addbuiltins("zftp", bintab,
 			   sizeof(bintab)/sizeof(*bintab))) == 1) {
 	/* if successful, set some default parameters */
 	off_t tmout_def = 60;
@@ -3221,6 +3306,8 @@ boot_(Module m)
     
 	zfsessions = znewlinklist();
 	newsession("default");
+
+	addhookfunc("exit", zftpexithook);
     }
 
     return !ret;
@@ -3230,27 +3317,8 @@ boot_(Module m)
 int
 cleanup_(Module m)
 {
-    /*
-     * There are various parameters hanging around, but they're
-     * all non-special so are entirely non-life-threatening.
-     */
-    LinkNode nptr;
-    Zftp_session cursess = zfsess;
-    for (zfsessno = 0, nptr = firstnode(zfsessions); nptr;
-	 zfsessno++, incnode(nptr)) {
-	zfsess = (Zftp_session)nptr->dat;
-	zfclosedata();
-	/*
-	 * When closing the current session, do the usual unsetting,
-	 * otherwise don't.
-	 */
-	zfclose(zfsess != cursess);
-    }
-    zsfree(lastmsg);
-    zfunsetparam("ZFTP_SESSION");
-    freelinklist(zfsessions, (FreeFunc) freesession);
-    zfree(zfstatusp, sizeof(int)*zfsesscnt);
-    deletebuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
+    deletehookfunc("exit", zftpexithook);
+    zftp_cleanup();
     return 0;
 }
 
diff --git a/Src/prompt.c b/Src/prompt.c
index eb79c7e85..d5df9d1ce 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -517,12 +517,12 @@ putpromptchar(int doprint, int endchar)
 		if (*ttystrname) {
                    ss = (strncmp(ttystrname, "/dev/tty", 8) ?
                            ttystrname + 5 : ttystrname + 8);
-                   stradd(ss);
-               } else
-                   stradd("()");
-               break;
-           case 'y':
-               if (*ttystrname) {
+		    stradd(ss);
+		} else
+		    stradd("()");
+		break;
+	    case 'y':
+		if (*ttystrname) {
 		    ss = (strncmp(ttystrname, "/dev/", 5) ?
 			    ttystrname : ttystrname + 5);
 		    stradd(ss);
diff --git a/acconfig.h b/acconfig.h
index 715d45c28..2276d7d1d 100644
--- a/acconfig.h
+++ b/acconfig.h
@@ -139,6 +139,10 @@
 /* Define to be a string corresponding the vendor of the machine */
 #undef VENDOR
 
+/* Define to limit job table size */
+#undef MAXJOB
+#undef NEED_LINUX_TASKS_H
+
 /* Define if your system defines `struct winsize' in sys/ptem.h.  */
 #undef WINSIZE_IN_PTEM
 
@@ -169,6 +173,9 @@
 /* Define for Maildir support */
 #undef MAILDIR_SUPPORT
 
+/* Define for function depth limits */
+#undef MAX_FUNCTION_DEPTH
+
 /* Define if you want locale features.  By default this is defined. */
 #undef CONFIG_LOCALE
 
@@ -289,3 +296,30 @@
 
 /* Define to 1 if ino_t is 64 bit (for large file support) */
 #undef INO_T_IS_64_BIT
+
+/* Define to 1 if h_errno is not defined by the system */
+#undef USE_LOCAL_H_ERRNO
+
+/* Define if you have the termcap boolcodes symbol.  */
+#undef HAVE_BOOLCODES
+
+/* Define if you have the termcap numcodes symbol.  */
+#undef HAVE_NUMCODES
+
+/* Define if you have the termcap strcodes symbol.  */
+#undef HAVE_STRCODES
+
+/* Define if you have the terminfo boolnames symbol.  */
+#undef HAVE_BOOLNAMES
+
+/* Define if you have the terminfo numnames symbol.  */
+#undef HAVE_NUMNAMES
+
+/* Define if you have the terminfo strnames symbol.  */
+#undef HAVE_STRNAMES
+
+/* Define if term.h chokes without curses.h */
+#undef TERM_H_NEEDS_CURSES_H
+
+/* Define to the base type of the third argument of accept */
+#undef SOCKLEN_T
diff --git a/aczsh.m4 b/aczsh.m4
index 9ebb275c6..4ac1f6f2e 100644
--- a/aczsh.m4
+++ b/aczsh.m4
@@ -84,6 +84,7 @@ dnl   specified directly as --enable-lfs="long long".
 dnl   Sets the variable given in the second argument to the first argument
 dnl   if the test worked, `no' otherwise.  Be careful testing this, as it
 dnl   may produce two words `long long' on an unquoted substitution.
+dnl   Also check that the compiler does not mind it being cast to int.
 dnl   This macro does not produce messages as it may be run several times
 dnl   before finding the right type.
 dnl
@@ -97,6 +98,7 @@ AC_DEFUN(zsh_64_BIT_TYPE,
 main()
 {
   $1 foo = 0; 
+  int bar = (int) foo;
   return sizeof($1) != 8;
 }
 ], $2="$1", $2=no,
@@ -109,36 +111,63 @@ main()
 
 
 dnl
-dnl zsh_SYS_DYNAMIC_BROKEN
-dnl   Check whether static/shared library linking is broken.
+dnl zsh_SHARED_FUNCTION
+dnl
+dnl This is just a frontend to zsh_SHARED_SYMBOL
+dnl
+dnl Usage: zsh_SHARED_FUNCTION(name[,rettype[,paramtype]])
+dnl
+
+AC_DEFUN(zsh_SHARED_FUNCTION,
+[zsh_SHARED_SYMBOL($1, ifelse([$2], ,[int ],[$2]) $1 [(]ifelse([$3], ,[ ],[$3])[)], $1)])
+
+dnl
+dnl zsh_SHARED_VARIABLE
+dnl
+dnl This is just a frontend to zsh_SHARED_SYMBOL
+dnl
+dnl Usage: zsh_SHARED_VARIABLE(name[,type])
+dnl
+
+AC_DEFUN(zsh_SHARED_VARIABLE,
+[zsh_SHARED_SYMBOL($1, ifelse([$2], ,[int ],[$2]) $1, [&$1])])
+
+dnl
+dnl zsh_SHARED_SYMBOL
+dnl   Check whether symbol is available in static or shared library
 dnl
 dnl   On some systems, static modifiable library symbols (such as environ)
 dnl   may appear only in statically linked libraries.  If this is the case,
 dnl   then two shared libraries that reference the same symbol, each linked
 dnl   with the static library, could be given distinct copies of the symbol.
-dnl   If this is the case then dynamic linking is FUBAR.
+dnl
+dnl Usage: zsh_SHARED_SYMBOL(name,declaration,address)
+dnl Sets zsh_cv_shared_$1 cache variable to yes/no
 dnl
 
-AC_DEFUN(zsh_SYS_DYNAMIC_BROKEN,
-[AC_CACHE_CHECK([if static/shared library linking is broken],
-zsh_cv_sys_dynamic_broken,
+AC_DEFUN(zsh_SHARED_SYMBOL,
+[AC_CACHE_CHECK([if $1 is available in shared libraries],
+zsh_cv_shared_$1,
 [if test "$zsh_cv_func_dlsym_needs_underscore" = yes; then
     us=_
 else
     us=
 fi
 echo '
-	extern char **environ;
-	void *symlist1[[]] = {
-		(void *)&environ,
-		(void *)0
-	};
+void *zsh_getaddr1()
+{
+#ifdef __CYGWIN__
+	__attribute__((__dllimport__))	
+#endif
+	extern $2;
+	return $3;
+};
 ' > conftest1.c
-sed 's/symlist1/symlist2/' < conftest1.c > conftest2.c
-if $CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&5 2>&5 &&
-$DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&5 2>&5 &&
-$CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&5 2>&5 &&
-$DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&5 2>&5; then
+sed 's/zsh_getaddr1/zsh_getaddr2/' < conftest1.c > conftest2.c
+if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
+AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC) &&
+AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&AC_FD_CC) &&
+AC_TRY_COMMAND($DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&AC_FD_CC); then
     AC_TRY_RUN([
 #ifdef HPUXDYNAMIC
 #include <dl.h>
@@ -170,25 +199,33 @@ char *zsh_gl_sym_addr ;
 main()
 {
     void *handle1, *handle2;
-    void **symlist1, **symlist2;
+    void *(*zsh_getaddr1)(), *(*zsh_getaddr2)();
+    void *sym1, *sym2;
     handle1 = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
     if(!handle1) exit(1);
     handle2 = dlopen("./conftest2.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
     if(!handle2) exit(1);
-    symlist1 = (void **) dlsym(handle1, "${us}symlist1");
-    symlist2 = (void **) dlsym(handle2, "${us}symlist2");
-    if(!symlist1 || !symlist2) exit(1);
-    for(; *symlist1; symlist1++, symlist2++)
-	if(*symlist1 != *symlist2)
-	    exit(1);
+    zsh_getaddr1 = (void *(*)()) dlsym(handle1, "${us}zsh_getaddr1");
+    zsh_getaddr2 = (void *(*)()) dlsym(handle2, "${us}zsh_getaddr2");
+    sym1 = zsh_getaddr1();
+    sym2 = zsh_getaddr2();
+    if(!sym1 || !sym2) exit(1);
+    if(sym1 != sym2) exit(1);
+    dlclose(handle1);
+    handle1 = dlopen("./conftest1.$DL_EXT", RTLD_LAZY | RTLD_GLOBAL);
+    if(!handle1) exit(1);
+    zsh_getaddr1 = (void *(*)()) dlsym(handle1, "${us}zsh_getaddr1");
+    sym1 = zsh_getaddr1();
+    if(!sym1) exit(1);
+    if(sym1 != sym2) exit(1);
     exit(0);
 }
-], [zsh_cv_sys_dynamic_broken=no],
-[zsh_cv_sys_dynamic_broken=yes],
-[zsh_cv_sys_dynamic_broken=yes]
+], [zsh_cv_shared_$1=yes],
+[zsh_cv_shared_$1=no],
+[zsh_cv_shared_$1=no]
 )
 else
-    zsh_cv_sys_dynamic_broken=yes
+    zsh_cv_shared_$1=no
 fi
 ])
 ])
@@ -208,10 +245,10 @@ else
 fi
 echo 'int fred () { return 42; }' > conftest1.c
 echo 'int fred () { return 69; }' > conftest2.c
-if $CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&5 2>&5 &&
-$DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&5 2>&5 &&
-$CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&5 2>&5 &&
-$DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&5 2>&5; then
+if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
+AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC) &&
+AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&AC_FD_CC) &&
+AC_TRY_COMMAND($DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&AC_FD_CC); then
     AC_TRY_RUN([
 #ifdef HPUXDYNAMIC
 #include <dl.h>
@@ -283,10 +320,10 @@ else
 fi
 echo 'int fred () { return 42; }' > conftest1.c
 echo 'extern int fred(); int barney () { return fred() + 27; }' > conftest2.c
-if $CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&5 2>&5 &&
-$DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&5 2>&5 &&
-$CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&5 2>&5 &&
-$DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&5 2>&5; then
+if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
+AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC) &&
+AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest2.c 1>&AC_FD_CC) &&
+AC_TRY_COMMAND($DLLD -o conftest2.$DL_EXT $LDFLAGS $DLLDFLAGS conftest2.o $LIBS 1>&AC_FD_CC); then
     AC_TRY_RUN([
 #ifdef HPUXDYNAMIC
 #include <dl.h>
@@ -353,8 +390,8 @@ else
     us=
 fi
 echo 'extern int fred(); int barney () { return fred() + 27; }' > conftest1.c
-if $CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&5 2>&5 &&
-$DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&5 2>&5; then
+if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
+AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC); then
     save_ldflags=$LDFLAGS
     LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
     AC_TRY_RUN([
@@ -426,8 +463,8 @@ elif
 	us=
     fi
     echo 'extern int fred(); int barney() { return fred() + 27; }' > conftest1.c
-    $CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&5 2>&5 &&
-    $DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&5 2>&5; then
+    AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
+    AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS conftest1.o $LIBS 1>&AC_FD_CC); then
     save_ldflags=$LDFLAGS
     LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS -s"
     AC_TRY_RUN([
@@ -495,8 +532,8 @@ else
     us=
 fi
 echo 'int fred () { return 42; }' > conftest1.c
-if $CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&5 2>&5 &&
-$DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS -s conftest1.o $LIBS 1>&5 2>&5; then
+if AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest1.c 1>&AC_FD_CC) &&
+AC_TRY_COMMAND($DLLD -o conftest1.$DL_EXT $LDFLAGS $DLLDFLAGS -s conftest1.o $LIBS 1>&AC_FD_CC); then
     AC_TRY_RUN([
 #ifdef HPUXDYNAMIC
 #include <dl.h>
@@ -620,3 +657,57 @@ tzsh=`echo ${tzsh_name} | sed -f conftestsed`
 rm -f conftestsed
 AC_SUBST(tzsh)dnl
 ])
+
+AC_DEFUN(zsh_COMPILE_FLAGS,
+    [AC_ARG_ENABLE(cppflags,
+	[  --enable-cppflags=...      specify C preprocessor flags],
+	if test "$enableval" = "yes"
+	then CPPFLAGS="$1"
+	else CPPFLAGS="$enable_cppflags"
+	fi)
+    AC_ARG_ENABLE(cflags,
+	[  --enable-cflags=...        specify C compiler flags],
+	if test "$enableval" = "yes"
+	then CFLAGS="$2"
+	else CFLAGS="$enable_cflags"
+	fi)
+    AC_ARG_ENABLE(ldflags,
+	[  --enable-ldflags=...       specify linker flags],
+	if test "$enableval" = "yes"
+	then LDFLAGS="$3"
+	else LDFLAGS="$enable_ldflags"
+	fi)
+    AC_ARG_ENABLE(libs,
+	[  --enable-libs=...          specify link libraries],
+	if test "$enableval" = "yes"
+	then LIBS="$4"
+	else LIBS="$enable_libs"
+	fi)])
+
+dnl 
+dnl zsh_CHECK_SOCKLEN_T
+dnl
+dnl	check type of third argument of some network functions; currently
+dnl	tested are size_t *, unsigned long *, int *.
+dnl
+AC_DEFUN([zsh_CHECK_SOCKLEN_T],[
+  AC_CACHE_CHECK(
+    [base type of the third argument to accept],
+    [zsh_cv_type_socklen_t],
+    [zsh_cv_type_socklen_t=
+    for zsh_type in socklen_t int "unsigned long" size_t ; do
+      AC_TRY_COMPILE(
+        [#include <sys/types.h>
+         #include <sys/socket.h>],
+        [extern int accept (int, struct sockaddr *, $zsh_type *);],
+        [zsh_cv_type_socklen_t="$zsh_type"; break],
+        []
+      )
+    done
+    if test -z "$zsh_cv_type_socklen_t"; then
+      zsh_cv_type_socklen_t=int
+    fi]
+  )
+  AC_DEFINE_UNQUOTED([SOCKLEN_T], [$zsh_cv_type_socklen_t])]
+)
+
diff --git a/zshconfig.ac b/zshconfig.ac
index 0f6250cd8..09ab2be69 100644
--- a/zshconfig.ac
+++ b/zshconfig.ac
@@ -1485,6 +1485,12 @@ fi
 
 
 dnl ---------------
+dnl check for the type of third argument of accept
+dnl ---------------
+
+zsh_CHECK_SOCKLEN_T
+
+dnl ---------------
 dnl dynamic loading
 dnl ---------------
 L=N
@@ -1496,29 +1502,30 @@ MOD_IMPORT_VARIABLE=
 MOD_IMPORT_FUNCTION=
 aixdynamic=no
 hpuxdynamic=no
-if test "$ac_cv_func_dlopen"  != yes ||
-   test "$ac_cv_func_dlsym"   != yes ||
-   test "$ac_cv_func_dlerror" != yes; then
-  if test "$ac_cv_func_load"      != yes ||
-     test "$ac_cv_func_unload"    != yes ||
-     test "$ac_cv_func_loadbind"  != yes ||
-     test "$ac_cv_func_loadquery" != yes; then
-    if test "$ac_cv_func_shl_load" != yes ||
-       test "$ac_cv_func_shl_unload" != yes ||
-       test "$ac_cv_func_shl_findsym" != yes; then
-      dynamic=no
-    elif test "x$dynamic" = xyes; then
-      hpuxdynamic=yes
-      DL_EXT="${DL_EXT=sl}"
-      dnl autoheader won't allow us to define anything which isn't
-      dnl going into a header, and we can't undefine anything, so
-      dnl just define this anyway and rely on the later tests to
-      dnl define DYNAMIC or not.
-      AC_DEFINE(HPUXDYNAMIC)dnl
-    fi
-  elif test "x$dynamic" = xyes; then
+if test "$ac_cv_func_load"      = yes &&
+   test "$ac_cv_func_unload"    = yes &&
+   test "$ac_cv_func_loadbind"  = yes &&
+   test "$ac_cv_func_loadquery" = yes; then
+  dnl Force AIXDYNAMIC even on newer versions that have dl family
+  if test "x$dynamic" = xyes; then
     aixdynamic=yes
   fi
+elif test "$ac_cv_func_dlopen"  != yes ||
+     test "$ac_cv_func_dlsym"   != yes ||
+     test "$ac_cv_func_dlerror" != yes; then
+  if test "$ac_cv_func_shl_load" != yes ||
+     test "$ac_cv_func_shl_unload" != yes ||
+     test "$ac_cv_func_shl_findsym" != yes; then
+    dynamic=no
+  elif test "x$dynamic" = xyes; then
+    hpuxdynamic=yes
+    DL_EXT="${DL_EXT=sl}"
+    dnl autoheader won't allow us to define anything which isn't
+    dnl going into a header, and we can't undefine anything, so
+    dnl just define this anyway and rely on the later tests to
+    dnl define DYNAMIC or not.
+    AC_DEFINE(HPUXDYNAMIC)dnl
+  fi
 fi
 
 test -n "$GCC" && LDARG=-Wl,